aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/driver-model/devres.txt2
-rw-r--r--Documentation/feature-removal-schedule.txt45
-rw-r--r--Documentation/i2c/busses/i2c-nforce22
-rw-r--r--Documentation/i2c/porting-clients18
-rw-r--r--Documentation/i2c/summary29
-rw-r--r--Documentation/i2c/writing-clients415
-rw-r--r--Documentation/input/input-programming.txt125
-rw-r--r--Documentation/pci.txt12
-rw-r--r--Documentation/power/pci.txt2
-rw-r--r--Documentation/scsi/aacraid.txt7
-rw-r--r--Documentation/scsi/ncr53c8xx.txt5
-rw-r--r--Documentation/usb/usb-serial.txt2
-rw-r--r--MAINTAINERS33
-rw-r--r--arch/alpha/kernel/err_common.c1
-rw-r--r--arch/alpha/kernel/err_ev6.c1
-rw-r--r--arch/alpha/kernel/err_ev7.c1
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/mach-omap1/pm.c6
-rw-r--r--arch/i386/Kconfig1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/longhaul.c21
-rw-r--r--arch/i386/kernel/cpu/cpufreq/p4-clockmod.c31
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c6
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.h2
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c10
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-lib.c1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-smi.c2
-rw-r--r--arch/i386/kernel/i8253.c2
-rw-r--r--arch/i386/kernel/io_apic.c4
-rw-r--r--arch/i386/mach-voyager/setup.c8
-rw-r--r--arch/i386/mach-voyager/voyager_cat.c4
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c97
-rw-r--r--arch/i386/mach-voyager/voyager_thread.c69
-rw-r--r--arch/i386/pci/fixup.c2
-rw-r--r--arch/i386/pci/i386.c4
-rw-r--r--arch/ia64/Kconfig1
-rw-r--r--arch/ia64/sn/kernel/huberror.c1
-rw-r--r--arch/ia64/sn/kernel/msi_sn.c4
-rw-r--r--arch/ia64/sn/kernel/xpnet.c1
-rw-r--r--arch/m68k/Kconfig3
-rw-r--r--arch/m68k/Makefile2
-rw-r--r--arch/m68k/amiga/config.c1091
-rw-r--r--arch/m68k/atari/Makefile1
-rw-r--r--arch/m68k/atari/atakeyb.c730
-rw-r--r--arch/m68k/atari/config.c998
-rw-r--r--arch/m68k/atari/debug.c482
-rw-r--r--arch/m68k/kernel/entry.S2
-rw-r--r--arch/m68k/kernel/head.S2
-rw-r--r--arch/m68k/kernel/setup.c368
-rw-r--r--arch/m68k/lib/checksum.c3
-rw-r--r--arch/m68k/mac/baboon.c32
-rw-r--r--arch/m68k/mac/config.c167
-rw-r--r--arch/m68k/mac/debug.c331
-rw-r--r--arch/m68k/mac/oss.c18
-rw-r--r--arch/m68k/mac/psc.c21
-rw-r--r--arch/m68k/mac/via.c284
-rw-r--r--arch/m68k/q40/config.c272
-rw-r--r--arch/m68k/sun3/sun3ints.c2
-rw-r--r--arch/m68k/sun3x/prom.c132
-rw-r--r--arch/m68knommu/kernel/dma.c1
-rw-r--r--arch/mips/cobalt/Makefile2
-rw-r--r--arch/mips/cobalt/buttons.c54
-rw-r--r--arch/mips/lib/iomap.c1
-rw-r--r--arch/powerpc/kernel/pci_64.c2
-rw-r--r--arch/powerpc/kernel/vio.c4
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c1
-rw-r--r--arch/powerpc/platforms/pseries/power.c8
-rw-r--r--arch/powerpc/platforms/pseries/ras.c1
-rw-r--r--arch/ppc/8260_io/enet.c1
-rw-r--r--arch/ppc/8260_io/fcc_enet.c1
-rw-r--r--arch/ppc/8xx_io/enet.c1
-rw-r--r--arch/ppc/syslib/ppc4xx_sgdma.c1
-rw-r--r--arch/s390/appldata/appldata_net_sum.c2
-rw-r--r--arch/s390/crypto/aes_s390.c15
-rw-r--r--arch/s390/kernel/ipl.c32
-rw-r--r--arch/s390/kernel/kprobes.c3
-rw-r--r--arch/s390/kernel/setup.c111
-rw-r--r--arch/s390/mm/fault.c40
-rw-r--r--arch/sh64/mach-cayman/iomap.c1
-rw-r--r--arch/sparc64/Kconfig1
-rw-r--r--arch/sparc64/kernel/pci.c4
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c4
-rw-r--r--arch/sparc64/solaris/ioctl.c3
-rw-r--r--arch/x86_64/Kconfig1
-rw-r--r--arch/x86_64/kernel/cpufreq/Kconfig19
-rw-r--r--arch/x86_64/kernel/io_apic.c4
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c1
-rw-r--r--arch/xtensa/platform-iss/setup.c1
-rw-r--r--block/genhd.c12
-rw-r--r--block/ll_rw_blk.c2
-rw-r--r--block/scsi_ioctl.c4
-rw-r--r--crypto/Kconfig13
-rw-r--r--crypto/Makefile2
-rw-r--r--crypto/ablkcipher.c83
-rw-r--r--crypto/algapi.c169
-rw-r--r--crypto/blkcipher.c72
-rw-r--r--crypto/cbc.c11
-rw-r--r--crypto/cryptd.c375
-rw-r--r--crypto/cryptomgr.c66
-rw-r--r--crypto/ecb.c11
-rw-r--r--crypto/hash.c2
-rw-r--r--crypto/hmac.c11
-rw-r--r--crypto/lrw.c11
-rw-r--r--crypto/pcbc.c11
-rw-r--r--crypto/tcrypt.c121
-rw-r--r--crypto/xcbc.c12
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acpi/processor_perflib.c46
-rw-r--r--drivers/atm/adummy.c1
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/bus.c16
-rw-r--r--drivers/base/class.c18
-rw-r--r--drivers/base/core.c29
-rw-r--r--drivers/base/dd.c41
-rw-r--r--drivers/base/firmware.c6
-rw-r--r--drivers/base/platform.c8
-rw-r--r--drivers/base/power/shutdown.c4
-rw-r--r--drivers/base/sys.c14
-rw-r--r--drivers/block/aoe/aoecmd.c8
-rw-r--r--drivers/char/agp/ali-agp.c2
-rw-r--r--drivers/char/agp/alpha-agp.c2
-rw-r--r--drivers/char/agp/generic.c22
-rw-r--r--drivers/char/agp/intel-agp.c8
-rw-r--r--drivers/char/agp/nvidia-agp.c9
-rw-r--r--drivers/char/agp/parisc-agp.c2
-rw-r--r--drivers/char/agp/sgi-agp.c5
-rw-r--r--drivers/char/agp/sis-agp.c278
-rw-r--r--drivers/char/agp/sworks-agp.c23
-rw-r--r--drivers/char/hw_random/via-rng.c1
-rw-r--r--drivers/char/keyboard.c101
-rw-r--r--drivers/char/pcmcia/synclink_cs.c1
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/watchdog/sc1200wdt.c1
-rw-r--r--drivers/char/watchdog/scx200_wdt.c2
-rw-r--r--drivers/cpufreq/Kconfig61
-rw-r--r--drivers/cpufreq/cpufreq.c47
-rw-r--r--drivers/crypto/Kconfig16
-rw-r--r--drivers/crypto/Makefile1
-rw-r--r--drivers/crypto/padlock.c58
-rw-r--r--drivers/firmware/efivars.c12
-rw-r--r--drivers/i2c/Kconfig18
-rw-r--r--drivers/i2c/Makefile1
-rw-r--r--drivers/i2c/algos/Kconfig8
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c286
-rw-r--r--drivers/i2c/algos/i2c-algo-sgi.c9
-rw-r--r--drivers/i2c/busses/Kconfig151
-rw-r--r--drivers/i2c/busses/Makefile4
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c2
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c2
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c2
-rw-r--r--drivers/i2c/busses/i2c-at91.c1
-rw-r--r--drivers/i2c/busses/i2c-bfin-twi.c644
-rw-r--r--drivers/i2c/busses/i2c-elektor.c51
-rw-r--r--drivers/i2c/busses/i2c-gpio.c215
-rw-r--r--drivers/i2c/busses/i2c-i801.c2
-rw-r--r--drivers/i2c/busses/i2c-isa.c43
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c2
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c1
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c2
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c6
-rw-r--r--drivers/i2c/busses/i2c-omap.c3
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c144
-rw-r--r--drivers/i2c/busses/i2c-parport.c25
-rw-r--r--drivers/i2c/busses/i2c-pasemi.c2
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c36
-rw-r--r--drivers/i2c/busses/i2c-piix4.c2
-rw-r--r--drivers/i2c/busses/i2c-pxa.c15
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c96
-rw-r--r--drivers/i2c/busses/i2c-simtec.c186
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c2
-rw-r--r--drivers/i2c/busses/i2c-tiny-usb.c277
-rw-r--r--drivers/i2c/busses/i2c-viapro.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c3
-rw-r--r--drivers/i2c/chips/Kconfig21
-rw-r--r--drivers/i2c/i2c-boardinfo.c90
-rw-r--r--drivers/i2c/i2c-core.c662
-rw-r--r--drivers/i2c/i2c-core.h31
-rw-r--r--drivers/ide/cris/ide-cris.c9
-rw-r--r--drivers/ide/legacy/ide-cs.c1
-rw-r--r--drivers/ide/pci/aec62xx.c22
-rw-r--r--drivers/ide/pci/alim15x3.c7
-rw-r--r--drivers/ide/pci/cmd64x.c537
-rw-r--r--drivers/ide/pci/hpt366.c7
-rw-r--r--drivers/ide/pci/it821x.c126
-rw-r--r--drivers/ide/pci/pdc202xx_new.c3
-rw-r--r--drivers/ide/pci/siimage.c12
-rw-r--r--drivers/ide/pci/sl82c105.c247
-rw-r--r--drivers/ieee1394/hosts.c1
-rw-r--r--drivers/infiniband/core/cm.c1
-rw-r--r--drivers/infiniband/core/iwcm.c1
-rw-r--r--drivers/infiniband/core/mad_priv.h1
-rw-r--r--drivers/infiniband/core/multicast.c1
-rw-r--r--drivers/infiniband/core/sa_query.c1
-rw-r--r--drivers/infiniband/core/user_mad.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_layer.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_stats.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sysfs.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.h1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h1
-rw-r--r--drivers/infiniband/ulp/iser/iser_initiator.c2
-rw-r--r--drivers/input/Makefile1
-rw-r--r--drivers/input/evbug.c32
-rw-r--r--drivers/input/evdev.c235
-rw-r--r--drivers/input/input.c266
-rw-r--r--drivers/input/joydev.c187
-rw-r--r--drivers/input/joystick/a3d.c9
-rw-r--r--drivers/input/joystick/adi.c9
-rw-r--r--drivers/input/joystick/analog.c9
-rw-r--r--drivers/input/joystick/cobra.c9
-rw-r--r--drivers/input/joystick/db9.c7
-rw-r--r--drivers/input/joystick/gamecon.c7
-rw-r--r--drivers/input/joystick/gf2k.c10
-rw-r--r--drivers/input/joystick/grip.c9
-rw-r--r--drivers/input/joystick/grip_mp.c11
-rw-r--r--drivers/input/joystick/guillemot.c9
-rw-r--r--drivers/input/joystick/iforce/iforce-ff.c10
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c26
-rw-r--r--drivers/input/joystick/iforce/iforce-packets.c22
-rw-r--r--drivers/input/joystick/iforce/iforce-serio.c2
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c13
-rw-r--r--drivers/input/joystick/iforce/iforce.h2
-rw-r--r--drivers/input/joystick/interact.c8
-rw-r--r--drivers/input/joystick/magellan.c3
-rw-r--r--drivers/input/joystick/sidewinder.c9
-rw-r--r--drivers/input/joystick/spaceball.c3
-rw-r--r--drivers/input/joystick/spaceorb.c3
-rw-r--r--drivers/input/joystick/stinger.c3
-rw-r--r--drivers/input/joystick/tmdc.c9
-rw-r--r--drivers/input/joystick/turbografx.c7
-rw-r--r--drivers/input/joystick/twidjoy.c4
-rw-r--r--drivers/input/joystick/warrior.c3
-rw-r--r--drivers/input/keyboard/Kconfig20
-rw-r--r--drivers/input/keyboard/Makefile2
-rw-r--r--drivers/input/keyboard/aaed2000_kbd.c9
-rw-r--r--drivers/input/keyboard/atakbd.c134
-rw-r--r--drivers/input/keyboard/atkbd.c7
-rw-r--r--drivers/input/keyboard/corgikbd.c3
-rw-r--r--drivers/input/keyboard/gpio_keys.c22
-rw-r--r--drivers/input/keyboard/hil_kbd.c89
-rw-r--r--drivers/input/keyboard/hilkbd.c8
-rw-r--r--drivers/input/keyboard/lkkbd.c7
-rw-r--r--drivers/input/keyboard/locomokbd.c2
-rw-r--r--drivers/input/keyboard/newtonkbd.c3
-rw-r--r--drivers/input/keyboard/omap-keypad.c3
-rw-r--r--drivers/input/keyboard/pxa27x_keyboard.c258
-rw-r--r--drivers/input/keyboard/spitzkbd.c3
-rw-r--r--drivers/input/keyboard/stowaway.c3
-rw-r--r--drivers/input/keyboard/sunkbd.c8
-rw-r--r--drivers/input/keyboard/xtkbd.c3
-rw-r--r--drivers/input/misc/Kconfig23
-rw-r--r--drivers/input/misc/Makefile2
-rw-r--r--drivers/input/misc/cobalt_btns.c172
-rw-r--r--drivers/input/misc/input-polldev.c171
-rw-r--r--drivers/input/misc/ixp4xx-beeper.c11
-rw-r--r--drivers/input/misc/m68kspkr.c2
-rw-r--r--drivers/input/misc/pcspkr.c2
-rw-r--r--drivers/input/misc/sparcspkr.c6
-rw-r--r--drivers/input/misc/uinput.c10
-rw-r--r--drivers/input/misc/wistron_btns.c685
-rw-r--r--drivers/input/mouse/Kconfig72
-rw-r--r--drivers/input/mouse/Makefile9
-rw-r--r--drivers/input/mouse/alps.c13
-rw-r--r--drivers/input/mouse/alps.h18
-rw-r--r--drivers/input/mouse/atarimouse.c160
-rw-r--r--drivers/input/mouse/hil_ptr.c97
-rw-r--r--drivers/input/mouse/lifebook.c195
-rw-r--r--drivers/input/mouse/lifebook.h11
-rw-r--r--drivers/input/mouse/logips2pp.c7
-rw-r--r--drivers/input/mouse/logips2pp.h7
-rw-r--r--drivers/input/mouse/psmouse-base.c50
-rw-r--r--drivers/input/mouse/psmouse.h1
-rw-r--r--drivers/input/mouse/sermouse.c19
-rw-r--r--drivers/input/mouse/synaptics.c109
-rw-r--r--drivers/input/mouse/synaptics.h18
-rw-r--r--drivers/input/mouse/touchkit_ps2.c100
-rw-r--r--drivers/input/mouse/touchkit_ps2.h24
-rw-r--r--drivers/input/mouse/trackpoint.h9
-rw-r--r--drivers/input/mouse/vsxxxaa.c3
-rw-r--r--drivers/input/mousedev.c441
-rw-r--r--drivers/input/power.c166
-rw-r--r--drivers/input/serio/hil_mlc.c505
-rw-r--r--drivers/input/serio/hp_sdc.c427
-rw-r--r--drivers/input/serio/hp_sdc_mlc.c227
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h24
-rw-r--r--drivers/input/serio/i8042.c7
-rw-r--r--drivers/input/touchscreen/ads7846.c30
-rw-r--r--drivers/input/touchscreen/corgi_ts.c3
-rw-r--r--drivers/input/touchscreen/elo.c3
-rw-r--r--drivers/input/touchscreen/gunze.c2
-rw-r--r--drivers/input/touchscreen/h3600_ts_input.c9
-rw-r--r--drivers/input/touchscreen/mtouch.c2
-rw-r--r--drivers/input/touchscreen/penmount.c3
-rw-r--r--drivers/input/touchscreen/touchright.c2
-rw-r--r--drivers/input/touchscreen/touchwin.c2
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c26
-rw-r--r--drivers/input/tsdev.c177
-rw-r--r--drivers/isdn/hisax/netjet.c1
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c1
-rw-r--r--drivers/macintosh/therm_windtunnel.c3
-rw-r--r--drivers/macintosh/via-cuda.c58
-rw-r--r--drivers/macintosh/via-macii.c582
-rw-r--r--drivers/macintosh/via-pmu68k.c3
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c3
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c2
-rw-r--r--drivers/media/dvb/frontends/dibx000_common.c4
-rw-r--r--drivers/media/video/adv7170.c1
-rw-r--r--drivers/media/video/adv7175.c1
-rw-r--r--drivers/media/video/bt819.c1
-rw-r--r--drivers/media/video/bt856.c1
-rw-r--r--drivers/media/video/bt866.c1
-rw-r--r--drivers/media/video/cx2341x.c1
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c1
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_priv.h1
-rw-r--r--drivers/media/video/saa7111.c1
-rw-r--r--drivers/media/video/saa7114.c1
-rw-r--r--drivers/media/video/saa711x.c1
-rw-r--r--drivers/media/video/saa7185.c1
-rw-r--r--drivers/media/video/usbvision/usbvision-cards.c1
-rw-r--r--drivers/message/fusion/mptbase.c27
-rw-r--r--drivers/message/fusion/mptbase.h1
-rw-r--r--drivers/message/fusion/mptscsih.c35
-rw-r--r--drivers/message/fusion/mptspi.c36
-rw-r--r--drivers/misc/hdpuftrs/hdpu_cpustate.c1
-rw-r--r--drivers/misc/hdpuftrs/hdpu_nexus.c1
-rw-r--r--drivers/misc/tifm_7xx1.c332
-rw-r--r--drivers/misc/tifm_core.c305
-rw-r--r--drivers/mmc/Kconfig106
-rw-r--r--drivers/mmc/Makefile33
-rw-r--r--drivers/mmc/card/Kconfig17
-rw-r--r--drivers/mmc/card/Makefile11
-rw-r--r--drivers/mmc/card/block.c (renamed from drivers/mmc/mmc_block.c)55
-rw-r--r--drivers/mmc/card/queue.c (renamed from drivers/mmc/mmc_queue.c)12
-rw-r--r--drivers/mmc/card/queue.h (renamed from drivers/mmc/mmc_queue.h)0
-rw-r--r--drivers/mmc/core/Kconfig17
-rw-r--r--drivers/mmc/core/Makefile11
-rw-r--r--drivers/mmc/core/core.c727
-rw-r--r--drivers/mmc/core/core.h70
-rw-r--r--drivers/mmc/core/mmc.c537
-rw-r--r--drivers/mmc/core/mmc_ops.c276
-rw-r--r--drivers/mmc/core/mmc_ops.h27
-rw-r--r--drivers/mmc/core/sd.c587
-rw-r--r--drivers/mmc/core/sd_ops.c316
-rw-r--r--drivers/mmc/core/sd_ops.h25
-rw-r--r--drivers/mmc/core/sysfs.c (renamed from drivers/mmc/mmc_sysfs.c)11
-rw-r--r--drivers/mmc/core/sysfs.h (renamed from drivers/mmc/mmc.h)10
-rw-r--r--drivers/mmc/host/Kconfig103
-rw-r--r--drivers/mmc/host/Makefile18
-rw-r--r--drivers/mmc/host/at91_mci.c (renamed from drivers/mmc/at91_mci.c)1
-rw-r--r--drivers/mmc/host/au1xmmc.c (renamed from drivers/mmc/au1xmmc.c)1
-rw-r--r--drivers/mmc/host/au1xmmc.h (renamed from drivers/mmc/au1xmmc.h)0
-rw-r--r--drivers/mmc/host/imxmmc.c (renamed from drivers/mmc/imxmmc.c)1
-rw-r--r--drivers/mmc/host/imxmmc.h (renamed from drivers/mmc/imxmmc.h)0
-rw-r--r--drivers/mmc/host/mmci.c (renamed from drivers/mmc/mmci.c)1
-rw-r--r--drivers/mmc/host/mmci.h (renamed from drivers/mmc/mmci.h)0
-rw-r--r--drivers/mmc/host/omap.c (renamed from drivers/mmc/omap.c)56
-rw-r--r--drivers/mmc/host/pxamci.c (renamed from drivers/mmc/pxamci.c)1
-rw-r--r--drivers/mmc/host/pxamci.h (renamed from drivers/mmc/pxamci.h)0
-rw-r--r--drivers/mmc/host/sdhci.c (renamed from drivers/mmc/sdhci.c)43
-rw-r--r--drivers/mmc/host/sdhci.h (renamed from drivers/mmc/sdhci.h)4
-rw-r--r--drivers/mmc/host/tifm_sd.c1102
-rw-r--r--drivers/mmc/host/wbsd.c (renamed from drivers/mmc/wbsd.c)205
-rw-r--r--drivers/mmc/host/wbsd.h (renamed from drivers/mmc/wbsd.h)9
-rw-r--r--drivers/mmc/mmc.c1724
-rw-r--r--drivers/mmc/tifm_sd.c987
-rw-r--r--drivers/mtd/devices/doc2000.c1
-rw-r--r--drivers/mtd/devices/doc2001.c1
-rw-r--r--drivers/mtd/devices/doc2001plus.c1
-rw-r--r--drivers/mtd/devices/docecc.c1
-rw-r--r--drivers/mtd/inftlmount.c1
-rw-r--r--drivers/mtd/nand/cs553x_nand.c1
-rw-r--r--drivers/mtd/nftlcore.c1
-rw-r--r--drivers/net/7990.c6
-rw-r--r--drivers/net/Kconfig6
-rw-r--r--drivers/net/Space.c4
-rw-r--r--drivers/net/a2065.c8
-rw-r--r--drivers/net/ariadne.c1
-rw-r--r--drivers/net/atl1/atl1_param.c1
-rw-r--r--drivers/net/au1000_eth.c1
-rw-r--r--drivers/net/bnx2.c974
-rw-r--r--drivers/net/bnx2.h65
-rw-r--r--drivers/net/bnx2_fw.h1697
-rw-r--r--drivers/net/bnx2_fw2.h7868
-rw-r--r--drivers/net/fec_8xx/fec_main.c1
-rw-r--r--drivers/net/fec_8xx/fec_mii.c1
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c1
-rw-r--r--drivers/net/fs_enet/mac-fcc.c1
-rw-r--r--drivers/net/fs_enet/mac-fec.c1
-rw-r--r--drivers/net/fs_enet/mac-scc.c1
-rw-r--r--drivers/net/fs_enet/mii-bitbang.c1
-rw-r--r--drivers/net/fs_enet/mii-fec.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c1
-rw-r--r--drivers/net/ixgb/ixgb_osdep.h1
-rw-r--r--drivers/net/jazzsonic.c27
-rw-r--r--drivers/net/lasi_82596.c1
-rw-r--r--drivers/net/mac8390.c245
-rw-r--r--drivers/net/mac89x0.c88
-rw-r--r--drivers/net/macmace.c591
-rw-r--r--drivers/net/macsonic.c65
-rw-r--r--drivers/net/sonic.c32
-rw-r--r--drivers/net/sun3_82586.c5
-rw-r--r--drivers/net/tg3.c167
-rw-r--r--drivers/net/tg3.h6
-rw-r--r--drivers/net/tokenring/madgemc.c1
-rw-r--r--drivers/net/tokenring/smctr.c1
-rw-r--r--drivers/net/tulip/21142.c1
-rw-r--r--drivers/net/tulip/pnic.c1
-rw-r--r--drivers/net/tulip/pnic2.c1
-rw-r--r--drivers/net/tulip/timer.c1
-rw-r--r--drivers/net/tulip/tulip.h1
-rw-r--r--drivers/net/wan/lmc/lmc_media.c1
-rw-r--r--drivers/net/wan/lmc/lmc_proto.c1
-rw-r--r--drivers/net/wan/pc300_tty.c1
-rw-r--r--drivers/net/wireless/strip.c4
-rw-r--r--drivers/parisc/hppb.c2
-rw-r--r--drivers/parisc/led.c2
-rw-r--r--drivers/parisc/pdc_stable.c94
-rw-r--r--drivers/pci/Kconfig31
-rw-r--r--drivers/pci/bus.c4
-rw-r--r--drivers/pci/hotplug/Kconfig25
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c4
-rw-r--r--drivers/pci/hotplug/cpcihp_zt5550.c6
-rw-r--r--drivers/pci/hotplug/fakephp.c2
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c4
-rw-r--r--drivers/pci/hotplug/pciehp.h19
-rw-r--r--drivers/pci/hotplug/pciehp_core.c82
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c616
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c34
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c27
-rw-r--r--drivers/pci/hotplug/rpaphp.h8
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c200
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c167
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c49
-rw-r--r--drivers/pci/hotplug/shpchp.h2
-rw-r--r--drivers/pci/hotplug/shpchp_core.c2
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c2
-rw-r--r--drivers/pci/msi.c398
-rw-r--r--drivers/pci/pci-driver.c19
-rw-r--r--drivers/pci/pci-sysfs.c9
-rw-r--r--drivers/pci/pci.c34
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/probe.c42
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/pci/search.c3
-rw-r--r--drivers/pci/setup-bus.c21
-rw-r--r--drivers/pci/setup-res.c6
-rw-r--r--drivers/pcmcia/cs.c1
-rw-r--r--drivers/pcmcia/socket_sysfs.c1
-rw-r--r--drivers/ps3/ps3av.c108
-rw-r--r--drivers/ps3/ps3av_cmd.c20
-rw-r--r--drivers/s390/block/dasd.c45
-rw-r--r--drivers/s390/block/dasd_eckd.c81
-rw-r--r--drivers/s390/block/dasd_fba.c2
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/s390/char/tape.h1
-rw-r--r--drivers/s390/char/tape_3590.c29
-rw-r--r--drivers/s390/char/tape_3590.h4
-rw-r--r--drivers/s390/char/tape_core.c3
-rw-r--r--drivers/s390/cio/qdio.c240
-rw-r--r--drivers/s390/cio/qdio.h52
-rw-r--r--drivers/s390/net/qeth.h3
-rw-r--r--drivers/s390/net/qeth_main.c77
-rw-r--r--drivers/s390/net/qeth_mpc.h1
-rw-r--r--drivers/s390/scsi/zfcp_erp.c2
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c10
-rw-r--r--drivers/sbus/sbus.c1
-rw-r--r--drivers/scsi/BusLogic.c73
-rw-r--r--drivers/scsi/Kconfig24
-rw-r--r--drivers/scsi/Makefile2
-rw-r--r--drivers/scsi/aacraid/aachba.c402
-rw-r--r--drivers/scsi/aacraid/aacraid.h76
-rw-r--r--drivers/scsi/aacraid/commctrl.c286
-rw-r--r--drivers/scsi/aacraid/comminit.c4
-rw-r--r--drivers/scsi/aacraid/commsup.c112
-rw-r--r--drivers/scsi/aacraid/dpcsup.c36
-rw-r--r--drivers/scsi/aacraid/linit.c65
-rw-r--r--drivers/scsi/aacraid/nark.c3
-rw-r--r--drivers/scsi/aacraid/rkt.c3
-rw-r--r--drivers/scsi/aacraid/rx.c115
-rw-r--r--drivers/scsi/aacraid/sa.c1
-rw-r--r--drivers/scsi/aha1542.c1
-rw-r--r--drivers/scsi/aic7xxx/Kconfig.aic79xx12
-rw-r--r--drivers/scsi/aic7xxx/Kconfig.aic7xxx10
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c6
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx.h5
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_core.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c1
-rw-r--r--drivers/scsi/arcmsr/arcmsr_attr.c1
-rw-r--r--drivers/scsi/atari_NCR5380.c4398
-rw-r--r--drivers/scsi/atari_scsi.c377
-rw-r--r--drivers/scsi/atari_scsi.h174
-rw-r--r--drivers/scsi/constants.c274
-rw-r--r--drivers/scsi/dpt/dpti_i2o.h48
-rw-r--r--drivers/scsi/dpt/dpti_ioctl.h2
-rw-r--r--drivers/scsi/dpt/dptsig.h4
-rw-r--r--drivers/scsi/dpt_i2o.c2
-rw-r--r--drivers/scsi/eata_generic.h7
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c80
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.h2
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c37
-rw-r--r--drivers/scsi/ipr.c290
-rw-r--r--drivers/scsi/ipr.h45
-rw-r--r--drivers/scsi/iscsi_tcp.c21
-rw-r--r--drivers/scsi/libiscsi.c29
-rw-r--r--drivers/scsi/libsas/sas_expander.c1
-rw-r--r--drivers/scsi/libsrp.c13
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c2
-rw-r--r--drivers/scsi/megaraid.c2
-rw-r--r--drivers/scsi/osst.c1
-rw-r--r--drivers/scsi/pci2000.h197
-rw-r--r--drivers/scsi/pcmcia/Kconfig9
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h13
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c177
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c16
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c11
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/scsi.c47
-rw-r--r--drivers/scsi/scsi_error.c19
-rw-r--r--drivers/scsi/scsi_lib.c8
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/scsi_sysfs.c54
-rw-r--r--drivers/scsi/scsi_tgt_if.c6
-rw-r--r--drivers/scsi/scsi_tgt_lib.c261
-rw-r--r--drivers/scsi/scsi_tgt_priv.h5
-rw-r--r--drivers/scsi/scsi_transport_fc.c2
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c6
-rw-r--r--drivers/scsi/sd.c405
-rw-r--r--drivers/scsi/sg.c13
-rw-r--r--drivers/scsi/sr.c2
-rw-r--r--drivers/scsi/st.c1
-rw-r--r--drivers/scsi/tmscsim.c2
-rw-r--r--drivers/usb/input/Makefile5
-rw-r--r--drivers/usb/input/acecad.c28
-rw-r--r--drivers/usb/input/aiptek.c38
-rw-r--r--drivers/usb/input/appletouch.c29
-rw-r--r--drivers/usb/input/ati_remote.c42
-rw-r--r--drivers/usb/input/ati_remote2.c16
-rw-r--r--drivers/usb/input/gtco.c634
-rw-r--r--drivers/usb/input/itmtouch.c271
-rw-r--r--drivers/usb/input/kbtab.c22
-rw-r--r--drivers/usb/input/keyspan_remote.c29
-rw-r--r--drivers/usb/input/mtouchusb.c332
-rw-r--r--drivers/usb/input/powermate.c27
-rw-r--r--drivers/usb/input/touchkitusb.c392
-rw-r--r--drivers/usb/input/usbtouchscreen.c10
-rw-r--r--drivers/usb/input/wacom_sys.c22
-rw-r--r--drivers/usb/input/xpad.c22
-rw-r--r--drivers/usb/input/yealink.c13
-rw-r--r--drivers/usb/net/kaweth.c1
-rw-r--r--drivers/video/Kconfig5
-rw-r--r--drivers/video/Makefile3
-rw-r--r--drivers/video/atafb.c2801
-rw-r--r--drivers/video/atafb.h36
-rw-r--r--drivers/video/atafb_iplan2p2.c293
-rw-r--r--drivers/video/atafb_iplan2p4.c308
-rw-r--r--drivers/video/atafb_iplan2p8.c345
-rw-r--r--drivers/video/atafb_mfb.c112
-rw-r--r--drivers/video/atafb_utils.h400
-rw-r--r--drivers/video/aty/radeon_i2c.c1
-rw-r--r--drivers/video/g364fb.c1
-rw-r--r--drivers/video/intelfb/intelfb_i2c.c3
-rw-r--r--drivers/video/matrox/i2c-matroxfb.c2
-rw-r--r--drivers/video/platinumfb.c1
-rw-r--r--drivers/video/ps3fb.c116
-rw-r--r--drivers/video/stifb.c1
-rw-r--r--drivers/video/valkyriefb.c1
-rw-r--r--drivers/zorro/proc.c5
-rw-r--r--drivers/zorro/zorro-sysfs.c3
-rw-r--r--drivers/zorro/zorro.c3
-rw-r--r--fs/Kconfig13
-rw-r--r--fs/afs/Makefile2
-rw-r--r--fs/afs/callback.c2
-rw-r--r--fs/afs/cmservice.c1
-rw-r--r--fs/afs/fsclient.c3
-rw-r--r--fs/afs/internal.h7
-rw-r--r--fs/afs/main.c2
-rw-r--r--fs/afs/netdevices.c68
-rw-r--r--fs/afs/super.c100
-rw-r--r--fs/afs/use-rtnetlink.c473
-rw-r--r--fs/afs/vlocation.c2
-rw-r--r--fs/configfs/mount.c2
-rw-r--r--fs/debugfs/inode.c2
-rw-r--r--fs/dlm/lockspace.c2
-rw-r--r--fs/ecryptfs/main.c12
-rw-r--r--fs/fuse/inode.c4
-rw-r--r--fs/gfs2/locking/dlm/sysfs.c2
-rw-r--r--fs/gfs2/sys.c2
-rw-r--r--fs/lockd/mon.c10
-rw-r--r--fs/lockd/xdr.c20
-rw-r--r--fs/lockd/xdr4.c24
-rw-r--r--fs/nfs/client.c3
-rw-r--r--fs/nfs/dir.c20
-rw-r--r--fs/nfs/direct.c5
-rw-r--r--fs/nfs/internal.h12
-rw-r--r--fs/nfs/mount_clnt.c7
-rw-r--r--fs/nfs/nfs2xdr.c7
-rw-r--r--fs/nfs/nfs3xdr.c13
-rw-r--r--fs/nfs/nfs4proc.c3
-rw-r--r--fs/nfs/nfs4xdr.c7
-rw-r--r--fs/nfs/nfsroot.c2
-rw-r--r--fs/nfs/pagelist.c242
-rw-r--r--fs/nfs/read.c92
-rw-r--r--fs/nfs/super.c10
-rw-r--r--fs/nfs/write.c258
-rw-r--r--fs/nfsd/nfs4callback.c7
-rw-r--r--fs/ocfs2/alloc.c6
-rw-r--r--fs/ocfs2/aops.c11
-rw-r--r--fs/ocfs2/cluster/heartbeat.c2
-rw-r--r--fs/ocfs2/cluster/masklog.c4
-rw-r--r--fs/ocfs2/cluster/masklog.h2
-rw-r--r--fs/ocfs2/cluster/sys.c7
-rw-r--r--fs/ocfs2/cluster/tcp.c10
-rw-r--r--fs/ocfs2/dir.c7
-rw-r--r--fs/ocfs2/dlm/dlmast.c12
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c4
-rw-r--r--fs/ocfs2/dlm/dlmthread.c2
-rw-r--r--fs/ocfs2/dlmglue.c54
-rw-r--r--fs/ocfs2/dlmglue.h7
-rw-r--r--fs/ocfs2/export.c6
-rw-r--r--fs/ocfs2/file.c17
-rw-r--r--fs/ocfs2/file.h5
-rw-r--r--fs/ocfs2/inode.c35
-rw-r--r--fs/ocfs2/inode.h1
-rw-r--r--fs/ocfs2/ioctl.c24
-rw-r--r--fs/ocfs2/ioctl.h1
-rw-r--r--fs/ocfs2/journal.c7
-rw-r--r--fs/ocfs2/namei.c5
-rw-r--r--fs/ocfs2/ocfs2.h12
-rw-r--r--fs/ocfs2/ocfs2_fs.h2
-rw-r--r--fs/ocfs2/suballoc.c10
-rw-r--r--fs/ocfs2/super.c2
-rw-r--r--fs/partitions/check.c6
-rw-r--r--fs/sysfs/bin.c2
-rw-r--r--fs/sysfs/file.c11
-rw-r--r--include/acpi/acpi_bus.h2
-rw-r--r--include/asm-alpha/scatterlist.h1
-rw-r--r--include/asm-arm/arch-imx/mmc.h2
-rw-r--r--include/asm-arm/arch-ixp4xx/dma.h1
-rw-r--r--include/asm-arm/arch-pxa/mmc.h2
-rw-r--r--include/asm-arm/arch-pxa/pxa27x_keyboard.h13
-rw-r--r--include/asm-arm/mach/mmc.h2
-rw-r--r--include/asm-avr32/scatterlist.h2
-rw-r--r--include/asm-frv/scatterlist.h2
-rw-r--r--include/asm-h8300/scatterlist.h2
-rw-r--r--include/asm-i386/agp.h6
-rw-r--r--include/asm-i386/scatterlist.h2
-rw-r--r--include/asm-i386/voyager.h6
-rw-r--r--include/asm-ia64/scatterlist.h2
-rw-r--r--include/asm-m32r/scatterlist.h2
-rw-r--r--include/asm-m68k/adb.h75
-rw-r--r--include/asm-m68k/atarikb.h6
-rw-r--r--include/asm-m68knommu/scatterlist.h1
-rw-r--r--include/asm-mips/scatterlist.h2
-rw-r--r--include/asm-parisc/scatterlist.h1
-rw-r--r--include/asm-powerpc/ps3av.h22
-rw-r--r--include/asm-s390/ccwdev.h6
-rw-r--r--include/asm-s390/elf.h7
-rw-r--r--include/asm-s390/kdebug.h18
-rw-r--r--include/asm-s390/kprobes.h16
-rw-r--r--include/asm-s390/lowcore.h10
-rw-r--r--include/asm-sh/scatterlist.h2
-rw-r--r--include/asm-sh64/scatterlist.h2
-rw-r--r--include/asm-sparc64/scatterlist.h1
-rw-r--r--include/asm-v850/scatterlist.h2
-rw-r--r--include/asm-x86_64/agp.h6
-rw-r--r--include/asm-x86_64/scatterlist.h2
-rw-r--r--include/asm-xtensa/scatterlist.h2
-rw-r--r--include/crypto/algapi.h84
-rw-r--r--include/linux/cpufreq.h1
-rw-r--r--include/linux/crypto.h236
-rw-r--r--include/linux/device.h9
-rw-r--r--include/linux/ethtool.h2
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/gpio_keys.h3
-rw-r--r--include/linux/highmem.h9
-rw-r--r--include/linux/hp_sdc.h1
-rw-r--r--include/linux/i2c-algo-bit.h7
-rw-r--r--include/linux/i2c-gpio.h38
-rw-r--r--include/linux/i2c-id.h3
-rw-r--r--include/linux/i2c.h123
-rw-r--r--include/linux/ide.h1
-rw-r--r--include/linux/ieee80211.h342
-rw-r--r--include/linux/input-polldev.h46
-rw-r--r--include/linux/input.h53
-rw-r--r--include/linux/interrupt.h6
-rw-r--r--include/linux/kobject.h58
-rw-r--r--include/linux/lockd/lockd.h2
-rw-r--r--include/linux/mmc/card.h32
-rw-r--r--include/linux/mmc/core.h112
-rw-r--r--include/linux/mmc/host.h59
-rw-r--r--include/linux/mmc/mmc.h322
-rw-r--r--include/linux/mmc/protocol.h327
-rw-r--r--include/linux/mmc/sd.h83
-rw-r--r--include/linux/module.h2
-rw-r--r--include/linux/msi.h11
-rw-r--r--include/linux/netdevice.h27
-rw-r--r--include/linux/netfilter/nf_conntrack_proto_gre.h18
-rw-r--r--include/linux/netfilter_bridge.h25
-rw-r--r--include/linux/netlink.h4
-rw-r--r--include/linux/nfs_fs.h4
-rw-r--r--include/linux/nfs_mount.h1
-rw-r--r--include/linux/nfs_page.h33
-rw-r--r--include/linux/nubus.h126
-rw-r--r--include/linux/parser.h6
-rw-r--r--include/linux/pci.h27
-rw-r--r--include/linux/pci_hotplug.h2
-rw-r--r--include/linux/pci_ids.h3
-rw-r--r--include/linux/skbuff.h2
-rw-r--r--include/linux/sunrpc/clnt.h9
-rw-r--r--include/linux/sunrpc/debug.h2
-rw-r--r--include/linux/sunrpc/msg_prot.h4
-rw-r--r--include/linux/sunrpc/sched.h2
-rw-r--r--include/linux/sunrpc/xprt.h7
-rw-r--r--include/linux/tifm.h117
-rw-r--r--include/linux/writeback.h2
-rw-r--r--include/linux/xfrm.h58
-rw-r--r--include/media/ovcamchip.h1
-rw-r--r--include/media/tuner.h1
-rw-r--r--include/net/ipv6.h15
-rw-r--r--include/net/iucv/af_iucv.h2
-rw-r--r--include/net/mac80211.h1045
-rw-r--r--include/net/sctp/command.h2
-rw-r--r--include/net/sctp/sctp.h4
-rw-r--r--include/net/sctp/structs.h1
-rw-r--r--include/net/tcp.h3
-rw-r--r--include/net/xfrm.h41
-rw-r--r--include/rdma/ib_mad.h2
-rw-r--r--include/scsi/iscsi_proto.h12
-rw-r--r--include/scsi/scsi.h1
-rw-r--r--include/scsi/scsi_cmnd.h3
-rw-r--r--include/scsi/scsi_dbg.h10
-rw-r--r--include/scsi/scsi_device.h14
-rw-r--r--include/scsi/scsi_host.h32
-rw-r--r--include/scsi/scsi_tgt_if.h6
-rw-r--r--include/scsi/scsi_transport_fc.h2
-rw-r--r--include/scsi/sd.h72
-rw-r--r--kernel/irq/chip.c3
-rw-r--r--kernel/ksysfs.c12
-rw-r--r--kernel/module.c8
-rw-r--r--kernel/params.c2
-rw-r--r--kernel/power/disk.c14
-rw-r--r--kernel/power/main.c10
-rw-r--r--kernel/power/power.h2
-rw-r--r--lib/iomap.c27
-rw-r--r--lib/kobject.c69
-rw-r--r--lib/parser.c10
-rw-r--r--net/8021q/vlan.c3
-rw-r--r--net/8021q/vlanproc.c36
-rw-r--r--net/Kconfig1
-rw-r--r--net/Makefile4
-rw-r--r--net/bridge/br_if.c4
-rw-r--r--net/bridge/br_ioctl.c4
-rw-r--r--net/bridge/br_netfilter.c138
-rw-r--r--net/bridge/br_netlink.c3
-rw-r--r--net/core/dev.c99
-rw-r--r--net/core/dev_mcast.c5
-rw-r--r--net/core/rtnetlink.c7
-rw-r--r--net/decnet/af_decnet.c11
-rw-r--r--net/decnet/dn_dev.c85
-rw-r--r--net/decnet/dn_fib.c2
-rw-r--r--net/decnet/dn_route.c14
-rw-r--r--net/ipv4/devinet.c17
-rw-r--r--net/ipv4/igmp.c15
-rw-r--r--net/ipv4/ipconfig.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_gre.c20
-rw-r--r--net/ipv4/netfilter/nf_nat_rule.c4
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c26
-rw-r--r--net/ipv4/tcp.c3
-rw-r--r--net/ipv4/tcp_highspeed.c24
-rw-r--r--net/ipv4/tcp_yeah.h7
-rw-r--r--net/ipv6/addrconf.c28
-rw-r--r--net/ipv6/anycast.c17
-rw-r--r--net/ipv6/mcast.c15
-rw-r--r--net/iucv/af_iucv.c193
-rw-r--r--net/iucv/iucv.c49
-rw-r--r--net/llc/llc_core.c10
-rw-r--r--net/mac80211/Kconfig78
-rw-r--r--net/mac80211/Makefile20
-rw-r--r--net/mac80211/aes_ccm.c155
-rw-r--r--net/mac80211/aes_ccm.h26
-rw-r--r--net/mac80211/debugfs.c433
-rw-r--r--net/mac80211/debugfs.h16
-rw-r--r--net/mac80211/debugfs_key.c252
-rw-r--r--net/mac80211/debugfs_key.h34
-rw-r--r--net/mac80211/debugfs_netdev.c440
-rw-r--r--net/mac80211/debugfs_netdev.h30
-rw-r--r--net/mac80211/debugfs_sta.c246
-rw-r--r--net/mac80211/debugfs_sta.h12
-rw-r--r--net/mac80211/hostapd_ioctl.h108
-rw-r--r--net/mac80211/ieee80211.c4984
-rw-r--r--net/mac80211/ieee80211_cfg.c66
-rw-r--r--net/mac80211/ieee80211_cfg.h9
-rw-r--r--net/mac80211/ieee80211_common.h98
-rw-r--r--net/mac80211/ieee80211_i.h798
-rw-r--r--net/mac80211/ieee80211_iface.c352
-rw-r--r--net/mac80211/ieee80211_ioctl.c1822
-rw-r--r--net/mac80211/ieee80211_key.h106
-rw-r--r--net/mac80211/ieee80211_led.c91
-rw-r--r--net/mac80211/ieee80211_led.h32
-rw-r--r--net/mac80211/ieee80211_rate.c140
-rw-r--r--net/mac80211/ieee80211_rate.h144
-rw-r--r--net/mac80211/ieee80211_sta.c3060
-rw-r--r--net/mac80211/michael.c104
-rw-r--r--net/mac80211/michael.h20
-rw-r--r--net/mac80211/rc80211_simple.c432
-rw-r--r--net/mac80211/sta_info.c470
-rw-r--r--net/mac80211/sta_info.h164
-rw-r--r--net/mac80211/tkip.c341
-rw-r--r--net/mac80211/tkip.h36
-rw-r--r--net/mac80211/wep.c328
-rw-r--r--net/mac80211/wep.h40
-rw-r--r--net/mac80211/wme.c678
-rw-r--r--net/mac80211/wme.h57
-rw-r--r--net/mac80211/wpa.c660
-rw-r--r--net/mac80211/wpa.h31
-rw-r--r--net/netlink/af_netlink.c34
-rw-r--r--net/netrom/nr_route.c5
-rw-r--r--net/rose/rose_route.c8
-rw-r--r--net/rxrpc/Kconfig3
-rw-r--r--net/rxrpc/ar-ack.c80
-rw-r--r--net/rxrpc/ar-error.c2
-rw-r--r--net/rxrpc/ar-output.c2
-rw-r--r--net/rxrpc/ar-peer.c45
-rw-r--r--net/sched/sch_api.c7
-rw-r--r--net/sctp/associola.c29
-rw-r--r--net/sctp/ipv6.c49
-rw-r--r--net/sctp/protocol.c81
-rw-r--r--net/sctp/sm_make_chunk.c15
-rw-r--r--net/sctp/sm_sideeffect.c35
-rw-r--r--net/sctp/sm_statefuns.c29
-rw-r--r--net/sctp/socket.c40
-rw-r--r--net/sunrpc/Makefile2
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_seal.c13
-rw-r--r--net/sunrpc/clnt.c69
-rw-r--r--net/sunrpc/pmap_clnt.c383
-rw-r--r--net/sunrpc/rpcb_clnt.c625
-rw-r--r--net/sunrpc/sched.c65
-rw-r--r--net/sunrpc/svc.c2
-rw-r--r--net/sunrpc/xprt.c4
-rw-r--r--net/sunrpc/xprtsock.c4
-rw-r--r--net/tipc/eth_media.c12
-rw-r--r--net/xfrm/xfrm_policy.c2
-rw-r--r--net/xfrm/xfrm_state.c2
-rw-r--r--net/xfrm/xfrm_user.c73
-rw-r--r--security/inode.c2
-rw-r--r--sound/core/init.c1
-rw-r--r--sound/oss/au1550_ac97.c1
-rw-r--r--sound/oss/dmasound/tas_ioctl.h1
-rw-r--r--sound/oss/soundcard.c1
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c2
-rw-r--r--sound/pci/ca0106/ca0106_proc.c2
-rw-r--r--sound/pci/cs46xx/dsp_spos.c1
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c1
-rw-r--r--sound/pci/hda/hda_generic.c1
-rw-r--r--sound/pci/hda/hda_proc.c1
-rw-r--r--sound/pci/hda/patch_atihdmi.c1
-rw-r--r--sound/pci/hda/patch_si3054.c1
-rw-r--r--sound/pci/hda/patch_via.c1
862 files changed, 54030 insertions, 26676 deletions
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 5163b85308f5..6c8d8f27db34 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -182,7 +182,7 @@ For example, you can do something like the following.
182 182
183 ... 183 ...
184 184
185 devres_close_group(dev, my_midlayer_something); 185 devres_close_group(dev, my_midlayer_create_something);
186 return 0; 186 return 0;
187 } 187 }
188 188
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 5c88ba1ea262..5f96cb33743e 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -117,13 +117,6 @@ Who: Adrian Bunk <bunk@stusta.de>
117 117
118--------------------------- 118---------------------------
119 119
120What: pci_module_init(driver)
121When: January 2007
122Why: Is replaced by pci_register_driver(pci_driver).
123Who: Richard Knutsson <ricknu-0@student.ltu.se> and Greg Kroah-Hartman <gregkh@suse.de>
124
125---------------------------
126
127What: Usage of invalid timevals in setitimer 120What: Usage of invalid timevals in setitimer
128When: March 2007 121When: March 2007
129Why: POSIX requires to validate timevals in the setitimer call. This 122Why: POSIX requires to validate timevals in the setitimer call. This
@@ -190,18 +183,10 @@ Who: Jean Delvare <khali@linux-fr.org>
190 183
191--------------------------- 184---------------------------
192 185
193What: i2c_adapter.dev 186What: i2c_adapter.list
194 i2c_adapter.list
195When: July 2007 187When: July 2007
196Why: Superfluous, given i2c_adapter.class_dev: 188Why: Superfluous, this list duplicates the one maintained by the driver
197 * The "dev" was a stand-in for the physical device node that legacy 189 core.
198 drivers would not have; but now it's almost always present. Any
199 remaining legacy drivers must upgrade (they now trigger warnings).
200 * The "list" duplicates class device children.
201 The delay in removing this is so upgraded lm_sensors and libsensors
202 can get deployed. (Removal causes minor changes in the sysfs layout,
203 notably the location of the adapter type name and parenting the i2c
204 client hardware directly from their controller.)
205Who: Jean Delvare <khali@linux-fr.org>, 190Who: Jean Delvare <khali@linux-fr.org>,
206 David Brownell <dbrownell@users.sourceforge.net> 191 David Brownell <dbrownell@users.sourceforge.net>
207 192
@@ -314,3 +299,27 @@ Why: Code was merged, then submitter immediately disappeared leaving
314Who: David S. Miller <davem@davemloft.net> 299Who: David S. Miller <davem@davemloft.net>
315 300
316--------------------------- 301---------------------------
302
303What: read_dev_chars(), read_conf_data{,_lpm}() (s390 common I/O layer)
304When: December 2007
305Why: These functions are a leftover from 2.4 times. They have several
306 problems:
307 - Duplication of checks that are done in the device driver's
308 interrupt handler
309 - common I/O layer can't do device specific error recovery
310 - device driver can't be notified for conditions happening during
311 execution of the function
312 Device drivers should issue the read device characteristics and read
313 configuration data ccws and do the appropriate error handling
314 themselves.
315Who: Cornelia Huck <cornelia.huck@de.ibm.com>
316
317---------------------------
318
319What: i2c-ixp2000, i2c-ixp4xx and scx200_i2c drivers
320When: September 2007
321Why: Obsolete. The new i2c-gpio driver replaces all hardware-specific
322 I2C-over-GPIO drivers.
323Who: Jean Delvare <khali@linux-fr.org>
324
325---------------------------
diff --git a/Documentation/i2c/busses/i2c-nforce2 b/Documentation/i2c/busses/i2c-nforce2
index 7f61fbc03f7f..fae3495bcbaf 100644
--- a/Documentation/i2c/busses/i2c-nforce2
+++ b/Documentation/i2c/busses/i2c-nforce2
@@ -9,6 +9,8 @@ Supported adapters:
9 * nForce4 MCP-04 10de:0034 9 * nForce4 MCP-04 10de:0034
10 * nForce4 MCP51 10de:0264 10 * nForce4 MCP51 10de:0264
11 * nForce4 MCP55 10de:0368 11 * nForce4 MCP55 10de:0368
12 * nForce4 MCP61 10de:03EB
13 * nForce4 MCP65 10de:0446
12 14
13Datasheet: not publicly available, but seems to be similar to the 15Datasheet: not publicly available, but seems to be similar to the
14 AMD-8111 SMBus 2.0 adapter. 16 AMD-8111 SMBus 2.0 adapter.
diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
index ca272b263a92..7bf82c08f6ca 100644
--- a/Documentation/i2c/porting-clients
+++ b/Documentation/i2c/porting-clients
@@ -1,4 +1,4 @@
1Revision 6, 2005-11-20 1Revision 7, 2007-04-19
2Jean Delvare <khali@linux-fr.org> 2Jean Delvare <khali@linux-fr.org>
3Greg KH <greg@kroah.com> 3Greg KH <greg@kroah.com>
4 4
@@ -20,6 +20,10 @@ yours for best results.
20 20
21Technical changes: 21Technical changes:
22 22
23* [Driver type] Any driver that was relying on i2c-isa has to be
24 converted to a proper isa, platform or pci driver. This is not
25 covered by this guide.
26
23* [Includes] Get rid of "version.h" and <linux/i2c-proc.h>. 27* [Includes] Get rid of "version.h" and <linux/i2c-proc.h>.
24 Includes typically look like that: 28 Includes typically look like that:
25 #include <linux/module.h> 29 #include <linux/module.h>
@@ -27,12 +31,10 @@ Technical changes:
27 #include <linux/slab.h> 31 #include <linux/slab.h>
28 #include <linux/jiffies.h> 32 #include <linux/jiffies.h>
29 #include <linux/i2c.h> 33 #include <linux/i2c.h>
30 #include <linux/i2c-isa.h> /* for ISA drivers */
31 #include <linux/hwmon.h> /* for hardware monitoring drivers */ 34 #include <linux/hwmon.h> /* for hardware monitoring drivers */
32 #include <linux/hwmon-sysfs.h> 35 #include <linux/hwmon-sysfs.h>
33 #include <linux/hwmon-vid.h> /* if you need VRM support */ 36 #include <linux/hwmon-vid.h> /* if you need VRM support */
34 #include <linux/err.h> /* for class registration */ 37 #include <linux/err.h> /* for class registration */
35 #include <asm/io.h> /* if you have I/O operations */
36 Please respect this inclusion order. Some extra headers may be 38 Please respect this inclusion order. Some extra headers may be
37 required for a given driver (e.g. "lm75.h"). 39 required for a given driver (e.g. "lm75.h").
38 40
@@ -69,20 +71,16 @@ Technical changes:
69 sensors mailing list <lm-sensors@lm-sensors.org> by providing a 71 sensors mailing list <lm-sensors@lm-sensors.org> by providing a
70 patch to the Documentation/hwmon/sysfs-interface file. 72 patch to the Documentation/hwmon/sysfs-interface file.
71 73
72* [Attach] For I2C drivers, the attach function should make sure 74* [Attach] The attach function should make sure that the adapter's
73 that the adapter's class has I2C_CLASS_HWMON (or whatever class is 75 class has I2C_CLASS_HWMON (or whatever class is suitable for your
74 suitable for your driver), using the following construct: 76 driver), using the following construct:
75 if (!(adapter->class & I2C_CLASS_HWMON)) 77 if (!(adapter->class & I2C_CLASS_HWMON))
76 return 0; 78 return 0;
77 ISA-only drivers of course don't need this.
78 Call i2c_probe() instead of i2c_detect(). 79 Call i2c_probe() instead of i2c_detect().
79 80
80* [Detect] As mentioned earlier, the flags parameter is gone. 81* [Detect] As mentioned earlier, the flags parameter is gone.
81 The type_name and client_name strings are replaced by a single 82 The type_name and client_name strings are replaced by a single
82 name string, which will be filled with a lowercase, short string. 83 name string, which will be filled with a lowercase, short string.
83 In i2c-only drivers, drop the i2c_is_isa_adapter check, it's
84 useless. Same for isa-only drivers, as the test would always be
85 true. Only hybrid drivers (which are quite rare) still need it.
86 The labels used for error paths are reduced to the number needed. 84 The labels used for error paths are reduced to the number needed.
87 It is advised that the labels are given descriptive names such as 85 It is advised that the labels are given descriptive names such as
88 exit and exit_free. Don't forget to properly set err before 86 exit and exit_free. Don't forget to properly set err before
diff --git a/Documentation/i2c/summary b/Documentation/i2c/summary
index 41dde8776791..aea60bf7e8f0 100644
--- a/Documentation/i2c/summary
+++ b/Documentation/i2c/summary
@@ -4,17 +4,23 @@ I2C and SMBus
4============= 4=============
5 5
6I2C (pronounce: I squared C) is a protocol developed by Philips. It is a 6I2C (pronounce: I squared C) is a protocol developed by Philips. It is a
7slow two-wire protocol (10-400 kHz), but it suffices for many types of 7slow two-wire protocol (variable speed, up to 400 kHz), with a high speed
8devices. 8extension (3.4 MHz). It provides an inexpensive bus for connecting many
9types of devices with infrequent or low bandwidth communications needs.
10I2C is widely used with embedded systems. Some systems use variants that
11don't meet branding requirements, and so are not advertised as being I2C.
9 12
10SMBus (System Management Bus) is a subset of the I2C protocol. Many 13SMBus (System Management Bus) is based on the I2C protocol, and is mostly
11modern mainboards have a System Management Bus. There are a lot of 14a subset of I2C protocols and signaling. Many I2C devices will work on an
12devices which can be connected to a SMBus; the most notable are modern 15SMBus, but some SMBus protocols add semantics beyond what is required to
13memory chips with EEPROM memories and chips for hardware monitoring. 16achieve I2C branding. Modern PC mainboards rely on SMBus. The most common
17devices connected through SMBus are RAM modules configured using I2C EEPROMs,
18and hardware monitoring chips.
14 19
15Because the SMBus is just a special case of the generalized I2C bus, we 20Because the SMBus is mostly a subset of the generalized I2C bus, we can
16can simulate the SMBus protocol on plain I2C busses. The reverse is 21use its protocols on many I2C systems. However, there are systems that don't
17regretfully impossible. 22meet both SMBus and I2C electrical constraints; and others which can't
23implement all the common SMBus protocol semantics or messages.
18 24
19 25
20Terminology 26Terminology
@@ -29,6 +35,7 @@ When we talk about I2C, we use the following terms:
29An Algorithm driver contains general code that can be used for a whole class 35An Algorithm driver contains general code that can be used for a whole class
30of I2C adapters. Each specific adapter driver depends on one algorithm 36of I2C adapters. Each specific adapter driver depends on one algorithm
31driver. 37driver.
38
32A Driver driver (yes, this sounds ridiculous, sorry) contains the general 39A Driver driver (yes, this sounds ridiculous, sorry) contains the general
33code to access some type of device. Each detected device gets its own 40code to access some type of device. Each detected device gets its own
34data in the Client structure. Usually, Driver and Client are more closely 41data in the Client structure. Usually, Driver and Client are more closely
@@ -40,6 +47,10 @@ a separate Adapter and Algorithm driver), and drivers for your I2C devices
40in this package. See the lm_sensors project http://www.lm-sensors.nu 47in this package. See the lm_sensors project http://www.lm-sensors.nu
41for device drivers. 48for device drivers.
42 49
50At this time, Linux only operates I2C (or SMBus) in master mode; you can't
51use these APIs to make a Linux system behave as a slave/device, either to
52speak a custom protocol or to emulate some other device.
53
43 54
44Included Bus Drivers 55Included Bus Drivers
45==================== 56====================
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index fbcff96f4ca1..3d8d36b0ad12 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -1,5 +1,5 @@
1This is a small guide for those who want to write kernel drivers for I2C 1This is a small guide for those who want to write kernel drivers for I2C
2or SMBus devices. 2or SMBus devices, using Linux as the protocol host/master (not slave).
3 3
4To set up a driver, you need to do several things. Some are optional, and 4To set up a driver, you need to do several things. Some are optional, and
5some things can be done slightly or completely different. Use this as a 5some things can be done slightly or completely different. Use this as a
@@ -29,8 +29,16 @@ static struct i2c_driver foo_driver = {
29 .driver = { 29 .driver = {
30 .name = "foo", 30 .name = "foo",
31 }, 31 },
32
33 /* iff driver uses driver model ("new style") binding model: */
34 .probe = foo_probe,
35 .remove = foo_remove,
36
37 /* else, driver uses "legacy" binding model: */
32 .attach_adapter = foo_attach_adapter, 38 .attach_adapter = foo_attach_adapter,
33 .detach_client = foo_detach_client, 39 .detach_client = foo_detach_client,
40
41 /* these may be used regardless of the driver binding model */
34 .shutdown = foo_shutdown, /* optional */ 42 .shutdown = foo_shutdown, /* optional */
35 .suspend = foo_suspend, /* optional */ 43 .suspend = foo_suspend, /* optional */
36 .resume = foo_resume, /* optional */ 44 .resume = foo_resume, /* optional */
@@ -40,7 +48,8 @@ static struct i2c_driver foo_driver = {
40The name field is the driver name, and must not contain spaces. It 48The name field is the driver name, and must not contain spaces. It
41should match the module name (if the driver can be compiled as a module), 49should match the module name (if the driver can be compiled as a module),
42although you can use MODULE_ALIAS (passing "foo" in this example) to add 50although you can use MODULE_ALIAS (passing "foo" in this example) to add
43another name for the module. 51another name for the module. If the driver name doesn't match the module
52name, the module won't be automatically loaded (hotplug/coldplug).
44 53
45All other fields are for call-back functions which will be explained 54All other fields are for call-back functions which will be explained
46below. 55below.
@@ -65,16 +74,13 @@ An example structure is below.
65 74
66 struct foo_data { 75 struct foo_data {
67 struct i2c_client client; 76 struct i2c_client client;
68 struct semaphore lock; /* For ISA access in `sensors' drivers. */
69 int sysctl_id; /* To keep the /proc directory entry for
70 `sensors' drivers. */
71 enum chips type; /* To keep the chips type for `sensors' drivers. */ 77 enum chips type; /* To keep the chips type for `sensors' drivers. */
72 78
73 /* Because the i2c bus is slow, it is often useful to cache the read 79 /* Because the i2c bus is slow, it is often useful to cache the read
74 information of a chip for some time (for example, 1 or 2 seconds). 80 information of a chip for some time (for example, 1 or 2 seconds).
75 It depends of course on the device whether this is really worthwhile 81 It depends of course on the device whether this is really worthwhile
76 or even sensible. */ 82 or even sensible. */
77 struct semaphore update_lock; /* When we are reading lots of information, 83 struct mutex update_lock; /* When we are reading lots of information,
78 another process should not update the 84 another process should not update the
79 below information */ 85 below information */
80 char valid; /* != 0 if the following fields are valid. */ 86 char valid; /* != 0 if the following fields are valid. */
@@ -95,8 +101,7 @@ some obscure clients). But we need generic reading and writing routines.
95I have found it useful to define foo_read and foo_write function for this. 101I have found it useful to define foo_read and foo_write function for this.
96For some cases, it will be easier to call the i2c functions directly, 102For some cases, it will be easier to call the i2c functions directly,
97but many chips have some kind of register-value idea that can easily 103but many chips have some kind of register-value idea that can easily
98be encapsulated. Also, some chips have both ISA and I2C interfaces, and 104be encapsulated.
99it useful to abstract from this (only for `sensors' drivers).
100 105
101The below functions are simple examples, and should not be copied 106The below functions are simple examples, and should not be copied
102literally. 107literally.
@@ -119,28 +124,101 @@ literally.
119 return i2c_smbus_write_word_data(client,reg,value); 124 return i2c_smbus_write_word_data(client,reg,value);
120 } 125 }
121 126
122For sensors code, you may have to cope with ISA registers too. Something
123like the below often works. Note the locking!
124
125 int foo_read_value(struct i2c_client *client, u8 reg)
126 {
127 int res;
128 if (i2c_is_isa_client(client)) {
129 down(&(((struct foo_data *) (client->data)) -> lock));
130 outb_p(reg,client->addr + FOO_ADDR_REG_OFFSET);
131 res = inb_p(client->addr + FOO_DATA_REG_OFFSET);
132 up(&(((struct foo_data *) (client->data)) -> lock));
133 return res;
134 } else
135 return i2c_smbus_read_byte_data(client,reg);
136 }
137
138Writing is done the same way.
139
140 127
141Probing and attaching 128Probing and attaching
142===================== 129=====================
143 130
131The Linux I2C stack was originally written to support access to hardware
132monitoring chips on PC motherboards, and thus it embeds some assumptions
133that are more appropriate to SMBus (and PCs) than to I2C. One of these
134assumptions is that most adapters and devices drivers support the SMBUS_QUICK
135protocol to probe device presence. Another is that devices and their drivers
136can be sufficiently configured using only such probe primitives.
137
138As Linux and its I2C stack became more widely used in embedded systems
139and complex components such as DVB adapters, those assumptions became more
140problematic. Drivers for I2C devices that issue interrupts need more (and
141different) configuration information, as do drivers handling chip variants
142that can't be distinguished by protocol probing, or which need some board
143specific information to operate correctly.
144
145Accordingly, the I2C stack now has two models for associating I2C devices
146with their drivers: the original "legacy" model, and a newer one that's
147fully compatible with the Linux 2.6 driver model. These models do not mix,
148since the "legacy" model requires drivers to create "i2c_client" device
149objects after SMBus style probing, while the Linux driver model expects
150drivers to be given such device objects in their probe() routines.
151
152
153Standard Driver Model Binding ("New Style")
154-------------------------------------------
155
156System infrastructure, typically board-specific initialization code or
157boot firmware, reports what I2C devices exist. For example, there may be
158a table, in the kernel or from the boot loader, identifying I2C devices
159and linking them to board-specific configuration information about IRQs
160and other wiring artifacts, chip type, and so on. That could be used to
161create i2c_client objects for each I2C device.
162
163I2C device drivers using this binding model work just like any other
164kind of driver in Linux: they provide a probe() method to bind to
165those devices, and a remove() method to unbind.
166
167 static int foo_probe(struct i2c_client *client);
168 static int foo_remove(struct i2c_client *client);
169
170Remember that the i2c_driver does not create those client handles. The
171handle may be used during foo_probe(). If foo_probe() reports success
172(zero not a negative status code) it may save the handle and use it until
173foo_remove() returns. That binding model is used by most Linux drivers.
174
175Drivers match devices when i2c_client.driver_name and the driver name are
176the same; this approach is used in several other busses that don't have
177device typing support in the hardware. The driver and module name should
178match, so hotplug/coldplug mechanisms will modprobe the driver.
179
180
181Device Creation (Standard driver model)
182---------------------------------------
183
184If you know for a fact that an I2C device is connected to a given I2C bus,
185you can instantiate that device by simply filling an i2c_board_info
186structure with the device address and driver name, and calling
187i2c_new_device(). This will create the device, then the driver core will
188take care of finding the right driver and will call its probe() method.
189If a driver supports different device types, you can specify the type you
190want using the type field. You can also specify an IRQ and platform data
191if needed.
192
193Sometimes you know that a device is connected to a given I2C bus, but you
194don't know the exact address it uses. This happens on TV adapters for
195example, where the same driver supports dozens of slightly different
196models, and I2C device addresses change from one model to the next. In
197that case, you can use the i2c_new_probed_device() variant, which is
198similar to i2c_new_device(), except that it takes an additional list of
199possible I2C addresses to probe. A device is created for the first
200responsive address in the list. If you expect more than one device to be
201present in the address range, simply call i2c_new_probed_device() that
202many times.
203
204The call to i2c_new_device() or i2c_new_probed_device() typically happens
205in the I2C bus driver. You may want to save the returned i2c_client
206reference for later use.
207
208
209Device Deletion (Standard driver model)
210---------------------------------------
211
212Each I2C device which has been created using i2c_new_device() or
213i2c_new_probed_device() can be unregistered by calling
214i2c_unregister_device(). If you don't call it explicitly, it will be
215called automatically before the underlying I2C bus itself is removed, as a
216device can't survive its parent in the device driver model.
217
218
219Legacy Driver Binding Model
220---------------------------
221
144Most i2c devices can be present on several i2c addresses; for some this 222Most i2c devices can be present on several i2c addresses; for some this
145is determined in hardware (by soldering some chip pins to Vcc or Ground), 223is determined in hardware (by soldering some chip pins to Vcc or Ground),
146for others this can be changed in software (by writing to specific client 224for others this can be changed in software (by writing to specific client
@@ -157,13 +235,9 @@ detection algorithm.
157You do not have to use this parameter interface; but don't try to use 235You do not have to use this parameter interface; but don't try to use
158function i2c_probe() if you don't. 236function i2c_probe() if you don't.
159 237
160NOTE: If you want to write a `sensors' driver, the interface is slightly
161 different! See below.
162
163 238
164 239Probing classes (Legacy model)
165Probing classes 240------------------------------
166---------------
167 241
168All parameters are given as lists of unsigned 16-bit integers. Lists are 242All parameters are given as lists of unsigned 16-bit integers. Lists are
169terminated by I2C_CLIENT_END. 243terminated by I2C_CLIENT_END.
@@ -210,8 +284,8 @@ Note that you *have* to call the defined variable `normal_i2c',
210without any prefix! 284without any prefix!
211 285
212 286
213Attaching to an adapter 287Attaching to an adapter (Legacy model)
214----------------------- 288--------------------------------------
215 289
216Whenever a new adapter is inserted, or for all adapters if the driver is 290Whenever a new adapter is inserted, or for all adapters if the driver is
217being registered, the callback attach_adapter() is called. Now is the 291being registered, the callback attach_adapter() is called. Now is the
@@ -237,17 +311,13 @@ them (unless a `force' parameter was used). In addition, addresses that
237are already in use (by some other registered client) are skipped. 311are already in use (by some other registered client) are skipped.
238 312
239 313
240The detect client function 314The detect client function (Legacy model)
241-------------------------- 315-----------------------------------------
242 316
243The detect client function is called by i2c_probe. The `kind' parameter 317The detect client function is called by i2c_probe. The `kind' parameter
244contains -1 for a probed detection, 0 for a forced detection, or a positive 318contains -1 for a probed detection, 0 for a forced detection, or a positive
245number for a forced detection with a chip type forced. 319number for a forced detection with a chip type forced.
246 320
247Below, some things are only needed if this is a `sensors' driver. Those
248parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */
249markers.
250
251Returning an error different from -ENODEV in a detect function will cause 321Returning an error different from -ENODEV in a detect function will cause
252the detection to stop: other addresses and adapters won't be scanned. 322the detection to stop: other addresses and adapters won't be scanned.
253This should only be done on fatal or internal errors, such as a memory 323This should only be done on fatal or internal errors, such as a memory
@@ -256,64 +326,20 @@ shortage or i2c_attach_client failing.
256For now, you can ignore the `flags' parameter. It is there for future use. 326For now, you can ignore the `flags' parameter. It is there for future use.
257 327
258 int foo_detect_client(struct i2c_adapter *adapter, int address, 328 int foo_detect_client(struct i2c_adapter *adapter, int address,
259 unsigned short flags, int kind) 329 int kind)
260 { 330 {
261 int err = 0; 331 int err = 0;
262 int i; 332 int i;
263 struct i2c_client *new_client; 333 struct i2c_client *client;
264 struct foo_data *data; 334 struct foo_data *data;
265 const char *client_name = ""; /* For non-`sensors' drivers, put the real 335 const char *name = "";
266 name here! */
267 336
268 /* Let's see whether this adapter can support what we need. 337 /* Let's see whether this adapter can support what we need.
269 Please substitute the things you need here! 338 Please substitute the things you need here! */
270 For `sensors' drivers, add `! is_isa &&' to the if statement */
271 if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WORD_DATA | 339 if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WORD_DATA |
272 I2C_FUNC_SMBUS_WRITE_BYTE)) 340 I2C_FUNC_SMBUS_WRITE_BYTE))
273 goto ERROR0; 341 goto ERROR0;
274 342
275 /* SENSORS ONLY START */
276 const char *type_name = "";
277 int is_isa = i2c_is_isa_adapter(adapter);
278
279 /* Do this only if the chip can additionally be found on the ISA bus
280 (hybrid chip). */
281
282 if (is_isa) {
283
284 /* Discard immediately if this ISA range is already used */
285 /* FIXME: never use check_region(), only request_region() */
286 if (check_region(address,FOO_EXTENT))
287 goto ERROR0;
288
289 /* Probe whether there is anything on this address.
290 Some example code is below, but you will have to adapt this
291 for your own driver */
292
293 if (kind < 0) /* Only if no force parameter was used */ {
294 /* We may need long timeouts at least for some chips. */
295 #define REALLY_SLOW_IO
296 i = inb_p(address + 1);
297 if (inb_p(address + 2) != i)
298 goto ERROR0;
299 if (inb_p(address + 3) != i)
300 goto ERROR0;
301 if (inb_p(address + 7) != i)
302 goto ERROR0;
303 #undef REALLY_SLOW_IO
304
305 /* Let's just hope nothing breaks here */
306 i = inb_p(address + 5) & 0x7f;
307 outb_p(~i & 0x7f,address+5);
308 if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
309 outb_p(i,address+5);
310 return 0;
311 }
312 }
313 }
314
315 /* SENSORS ONLY END */
316
317 /* OK. For now, we presume we have a valid client. We now create the 343 /* OK. For now, we presume we have a valid client. We now create the
318 client structure, even though we cannot fill it completely yet. 344 client structure, even though we cannot fill it completely yet.
319 But it allows us to access several i2c functions safely */ 345 But it allows us to access several i2c functions safely */
@@ -323,13 +349,12 @@ For now, you can ignore the `flags' parameter. It is there for future use.
323 goto ERROR0; 349 goto ERROR0;
324 } 350 }
325 351
326 new_client = &data->client; 352 client = &data->client;
327 i2c_set_clientdata(new_client, data); 353 i2c_set_clientdata(client, data);
328 354
329 new_client->addr = address; 355 client->addr = address;
330 new_client->adapter = adapter; 356 client->adapter = adapter;
331 new_client->driver = &foo_driver; 357 client->driver = &foo_driver;
332 new_client->flags = 0;
333 358
334 /* Now, we do the remaining detection. If no `force' parameter is used. */ 359 /* Now, we do the remaining detection. If no `force' parameter is used. */
335 360
@@ -337,19 +362,17 @@ For now, you can ignore the `flags' parameter. It is there for future use.
337 parameter was used. */ 362 parameter was used. */
338 if (kind < 0) { 363 if (kind < 0) {
339 /* The below is of course bogus */ 364 /* The below is of course bogus */
340 if (foo_read(new_client,FOO_REG_GENERIC) != FOO_GENERIC_VALUE) 365 if (foo_read(client, FOO_REG_GENERIC) != FOO_GENERIC_VALUE)
341 goto ERROR1; 366 goto ERROR1;
342 } 367 }
343 368
344 /* SENSORS ONLY START */
345
346 /* Next, specific detection. This is especially important for `sensors' 369 /* Next, specific detection. This is especially important for `sensors'
347 devices. */ 370 devices. */
348 371
349 /* Determine the chip type. Not needed if a `force_CHIPTYPE' parameter 372 /* Determine the chip type. Not needed if a `force_CHIPTYPE' parameter
350 was used. */ 373 was used. */
351 if (kind <= 0) { 374 if (kind <= 0) {
352 i = foo_read(new_client,FOO_REG_CHIPTYPE); 375 i = foo_read(client, FOO_REG_CHIPTYPE);
353 if (i == FOO_TYPE_1) 376 if (i == FOO_TYPE_1)
354 kind = chip1; /* As defined in the enum */ 377 kind = chip1; /* As defined in the enum */
355 else if (i == FOO_TYPE_2) 378 else if (i == FOO_TYPE_2)
@@ -363,63 +386,31 @@ For now, you can ignore the `flags' parameter. It is there for future use.
363 386
364 /* Now set the type and chip names */ 387 /* Now set the type and chip names */
365 if (kind == chip1) { 388 if (kind == chip1) {
366 type_name = "chip1"; /* For /proc entry */ 389 name = "chip1";
367 client_name = "CHIP 1";
368 } else if (kind == chip2) { 390 } else if (kind == chip2) {
369 type_name = "chip2"; /* For /proc entry */ 391 name = "chip2";
370 client_name = "CHIP 2";
371 } 392 }
372 393
373 /* Reserve the ISA region */
374 if (is_isa)
375 request_region(address,FOO_EXTENT,type_name);
376
377 /* SENSORS ONLY END */
378
379 /* Fill in the remaining client fields. */ 394 /* Fill in the remaining client fields. */
380 strcpy(new_client->name,client_name); 395 strlcpy(client->name, name, I2C_NAME_SIZE);
381
382 /* SENSORS ONLY BEGIN */
383 data->type = kind; 396 data->type = kind;
384 /* SENSORS ONLY END */ 397 mutex_init(&data->update_lock); /* Only if you use this field */
385
386 data->valid = 0; /* Only if you use this field */
387 init_MUTEX(&data->update_lock); /* Only if you use this field */
388 398
389 /* Any other initializations in data must be done here too. */ 399 /* Any other initializations in data must be done here too. */
390 400
391 /* Tell the i2c layer a new client has arrived */
392 if ((err = i2c_attach_client(new_client)))
393 goto ERROR3;
394
395 /* SENSORS ONLY BEGIN */
396 /* Register a new directory entry with module sensors. See below for
397 the `template' structure. */
398 if ((i = i2c_register_entry(new_client, type_name,
399 foo_dir_table_template,THIS_MODULE)) < 0) {
400 err = i;
401 goto ERROR4;
402 }
403 data->sysctl_id = i;
404
405 /* SENSORS ONLY END */
406
407 /* This function can write default values to the client registers, if 401 /* This function can write default values to the client registers, if
408 needed. */ 402 needed. */
409 foo_init_client(new_client); 403 foo_init_client(client);
404
405 /* Tell the i2c layer a new client has arrived */
406 if ((err = i2c_attach_client(client)))
407 goto ERROR1;
408
410 return 0; 409 return 0;
411 410
412 /* OK, this is not exactly good programming practice, usually. But it is 411 /* OK, this is not exactly good programming practice, usually. But it is
413 very code-efficient in this case. */ 412 very code-efficient in this case. */
414 413
415 ERROR4:
416 i2c_detach_client(new_client);
417 ERROR3:
418 ERROR2:
419 /* SENSORS ONLY START */
420 if (is_isa)
421 release_region(address,FOO_EXTENT);
422 /* SENSORS ONLY END */
423 ERROR1: 414 ERROR1:
424 kfree(data); 415 kfree(data);
425 ERROR0: 416 ERROR0:
@@ -427,8 +418,8 @@ For now, you can ignore the `flags' parameter. It is there for future use.
427 } 418 }
428 419
429 420
430Removing the client 421Removing the client (Legacy model)
431=================== 422==================================
432 423
433The detach_client call back function is called when a client should be 424The detach_client call back function is called when a client should be
434removed. It may actually fail, but only when panicking. This code is 425removed. It may actually fail, but only when panicking. This code is
@@ -436,22 +427,12 @@ much simpler than the attachment code, fortunately!
436 427
437 int foo_detach_client(struct i2c_client *client) 428 int foo_detach_client(struct i2c_client *client)
438 { 429 {
439 int err,i; 430 int err;
440
441 /* SENSORS ONLY START */
442 /* Deregister with the `i2c-proc' module. */
443 i2c_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id);
444 /* SENSORS ONLY END */
445 431
446 /* Try to detach the client from i2c space */ 432 /* Try to detach the client from i2c space */
447 if ((err = i2c_detach_client(client))) 433 if ((err = i2c_detach_client(client)))
448 return err; 434 return err;
449 435
450 /* HYBRID SENSORS CHIP ONLY START */
451 if i2c_is_isa_client(client)
452 release_region(client->addr,LM78_EXTENT);
453 /* HYBRID SENSORS CHIP ONLY END */
454
455 kfree(i2c_get_clientdata(client)); 436 kfree(i2c_get_clientdata(client));
456 return 0; 437 return 0;
457 } 438 }
@@ -464,45 +445,34 @@ When the kernel is booted, or when your foo driver module is inserted,
464you have to do some initializing. Fortunately, just attaching (registering) 445you have to do some initializing. Fortunately, just attaching (registering)
465the driver module is usually enough. 446the driver module is usually enough.
466 447
467 /* Keep track of how far we got in the initialization process. If several
468 things have to initialized, and we fail halfway, only those things
469 have to be cleaned up! */
470 static int __initdata foo_initialized = 0;
471
472 static int __init foo_init(void) 448 static int __init foo_init(void)
473 { 449 {
474 int res; 450 int res;
475 printk("foo version %s (%s)\n",FOO_VERSION,FOO_DATE);
476 451
477 if ((res = i2c_add_driver(&foo_driver))) { 452 if ((res = i2c_add_driver(&foo_driver))) {
478 printk("foo: Driver registration failed, module not inserted.\n"); 453 printk("foo: Driver registration failed, module not inserted.\n");
479 foo_cleanup();
480 return res; 454 return res;
481 } 455 }
482 foo_initialized ++;
483 return 0; 456 return 0;
484 } 457 }
485 458
486 void foo_cleanup(void) 459 static void __exit foo_cleanup(void)
487 { 460 {
488 if (foo_initialized == 1) { 461 i2c_del_driver(&foo_driver);
489 if ((res = i2c_del_driver(&foo_driver))) {
490 printk("foo: Driver registration failed, module not removed.\n");
491 return;
492 }
493 foo_initialized --;
494 }
495 } 462 }
496 463
497 /* Substitute your own name and email address */ 464 /* Substitute your own name and email address */
498 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>" 465 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"
499 MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices"); 466 MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices");
500 467
468 /* a few non-GPL license types are also allowed */
469 MODULE_LICENSE("GPL");
470
501 module_init(foo_init); 471 module_init(foo_init);
502 module_exit(foo_cleanup); 472 module_exit(foo_cleanup);
503 473
504Note that some functions are marked by `__init', and some data structures 474Note that some functions are marked by `__init', and some data structures
505by `__init_data'. Hose functions and structures can be removed after 475by `__initdata'. These functions and structures can be removed after
506kernel booting (or module loading) is completed. 476kernel booting (or module loading) is completed.
507 477
508 478
@@ -632,110 +602,7 @@ General purpose routines
632Below all general purpose routines are listed, that were not mentioned 602Below all general purpose routines are listed, that were not mentioned
633before. 603before.
634 604
635 /* This call returns a unique low identifier for each registered adapter, 605 /* This call returns a unique low identifier for each registered adapter.
636 * or -1 if the adapter was not registered.
637 */ 606 */
638 extern int i2c_adapter_id(struct i2c_adapter *adap); 607 extern int i2c_adapter_id(struct i2c_adapter *adap);
639 608
640
641The sensors sysctl/proc interface
642=================================
643
644This section only applies if you write `sensors' drivers.
645
646Each sensors driver creates a directory in /proc/sys/dev/sensors for each
647registered client. The directory is called something like foo-i2c-4-65.
648The sensors module helps you to do this as easily as possible.
649
650The template
651------------
652
653You will need to define a ctl_table template. This template will automatically
654be copied to a newly allocated structure and filled in where necessary when
655you call sensors_register_entry.
656
657First, I will give an example definition.
658 static ctl_table foo_dir_table_template[] = {
659 { FOO_SYSCTL_FUNC1, "func1", NULL, 0, 0644, NULL, &i2c_proc_real,
660 &i2c_sysctl_real,NULL,&foo_func },
661 { FOO_SYSCTL_FUNC2, "func2", NULL, 0, 0644, NULL, &i2c_proc_real,
662 &i2c_sysctl_real,NULL,&foo_func },
663 { FOO_SYSCTL_DATA, "data", NULL, 0, 0644, NULL, &i2c_proc_real,
664 &i2c_sysctl_real,NULL,&foo_data },
665 { 0 }
666 };
667
668In the above example, three entries are defined. They can either be
669accessed through the /proc interface, in the /proc/sys/dev/sensors/*
670directories, as files named func1, func2 and data, or alternatively
671through the sysctl interface, in the appropriate table, with identifiers
672FOO_SYSCTL_FUNC1, FOO_SYSCTL_FUNC2 and FOO_SYSCTL_DATA.
673
674The third, sixth and ninth parameters should always be NULL, and the
675fourth should always be 0. The fifth is the mode of the /proc file;
6760644 is safe, as the file will be owned by root:root.
677
678The seventh and eighth parameters should be &i2c_proc_real and
679&i2c_sysctl_real if you want to export lists of reals (scaled
680integers). You can also use your own function for them, as usual.
681Finally, the last parameter is the call-back to gather the data
682(see below) if you use the *_proc_real functions.
683
684
685Gathering the data
686------------------
687
688The call back functions (foo_func and foo_data in the above example)
689can be called in several ways; the operation parameter determines
690what should be done:
691
692 * If operation == SENSORS_PROC_REAL_INFO, you must return the
693 magnitude (scaling) in nrels_mag;
694 * If operation == SENSORS_PROC_REAL_READ, you must read information
695 from the chip and return it in results. The number of integers
696 to display should be put in nrels_mag;
697 * If operation == SENSORS_PROC_REAL_WRITE, you must write the
698 supplied information to the chip. nrels_mag will contain the number
699 of integers, results the integers themselves.
700
701The *_proc_real functions will display the elements as reals for the
702/proc interface. If you set the magnitude to 2, and supply 345 for
703SENSORS_PROC_REAL_READ, it would display 3.45; and if the user would
704write 45.6 to the /proc file, it would be returned as 4560 for
705SENSORS_PROC_REAL_WRITE. A magnitude may even be negative!
706
707An example function:
708
709 /* FOO_FROM_REG and FOO_TO_REG translate between scaled values and
710 register values. Note the use of the read cache. */
711 void foo_in(struct i2c_client *client, int operation, int ctl_name,
712 int *nrels_mag, long *results)
713 {
714 struct foo_data *data = client->data;
715 int nr = ctl_name - FOO_SYSCTL_FUNC1; /* reduce to 0 upwards */
716
717 if (operation == SENSORS_PROC_REAL_INFO)
718 *nrels_mag = 2;
719 else if (operation == SENSORS_PROC_REAL_READ) {
720 /* Update the readings cache (if necessary) */
721 foo_update_client(client);
722 /* Get the readings from the cache */
723 results[0] = FOO_FROM_REG(data->foo_func_base[nr]);
724 results[1] = FOO_FROM_REG(data->foo_func_more[nr]);
725 results[2] = FOO_FROM_REG(data->foo_func_readonly[nr]);
726 *nrels_mag = 2;
727 } else if (operation == SENSORS_PROC_REAL_WRITE) {
728 if (*nrels_mag >= 1) {
729 /* Update the cache */
730 data->foo_base[nr] = FOO_TO_REG(results[0]);
731 /* Update the chip */
732 foo_write_value(client,FOO_REG_FUNC_BASE(nr),data->foo_base[nr]);
733 }
734 if (*nrels_mag >= 2) {
735 /* Update the cache */
736 data->foo_more[nr] = FOO_TO_REG(results[1]);
737 /* Update the chip */
738 foo_write_value(client,FOO_REG_FUNC_MORE(nr),data->foo_more[nr]);
739 }
740 }
741 }
diff --git a/Documentation/input/input-programming.txt b/Documentation/input/input-programming.txt
index 180e0689676c..d9d523099bb7 100644
--- a/Documentation/input/input-programming.txt
+++ b/Documentation/input/input-programming.txt
@@ -1,5 +1,3 @@
1$Id: input-programming.txt,v 1.4 2001/05/04 09:47:14 vojtech Exp $
2
3Programming input drivers 1Programming input drivers
4~~~~~~~~~~~~~~~~~~~~~~~~~ 2~~~~~~~~~~~~~~~~~~~~~~~~~
5 3
@@ -20,28 +18,51 @@ pressed or released a BUTTON_IRQ happens. The driver could look like:
20#include <asm/irq.h> 18#include <asm/irq.h>
21#include <asm/io.h> 19#include <asm/io.h>
22 20
21static struct input_dev *button_dev;
22
23static void button_interrupt(int irq, void *dummy, struct pt_regs *fp) 23static void button_interrupt(int irq, void *dummy, struct pt_regs *fp)
24{ 24{
25 input_report_key(&button_dev, BTN_1, inb(BUTTON_PORT) & 1); 25 input_report_key(button_dev, BTN_1, inb(BUTTON_PORT) & 1);
26 input_sync(&button_dev); 26 input_sync(button_dev);
27} 27}
28 28
29static int __init button_init(void) 29static int __init button_init(void)
30{ 30{
31 int error;
32
31 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) { 33 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) {
32 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq); 34 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq);
33 return -EBUSY; 35 return -EBUSY;
34 } 36 }
35 37
36 button_dev.evbit[0] = BIT(EV_KEY); 38 button_dev = input_allocate_device();
37 button_dev.keybit[LONG(BTN_0)] = BIT(BTN_0); 39 if (!button_dev) {
38 40 printk(KERN_ERR "button.c: Not enough memory\n");
39 input_register_device(&button_dev); 41 error = -ENOMEM;
42 goto err_free_irq;
43 }
44
45 button_dev->evbit[0] = BIT(EV_KEY);
46 button_dev->keybit[LONG(BTN_0)] = BIT(BTN_0);
47
48 error = input_register_device(button_dev);
49 if (error) {
50 printk(KERN_ERR "button.c: Failed to register device\n");
51 goto err_free_dev;
52 }
53
54 return 0;
55
56 err_free_dev:
57 input_free_device(button_dev);
58 err_free_irq:
59 free_irq(BUTTON_IRQ, button_interrupt);
60 return error;
40} 61}
41 62
42static void __exit button_exit(void) 63static void __exit button_exit(void)
43{ 64{
44 input_unregister_device(&button_dev); 65 input_unregister_device(button_dev);
45 free_irq(BUTTON_IRQ, button_interrupt); 66 free_irq(BUTTON_IRQ, button_interrupt);
46} 67}
47 68
@@ -58,17 +79,18 @@ In the _init function, which is called either upon module load or when
58booting the kernel, it grabs the required resources (it should also check 79booting the kernel, it grabs the required resources (it should also check
59for the presence of the device). 80for the presence of the device).
60 81
61Then it sets the input bitfields. This way the device driver tells the other 82Then it allocates a new input device structure with input_aloocate_device()
83and sets up input bitfields. This way the device driver tells the other
62parts of the input systems what it is - what events can be generated or 84parts of the input systems what it is - what events can be generated or
63accepted by this input device. Our example device can only generate EV_KEY type 85accepted by this input device. Our example device can only generate EV_KEY
64events, and from those only BTN_0 event code. Thus we only set these two 86type events, and from those only BTN_0 event code. Thus we only set these
65bits. We could have used 87two bits. We could have used
66 88
67 set_bit(EV_KEY, button_dev.evbit); 89 set_bit(EV_KEY, button_dev.evbit);
68 set_bit(BTN_0, button_dev.keybit); 90 set_bit(BTN_0, button_dev.keybit);
69 91
70as well, but with more than single bits the first approach tends to be 92as well, but with more than single bits the first approach tends to be
71shorter. 93shorter.
72 94
73Then the example driver registers the input device structure by calling 95Then the example driver registers the input device structure by calling
74 96
@@ -76,16 +98,15 @@ Then the example driver registers the input device structure by calling
76 98
77This adds the button_dev structure to linked lists of the input driver and 99This adds the button_dev structure to linked lists of the input driver and
78calls device handler modules _connect functions to tell them a new input 100calls device handler modules _connect functions to tell them a new input
79device has appeared. Because the _connect functions may call kmalloc(, 101device has appeared. input_register_device() may sleep and therefore must
80GFP_KERNEL), which can sleep, input_register_device() must not be called 102not be called from an interrupt or with a spinlock held.
81from an interrupt or with a spinlock held.
82 103
83While in use, the only used function of the driver is 104While in use, the only used function of the driver is
84 105
85 button_interrupt() 106 button_interrupt()
86 107
87which upon every interrupt from the button checks its state and reports it 108which upon every interrupt from the button checks its state and reports it
88via the 109via the
89 110
90 input_report_key() 111 input_report_key()
91 112
@@ -113,16 +134,10 @@ can use the open and close callback to know when it can stop polling or
113release the interrupt and when it must resume polling or grab the interrupt 134release the interrupt and when it must resume polling or grab the interrupt
114again. To do that, we would add this to our example driver: 135again. To do that, we would add this to our example driver:
115 136
116int button_used = 0;
117
118static int button_open(struct input_dev *dev) 137static int button_open(struct input_dev *dev)
119{ 138{
120 if (button_used++)
121 return 0;
122
123 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) { 139 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) {
124 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq); 140 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq);
125 button_used--;
126 return -EBUSY; 141 return -EBUSY;
127 } 142 }
128 143
@@ -131,20 +146,21 @@ static int button_open(struct input_dev *dev)
131 146
132static void button_close(struct input_dev *dev) 147static void button_close(struct input_dev *dev)
133{ 148{
134 if (!--button_used) 149 free_irq(IRQ_AMIGA_VERTB, button_interrupt);
135 free_irq(IRQ_AMIGA_VERTB, button_interrupt);
136} 150}
137 151
138static int __init button_init(void) 152static int __init button_init(void)
139{ 153{
140 ... 154 ...
141 button_dev.open = button_open; 155 button_dev->open = button_open;
142 button_dev.close = button_close; 156 button_dev->close = button_close;
143 ... 157 ...
144} 158}
145 159
146Note the button_used variable - we have to track how many times the open 160Note that input core keeps track of number of users for the device and
147function was called to know when exactly our device stops being used. 161makes sure that dev->open() is called only when the first user connects
162to the device and that dev->close() is called when the very last user
163disconnects. Calls to both callbacks are serialized.
148 164
149The open() callback should return a 0 in case of success or any nonzero value 165The open() callback should return a 0 in case of success or any nonzero value
150in case of failure. The close() callback (which is void) must always succeed. 166in case of failure. The close() callback (which is void) must always succeed.
@@ -175,7 +191,7 @@ set the corresponding bits and call the
175 191
176 input_report_rel(struct input_dev *dev, int code, int value) 192 input_report_rel(struct input_dev *dev, int code, int value)
177 193
178function. Events are generated only for nonzero value. 194function. Events are generated only for nonzero value.
179 195
180However EV_ABS requires a little special care. Before calling 196However EV_ABS requires a little special care. Before calling
181input_register_device, you have to fill additional fields in the input_dev 197input_register_device, you have to fill additional fields in the input_dev
@@ -187,6 +203,10 @@ the ABS_X axis:
187 button_dev.absfuzz[ABS_X] = 4; 203 button_dev.absfuzz[ABS_X] = 4;
188 button_dev.absflat[ABS_X] = 8; 204 button_dev.absflat[ABS_X] = 8;
189 205
206Or, you can just say:
207
208 input_set_abs_params(button_dev, ABS_X, 0, 255, 4, 8);
209
190This setting would be appropriate for a joystick X axis, with the minimum of 210This setting would be appropriate for a joystick X axis, with the minimum of
1910, maximum of 255 (which the joystick *must* be able to reach, no problem if 2110, maximum of 255 (which the joystick *must* be able to reach, no problem if
192it sometimes reports more, but it must be able to always reach the min and 212it sometimes reports more, but it must be able to always reach the min and
@@ -197,14 +217,7 @@ If you don't need absfuzz and absflat, you can set them to zero, which mean
197that the thing is precise and always returns to exactly the center position 217that the thing is precise and always returns to exactly the center position
198(if it has any). 218(if it has any).
199 219
2001.4 The void *private field 2201.4 NBITS(), LONG(), BIT()
201~~~~~~~~~~~~~~~~~~~~~~~~~~~
202
203This field in the input structure can be used to point to any private data
204structures in the input device driver, in case the driver handles more than
205one device. You'll need it in the open and close callbacks.
206
2071.5 NBITS(), LONG(), BIT()
208~~~~~~~~~~~~~~~~~~~~~~~~~~ 221~~~~~~~~~~~~~~~~~~~~~~~~~~
209 222
210These three macros from input.h help some bitfield computations: 223These three macros from input.h help some bitfield computations:
@@ -213,13 +226,9 @@ These three macros from input.h help some bitfield computations:
213 LONG(x) - returns the index in the array in longs for bit x 226 LONG(x) - returns the index in the array in longs for bit x
214 BIT(x) - returns the index in a long for bit x 227 BIT(x) - returns the index in a long for bit x
215 228
2161.6 The number, id* and name fields 2291.5 The id* and name fields
217~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 230~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218 231
219The dev->number is assigned by the input system to the input device when it
220is registered. It has no use except for identifying the device to the user
221in system messages.
222
223The dev->name should be set before registering the input device by the input 232The dev->name should be set before registering the input device by the input
224device driver. It's a string like 'Generic button device' containing a 233device driver. It's a string like 'Generic button device' containing a
225user friendly name of the device. 234user friendly name of the device.
@@ -234,15 +243,25 @@ driver.
234 243
235The id and name fields can be passed to userland via the evdev interface. 244The id and name fields can be passed to userland via the evdev interface.
236 245
2371.7 The keycode, keycodemax, keycodesize fields 2461.6 The keycode, keycodemax, keycodesize fields
238~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 247~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239 248
240These two fields will be used for any input devices that report their data 249These three fields should be used by input devices that have dense keymaps.
241as scancodes. If not all scancodes can be known by autodetection, they may 250The keycode is an array used to map from scancodes to input system keycodes.
242need to be set by userland utilities. The keycode array then is an array 251The keycode max should contain the size of the array and keycodesize the
243used to map from scancodes to input system keycodes. The keycode max will 252size of each entry in it (in bytes).
244contain the size of the array and keycodesize the size of each entry in it 253
245(in bytes). 254Userspace can query and alter current scancode to keycode mappings using
255EVIOCGKEYCODE and EVIOCSKEYCODE ioctls on corresponding evdev interface.
256When a device has all 3 aforementioned fields filled in, the driver may
257rely on kernel's default implementation of setting and querying keycode
258mappings.
259
2601.7 dev->getkeycode() and dev->setkeycode()
261~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
262getkeycode() and setkeycode() callbacks allow drivers to override default
263keycode/keycodesize/keycodemax mapping mechanism provided by input core
264and implement sparse keycode maps.
246 265
2471.8 Key autorepeat 2661.8 Key autorepeat
248~~~~~~~~~~~~~~~~~~ 267~~~~~~~~~~~~~~~~~~
@@ -266,7 +285,7 @@ direction - from the system to the input device driver. If your input device
266driver can handle these events, it has to set the respective bits in evbit, 285driver can handle these events, it has to set the respective bits in evbit,
267*and* also the callback routine: 286*and* also the callback routine:
268 287
269 button_dev.event = button_event; 288 button_dev->event = button_event;
270 289
271int button_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); 290int button_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
272{ 291{
diff --git a/Documentation/pci.txt b/Documentation/pci.txt
index cdf2f3c0ab14..e2c9d0a0c43d 100644
--- a/Documentation/pci.txt
+++ b/Documentation/pci.txt
@@ -124,10 +124,6 @@ initialization with a pointer to a structure describing the driver
124 124
125 err_handler See Documentation/pci-error-recovery.txt 125 err_handler See Documentation/pci-error-recovery.txt
126 126
127 multithread_probe Enable multi-threaded probe/scan. Driver must
128 provide its own locking/syncronization for init
129 operations if this is enabled.
130
131 127
132The ID table is an array of struct pci_device_id entries ending with an 128The ID table is an array of struct pci_device_id entries ending with an
133all-zero entry. Each entry consists of: 129all-zero entry. Each entry consists of:
@@ -163,9 +159,9 @@ echo "vendor device subvendor subdevice class class_mask driver_data" > \
163/sys/bus/pci/drivers/{driver}/new_id 159/sys/bus/pci/drivers/{driver}/new_id
164 160
165All fields are passed in as hexadecimal values (no leading 0x). 161All fields are passed in as hexadecimal values (no leading 0x).
166Users need pass only as many fields as necessary: 162The vendor and device fields are mandatory, the others are optional. Users
167 o vendor, device, subvendor, and subdevice fields default 163need pass only as many optional fields as necessary:
168 to PCI_ANY_ID (FFFFFFFF), 164 o subvendor and subdevice fields default to PCI_ANY_ID (FFFFFFFF)
169 o class and classmask fields default to 0 165 o class and classmask fields default to 0
170 o driver_data defaults to 0UL. 166 o driver_data defaults to 0UL.
171 167
@@ -549,8 +545,6 @@ pci_find_slot() Find pci_dev corresponding to given bus and
549pci_set_power_state() Set PCI Power Management state (0=D0 ... 3=D3) 545pci_set_power_state() Set PCI Power Management state (0=D0 ... 3=D3)
550pci_find_capability() Find specified capability in device's capability 546pci_find_capability() Find specified capability in device's capability
551 list. 547 list.
552pci_module_init() Inline helper function for ensuring correct
553 pci_driver initialization and error handling.
554pci_resource_start() Returns bus start address for a given PCI region 548pci_resource_start() Returns bus start address for a given PCI region
555pci_resource_end() Returns bus end address for a given PCI region 549pci_resource_end() Returns bus end address for a given PCI region
556pci_resource_len() Returns the byte length of a PCI region 550pci_resource_len() Returns the byte length of a PCI region
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt
index b6a3cbf7e846..e00b099a4b86 100644
--- a/Documentation/power/pci.txt
+++ b/Documentation/power/pci.txt
@@ -203,7 +203,7 @@ resume
203 203
204Usage: 204Usage:
205 205
206if (dev->driver && dev->driver->suspend) 206if (dev->driver && dev->driver->resume)
207 dev->driver->resume(dev) 207 dev->driver->resume(dev)
208 208
209The resume callback may be called from any power state, and is always meant to 209The resume callback may be called from any power state, and is always meant to
diff --git a/Documentation/scsi/aacraid.txt b/Documentation/scsi/aacraid.txt
index dc8e44fc650f..2368e7e4a8cf 100644
--- a/Documentation/scsi/aacraid.txt
+++ b/Documentation/scsi/aacraid.txt
@@ -37,7 +37,11 @@ Supported Cards/Chipsets
37 9005:0286:9005:029d Adaptec 2420SA (Intruder HP release) 37 9005:0286:9005:029d Adaptec 2420SA (Intruder HP release)
38 9005:0286:9005:02ac Adaptec 1800 (Typhoon44) 38 9005:0286:9005:02ac Adaptec 1800 (Typhoon44)
39 9005:0285:9005:02b5 Adaptec 5445 (Voodoo44) 39 9005:0285:9005:02b5 Adaptec 5445 (Voodoo44)
40 9005:0285:15d9:02b5 SMC AOC-USAS-S4i
41 9005:0285:15d9:02c9 SMC AOC-USAS-S4iR
40 9005:0285:9005:02b6 Adaptec 5805 (Voodoo80) 42 9005:0285:9005:02b6 Adaptec 5805 (Voodoo80)
43 9005:0285:15d9:02b6 SMC AOC-USAS-S8i
44 9005:0285:15d9:02ca SMC AOC-USAS-S8iR
41 9005:0285:9005:02b7 Adaptec 5085 (Voodoo08) 45 9005:0285:9005:02b7 Adaptec 5085 (Voodoo08)
42 9005:0285:9005:02bb Adaptec 3405 (Marauder40LP) 46 9005:0285:9005:02bb Adaptec 3405 (Marauder40LP)
43 9005:0285:9005:02bc Adaptec 3805 (Marauder80LP) 47 9005:0285:9005:02bc Adaptec 3805 (Marauder80LP)
@@ -93,6 +97,9 @@ Supported Cards/Chipsets
93 9005:0286:9005:02ae (Aurora Lite ARK) 97 9005:0286:9005:02ae (Aurora Lite ARK)
94 9005:0285:9005:02b0 (Sunrise Lake ARK) 98 9005:0285:9005:02b0 (Sunrise Lake ARK)
95 9005:0285:9005:02b1 Adaptec (Voodoo 8 internal 8 external) 99 9005:0285:9005:02b1 Adaptec (Voodoo 8 internal 8 external)
100 9005:0285:108e:7aac SUN STK RAID REM (Voodoo44 Coyote)
101 9005:0285:108e:0286 SUN SG-XPCIESAS-R-IN (Cougar)
102 9005:0285:108e:0287 SUN SG-XPCIESAS-R-EX (Prometheus)
96 103
97People 104People
98------------------------- 105-------------------------
diff --git a/Documentation/scsi/ncr53c8xx.txt b/Documentation/scsi/ncr53c8xx.txt
index caf10b155185..88ef88b949f7 100644
--- a/Documentation/scsi/ncr53c8xx.txt
+++ b/Documentation/scsi/ncr53c8xx.txt
@@ -562,11 +562,6 @@ if only one has a flaw for some SCSI feature, you can disable the
562support by the driver of this feature at linux start-up and enable 562support by the driver of this feature at linux start-up and enable
563this feature after boot-up only for devices that support it safely. 563this feature after boot-up only for devices that support it safely.
564 564
565CONFIG_SCSI_NCR53C8XX_PROFILE_SUPPORT (default answer: n)
566 This option must be set for profiling information to be gathered
567 and printed out through the proc file system. This features may
568 impact performances.
569
570CONFIG_SCSI_NCR53C8XX_IOMAPPED (default answer: n) 565CONFIG_SCSI_NCR53C8XX_IOMAPPED (default answer: n)
571 Answer "y" if you suspect your mother board to not allow memory mapped I/O. 566 Answer "y" if you suspect your mother board to not allow memory mapped I/O.
572 May slow down performance a little. This option is required by 567 May slow down performance a little. This option is required by
diff --git a/Documentation/usb/usb-serial.txt b/Documentation/usb/usb-serial.txt
index d61f6e7865de..b18e86a22506 100644
--- a/Documentation/usb/usb-serial.txt
+++ b/Documentation/usb/usb-serial.txt
@@ -42,7 +42,7 @@ ConnectTech WhiteHEAT 4 port converter
42 http://www.connecttech.com 42 http://www.connecttech.com
43 43
44 For any questions or problems with this driver, please contact 44 For any questions or problems with this driver, please contact
45 Stuart MacDonald at stuartm@connecttech.com 45 Connect Tech's Support Department at support@connecttech.com
46 46
47 47
48HandSpring Visor, Palm USB, and Clié USB driver 48HandSpring Visor, Palm USB, and Clié USB driver
diff --git a/MAINTAINERS b/MAINTAINERS
index 4b307e6263c2..0492dd88e12a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -733,6 +733,13 @@ M: tigran@aivazian.fsnet.co.uk
733L: linux-kernel@vger.kernel.org 733L: linux-kernel@vger.kernel.org
734S: Maintained 734S: Maintained
735 735
736BLACKFIN I2C TWI DRIVER
737P: Sonic Zhang
738M: sonic.zhang@analog.com
739L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only)
740W: http://blackfin.uclinux.org/
741S: Supported
742
736BLOCK LAYER 743BLOCK LAYER
737P: Jens Axboe 744P: Jens Axboe
738M: axboe@kernel.dk 745M: axboe@kernel.dk
@@ -1459,6 +1466,11 @@ L: linux-scsi@vger.kernel.org
1459W: http://www.icp-vortex.com/ 1466W: http://www.icp-vortex.com/
1460S: Supported 1467S: Supported
1461 1468
1469GENERIC GPIO I2C DRIVER
1470P: Haavard Skinnemoen
1471M: hskinnemoen@atmel.com
1472S: Supported
1473
1462GENERIC HDLC DRIVER, N2, C101, PCI200SYN and WANXL DRIVERS 1474GENERIC HDLC DRIVER, N2, C101, PCI200SYN and WANXL DRIVERS
1463P: Krzysztof Halasa 1475P: Krzysztof Halasa
1464M: khc@pm.waw.pl 1476M: khc@pm.waw.pl
@@ -1631,6 +1643,13 @@ L: i2c@lm-sensors.org
1631T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/ 1643T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/
1632S: Maintained 1644S: Maintained
1633 1645
1646I2C-TINY-USB DRIVER
1647P: Till Harbaum
1648M: till@harbaum.org
1649L: i2c@lm-sensors.org
1650T: http://www.harbaum.org/till/i2c_tiny_usb
1651S: Maintained
1652
1634i386 BOOT CODE 1653i386 BOOT CODE
1635P: Riley H. Williams 1654P: Riley H. Williams
1636M: Riley@Williams.Name 1655M: Riley@Williams.Name
@@ -2209,6 +2228,16 @@ M: philb@gnu.org
2209W: http://www.tazenda.demon.co.uk/phil/linux-hp 2228W: http://www.tazenda.demon.co.uk/phil/linux-hp
2210S: Maintained 2229S: Maintained
2211 2230
2231MAC80211
2232P: Jiri Benc
2233M: jbenc@suse.cz
2234P: Michael Wu
2235M: flamingice@sourmilk.net
2236L: linux-wireless@vger.kernel.org
2237W: http://linuxwireless.org/
2238T: git kernel.org:/pub/scm/linux/kernel/git/jbenc/mac80211.git
2239S: Maintained
2240
2212MARVELL YUKON / SYSKONNECT DRIVER 2241MARVELL YUKON / SYSKONNECT DRIVER
2213P: Mirko Lindner 2242P: Mirko Lindner
2214M: mlindner@syskonnect.de 2243M: mlindner@syskonnect.de
@@ -3640,8 +3669,8 @@ W: http://www.kroah.com/linux/
3640S: Maintained 3669S: Maintained
3641 3670
3642USB SERIAL WHITEHEAT DRIVER 3671USB SERIAL WHITEHEAT DRIVER
3643P: Stuart MacDonald 3672P: Support Department
3644M: stuartm@connecttech.com 3673M: support@connecttech.com
3645L: linux-usb-users@lists.sourceforge.net 3674L: linux-usb-users@lists.sourceforge.net
3646L: linux-usb-devel@lists.sourceforge.net 3675L: linux-usb-devel@lists.sourceforge.net
3647W: http://www.connecttech.com 3676W: http://www.connecttech.com
diff --git a/arch/alpha/kernel/err_common.c b/arch/alpha/kernel/err_common.c
index 687580b16b41..13d53b1c9657 100644
--- a/arch/alpha/kernel/err_common.c
+++ b/arch/alpha/kernel/err_common.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pci.h>
11#include <linux/sched.h> 10#include <linux/sched.h>
12 11
13#include <asm/io.h> 12#include <asm/io.h>
diff --git a/arch/alpha/kernel/err_ev6.c b/arch/alpha/kernel/err_ev6.c
index 69b5f4ea7355..11aee012a8ae 100644
--- a/arch/alpha/kernel/err_ev6.c
+++ b/arch/alpha/kernel/err_ev6.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pci.h>
11#include <linux/sched.h> 10#include <linux/sched.h>
12 11
13#include <asm/io.h> 12#include <asm/io.h>
diff --git a/arch/alpha/kernel/err_ev7.c b/arch/alpha/kernel/err_ev7.c
index 95463ab1cf35..bc799f72d8c1 100644
--- a/arch/alpha/kernel/err_ev7.c
+++ b/arch/alpha/kernel/err_ev7.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pci.h>
11#include <linux/sched.h> 10#include <linux/sched.h>
12 11
13#include <asm/io.h> 12#include <asm/io.h>
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e7baca29f3fb..db00376aca15 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -255,6 +255,7 @@ config ARCH_IOP13XX
255 depends on MMU 255 depends on MMU
256 select PLAT_IOP 256 select PLAT_IOP
257 select PCI 257 select PCI
258 select ARCH_SUPPORTS_MSI
258 help 259 help
259 Support for Intel's IOP13XX (XScale) family of processors. 260 Support for Intel's IOP13XX (XScale) family of processors.
260 261
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 0383ab334270..6f4ea4bda5e0 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -72,12 +72,12 @@ static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];
72 72
73static unsigned short enable_dyn_sleep = 1; 73static unsigned short enable_dyn_sleep = 1;
74 74
75static ssize_t omap_pm_sleep_while_idle_show(struct subsystem * subsys, char *buf) 75static ssize_t omap_pm_sleep_while_idle_show(struct kset *kset, char *buf)
76{ 76{
77 return sprintf(buf, "%hu\n", enable_dyn_sleep); 77 return sprintf(buf, "%hu\n", enable_dyn_sleep);
78} 78}
79 79
80static ssize_t omap_pm_sleep_while_idle_store(struct subsystem * subsys, 80static ssize_t omap_pm_sleep_while_idle_store(struct kset *kset,
81 const char * buf, 81 const char * buf,
82 size_t n) 82 size_t n)
83{ 83{
@@ -100,7 +100,7 @@ static struct subsys_attribute sleep_while_idle_attr = {
100 .store = omap_pm_sleep_while_idle_store, 100 .store = omap_pm_sleep_while_idle_store,
101}; 101};
102 102
103extern struct subsystem power_subsys; 103extern struct kset power_subsys;
104static void (*omap_sram_idle)(void) = NULL; 104static void (*omap_sram_idle)(void) = NULL;
105static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL; 105static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;
106 106
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index c6f8d6856c4d..a9af760c7e5f 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -1057,6 +1057,7 @@ config PCI
1057 bool "PCI support" if !X86_VISWS 1057 bool "PCI support" if !X86_VISWS
1058 depends on !X86_VOYAGER 1058 depends on !X86_VOYAGER
1059 default y if X86_VISWS 1059 default y if X86_VISWS
1060 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
1060 help 1061 help
1061 Find out whether you have a PCI motherboard. PCI is the name of a 1062 Find out whether you have a PCI motherboard. PCI is the name of a
1062 bus system, i.e. the way the CPU talks to the other stuff inside 1063 bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c
index 2b030d6ccbf7..a3df9c039bd4 100644
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.c
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c
@@ -590,20 +590,23 @@ static acpi_status longhaul_walk_callback(acpi_handle obj_handle,
590static int enable_arbiter_disable(void) 590static int enable_arbiter_disable(void)
591{ 591{
592 struct pci_dev *dev; 592 struct pci_dev *dev;
593 int status;
593 int reg; 594 int reg;
594 u8 pci_cmd; 595 u8 pci_cmd;
595 596
597 status = 1;
596 /* Find PLE133 host bridge */ 598 /* Find PLE133 host bridge */
597 reg = 0x78; 599 reg = 0x78;
598 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8601_0, NULL); 600 dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8601_0,
601 NULL);
599 /* Find CLE266 host bridge */ 602 /* Find CLE266 host bridge */
600 if (dev == NULL) { 603 if (dev == NULL) {
601 reg = 0x76; 604 reg = 0x76;
602 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_862X_0, NULL); 605 dev = pci_get_device(PCI_VENDOR_ID_VIA,
606 PCI_DEVICE_ID_VIA_862X_0, NULL);
603 /* Find CN400 V-Link host bridge */ 607 /* Find CN400 V-Link host bridge */
604 if (dev == NULL) 608 if (dev == NULL)
605 dev = pci_find_device(PCI_VENDOR_ID_VIA, 0x7259, NULL); 609 dev = pci_get_device(PCI_VENDOR_ID_VIA, 0x7259, NULL);
606
607 } 610 }
608 if (dev != NULL) { 611 if (dev != NULL) {
609 /* Enable access to port 0x22 */ 612 /* Enable access to port 0x22 */
@@ -615,10 +618,11 @@ static int enable_arbiter_disable(void)
615 if (!(pci_cmd & 1<<7)) { 618 if (!(pci_cmd & 1<<7)) {
616 printk(KERN_ERR PFX 619 printk(KERN_ERR PFX
617 "Can't enable access to port 0x22.\n"); 620 "Can't enable access to port 0x22.\n");
618 return 0; 621 status = 0;
619 } 622 }
620 } 623 }
621 return 1; 624 pci_dev_put(dev);
625 return status;
622 } 626 }
623 return 0; 627 return 0;
624} 628}
@@ -629,7 +633,7 @@ static int longhaul_setup_vt8235(void)
629 u8 pci_cmd; 633 u8 pci_cmd;
630 634
631 /* Find VT8235 southbridge */ 635 /* Find VT8235 southbridge */
632 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, NULL); 636 dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, NULL);
633 if (dev != NULL) { 637 if (dev != NULL) {
634 /* Set transition time to max */ 638 /* Set transition time to max */
635 pci_read_config_byte(dev, 0xec, &pci_cmd); 639 pci_read_config_byte(dev, 0xec, &pci_cmd);
@@ -641,6 +645,7 @@ static int longhaul_setup_vt8235(void)
641 pci_read_config_byte(dev, 0xe5, &pci_cmd); 645 pci_read_config_byte(dev, 0xe5, &pci_cmd);
642 pci_cmd |= 1 << 7; 646 pci_cmd |= 1 << 7;
643 pci_write_config_byte(dev, 0xe5, pci_cmd); 647 pci_write_config_byte(dev, 0xe5, pci_cmd);
648 pci_dev_put(dev);
644 return 1; 649 return 1;
645 } 650 }
646 return 0; 651 return 0;
@@ -678,7 +683,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
678 sizeof(samuel2_eblcr)); 683 sizeof(samuel2_eblcr));
679 break; 684 break;
680 case 1 ... 15: 685 case 1 ... 15:
681 longhaul_version = TYPE_LONGHAUL_V2; 686 longhaul_version = TYPE_LONGHAUL_V1;
682 if (c->x86_mask < 8) { 687 if (c->x86_mask < 8) {
683 cpu_model = CPU_SAMUEL2; 688 cpu_model = CPU_SAMUEL2;
684 cpuname = "C3 'Samuel 2' [C5B]"; 689 cpuname = "C3 'Samuel 2' [C5B]";
diff --git a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
index 4786fedca6eb..4c76b511e194 100644
--- a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
@@ -27,7 +27,6 @@
27#include <linux/cpufreq.h> 27#include <linux/cpufreq.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/cpumask.h> 29#include <linux/cpumask.h>
30#include <linux/sched.h> /* current / set_cpus_allowed() */
31 30
32#include <asm/processor.h> 31#include <asm/processor.h>
33#include <asm/msr.h> 32#include <asm/msr.h>
@@ -62,7 +61,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
62 if (!cpu_online(cpu) || (newstate > DC_DISABLE) || (newstate == DC_RESV)) 61 if (!cpu_online(cpu) || (newstate > DC_DISABLE) || (newstate == DC_RESV))
63 return -EINVAL; 62 return -EINVAL;
64 63
65 rdmsr(MSR_IA32_THERM_STATUS, l, h); 64 rdmsr_on_cpu(cpu, MSR_IA32_THERM_STATUS, &l, &h);
66 65
67 if (l & 0x01) 66 if (l & 0x01)
68 dprintk("CPU#%d currently thermal throttled\n", cpu); 67 dprintk("CPU#%d currently thermal throttled\n", cpu);
@@ -70,10 +69,10 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
70 if (has_N44_O17_errata[cpu] && (newstate == DC_25PT || newstate == DC_DFLT)) 69 if (has_N44_O17_errata[cpu] && (newstate == DC_25PT || newstate == DC_DFLT))
71 newstate = DC_38PT; 70 newstate = DC_38PT;
72 71
73 rdmsr(MSR_IA32_THERM_CONTROL, l, h); 72 rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, &l, &h);
74 if (newstate == DC_DISABLE) { 73 if (newstate == DC_DISABLE) {
75 dprintk("CPU#%d disabling modulation\n", cpu); 74 dprintk("CPU#%d disabling modulation\n", cpu);
76 wrmsr(MSR_IA32_THERM_CONTROL, l & ~(1<<4), h); 75 wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, l & ~(1<<4), h);
77 } else { 76 } else {
78 dprintk("CPU#%d setting duty cycle to %d%%\n", 77 dprintk("CPU#%d setting duty cycle to %d%%\n",
79 cpu, ((125 * newstate) / 10)); 78 cpu, ((125 * newstate) / 10));
@@ -84,7 +83,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
84 */ 83 */
85 l = (l & ~14); 84 l = (l & ~14);
86 l = l | (1<<4) | ((newstate & 0x7)<<1); 85 l = l | (1<<4) | ((newstate & 0x7)<<1);
87 wrmsr(MSR_IA32_THERM_CONTROL, l, h); 86 wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, l, h);
88 } 87 }
89 88
90 return 0; 89 return 0;
@@ -111,7 +110,6 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
111{ 110{
112 unsigned int newstate = DC_RESV; 111 unsigned int newstate = DC_RESV;
113 struct cpufreq_freqs freqs; 112 struct cpufreq_freqs freqs;
114 cpumask_t cpus_allowed;
115 int i; 113 int i;
116 114
117 if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0], target_freq, relation, &newstate)) 115 if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0], target_freq, relation, &newstate))
@@ -132,17 +130,8 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
132 /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software 130 /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software
133 * Developer's Manual, Volume 3 131 * Developer's Manual, Volume 3
134 */ 132 */
135 cpus_allowed = current->cpus_allowed; 133 for_each_cpu_mask(i, policy->cpus)
136
137 for_each_cpu_mask(i, policy->cpus) {
138 cpumask_t this_cpu = cpumask_of_cpu(i);
139
140 set_cpus_allowed(current, this_cpu);
141 BUG_ON(smp_processor_id() != i);
142
143 cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); 134 cpufreq_p4_setdc(i, p4clockmod_table[newstate].index);
144 }
145 set_cpus_allowed(current, cpus_allowed);
146 135
147 /* notifiers */ 136 /* notifiers */
148 for_each_cpu_mask(i, policy->cpus) { 137 for_each_cpu_mask(i, policy->cpus) {
@@ -256,17 +245,9 @@ static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy)
256 245
257static unsigned int cpufreq_p4_get(unsigned int cpu) 246static unsigned int cpufreq_p4_get(unsigned int cpu)
258{ 247{
259 cpumask_t cpus_allowed;
260 u32 l, h; 248 u32 l, h;
261 249
262 cpus_allowed = current->cpus_allowed; 250 rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, &l, &h);
263
264 set_cpus_allowed(current, cpumask_of_cpu(cpu));
265 BUG_ON(smp_processor_id() != cpu);
266
267 rdmsr(MSR_IA32_THERM_CONTROL, l, h);
268
269 set_cpus_allowed(current, cpus_allowed);
270 251
271 if (l & 0x10) { 252 if (l & 0x10) {
272 l = l >> 1; 253 l = l >> 1;
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index fe3b67005ebb..7cf3d207b6b3 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -661,7 +661,8 @@ static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst,
661 661
662 dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid); 662 dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);
663 data->powernow_table = powernow_table; 663 data->powernow_table = powernow_table;
664 print_basics(data); 664 if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
665 print_basics(data);
665 666
666 for (j = 0; j < data->numps; j++) 667 for (j = 0; j < data->numps; j++)
667 if ((pst[j].fid==data->currfid) && (pst[j].vid==data->currvid)) 668 if ((pst[j].fid==data->currfid) && (pst[j].vid==data->currvid))
@@ -814,7 +815,8 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
814 815
815 /* fill in data */ 816 /* fill in data */
816 data->numps = data->acpi_data.state_count; 817 data->numps = data->acpi_data.state_count;
817 print_basics(data); 818 if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
819 print_basics(data);
818 powernow_k8_acpi_pst_values(data, 0); 820 powernow_k8_acpi_pst_values(data, 0);
819 821
820 /* notify BIOS that we exist */ 822 /* notify BIOS that we exist */
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
index 0fb2a3001ba5..95be5013c984 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
@@ -215,8 +215,10 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);
215 215
216static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index); 216static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index);
217 217
218#ifdef CONFIG_X86_POWERNOW_K8_ACPI
218static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table); 219static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table);
219static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table); 220static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table);
221#endif
220 222
221#ifdef CONFIG_SMP 223#ifdef CONFIG_SMP
222static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[]) 224static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[])
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index f43b987f952b..35489fd68852 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -720,6 +720,7 @@ static int centrino_target (struct cpufreq_policy *policy,
720 cpu_set(j, set_mask); 720 cpu_set(j, set_mask);
721 721
722 set_cpus_allowed(current, set_mask); 722 set_cpus_allowed(current, set_mask);
723 preempt_disable();
723 if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) { 724 if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) {
724 dprintk("couldn't limit to CPUs in this domain\n"); 725 dprintk("couldn't limit to CPUs in this domain\n");
725 retval = -EAGAIN; 726 retval = -EAGAIN;
@@ -727,6 +728,7 @@ static int centrino_target (struct cpufreq_policy *policy,
727 /* We haven't started the transition yet. */ 728 /* We haven't started the transition yet. */
728 goto migrate_end; 729 goto migrate_end;
729 } 730 }
731 preempt_enable();
730 break; 732 break;
731 } 733 }
732 734
@@ -761,10 +763,13 @@ static int centrino_target (struct cpufreq_policy *policy,
761 } 763 }
762 764
763 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); 765 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
764 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) 766 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
767 preempt_enable();
765 break; 768 break;
769 }
766 770
767 cpu_set(j, covered_cpus); 771 cpu_set(j, covered_cpus);
772 preempt_enable();
768 } 773 }
769 774
770 for_each_cpu_mask(k, online_policy_cpus) { 775 for_each_cpu_mask(k, online_policy_cpus) {
@@ -796,8 +801,11 @@ static int centrino_target (struct cpufreq_policy *policy,
796 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 801 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
797 } 802 }
798 } 803 }
804 set_cpus_allowed(current, saved_mask);
805 return 0;
799 806
800migrate_end: 807migrate_end:
808 preempt_enable();
801 set_cpus_allowed(current, saved_mask); 809 set_cpus_allowed(current, saved_mask);
802 return 0; 810 return 0;
803} 811}
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
index d59277c00911..b1acc8ce3167 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
@@ -13,7 +13,6 @@
13#include <linux/moduleparam.h> 13#include <linux/moduleparam.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/cpufreq.h> 15#include <linux/cpufreq.h>
16#include <linux/pci.h>
17#include <linux/slab.h> 16#include <linux/slab.h>
18 17
19#include <asm/msr.h> 18#include <asm/msr.h>
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
index ff0d89806114..e1c509aa3054 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
@@ -17,10 +17,10 @@
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/cpufreq.h> 19#include <linux/cpufreq.h>
20#include <linux/pci.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <asm/ist.h> 22#include <asm/ist.h>
23#include <asm/io.h>
24 24
25#include "speedstep-lib.h" 25#include "speedstep-lib.h"
26 26
diff --git a/arch/i386/kernel/i8253.c b/arch/i386/kernel/i8253.c
index 10cef5ca8a5b..f8a3c4054c70 100644
--- a/arch/i386/kernel/i8253.c
+++ b/arch/i386/kernel/i8253.c
@@ -110,7 +110,7 @@ void __init setup_pit_timer(void)
110 * Start pit with the boot cpu mask and make it global after the 110 * Start pit with the boot cpu mask and make it global after the
111 * IO_APIC has been initialized. 111 * IO_APIC has been initialized.
112 */ 112 */
113 pit_clockevent.cpumask = cpumask_of_cpu(0); 113 pit_clockevent.cpumask = cpumask_of_cpu(smp_processor_id());
114 pit_clockevent.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, 32); 114 pit_clockevent.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, 32);
115 pit_clockevent.max_delta_ns = 115 pit_clockevent.max_delta_ns =
116 clockevent_delta2ns(0x7FFF, &pit_clockevent); 116 clockevent_delta2ns(0x7FFF, &pit_clockevent);
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index f23a17b3b8cf..1b623cda3a64 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -2579,19 +2579,19 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
2579 if (irq < 0) 2579 if (irq < 0)
2580 return irq; 2580 return irq;
2581 2581
2582 set_irq_msi(irq, desc);
2583 ret = msi_compose_msg(dev, irq, &msg); 2582 ret = msi_compose_msg(dev, irq, &msg);
2584 if (ret < 0) { 2583 if (ret < 0) {
2585 destroy_irq(irq); 2584 destroy_irq(irq);
2586 return ret; 2585 return ret;
2587 } 2586 }
2588 2587
2588 set_irq_msi(irq, desc);
2589 write_msi_msg(irq, &msg); 2589 write_msi_msg(irq, &msg);
2590 2590
2591 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, 2591 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq,
2592 "edge"); 2592 "edge");
2593 2593
2594 return irq; 2594 return 0;
2595} 2595}
2596 2596
2597void arch_teardown_msi_irq(unsigned int irq) 2597void arch_teardown_msi_irq(unsigned int irq)
diff --git a/arch/i386/mach-voyager/setup.c b/arch/i386/mach-voyager/setup.c
index cfa16c151c8f..447bb105cf58 100644
--- a/arch/i386/mach-voyager/setup.c
+++ b/arch/i386/mach-voyager/setup.c
@@ -40,10 +40,16 @@ void __init trap_init_hook(void)
40{ 40{
41} 41}
42 42
43static struct irqaction irq0 = { timer_interrupt, IRQF_DISABLED, CPU_MASK_NONE, "timer", NULL, NULL}; 43static struct irqaction irq0 = {
44 .handler = timer_interrupt,
45 .flags = IRQF_DISABLED | IRQF_NOBALANCING,
46 .mask = CPU_MASK_NONE,
47 .name = "timer"
48};
44 49
45void __init time_init_hook(void) 50void __init time_init_hook(void)
46{ 51{
52 irq0.mask = cpumask_of_cpu(safe_smp_processor_id());
47 setup_irq(0, &irq0); 53 setup_irq(0, &irq0);
48} 54}
49 55
diff --git a/arch/i386/mach-voyager/voyager_cat.c b/arch/i386/mach-voyager/voyager_cat.c
index 943a9473b138..26a2d4c54b68 100644
--- a/arch/i386/mach-voyager/voyager_cat.c
+++ b/arch/i386/mach-voyager/voyager_cat.c
@@ -1111,7 +1111,7 @@ voyager_cat_do_common_interrupt(void)
1111 printk(KERN_ERR "Voyager front panel switch turned off\n"); 1111 printk(KERN_ERR "Voyager front panel switch turned off\n");
1112 voyager_status.switch_off = 1; 1112 voyager_status.switch_off = 1;
1113 voyager_status.request_from_kernel = 1; 1113 voyager_status.request_from_kernel = 1;
1114 up(&kvoyagerd_sem); 1114 wake_up_process(voyager_thread);
1115 } 1115 }
1116 /* Tell the hardware we're taking care of the 1116 /* Tell the hardware we're taking care of the
1117 * shutdown, otherwise it will power the box off 1117 * shutdown, otherwise it will power the box off
@@ -1157,7 +1157,7 @@ voyager_cat_do_common_interrupt(void)
1157 outb(VOYAGER_CAT_END, CAT_CMD); 1157 outb(VOYAGER_CAT_END, CAT_CMD);
1158 voyager_status.power_fail = 1; 1158 voyager_status.power_fail = 1;
1159 voyager_status.request_from_kernel = 1; 1159 voyager_status.request_from_kernel = 1;
1160 up(&kvoyagerd_sem); 1160 wake_up_process(voyager_thread);
1161 } 1161 }
1162 1162
1163 1163
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index b9ce33c0c202..1a5e448a29c7 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -536,15 +536,6 @@ do_boot_cpu(__u8 cpu)
536 & ~( voyager_extended_vic_processors 536 & ~( voyager_extended_vic_processors
537 & voyager_allowed_boot_processors); 537 & voyager_allowed_boot_processors);
538 538
539 /* For the 486, we can't use the 4Mb page table trick, so
540 * must map a region of memory */
541#ifdef CONFIG_M486
542 int i;
543 unsigned long *page_table_copies = (unsigned long *)
544 __get_free_page(GFP_KERNEL);
545#endif
546 pgd_t orig_swapper_pg_dir0;
547
548 /* This is an area in head.S which was used to set up the 539 /* This is an area in head.S which was used to set up the
549 * initial kernel stack. We need to alter this to give the 540 * initial kernel stack. We need to alter this to give the
550 * booting CPU a new stack (taken from its idle process) */ 541 * booting CPU a new stack (taken from its idle process) */
@@ -573,6 +564,8 @@ do_boot_cpu(__u8 cpu)
573 hijack_source.idt.Segment = (start_phys_address >> 4) & 0xFFFF; 564 hijack_source.idt.Segment = (start_phys_address >> 4) & 0xFFFF;
574 565
575 cpucount++; 566 cpucount++;
567 alternatives_smp_switch(1);
568
576 idle = fork_idle(cpu); 569 idle = fork_idle(cpu);
577 if(IS_ERR(idle)) 570 if(IS_ERR(idle))
578 panic("failed fork for CPU%d", cpu); 571 panic("failed fork for CPU%d", cpu);
@@ -587,24 +580,11 @@ do_boot_cpu(__u8 cpu)
587 VDEBUG(("VOYAGER SMP: Booting CPU%d at 0x%lx[%x:%x], stack %p\n", cpu, 580 VDEBUG(("VOYAGER SMP: Booting CPU%d at 0x%lx[%x:%x], stack %p\n", cpu,
588 (unsigned long)hijack_source.val, hijack_source.idt.Segment, 581 (unsigned long)hijack_source.val, hijack_source.idt.Segment,
589 hijack_source.idt.Offset, stack_start.esp)); 582 hijack_source.idt.Offset, stack_start.esp));
590 /* set the original swapper_pg_dir[0] to map 0 to 4Mb transparently 583
591 * (so that the booting CPU can find start_32 */ 584 /* init lowmem identity mapping */
592 orig_swapper_pg_dir0 = swapper_pg_dir[0]; 585 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
593#ifdef CONFIG_M486 586 min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS));
594 if(page_table_copies == NULL) 587 flush_tlb_all();
595 panic("No free memory for 486 page tables\n");
596 for(i = 0; i < PAGE_SIZE/sizeof(unsigned long); i++)
597 page_table_copies[i] = (i * PAGE_SIZE)
598 | _PAGE_RW | _PAGE_USER | _PAGE_PRESENT;
599
600 ((unsigned long *)swapper_pg_dir)[0] =
601 ((virt_to_phys(page_table_copies)) & PAGE_MASK)
602 | _PAGE_RW | _PAGE_USER | _PAGE_PRESENT;
603#else
604 ((unsigned long *)swapper_pg_dir)[0] =
605 (virt_to_phys(pg0) & PAGE_MASK)
606 | _PAGE_RW | _PAGE_USER | _PAGE_PRESENT;
607#endif
608 588
609 if(quad_boot) { 589 if(quad_boot) {
610 printk("CPU %d: non extended Quad boot\n", cpu); 590 printk("CPU %d: non extended Quad boot\n", cpu);
@@ -647,11 +627,7 @@ do_boot_cpu(__u8 cpu)
647 udelay(100); 627 udelay(100);
648 } 628 }
649 /* reset the page table */ 629 /* reset the page table */
650 swapper_pg_dir[0] = orig_swapper_pg_dir0; 630 zap_low_mappings();
651 local_flush_tlb();
652#ifdef CONFIG_M486
653 free_page((unsigned long)page_table_copies);
654#endif
655 631
656 if (cpu_booted_map) { 632 if (cpu_booted_map) {
657 VDEBUG(("CPU%d: Booted successfully, back in CPU %d\n", 633 VDEBUG(("CPU%d: Booted successfully, back in CPU %d\n",
@@ -1068,20 +1044,11 @@ smp_call_function_interrupt(void)
1068 } 1044 }
1069} 1045}
1070 1046
1071/* Call this function on all CPUs using the function_interrupt above 1047static int
1072 <func> The function to run. This must be fast and non-blocking. 1048__smp_call_function_mask (void (*func) (void *info), void *info, int retry,
1073 <info> An arbitrary pointer to pass to the function. 1049 int wait, __u32 mask)
1074 <retry> If true, keep retrying until ready.
1075 <wait> If true, wait until function has completed on other CPUs.
1076 [RETURNS] 0 on success, else a negative status code. Does not return until
1077 remote CPUs are nearly ready to execute <<func>> or are or have executed.
1078*/
1079int
1080smp_call_function (void (*func) (void *info), void *info, int retry,
1081 int wait)
1082{ 1050{
1083 struct call_data_struct data; 1051 struct call_data_struct data;
1084 __u32 mask = cpus_addr(cpu_online_map)[0];
1085 1052
1086 mask &= ~(1<<smp_processor_id()); 1053 mask &= ~(1<<smp_processor_id());
1087 1054
@@ -1102,7 +1069,7 @@ smp_call_function (void (*func) (void *info), void *info, int retry,
1102 call_data = &data; 1069 call_data = &data;
1103 wmb(); 1070 wmb();
1104 /* Send a message to all other CPUs and wait for them to respond */ 1071 /* Send a message to all other CPUs and wait for them to respond */
1105 send_CPI_allbutself(VIC_CALL_FUNCTION_CPI); 1072 send_CPI(mask, VIC_CALL_FUNCTION_CPI);
1106 1073
1107 /* Wait for response */ 1074 /* Wait for response */
1108 while (data.started) 1075 while (data.started)
@@ -1116,8 +1083,48 @@ smp_call_function (void (*func) (void *info), void *info, int retry,
1116 1083
1117 return 0; 1084 return 0;
1118} 1085}
1086
1087/* Call this function on all CPUs using the function_interrupt above
1088 <func> The function to run. This must be fast and non-blocking.
1089 <info> An arbitrary pointer to pass to the function.
1090 <retry> If true, keep retrying until ready.
1091 <wait> If true, wait until function has completed on other CPUs.
1092 [RETURNS] 0 on success, else a negative status code. Does not return until
1093 remote CPUs are nearly ready to execute <<func>> or are or have executed.
1094*/
1095int
1096smp_call_function(void (*func) (void *info), void *info, int retry,
1097 int wait)
1098{
1099 __u32 mask = cpus_addr(cpu_online_map)[0];
1100
1101 return __smp_call_function_mask(func, info, retry, wait, mask);
1102}
1119EXPORT_SYMBOL(smp_call_function); 1103EXPORT_SYMBOL(smp_call_function);
1120 1104
1105/*
1106 * smp_call_function_single - Run a function on another CPU
1107 * @func: The function to run. This must be fast and non-blocking.
1108 * @info: An arbitrary pointer to pass to the function.
1109 * @nonatomic: Currently unused.
1110 * @wait: If true, wait until function has completed on other CPUs.
1111 *
1112 * Retrurns 0 on success, else a negative status code.
1113 *
1114 * Does not return until the remote CPU is nearly ready to execute <func>
1115 * or is or has executed.
1116 */
1117
1118int
1119smp_call_function_single(int cpu, void (*func) (void *info), void *info,
1120 int nonatomic, int wait)
1121{
1122 __u32 mask = 1 << cpu;
1123
1124 return __smp_call_function_mask(func, info, nonatomic, wait, mask);
1125}
1126EXPORT_SYMBOL(smp_call_function_single);
1127
1121/* Sorry about the name. In an APIC based system, the APICs 1128/* Sorry about the name. In an APIC based system, the APICs
1122 * themselves are programmed to send a timer interrupt. This is used 1129 * themselves are programmed to send a timer interrupt. This is used
1123 * by linux to reschedule the processor. Voyager doesn't have this, 1130 * by linux to reschedule the processor. Voyager doesn't have this,
diff --git a/arch/i386/mach-voyager/voyager_thread.c b/arch/i386/mach-voyager/voyager_thread.c
index f39887359e8e..fdc1d926fb2a 100644
--- a/arch/i386/mach-voyager/voyager_thread.c
+++ b/arch/i386/mach-voyager/voyager_thread.c
@@ -24,33 +24,16 @@
24#include <linux/kmod.h> 24#include <linux/kmod.h>
25#include <linux/completion.h> 25#include <linux/completion.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/kthread.h>
27#include <asm/desc.h> 28#include <asm/desc.h>
28#include <asm/voyager.h> 29#include <asm/voyager.h>
29#include <asm/vic.h> 30#include <asm/vic.h>
30#include <asm/mtrr.h> 31#include <asm/mtrr.h>
31#include <asm/msr.h> 32#include <asm/msr.h>
32 33
33#define THREAD_NAME "kvoyagerd"
34 34
35/* external variables */ 35struct task_struct *voyager_thread;
36int kvoyagerd_running = 0; 36static __u8 set_timeout;
37DECLARE_MUTEX_LOCKED(kvoyagerd_sem);
38
39static int thread(void *);
40
41static __u8 set_timeout = 0;
42
43/* Start the machine monitor thread. Return 1 if OK, 0 if fail */
44static int __init
45voyager_thread_start(void)
46{
47 if(kernel_thread(thread, NULL, CLONE_KERNEL) < 0) {
48 /* This is serious, but not fatal */
49 printk(KERN_ERR "Voyager: Failed to create system monitor thread!!!\n");
50 return 1;
51 }
52 return 0;
53}
54 37
55static int 38static int
56execute(const char *string) 39execute(const char *string)
@@ -110,31 +93,15 @@ check_continuing_condition(void)
110 } 93 }
111} 94}
112 95
113static void
114wakeup(unsigned long unused)
115{
116 up(&kvoyagerd_sem);
117}
118
119static int 96static int
120thread(void *unused) 97thread(void *unused)
121{ 98{
122 struct timer_list wakeup_timer;
123
124 kvoyagerd_running = 1;
125
126 daemonize(THREAD_NAME);
127
128 set_timeout = 0;
129
130 init_timer(&wakeup_timer);
131
132 sigfillset(&current->blocked);
133
134 printk(KERN_NOTICE "Voyager starting monitor thread\n"); 99 printk(KERN_NOTICE "Voyager starting monitor thread\n");
135 100
136 for(;;) { 101 for (;;) {
137 down_interruptible(&kvoyagerd_sem); 102 set_current_state(TASK_INTERRUPTIBLE);
103 schedule_timeout(set_timeout ? HZ : MAX_SCHEDULE_TIMEOUT);
104
138 VDEBUG(("Voyager Daemon awoken\n")); 105 VDEBUG(("Voyager Daemon awoken\n"));
139 if(voyager_status.request_from_kernel == 0) { 106 if(voyager_status.request_from_kernel == 0) {
140 /* probably awoken from timeout */ 107 /* probably awoken from timeout */
@@ -143,20 +110,26 @@ thread(void *unused)
143 check_from_kernel(); 110 check_from_kernel();
144 voyager_status.request_from_kernel = 0; 111 voyager_status.request_from_kernel = 0;
145 } 112 }
146 if(set_timeout) {
147 del_timer(&wakeup_timer);
148 wakeup_timer.expires = HZ + jiffies;
149 wakeup_timer.function = wakeup;
150 add_timer(&wakeup_timer);
151 }
152 } 113 }
153} 114}
154 115
116static int __init
117voyager_thread_start(void)
118{
119 voyager_thread = kthread_run(thread, NULL, "kvoyagerd");
120 if (IS_ERR(voyager_thread)) {
121 printk(KERN_ERR "Voyager: Failed to create system monitor thread.\n");
122 return PTR_ERR(voyager_thread);
123 }
124 return 0;
125}
126
127
155static void __exit 128static void __exit
156voyager_thread_stop(void) 129voyager_thread_stop(void)
157{ 130{
158 /* FIXME: do nothing at the moment */ 131 kthread_stop(voyager_thread);
159} 132}
160 133
161module_init(voyager_thread_start); 134module_init(voyager_thread_start);
162//module_exit(voyager_thread_stop); 135module_exit(voyager_thread_stop);
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index 8053b17ab647..b62eafb997bc 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -354,7 +354,7 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
354 printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev)); 354 printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev));
355 } 355 }
356} 356}
357DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video); 357DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);
358 358
359/* 359/*
360 * Some Toshiba laptops need extra code to enable their TI TSB43AB22/A. 360 * Some Toshiba laptops need extra code to enable their TI TSB43AB22/A.
diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c
index 43005f044424..bcd2f94b732c 100644
--- a/arch/i386/pci/i386.c
+++ b/arch/i386/pci/i386.c
@@ -246,8 +246,8 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask)
246 continue; 246 continue;
247 if (!r->start && r->end) { 247 if (!r->start && r->end) {
248 printk(KERN_ERR "PCI: Device %s not available " 248 printk(KERN_ERR "PCI: Device %s not available "
249 "because of resource collisions\n", 249 "because of resource %d collisions\n",
250 pci_name(dev)); 250 pci_name(dev), idx);
251 return -EINVAL; 251 return -EINVAL;
252 } 252 }
253 if (r->flags & IORESOURCE_IO) 253 if (r->flags & IORESOURCE_IO)
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index e19185d26554..3b71f97d0b60 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -14,6 +14,7 @@ config IA64
14 select PCI if (!IA64_HP_SIM) 14 select PCI if (!IA64_HP_SIM)
15 select ACPI if (!IA64_HP_SIM) 15 select ACPI if (!IA64_HP_SIM)
16 select PM if (!IA64_HP_SIM) 16 select PM if (!IA64_HP_SIM)
17 select ARCH_SUPPORTS_MSI
17 default y 18 default y
18 help 19 help
19 The Itanium Processor Family is Intel's 64-bit successor to 20 The Itanium Processor Family is Intel's 64-bit successor to
diff --git a/arch/ia64/sn/kernel/huberror.c b/arch/ia64/sn/kernel/huberror.c
index fcf7f93c4b61..2c3f9dfca78b 100644
--- a/arch/ia64/sn/kernel/huberror.c
+++ b/arch/ia64/sn/kernel/huberror.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/pci.h>
12#include <asm/delay.h> 11#include <asm/delay.h>
13#include <asm/sn/sn_sal.h> 12#include <asm/sn/sn_sal.h>
14#include "ioerror.h" 13#include "ioerror.h"
diff --git a/arch/ia64/sn/kernel/msi_sn.c b/arch/ia64/sn/kernel/msi_sn.c
index 49873aa4a37d..83f190ffe350 100644
--- a/arch/ia64/sn/kernel/msi_sn.c
+++ b/arch/ia64/sn/kernel/msi_sn.c
@@ -87,7 +87,6 @@ int sn_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *entry)
87 if (irq < 0) 87 if (irq < 0)
88 return irq; 88 return irq;
89 89
90 set_irq_msi(irq, entry);
91 /* 90 /*
92 * Set up the vector plumbing. Let the prom (via sn_intr_alloc) 91 * Set up the vector plumbing. Let the prom (via sn_intr_alloc)
93 * decide which cpu to direct this msi at by default. 92 * decide which cpu to direct this msi at by default.
@@ -144,10 +143,11 @@ int sn_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *entry)
144 */ 143 */
145 msg.data = 0x100 + irq; 144 msg.data = 0x100 + irq;
146 145
146 set_irq_msi(irq, entry);
147 write_msi_msg(irq, &msg); 147 write_msi_msg(irq, &msg);
148 set_irq_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq); 148 set_irq_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq);
149 149
150 return irq; 150 return 0;
151} 151}
152 152
153#ifdef CONFIG_SMP 153#ifdef CONFIG_SMP
diff --git a/arch/ia64/sn/kernel/xpnet.c b/arch/ia64/sn/kernel/xpnet.c
index 5419acb89a8c..88fad85ceeff 100644
--- a/arch/ia64/sn/kernel/xpnet.c
+++ b/arch/ia64/sn/kernel/xpnet.c
@@ -24,7 +24,6 @@
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/pci.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/ioport.h> 28#include <linux/ioport.h>
30#include <linux/netdevice.h> 29#include <linux/netdevice.h>
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index a8e1e604dfa8..b8536c7c0877 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -409,6 +409,9 @@ config STRAM_PROC
409 help 409 help
410 Say Y here to report ST-RAM usage statistics in /proc/stram. 410 Say Y here to report ST-RAM usage statistics in /proc/stram.
411 411
412config ATARI_KBD_CORE
413 bool
414
412config HEARTBEAT 415config HEARTBEAT
413 bool "Use power LED as a heartbeat" if AMIGA || APOLLO || ATARI || MAC ||Q40 416 bool "Use power LED as a heartbeat" if AMIGA || APOLLO || ATARI || MAC ||Q40
414 default y if !AMIGA && !APOLLO && !ATARI && !MAC && !Q40 && HP300 417 default y if !AMIGA && !APOLLO && !ATARI && !MAC && !Q40 && HP300
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 34d826d10f1b..c20831a7e1a9 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -21,7 +21,7 @@ AS += -m68020
21LDFLAGS := -m m68kelf 21LDFLAGS := -m m68kelf
22ifneq ($(COMPILE_ARCH),$(ARCH)) 22ifneq ($(COMPILE_ARCH),$(ARCH))
23 # prefix for cross-compiling binaries 23 # prefix for cross-compiling binaries
24 CROSS_COMPILE = m68k-linux- 24 CROSS_COMPILE = m68k-linux-gnu-
25endif 25endif
26 26
27ifdef CONFIG_SUN3 27ifdef CONFIG_SUN3
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index 3204f412cad8..35748531327d 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -22,9 +22,7 @@
22#include <linux/vt_kern.h> 22#include <linux/vt_kern.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#ifdef CONFIG_ZORRO
26#include <linux/zorro.h> 25#include <linux/zorro.h>
27#endif
28 26
29#include <asm/bootinfo.h> 27#include <asm/bootinfo.h>
30#include <asm/setup.h> 28#include <asm/setup.h>
@@ -62,55 +60,51 @@ static char s_cdtv[] __initdata = "CDTV";
62static char s_cd32[] __initdata = "CD32"; 60static char s_cd32[] __initdata = "CD32";
63static char s_draco[] __initdata = "Draco"; 61static char s_draco[] __initdata = "Draco";
64static char *amiga_models[] __initdata = { 62static char *amiga_models[] __initdata = {
65 [AMI_500-AMI_500] = s_a500, 63 [AMI_500-AMI_500] = s_a500,
66 [AMI_500PLUS-AMI_500] = s_a500p, 64 [AMI_500PLUS-AMI_500] = s_a500p,
67 [AMI_600-AMI_500] = s_a600, 65 [AMI_600-AMI_500] = s_a600,
68 [AMI_1000-AMI_500] = s_a1000, 66 [AMI_1000-AMI_500] = s_a1000,
69 [AMI_1200-AMI_500] = s_a1200, 67 [AMI_1200-AMI_500] = s_a1200,
70 [AMI_2000-AMI_500] = s_a2000, 68 [AMI_2000-AMI_500] = s_a2000,
71 [AMI_2500-AMI_500] = s_a2500, 69 [AMI_2500-AMI_500] = s_a2500,
72 [AMI_3000-AMI_500] = s_a3000, 70 [AMI_3000-AMI_500] = s_a3000,
73 [AMI_3000T-AMI_500] = s_a3000t, 71 [AMI_3000T-AMI_500] = s_a3000t,
74 [AMI_3000PLUS-AMI_500] = s_a3000p, 72 [AMI_3000PLUS-AMI_500] = s_a3000p,
75 [AMI_4000-AMI_500] = s_a4000, 73 [AMI_4000-AMI_500] = s_a4000,
76 [AMI_4000T-AMI_500] = s_a4000t, 74 [AMI_4000T-AMI_500] = s_a4000t,
77 [AMI_CDTV-AMI_500] = s_cdtv, 75 [AMI_CDTV-AMI_500] = s_cdtv,
78 [AMI_CD32-AMI_500] = s_cd32, 76 [AMI_CD32-AMI_500] = s_cd32,
79 [AMI_DRACO-AMI_500] = s_draco, 77 [AMI_DRACO-AMI_500] = s_draco,
80}; 78};
81 79
82static char amiga_model_name[13] = "Amiga "; 80static char amiga_model_name[13] = "Amiga ";
83 81
84extern char m68k_debug_device[];
85
86static void amiga_sched_init(irq_handler_t handler); 82static void amiga_sched_init(irq_handler_t handler);
87/* amiga specific irq functions */ 83/* amiga specific irq functions */
88extern void amiga_init_IRQ (void); 84extern void amiga_init_IRQ(void);
89static void amiga_get_model(char *model); 85static void amiga_get_model(char *model);
90static int amiga_get_hardware_list(char *buffer); 86static int amiga_get_hardware_list(char *buffer);
91/* amiga specific timer functions */ 87/* amiga specific timer functions */
92static unsigned long amiga_gettimeoffset (void); 88static unsigned long amiga_gettimeoffset(void);
93static int a3000_hwclk (int, struct rtc_time *); 89static int a3000_hwclk(int, struct rtc_time *);
94static int a2000_hwclk (int, struct rtc_time *); 90static int a2000_hwclk(int, struct rtc_time *);
95static int amiga_set_clock_mmss (unsigned long); 91static int amiga_set_clock_mmss(unsigned long);
96static unsigned int amiga_get_ss (void); 92static unsigned int amiga_get_ss(void);
97extern void amiga_mksound( unsigned int count, unsigned int ticks ); 93extern void amiga_mksound(unsigned int count, unsigned int ticks);
98static void amiga_reset (void); 94static void amiga_reset(void);
99extern void amiga_init_sound(void); 95extern void amiga_init_sound(void);
100static void amiga_savekmsg_init(void);
101static void amiga_mem_console_write(struct console *co, const char *b, 96static void amiga_mem_console_write(struct console *co, const char *b,
102 unsigned int count); 97 unsigned int count);
103void amiga_serial_console_write(struct console *co, const char *s, 98void amiga_serial_console_write(struct console *co, const char *s,
104 unsigned int count); 99 unsigned int count);
105static void amiga_debug_init(void);
106#ifdef CONFIG_HEARTBEAT 100#ifdef CONFIG_HEARTBEAT
107static void amiga_heartbeat(int on); 101static void amiga_heartbeat(int on);
108#endif 102#endif
109 103
110static struct console amiga_console_driver = { 104static struct console amiga_console_driver = {
111 .name = "debug", 105 .name = "debug",
112 .flags = CON_PRINTBUFFER, 106 .flags = CON_PRINTBUFFER,
113 .index = -1, 107 .index = -1,
114}; 108};
115 109
116 110
@@ -119,24 +113,24 @@ static struct console amiga_console_driver = {
119 */ 113 */
120 114
121static struct { 115static struct {
122 struct resource _ciab, _ciaa, _custom, _kickstart; 116 struct resource _ciab, _ciaa, _custom, _kickstart;
123} mb_resources = { 117} mb_resources = {
124 ._ciab = { 118 ._ciab = {
125 .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff 119 .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
126 }, 120 },
127 ._ciaa = { 121 ._ciaa = {
128 .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff 122 .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
129 }, 123 },
130 ._custom = { 124 ._custom = {
131 .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff 125 .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
132 }, 126 },
133 ._kickstart = { 127 ._kickstart = {
134 .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff 128 .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
135 } 129 }
136}; 130};
137 131
138static struct resource rtc_resource = { 132static struct resource rtc_resource = {
139 .start = 0x00dc0000, .end = 0x00dcffff 133 .start = 0x00dc0000, .end = 0x00dcffff
140}; 134};
141 135
142static struct resource ram_resource[NUM_MEMINFO]; 136static struct resource ram_resource[NUM_MEMINFO];
@@ -148,57 +142,57 @@ static struct resource ram_resource[NUM_MEMINFO];
148 142
149int amiga_parse_bootinfo(const struct bi_record *record) 143int amiga_parse_bootinfo(const struct bi_record *record)
150{ 144{
151 int unknown = 0; 145 int unknown = 0;
152 const unsigned long *data = record->data; 146 const unsigned long *data = record->data;
153 147
154 switch (record->tag) { 148 switch (record->tag) {
155 case BI_AMIGA_MODEL: 149 case BI_AMIGA_MODEL:
156 amiga_model = *data; 150 amiga_model = *data;
157 break; 151 break;
158 152
159 case BI_AMIGA_ECLOCK: 153 case BI_AMIGA_ECLOCK:
160 amiga_eclock = *data; 154 amiga_eclock = *data;
161 break; 155 break;
162 156
163 case BI_AMIGA_CHIPSET: 157 case BI_AMIGA_CHIPSET:
164 amiga_chipset = *data; 158 amiga_chipset = *data;
165 break; 159 break;
166 160
167 case BI_AMIGA_CHIP_SIZE: 161 case BI_AMIGA_CHIP_SIZE:
168 amiga_chip_size = *(const int *)data; 162 amiga_chip_size = *(const int *)data;
169 break; 163 break;
170 164
171 case BI_AMIGA_VBLANK: 165 case BI_AMIGA_VBLANK:
172 amiga_vblank = *(const unsigned char *)data; 166 amiga_vblank = *(const unsigned char *)data;
173 break; 167 break;
174 168
175 case BI_AMIGA_PSFREQ: 169 case BI_AMIGA_PSFREQ:
176 amiga_psfreq = *(const unsigned char *)data; 170 amiga_psfreq = *(const unsigned char *)data;
177 break; 171 break;
178 172
179 case BI_AMIGA_AUTOCON: 173 case BI_AMIGA_AUTOCON:
180#ifdef CONFIG_ZORRO 174#ifdef CONFIG_ZORRO
181 if (zorro_num_autocon < ZORRO_NUM_AUTO) { 175 if (zorro_num_autocon < ZORRO_NUM_AUTO) {
182 const struct ConfigDev *cd = (struct ConfigDev *)data; 176 const struct ConfigDev *cd = (struct ConfigDev *)data;
183 struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++]; 177 struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++];
184 dev->rom = cd->cd_Rom; 178 dev->rom = cd->cd_Rom;
185 dev->slotaddr = cd->cd_SlotAddr; 179 dev->slotaddr = cd->cd_SlotAddr;
186 dev->slotsize = cd->cd_SlotSize; 180 dev->slotsize = cd->cd_SlotSize;
187 dev->resource.start = (unsigned long)cd->cd_BoardAddr; 181 dev->resource.start = (unsigned long)cd->cd_BoardAddr;
188 dev->resource.end = dev->resource.start+cd->cd_BoardSize-1; 182 dev->resource.end = dev->resource.start + cd->cd_BoardSize - 1;
189 } else 183 } else
190 printk("amiga_parse_bootinfo: too many AutoConfig devices\n"); 184 printk("amiga_parse_bootinfo: too many AutoConfig devices\n");
191#endif /* CONFIG_ZORRO */ 185#endif /* CONFIG_ZORRO */
192 break; 186 break;
193 187
194 case BI_AMIGA_SERPER: 188 case BI_AMIGA_SERPER:
195 /* serial port period: ignored here */ 189 /* serial port period: ignored here */
196 break; 190 break;
197 191
198 default: 192 default:
199 unknown = 1; 193 unknown = 1;
200 } 194 }
201 return(unknown); 195 return unknown;
202} 196}
203 197
204 /* 198 /*
@@ -207,159 +201,159 @@ int amiga_parse_bootinfo(const struct bi_record *record)
207 201
208static void __init amiga_identify(void) 202static void __init amiga_identify(void)
209{ 203{
210 /* Fill in some default values, if necessary */ 204 /* Fill in some default values, if necessary */
211 if (amiga_eclock == 0) 205 if (amiga_eclock == 0)
212 amiga_eclock = 709379; 206 amiga_eclock = 709379;
213
214 memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
215
216 printk("Amiga hardware found: ");
217 if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
218 printk("[%s] ", amiga_models[amiga_model-AMI_500]);
219 strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
220 }
221
222 switch(amiga_model) {
223 case AMI_UNKNOWN:
224 goto Generic;
225
226 case AMI_600:
227 case AMI_1200:
228 AMIGAHW_SET(A1200_IDE);
229 AMIGAHW_SET(PCMCIA);
230 case AMI_500:
231 case AMI_500PLUS:
232 case AMI_1000:
233 case AMI_2000:
234 case AMI_2500:
235 AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
236 goto Generic;
237
238 case AMI_3000:
239 case AMI_3000T:
240 AMIGAHW_SET(AMBER_FF);
241 AMIGAHW_SET(MAGIC_REKICK);
242 /* fall through */
243 case AMI_3000PLUS:
244 AMIGAHW_SET(A3000_SCSI);
245 AMIGAHW_SET(A3000_CLK);
246 AMIGAHW_SET(ZORRO3);
247 goto Generic;
248
249 case AMI_4000T:
250 AMIGAHW_SET(A4000_SCSI);
251 /* fall through */
252 case AMI_4000:
253 AMIGAHW_SET(A4000_IDE);
254 AMIGAHW_SET(A3000_CLK);
255 AMIGAHW_SET(ZORRO3);
256 goto Generic;
257
258 case AMI_CDTV:
259 case AMI_CD32:
260 AMIGAHW_SET(CD_ROM);
261 AMIGAHW_SET(A2000_CLK); /* Is this correct? */
262 goto Generic;
263
264 Generic:
265 AMIGAHW_SET(AMI_VIDEO);
266 AMIGAHW_SET(AMI_BLITTER);
267 AMIGAHW_SET(AMI_AUDIO);
268 AMIGAHW_SET(AMI_FLOPPY);
269 AMIGAHW_SET(AMI_KEYBOARD);
270 AMIGAHW_SET(AMI_MOUSE);
271 AMIGAHW_SET(AMI_SERIAL);
272 AMIGAHW_SET(AMI_PARALLEL);
273 AMIGAHW_SET(CHIP_RAM);
274 AMIGAHW_SET(PAULA);
275
276 switch(amiga_chipset) {
277 case CS_OCS:
278 case CS_ECS:
279 case CS_AGA:
280 switch (amiga_custom.deniseid & 0xf) {
281 case 0x0c:
282 AMIGAHW_SET(DENISE_HR);
283 break;
284 case 0x08:
285 AMIGAHW_SET(LISA);
286 break;
287 }
288 break;
289 default:
290 AMIGAHW_SET(DENISE);
291 break;
292 }
293 switch ((amiga_custom.vposr>>8) & 0x7f) {
294 case 0x00:
295 AMIGAHW_SET(AGNUS_PAL);
296 break;
297 case 0x10:
298 AMIGAHW_SET(AGNUS_NTSC);
299 break;
300 case 0x20:
301 case 0x21:
302 AMIGAHW_SET(AGNUS_HR_PAL);
303 break;
304 case 0x30:
305 case 0x31:
306 AMIGAHW_SET(AGNUS_HR_NTSC);
307 break;
308 case 0x22:
309 case 0x23:
310 AMIGAHW_SET(ALICE_PAL);
311 break;
312 case 0x32:
313 case 0x33:
314 AMIGAHW_SET(ALICE_NTSC);
315 break;
316 }
317 AMIGAHW_SET(ZORRO);
318 break;
319
320 case AMI_DRACO:
321 panic("No support for Draco yet");
322
323 default:
324 panic("Unknown Amiga Model");
325 }
326 207
327#define AMIGAHW_ANNOUNCE(name, str) \ 208 memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
328 if (AMIGAHW_PRESENT(name)) \ 209
329 printk(str) 210 printk("Amiga hardware found: ");
330 211 if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
331 AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO "); 212 printk("[%s] ", amiga_models[amiga_model-AMI_500]);
332 AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER "); 213 strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
333 AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF "); 214 }
334 AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO "); 215
335 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY "); 216 switch (amiga_model) {
336 AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI "); 217 case AMI_UNKNOWN:
337 AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI "); 218 goto Generic;
338 AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE "); 219
339 AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE "); 220 case AMI_600:
340 AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM "); 221 case AMI_1200:
341 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD "); 222 AMIGAHW_SET(A1200_IDE);
342 AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE "); 223 AMIGAHW_SET(PCMCIA);
343 AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL "); 224 case AMI_500:
344 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL "); 225 case AMI_500PLUS:
345 AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK "); 226 case AMI_1000:
346 AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK "); 227 case AMI_2000:
347 AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM "); 228 case AMI_2500:
348 AMIGAHW_ANNOUNCE(PAULA, "PAULA "); 229 AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
349 AMIGAHW_ANNOUNCE(DENISE, "DENISE "); 230 goto Generic;
350 AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR "); 231
351 AMIGAHW_ANNOUNCE(LISA, "LISA "); 232 case AMI_3000:
352 AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL "); 233 case AMI_3000T:
353 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC "); 234 AMIGAHW_SET(AMBER_FF);
354 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL "); 235 AMIGAHW_SET(MAGIC_REKICK);
355 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC "); 236 /* fall through */
356 AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL "); 237 case AMI_3000PLUS:
357 AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC "); 238 AMIGAHW_SET(A3000_SCSI);
358 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK "); 239 AMIGAHW_SET(A3000_CLK);
359 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA "); 240 AMIGAHW_SET(ZORRO3);
360 if (AMIGAHW_PRESENT(ZORRO)) 241 goto Generic;
361 printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : ""); 242
362 printk("\n"); 243 case AMI_4000T:
244 AMIGAHW_SET(A4000_SCSI);
245 /* fall through */
246 case AMI_4000:
247 AMIGAHW_SET(A4000_IDE);
248 AMIGAHW_SET(A3000_CLK);
249 AMIGAHW_SET(ZORRO3);
250 goto Generic;
251
252 case AMI_CDTV:
253 case AMI_CD32:
254 AMIGAHW_SET(CD_ROM);
255 AMIGAHW_SET(A2000_CLK); /* Is this correct? */
256 goto Generic;
257
258 Generic:
259 AMIGAHW_SET(AMI_VIDEO);
260 AMIGAHW_SET(AMI_BLITTER);
261 AMIGAHW_SET(AMI_AUDIO);
262 AMIGAHW_SET(AMI_FLOPPY);
263 AMIGAHW_SET(AMI_KEYBOARD);
264 AMIGAHW_SET(AMI_MOUSE);
265 AMIGAHW_SET(AMI_SERIAL);
266 AMIGAHW_SET(AMI_PARALLEL);
267 AMIGAHW_SET(CHIP_RAM);
268 AMIGAHW_SET(PAULA);
269
270 switch (amiga_chipset) {
271 case CS_OCS:
272 case CS_ECS:
273 case CS_AGA:
274 switch (amiga_custom.deniseid & 0xf) {
275 case 0x0c:
276 AMIGAHW_SET(DENISE_HR);
277 break;
278 case 0x08:
279 AMIGAHW_SET(LISA);
280 break;
281 }
282 break;
283 default:
284 AMIGAHW_SET(DENISE);
285 break;
286 }
287 switch ((amiga_custom.vposr>>8) & 0x7f) {
288 case 0x00:
289 AMIGAHW_SET(AGNUS_PAL);
290 break;
291 case 0x10:
292 AMIGAHW_SET(AGNUS_NTSC);
293 break;
294 case 0x20:
295 case 0x21:
296 AMIGAHW_SET(AGNUS_HR_PAL);
297 break;
298 case 0x30:
299 case 0x31:
300 AMIGAHW_SET(AGNUS_HR_NTSC);
301 break;
302 case 0x22:
303 case 0x23:
304 AMIGAHW_SET(ALICE_PAL);
305 break;
306 case 0x32:
307 case 0x33:
308 AMIGAHW_SET(ALICE_NTSC);
309 break;
310 }
311 AMIGAHW_SET(ZORRO);
312 break;
313
314 case AMI_DRACO:
315 panic("No support for Draco yet");
316
317 default:
318 panic("Unknown Amiga Model");
319 }
320
321#define AMIGAHW_ANNOUNCE(name, str) \
322 if (AMIGAHW_PRESENT(name)) \
323 printk(str)
324
325 AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
326 AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
327 AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
328 AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
329 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
330 AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
331 AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
332 AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
333 AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
334 AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
335 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
336 AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
337 AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
338 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
339 AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
340 AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
341 AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
342 AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
343 AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
344 AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
345 AMIGAHW_ANNOUNCE(LISA, "LISA ");
346 AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
347 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
348 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
349 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
350 AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
351 AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
352 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
353 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
354 if (AMIGAHW_PRESENT(ZORRO))
355 printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
356 printk("\n");
363 357
364#undef AMIGAHW_ANNOUNCE 358#undef AMIGAHW_ANNOUNCE
365} 359}
@@ -370,119 +364,105 @@ static void __init amiga_identify(void)
370 364
371void __init config_amiga(void) 365void __init config_amiga(void)
372{ 366{
373 int i; 367 int i;
374 368
375 amiga_debug_init(); 369 amiga_identify();
376 amiga_identify(); 370
377 371 /* Yuk, we don't have PCI memory */
378 /* Yuk, we don't have PCI memory */ 372 iomem_resource.name = "Memory";
379 iomem_resource.name = "Memory"; 373 for (i = 0; i < 4; i++)
380 for (i = 0; i < 4; i++) 374 request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
381 request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]); 375
382 376 mach_sched_init = amiga_sched_init;
383 mach_sched_init = amiga_sched_init; 377 mach_init_IRQ = amiga_init_IRQ;
384 mach_init_IRQ = amiga_init_IRQ; 378 mach_get_model = amiga_get_model;
385 mach_get_model = amiga_get_model; 379 mach_get_hardware_list = amiga_get_hardware_list;
386 mach_get_hardware_list = amiga_get_hardware_list; 380 mach_gettimeoffset = amiga_gettimeoffset;
387 mach_gettimeoffset = amiga_gettimeoffset; 381 if (AMIGAHW_PRESENT(A3000_CLK)) {
388 if (AMIGAHW_PRESENT(A3000_CLK)){ 382 mach_hwclk = a3000_hwclk;
389 mach_hwclk = a3000_hwclk; 383 rtc_resource.name = "A3000 RTC";
390 rtc_resource.name = "A3000 RTC"; 384 request_resource(&iomem_resource, &rtc_resource);
391 request_resource(&iomem_resource, &rtc_resource); 385 } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ {
392 } 386 mach_hwclk = a2000_hwclk;
393 else{ /* if (AMIGAHW_PRESENT(A2000_CLK)) */ 387 rtc_resource.name = "A2000 RTC";
394 mach_hwclk = a2000_hwclk; 388 request_resource(&iomem_resource, &rtc_resource);
395 rtc_resource.name = "A2000 RTC"; 389 }
396 request_resource(&iomem_resource, &rtc_resource); 390
397 } 391 /*
398 392 * default MAX_DMA=0xffffffff on all machines. If we don't do so, the SCSI
399 mach_max_dma_address = 0xffffffff; /* 393 * code will not be able to allocate any mem for transfers, unless we are
400 * default MAX_DMA=0xffffffff 394 * dealing with a Z2 mem only system. /Jes
401 * on all machines. If we don't 395 */
402 * do so, the SCSI code will not 396 mach_max_dma_address = 0xffffffff;
403 * be able to allocate any mem 397
404 * for transfers, unless we are 398 mach_set_clock_mmss = amiga_set_clock_mmss;
405 * dealing with a Z2 mem only 399 mach_get_ss = amiga_get_ss;
406 * system. /Jes 400 mach_reset = amiga_reset;
407 */
408
409 mach_set_clock_mmss = amiga_set_clock_mmss;
410 mach_get_ss = amiga_get_ss;
411 mach_reset = amiga_reset;
412#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 401#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
413 mach_beep = amiga_mksound; 402 mach_beep = amiga_mksound;
414#endif 403#endif
415 404
416#ifdef CONFIG_HEARTBEAT 405#ifdef CONFIG_HEARTBEAT
417 mach_heartbeat = amiga_heartbeat; 406 mach_heartbeat = amiga_heartbeat;
418#endif 407#endif
419 408
420 /* Fill in the clock values (based on the 700 kHz E-Clock) */ 409 /* Fill in the clock values (based on the 700 kHz E-Clock) */
421 amiga_masterclock = 40*amiga_eclock; /* 28 MHz */ 410 amiga_masterclock = 40*amiga_eclock; /* 28 MHz */
422 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */ 411 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
423 412
424 /* clear all DMA bits */ 413 /* clear all DMA bits */
425 amiga_custom.dmacon = DMAF_ALL; 414 amiga_custom.dmacon = DMAF_ALL;
426 /* ensure that the DMA master bit is set */ 415 /* ensure that the DMA master bit is set */
427 amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER; 416 amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
428 417
429 /* don't use Z2 RAM as system memory on Z3 capable machines */ 418 /* don't use Z2 RAM as system memory on Z3 capable machines */
430 if (AMIGAHW_PRESENT(ZORRO3)) { 419 if (AMIGAHW_PRESENT(ZORRO3)) {
431 int i, j; 420 int i, j;
432 u32 disabled_z2mem = 0; 421 u32 disabled_z2mem = 0;
433 for (i = 0; i < m68k_num_memory; i++) 422
434 if (m68k_memory[i].addr < 16*1024*1024) { 423 for (i = 0; i < m68k_num_memory; i++) {
435 if (i == 0) { 424 if (m68k_memory[i].addr < 16*1024*1024) {
436 /* don't cut off the branch we're sitting on */ 425 if (i == 0) {
437 printk("Warning: kernel runs in Zorro II memory\n"); 426 /* don't cut off the branch we're sitting on */
438 continue; 427 printk("Warning: kernel runs in Zorro II memory\n");
428 continue;
429 }
430 disabled_z2mem += m68k_memory[i].size;
431 m68k_num_memory--;
432 for (j = i; j < m68k_num_memory; j++)
433 m68k_memory[j] = m68k_memory[j+1];
434 i--;
435 }
436 }
437 if (disabled_z2mem)
438 printk("%dK of Zorro II memory will not be used as system memory\n",
439 disabled_z2mem>>10);
439 } 440 }
440 disabled_z2mem += m68k_memory[i].size; 441
441 m68k_num_memory--; 442 /* request all RAM */
442 for (j = i; j < m68k_num_memory; j++) 443 for (i = 0; i < m68k_num_memory; i++) {
443 m68k_memory[j] = m68k_memory[j+1]; 444 ram_resource[i].name =
444 i--; 445 (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
445 } 446 (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
446 if (disabled_z2mem) 447 "16-bit Slow RAM";
447 printk("%dK of Zorro II memory will not be used as system memory\n", 448 ram_resource[i].start = m68k_memory[i].addr;
448 disabled_z2mem>>10); 449 ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
449 } 450 request_resource(&iomem_resource, &ram_resource[i]);
450 451 }
451 /* request all RAM */ 452
452 for (i = 0; i < m68k_num_memory; i++) { 453 /* initialize chipram allocator */
453 ram_resource[i].name = 454 amiga_chip_init();
454 (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" : 455
455 (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" : 456 /* our beloved beeper */
456 "16-bit Slow RAM"; 457 if (AMIGAHW_PRESENT(AMI_AUDIO))
457 ram_resource[i].start = m68k_memory[i].addr; 458 amiga_init_sound();
458 ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1; 459
459 request_resource(&iomem_resource, &ram_resource[i]); 460 /*
460 } 461 * if it is an A3000, set the magic bit that forces
461 462 * a hard rekick
462 /* initialize chipram allocator */ 463 */
463 amiga_chip_init (); 464 if (AMIGAHW_PRESENT(MAGIC_REKICK))
464 465 *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
465 /* debugging using chipram */
466 if (!strcmp( m68k_debug_device, "mem" )){
467 if (!AMIGAHW_PRESENT(CHIP_RAM))
468 printk("Warning: no chipram present for debugging\n");
469 else {
470 amiga_savekmsg_init();
471 amiga_console_driver.write = amiga_mem_console_write;
472 register_console(&amiga_console_driver);
473 }
474 }
475
476 /* our beloved beeper */
477 if (AMIGAHW_PRESENT(AMI_AUDIO))
478 amiga_init_sound();
479
480 /*
481 * if it is an A3000, set the magic bit that forces
482 * a hard rekick
483 */
484 if (AMIGAHW_PRESENT(MAGIC_REKICK))
485 *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
486} 466}
487 467
488static unsigned short jiffy_ticks; 468static unsigned short jiffy_ticks;
@@ -490,12 +470,12 @@ static unsigned short jiffy_ticks;
490static void __init amiga_sched_init(irq_handler_t timer_routine) 470static void __init amiga_sched_init(irq_handler_t timer_routine)
491{ 471{
492 static struct resource sched_res = { 472 static struct resource sched_res = {
493 .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff, 473 .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
494 }; 474 };
495 jiffy_ticks = (amiga_eclock+HZ/2)/HZ; 475 jiffy_ticks = (amiga_eclock+HZ/2)/HZ;
496 476
497 if (request_resource(&mb_resources._ciab, &sched_res)) 477 if (request_resource(&mb_resources._ciab, &sched_res))
498 printk("Cannot allocate ciab.ta{lo,hi}\n"); 478 printk("Cannot allocate ciab.ta{lo,hi}\n");
499 ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */ 479 ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */
500 ciab.talo = jiffy_ticks % 256; 480 ciab.talo = jiffy_ticks % 256;
501 ciab.tahi = jiffy_ticks / 256; 481 ciab.tahi = jiffy_ticks / 256;
@@ -513,7 +493,7 @@ static void __init amiga_sched_init(irq_handler_t timer_routine)
513#define TICK_SIZE 10000 493#define TICK_SIZE 10000
514 494
515/* This is always executed with interrupts disabled. */ 495/* This is always executed with interrupts disabled. */
516static unsigned long amiga_gettimeoffset (void) 496static unsigned long amiga_gettimeoffset(void)
517{ 497{
518 unsigned short hi, lo, hi2; 498 unsigned short hi, lo, hi2;
519 unsigned long ticks, offset = 0; 499 unsigned long ticks, offset = 0;
@@ -585,15 +565,15 @@ static int a2000_hwclk(int op, struct rtc_time *t)
585 565
586 tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD; 566 tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD;
587 567
588 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) 568 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) {
589 { 569 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
590 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 570 udelay(70);
591 udelay(70); 571 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
592 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
593 } 572 }
594 573
595 if (!cnt) 574 if (!cnt)
596 printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1); 575 printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n",
576 tod_2000.cntrl1);
597 577
598 if (!op) { /* read */ 578 if (!op) { /* read */
599 t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2; 579 t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2;
@@ -606,7 +586,7 @@ static int a2000_hwclk(int op, struct rtc_time *t)
606 if (t->tm_year <= 69) 586 if (t->tm_year <= 69)
607 t->tm_year += 100; 587 t->tm_year += 100;
608 588
609 if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)){ 589 if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)) {
610 if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12) 590 if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12)
611 t->tm_hour = 0; 591 t->tm_hour = 0;
612 else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12) 592 else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12)
@@ -642,7 +622,7 @@ static int a2000_hwclk(int op, struct rtc_time *t)
642 return 0; 622 return 0;
643} 623}
644 624
645static int amiga_set_clock_mmss (unsigned long nowtime) 625static int amiga_set_clock_mmss(unsigned long nowtime)
646{ 626{
647 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; 627 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
648 628
@@ -660,8 +640,7 @@ static int amiga_set_clock_mmss (unsigned long nowtime)
660 640
661 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 641 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
662 642
663 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) 643 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) {
664 {
665 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 644 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
666 udelay(70); 645 udelay(70);
667 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 646 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
@@ -681,7 +660,7 @@ static int amiga_set_clock_mmss (unsigned long nowtime)
681 return 0; 660 return 0;
682} 661}
683 662
684static unsigned int amiga_get_ss( void ) 663static unsigned int amiga_get_ss(void)
685{ 664{
686 unsigned int s; 665 unsigned int s;
687 666
@@ -695,71 +674,72 @@ static unsigned int amiga_get_ss( void )
695 return s; 674 return s;
696} 675}
697 676
698static NORET_TYPE void amiga_reset( void ) 677static NORET_TYPE void amiga_reset(void)
699 ATTRIB_NORET; 678 ATTRIB_NORET;
700 679
701static void amiga_reset (void) 680static void amiga_reset(void)
702{ 681{
703 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040); 682 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
704 unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label); 683 unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label);
705 684
706 local_irq_disable(); 685 local_irq_disable();
707 if (CPU_IS_040_OR_060) 686 if (CPU_IS_040_OR_060)
708 /* Setup transparent translation registers for mapping 687 /* Setup transparent translation registers for mapping
709 * of 16 MB kernel segment before disabling translation 688 * of 16 MB kernel segment before disabling translation
710 */ 689 */
711 __asm__ __volatile__ 690 asm volatile ("\n"
712 ("movel %0,%/d0\n\t" 691 " move.l %0,%%d0\n"
713 "andl #0xff000000,%/d0\n\t" 692 " and.l #0xff000000,%%d0\n"
714 "orw #0xe020,%/d0\n\t" /* map 16 MB, enable, cacheable */ 693 " or.w #0xe020,%%d0\n" /* map 16 MB, enable, cacheable */
715 ".chip 68040\n\t" 694 " .chip 68040\n"
716 "movec %%d0,%%itt0\n\t" 695 " movec %%d0,%%itt0\n"
717 "movec %%d0,%%dtt0\n\t" 696 " movec %%d0,%%dtt0\n"
718 ".chip 68k\n\t" 697 " .chip 68k\n"
719 "jmp %0@\n\t" 698 " jmp %0@\n"
720 : /* no outputs */ 699 : /* no outputs */
721 : "a" (jmp_addr040)); 700 : "a" (jmp_addr040)
722 else 701 : "d0");
723 /* for 680[23]0, just disable translation and jump to the physical 702 else
724 * address of the label 703 /* for 680[23]0, just disable translation and jump to the physical
725 */ 704 * address of the label
726 __asm__ __volatile__ 705 */
727 ("pmove %/tc,%@\n\t" 706 asm volatile ("\n"
728 "bclr #7,%@\n\t" 707 " pmove %%tc,%@\n"
729 "pmove %@,%/tc\n\t" 708 " bclr #7,%@\n"
730 "jmp %0@\n\t" 709 " pmove %@,%%tc\n"
731 : /* no outputs */ 710 " jmp %0@\n"
732 : "a" (jmp_addr)); 711 : /* no outputs */
733 jmp_addr_label040: 712 : "a" (jmp_addr));
734 /* disable translation on '040 now */ 713jmp_addr_label040:
735 __asm__ __volatile__ 714 /* disable translation on '040 now */
736 ("moveq #0,%/d0\n\t" 715 asm volatile ("\n"
737 ".chip 68040\n\t" 716 " moveq #0,%%d0\n"
738 "movec %%d0,%%tc\n\t" /* disable MMU */ 717 " .chip 68040\n"
739 ".chip 68k\n\t" 718 " movec %%d0,%%tc\n" /* disable MMU */
740 : /* no outputs */ 719 " .chip 68k\n"
741 : /* no inputs */ 720 : /* no outputs */
742 : "d0"); 721 : /* no inputs */
743 722 : "d0");
744 jmp_addr_label: 723
745 /* pickup reset address from AmigaOS ROM, reset devices and jump 724 jmp_addr_label:
746 * to reset address 725 /* pickup reset address from AmigaOS ROM, reset devices and jump
747 */ 726 * to reset address
748 __asm__ __volatile__ 727 */
749 ("movew #0x2700,%/sr\n\t" 728 asm volatile ("\n"
750 "leal 0x01000000,%/a0\n\t" 729 " move.w #0x2700,%sr\n"
751 "subl %/a0@(-0x14),%/a0\n\t" 730 " lea 0x01000000,%a0\n"
752 "movel %/a0@(4),%/a0\n\t" 731 " sub.l %a0@(-0x14),%a0\n"
753 "subql #2,%/a0\n\t" 732 " move.l %a0@(4),%a0\n"
754 "bra 1f\n\t" 733 " subq.l #2,%a0\n"
755 /* align on a longword boundary */ 734 " jra 1f\n"
756 __ALIGN_STR "\n" 735 /* align on a longword boundary */
757 "1:\n\t" 736 " " __ALIGN_STR "\n"
758 "reset\n\t" 737 "1:\n"
759 "jmp %/a0@" : /* Just that gcc scans it for % escapes */ ); 738 " reset\n"
760 739 " jmp %a0@");
761 for (;;); 740
762 741 for (;;)
742 ;
763} 743}
764 744
765 745
@@ -773,11 +753,11 @@ static void amiga_reset (void)
773#define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */ 753#define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */
774 754
775struct savekmsg { 755struct savekmsg {
776 unsigned long magic1; /* SAVEKMSG_MAGIC1 */ 756 unsigned long magic1; /* SAVEKMSG_MAGIC1 */
777 unsigned long magic2; /* SAVEKMSG_MAGIC2 */ 757 unsigned long magic2; /* SAVEKMSG_MAGIC2 */
778 unsigned long magicptr; /* address of magic1 */ 758 unsigned long magicptr; /* address of magic1 */
779 unsigned long size; 759 unsigned long size;
780 char data[0]; 760 char data[0];
781}; 761};
782 762
783static struct savekmsg *savekmsg; 763static struct savekmsg *savekmsg;
@@ -785,113 +765,132 @@ static struct savekmsg *savekmsg;
785static void amiga_mem_console_write(struct console *co, const char *s, 765static void amiga_mem_console_write(struct console *co, const char *s,
786 unsigned int count) 766 unsigned int count)
787{ 767{
788 if (savekmsg->size+count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) { 768 if (savekmsg->size + count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
789 memcpy(savekmsg->data+savekmsg->size, s, count); 769 memcpy(savekmsg->data + savekmsg->size, s, count);
790 savekmsg->size += count; 770 savekmsg->size += count;
791 } 771 }
792} 772}
793 773
794static void amiga_savekmsg_init(void) 774static int __init amiga_savekmsg_setup(char *arg)
795{ 775{
796 static struct resource debug_res = { .name = "Debug" }; 776 static struct resource debug_res = { .name = "Debug" };
777
778 if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
779 goto done;
780
781 if (!AMIGAHW_PRESENT(CHIP_RAM)) {
782 printk("Warning: no chipram present for debugging\n");
783 goto done;
784 }
797 785
798 savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res); 786 savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res);
799 savekmsg->magic1 = SAVEKMSG_MAGIC1; 787 savekmsg->magic1 = SAVEKMSG_MAGIC1;
800 savekmsg->magic2 = SAVEKMSG_MAGIC2; 788 savekmsg->magic2 = SAVEKMSG_MAGIC2;
801 savekmsg->magicptr = ZTWO_PADDR(savekmsg); 789 savekmsg->magicptr = ZTWO_PADDR(savekmsg);
802 savekmsg->size = 0; 790 savekmsg->size = 0;
791
792 amiga_console_driver.write = amiga_mem_console_write;
793 register_console(&amiga_console_driver);
794
795done:
796 return 0;
803} 797}
804 798
799early_param("debug", amiga_savekmsg_setup);
800
805static void amiga_serial_putc(char c) 801static void amiga_serial_putc(char c)
806{ 802{
807 amiga_custom.serdat = (unsigned char)c | 0x100; 803 amiga_custom.serdat = (unsigned char)c | 0x100;
808 while (!(amiga_custom.serdatr & 0x2000)) 804 while (!(amiga_custom.serdatr & 0x2000))
809 ; 805 ;
810} 806}
811 807
812void amiga_serial_console_write(struct console *co, const char *s, 808void amiga_serial_console_write(struct console *co, const char *s,
813 unsigned int count) 809 unsigned int count)
814{ 810{
815 while (count--) { 811 while (count--) {
816 if (*s == '\n') 812 if (*s == '\n')
817 amiga_serial_putc('\r'); 813 amiga_serial_putc('\r');
818 amiga_serial_putc(*s++); 814 amiga_serial_putc(*s++);
819 } 815 }
820} 816}
821 817
822#ifdef CONFIG_SERIAL_CONSOLE 818#ifdef CONFIG_SERIAL_CONSOLE
823void amiga_serial_puts(const char *s) 819void amiga_serial_puts(const char *s)
824{ 820{
825 amiga_serial_console_write(NULL, s, strlen(s)); 821 amiga_serial_console_write(NULL, s, strlen(s));
826} 822}
827 823
828int amiga_serial_console_wait_key(struct console *co) 824int amiga_serial_console_wait_key(struct console *co)
829{ 825{
830 int ch; 826 int ch;
831 827
832 while (!(amiga_custom.intreqr & IF_RBF)) 828 while (!(amiga_custom.intreqr & IF_RBF))
833 barrier(); 829 barrier();
834 ch = amiga_custom.serdatr & 0xff; 830 ch = amiga_custom.serdatr & 0xff;
835 /* clear the interrupt, so that another character can be read */ 831 /* clear the interrupt, so that another character can be read */
836 amiga_custom.intreq = IF_RBF; 832 amiga_custom.intreq = IF_RBF;
837 return ch; 833 return ch;
838} 834}
839 835
840void amiga_serial_gets(struct console *co, char *s, int len) 836void amiga_serial_gets(struct console *co, char *s, int len)
841{ 837{
842 int ch, cnt = 0; 838 int ch, cnt = 0;
843 839
844 while (1) { 840 while (1) {
845 ch = amiga_serial_console_wait_key(co); 841 ch = amiga_serial_console_wait_key(co);
846 842
847 /* Check for backspace. */ 843 /* Check for backspace. */
848 if (ch == 8 || ch == 127) { 844 if (ch == 8 || ch == 127) {
849 if (cnt == 0) { 845 if (cnt == 0) {
850 amiga_serial_putc('\007'); 846 amiga_serial_putc('\007');
851 continue; 847 continue;
852 } 848 }
853 cnt--; 849 cnt--;
854 amiga_serial_puts("\010 \010"); 850 amiga_serial_puts("\010 \010");
855 continue; 851 continue;
856 } 852 }
857 853
858 /* Check for enter. */ 854 /* Check for enter. */
859 if (ch == 10 || ch == 13) 855 if (ch == 10 || ch == 13)
860 break; 856 break;
861 857
862 /* See if line is too long. */ 858 /* See if line is too long. */
863 if (cnt >= len + 1) { 859 if (cnt >= len + 1) {
864 amiga_serial_putc(7); 860 amiga_serial_putc(7);
865 cnt--; 861 cnt--;
866 continue; 862 continue;
867 } 863 }
868 864
869 /* Store and echo character. */ 865 /* Store and echo character. */
870 s[cnt++] = ch; 866 s[cnt++] = ch;
871 amiga_serial_putc(ch); 867 amiga_serial_putc(ch);
872 } 868 }
873 /* Print enter. */ 869 /* Print enter. */
874 amiga_serial_puts("\r\n"); 870 amiga_serial_puts("\r\n");
875 s[cnt] = 0; 871 s[cnt] = 0;
876} 872}
877#endif 873#endif
878 874
879static void __init amiga_debug_init(void) 875static int __init amiga_debug_setup(char *arg)
880{ 876{
881 if (!strcmp( m68k_debug_device, "ser" )) { 877 if (MACH_IS_AMIGA && !strcmp(arg, "ser")) {
882 /* no initialization required (?) */ 878 /* no initialization required (?) */
883 amiga_console_driver.write = amiga_serial_console_write; 879 amiga_console_driver.write = amiga_serial_console_write;
884 register_console(&amiga_console_driver); 880 register_console(&amiga_console_driver);
885 } 881 }
882 return 0;
886} 883}
887 884
885early_param("debug", amiga_debug_setup);
886
888#ifdef CONFIG_HEARTBEAT 887#ifdef CONFIG_HEARTBEAT
889static void amiga_heartbeat(int on) 888static void amiga_heartbeat(int on)
890{ 889{
891 if (on) 890 if (on)
892 ciaa.pra &= ~2; 891 ciaa.pra &= ~2;
893 else 892 else
894 ciaa.pra |= 2; 893 ciaa.pra |= 2;
895} 894}
896#endif 895#endif
897 896
@@ -901,81 +900,81 @@ static void amiga_heartbeat(int on)
901 900
902static void amiga_get_model(char *model) 901static void amiga_get_model(char *model)
903{ 902{
904 strcpy(model, amiga_model_name); 903 strcpy(model, amiga_model_name);
905} 904}
906 905
907 906
908static int amiga_get_hardware_list(char *buffer) 907static int amiga_get_hardware_list(char *buffer)
909{ 908{
910 int len = 0; 909 int len = 0;
911 910
912 if (AMIGAHW_PRESENT(CHIP_RAM)) 911 if (AMIGAHW_PRESENT(CHIP_RAM))
913 len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10); 912 len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10);
914 len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n", 913 len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n",
915 amiga_psfreq, amiga_eclock); 914 amiga_psfreq, amiga_eclock);
916 if (AMIGAHW_PRESENT(AMI_VIDEO)) { 915 if (AMIGAHW_PRESENT(AMI_VIDEO)) {
917 char *type; 916 char *type;
918 switch(amiga_chipset) { 917 switch (amiga_chipset) {
919 case CS_OCS: 918 case CS_OCS:
920 type = "OCS"; 919 type = "OCS";
921 break; 920 break;
922 case CS_ECS: 921 case CS_ECS:
923 type = "ECS"; 922 type = "ECS";
924 break; 923 break;
925 case CS_AGA: 924 case CS_AGA:
926 type = "AGA"; 925 type = "AGA";
927 break; 926 break;
928 default: 927 default:
929 type = "Old or Unknown"; 928 type = "Old or Unknown";
930 break; 929 break;
930 }
931 len += sprintf(buffer+len, "Graphics:\t%s\n", type);
931 } 932 }
932 len += sprintf(buffer+len, "Graphics:\t%s\n", type);
933 }
934 933
935#define AMIGAHW_ANNOUNCE(name, str) \ 934#define AMIGAHW_ANNOUNCE(name, str) \
936 if (AMIGAHW_PRESENT(name)) \ 935 if (AMIGAHW_PRESENT(name)) \
937 len += sprintf (buffer+len, "\t%s\n", str) 936 len += sprintf (buffer+len, "\t%s\n", str)
938 937
939 len += sprintf (buffer + len, "Detected hardware:\n"); 938 len += sprintf (buffer + len, "Detected hardware:\n");
940 939
941 AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video"); 940 AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video");
942 AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter"); 941 AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter");
943 AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer"); 942 AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer");
944 AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio"); 943 AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio");
945 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller"); 944 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller");
946 AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)"); 945 AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)");
947 AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)"); 946 AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)");
948 AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)"); 947 AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)");
949 AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)"); 948 AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)");
950 AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive"); 949 AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive");
951 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard"); 950 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard");
952 AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port"); 951 AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port");
953 AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port"); 952 AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port");
954 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port"); 953 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port");
955 AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)"); 954 AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)");
956 AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)"); 955 AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)");
957 AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM"); 956 AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM");
958 AMIGAHW_ANNOUNCE(PAULA, "Paula 8364"); 957 AMIGAHW_ANNOUNCE(PAULA, "Paula 8364");
959 AMIGAHW_ANNOUNCE(DENISE, "Denise 8362"); 958 AMIGAHW_ANNOUNCE(DENISE, "Denise 8362");
960 AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373"); 959 AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373");
961 AMIGAHW_ANNOUNCE(LISA, "Lisa 8375"); 960 AMIGAHW_ANNOUNCE(LISA, "Lisa 8375");
962 AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371"); 961 AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371");
963 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370"); 962 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370");
964 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372"); 963 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372");
965 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372"); 964 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372");
966 AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374"); 965 AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374");
967 AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374"); 966 AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374");
968 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick"); 967 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick");
969 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot"); 968 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot");
970#ifdef CONFIG_ZORRO 969#ifdef CONFIG_ZORRO
971 if (AMIGAHW_PRESENT(ZORRO)) 970 if (AMIGAHW_PRESENT(ZORRO))
972 len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion " 971 len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion "
973 "Device%s\n", 972 "Device%s\n",
974 AMIGAHW_PRESENT(ZORRO3) ? "I" : "", 973 AMIGAHW_PRESENT(ZORRO3) ? "I" : "",
975 zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s"); 974 zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
976#endif /* CONFIG_ZORRO */ 975#endif /* CONFIG_ZORRO */
977 976
978#undef AMIGAHW_ANNOUNCE 977#undef AMIGAHW_ANNOUNCE
979 978
980 return(len); 979 return len;
981} 980}
diff --git a/arch/m68k/atari/Makefile b/arch/m68k/atari/Makefile
index 8cb6236b39db..2cb86191f0aa 100644
--- a/arch/m68k/atari/Makefile
+++ b/arch/m68k/atari/Makefile
@@ -8,3 +8,4 @@ obj-y := config.o time.o debug.o ataints.o stdma.o \
8ifeq ($(CONFIG_PCI),y) 8ifeq ($(CONFIG_PCI),y)
9obj-$(CONFIG_HADES) += hades-pci.o 9obj-$(CONFIG_HADES) += hades-pci.o
10endif 10endif
11obj-$(CONFIG_ATARI_KBD_CORE) += atakeyb.o
diff --git a/arch/m68k/atari/atakeyb.c b/arch/m68k/atari/atakeyb.c
new file mode 100644
index 000000000000..1c29603b16b3
--- /dev/null
+++ b/arch/m68k/atari/atakeyb.c
@@ -0,0 +1,730 @@
1/*
2 * linux/atari/atakeyb.c
3 *
4 * Atari Keyboard driver for 680x0 Linux
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11/*
12 * Atari support by Robert de Vries
13 * enhanced by Bjoern Brauel and Roman Hodek
14 */
15
16#include <linux/sched.h>
17#include <linux/kernel.h>
18#include <linux/interrupt.h>
19#include <linux/errno.h>
20#include <linux/keyboard.h>
21#include <linux/delay.h>
22#include <linux/timer.h>
23#include <linux/kd.h>
24#include <linux/random.h>
25#include <linux/init.h>
26#include <linux/kbd_kern.h>
27
28#include <asm/atariints.h>
29#include <asm/atarihw.h>
30#include <asm/atarikb.h>
31#include <asm/atari_joystick.h>
32#include <asm/irq.h>
33
34static void atakeyb_rep(unsigned long ignore);
35extern unsigned int keymap_count;
36
37/* Hook for MIDI serial driver */
38void (*atari_MIDI_interrupt_hook) (void);
39/* Hook for mouse driver */
40void (*atari_mouse_interrupt_hook) (char *);
41/* Hook for keyboard inputdev driver */
42void (*atari_input_keyboard_interrupt_hook) (unsigned char, char);
43/* Hook for mouse inputdev driver */
44void (*atari_input_mouse_interrupt_hook) (char *);
45
46/* variables for IKBD self test: */
47
48/* state: 0: off; >0: in progress; >1: 0xf1 received */
49static volatile int ikbd_self_test;
50/* timestamp when last received a char */
51static volatile unsigned long self_test_last_rcv;
52/* bitmap of keys reported as broken */
53static unsigned long broken_keys[128/(sizeof(unsigned long)*8)] = { 0, };
54
55#define BREAK_MASK (0x80)
56
57/*
58 * ++roman: The following changes were applied manually:
59 *
60 * - The Alt (= Meta) key works in combination with Shift and
61 * Control, e.g. Alt+Shift+a sends Meta-A (0xc1), Alt+Control+A sends
62 * Meta-Ctrl-A (0x81) ...
63 *
64 * - The parentheses on the keypad send '(' and ')' with all
65 * modifiers (as would do e.g. keypad '+'), but they cannot be used as
66 * application keys (i.e. sending Esc O c).
67 *
68 * - HELP and UNDO are mapped to be F21 and F24, resp, that send the
69 * codes "\E[M" and "\E[P". (This is better than the old mapping to
70 * F11 and F12, because these codes are on Shift+F1/2 anyway.) This
71 * way, applications that allow their own keyboard mappings
72 * (e.g. tcsh, X Windows) can be configured to use them in the way
73 * the label suggests (providing help or undoing).
74 *
75 * - Console switching is done with Alt+Fx (consoles 1..10) and
76 * Shift+Alt+Fx (consoles 11..20).
77 *
78 * - The misc. special function implemented in the kernel are mapped
79 * to the following key combinations:
80 *
81 * ClrHome -> Home/Find
82 * Shift + ClrHome -> End/Select
83 * Shift + Up -> Page Up
84 * Shift + Down -> Page Down
85 * Alt + Help -> show system status
86 * Shift + Help -> show memory info
87 * Ctrl + Help -> show registers
88 * Ctrl + Alt + Del -> Reboot
89 * Alt + Undo -> switch to last console
90 * Shift + Undo -> send interrupt
91 * Alt + Insert -> stop/start output (same as ^S/^Q)
92 * Alt + Up -> Scroll back console (if implemented)
93 * Alt + Down -> Scroll forward console (if implemented)
94 * Alt + CapsLock -> NumLock
95 *
96 * ++Andreas:
97 *
98 * - Help mapped to K_HELP
99 * - Undo mapped to K_UNDO (= K_F246)
100 * - Keypad Left/Right Parenthesis mapped to new K_PPAREN[LR]
101 */
102
103static u_short ataplain_map[NR_KEYS] __initdata = {
104 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,
105 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf008, 0xf009,
106 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69,
107 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73,
108 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b,
109 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76,
110 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf200,
111 0xf703, 0xf020, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104,
112 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf200, 0xf200, 0xf114,
113 0xf603, 0xf200, 0xf30b, 0xf601, 0xf200, 0xf602, 0xf30a, 0xf200,
114 0xf600, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf200, 0xf200,
115 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
116 0xf200, 0xf1ff, 0xf11b, 0xf312, 0xf313, 0xf30d, 0xf30c, 0xf307,
117 0xf308, 0xf309, 0xf304, 0xf305, 0xf306, 0xf301, 0xf302, 0xf303,
118 0xf300, 0xf310, 0xf30e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
119 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200
120};
121
122typedef enum kb_state_t {
123 KEYBOARD, AMOUSE, RMOUSE, JOYSTICK, CLOCK, RESYNC
124} KB_STATE_T;
125
126#define IS_SYNC_CODE(sc) ((sc) >= 0x04 && (sc) <= 0xfb)
127
128typedef struct keyboard_state {
129 unsigned char buf[6];
130 int len;
131 KB_STATE_T state;
132} KEYBOARD_STATE;
133
134KEYBOARD_STATE kb_state;
135
136#define DEFAULT_KEYB_REP_DELAY (HZ/4)
137#define DEFAULT_KEYB_REP_RATE (HZ/25)
138
139/* These could be settable by some ioctl() in future... */
140static unsigned int key_repeat_delay = DEFAULT_KEYB_REP_DELAY;
141static unsigned int key_repeat_rate = DEFAULT_KEYB_REP_RATE;
142
143static unsigned char rep_scancode;
144static struct timer_list atakeyb_rep_timer = {
145 .function = atakeyb_rep,
146};
147
148static void atakeyb_rep(unsigned long ignore)
149{
150 /* Disable keyboard for the time we call handle_scancode(), else a race
151 * in the keyboard tty queue may happen */
152 atari_disable_irq(IRQ_MFP_ACIA);
153 del_timer(&atakeyb_rep_timer);
154
155 /* A keyboard int may have come in before we disabled the irq, so
156 * double-check whether rep_scancode is still != 0 */
157 if (rep_scancode) {
158 init_timer(&atakeyb_rep_timer);
159 atakeyb_rep_timer.expires = jiffies + key_repeat_rate;
160 add_timer(&atakeyb_rep_timer);
161
162 //handle_scancode(rep_scancode, 1);
163 if (atari_input_keyboard_interrupt_hook)
164 atari_input_keyboard_interrupt_hook(rep_scancode, 1);
165 }
166
167 atari_enable_irq(IRQ_MFP_ACIA);
168}
169
170
171/* ++roman: If a keyboard overrun happened, we can't tell in general how much
172 * bytes have been lost and in which state of the packet structure we are now.
173 * This usually causes keyboards bytes to be interpreted as mouse movements
174 * and vice versa, which is very annoying. It seems better to throw away some
175 * bytes (that are usually mouse bytes) than to misinterpret them. Therefor I
176 * introduced the RESYNC state for IKBD data. In this state, the bytes up to
177 * one that really looks like a key event (0x04..0xf2) or the start of a mouse
178 * packet (0xf8..0xfb) are thrown away, but at most 2 bytes. This at least
179 * speeds up the resynchronization of the event structure, even if maybe a
180 * mouse movement is lost. However, nothing is perfect. For bytes 0x01..0x03,
181 * it's really hard to decide whether they're mouse or keyboard bytes. Since
182 * overruns usually occur when moving the Atari mouse rapidly, they're seen as
183 * mouse bytes here. If this is wrong, only a make code of the keyboard gets
184 * lost, which isn't too bad. Loosing a break code would be disastrous,
185 * because then the keyboard repeat strikes...
186 */
187
188static irqreturn_t atari_keyboard_interrupt(int irq, void *dummy)
189{
190 u_char acia_stat;
191 int scancode;
192 int break_flag;
193
194repeat:
195 if (acia.mid_ctrl & ACIA_IRQ)
196 if (atari_MIDI_interrupt_hook)
197 atari_MIDI_interrupt_hook();
198 acia_stat = acia.key_ctrl;
199 /* check out if the interrupt came from this ACIA */
200 if (!((acia_stat | acia.mid_ctrl) & ACIA_IRQ))
201 return IRQ_HANDLED;
202
203 if (acia_stat & ACIA_OVRN) {
204 /* a very fast typist or a slow system, give a warning */
205 /* ...happens often if interrupts were disabled for too long */
206 printk(KERN_DEBUG "Keyboard overrun\n");
207 scancode = acia.key_data;
208 /* Turn off autorepeating in case a break code has been lost */
209 del_timer(&atakeyb_rep_timer);
210 rep_scancode = 0;
211 if (ikbd_self_test)
212 /* During self test, don't do resyncing, just process the code */
213 goto interpret_scancode;
214 else if (IS_SYNC_CODE(scancode)) {
215 /* This code seem already to be the start of a new packet or a
216 * single scancode */
217 kb_state.state = KEYBOARD;
218 goto interpret_scancode;
219 } else {
220 /* Go to RESYNC state and skip this byte */
221 kb_state.state = RESYNC;
222 kb_state.len = 1; /* skip max. 1 another byte */
223 goto repeat;
224 }
225 }
226
227 if (acia_stat & ACIA_RDRF) {
228 /* received a character */
229 scancode = acia.key_data; /* get it or reset the ACIA, I'll get it! */
230 tasklet_schedule(&keyboard_tasklet);
231 interpret_scancode:
232 switch (kb_state.state) {
233 case KEYBOARD:
234 switch (scancode) {
235 case 0xF7:
236 kb_state.state = AMOUSE;
237 kb_state.len = 0;
238 break;
239
240 case 0xF8:
241 case 0xF9:
242 case 0xFA:
243 case 0xFB:
244 kb_state.state = RMOUSE;
245 kb_state.len = 1;
246 kb_state.buf[0] = scancode;
247 break;
248
249 case 0xFC:
250 kb_state.state = CLOCK;
251 kb_state.len = 0;
252 break;
253
254 case 0xFE:
255 case 0xFF:
256 kb_state.state = JOYSTICK;
257 kb_state.len = 1;
258 kb_state.buf[0] = scancode;
259 break;
260
261 case 0xF1:
262 /* during self-test, note that 0xf1 received */
263 if (ikbd_self_test) {
264 ++ikbd_self_test;
265 self_test_last_rcv = jiffies;
266 break;
267 }
268 /* FALL THROUGH */
269
270 default:
271 break_flag = scancode & BREAK_MASK;
272 scancode &= ~BREAK_MASK;
273 if (ikbd_self_test) {
274 /* Scancodes sent during the self-test stand for broken
275 * keys (keys being down). The code *should* be a break
276 * code, but nevertheless some AT keyboard interfaces send
277 * make codes instead. Therefore, simply ignore
278 * break_flag...
279 */
280 int keyval = plain_map[scancode], keytyp;
281
282 set_bit(scancode, broken_keys);
283 self_test_last_rcv = jiffies;
284 keyval = plain_map[scancode];
285 keytyp = KTYP(keyval) - 0xf0;
286 keyval = KVAL(keyval);
287
288 printk(KERN_WARNING "Key with scancode %d ", scancode);
289 if (keytyp == KT_LATIN || keytyp == KT_LETTER) {
290 if (keyval < ' ')
291 printk("('^%c') ", keyval + '@');
292 else
293 printk("('%c') ", keyval);
294 }
295 printk("is broken -- will be ignored.\n");
296 break;
297 } else if (test_bit(scancode, broken_keys))
298 break;
299
300#if 0 // FIXME; hangs at boot
301 if (break_flag) {
302 del_timer(&atakeyb_rep_timer);
303 rep_scancode = 0;
304 } else {
305 del_timer(&atakeyb_rep_timer);
306 rep_scancode = scancode;
307 atakeyb_rep_timer.expires = jiffies + key_repeat_delay;
308 add_timer(&atakeyb_rep_timer);
309 }
310#endif
311
312 // handle_scancode(scancode, !break_flag);
313 if (atari_input_keyboard_interrupt_hook)
314 atari_input_keyboard_interrupt_hook((unsigned char)scancode, !break_flag);
315 break;
316 }
317 break;
318
319 case AMOUSE:
320 kb_state.buf[kb_state.len++] = scancode;
321 if (kb_state.len == 5) {
322 kb_state.state = KEYBOARD;
323 /* not yet used */
324 /* wake up someone waiting for this */
325 }
326 break;
327
328 case RMOUSE:
329 kb_state.buf[kb_state.len++] = scancode;
330 if (kb_state.len == 3) {
331 kb_state.state = KEYBOARD;
332 if (atari_mouse_interrupt_hook)
333 atari_mouse_interrupt_hook(kb_state.buf);
334 }
335 break;
336
337 case JOYSTICK:
338 kb_state.buf[1] = scancode;
339 kb_state.state = KEYBOARD;
340#ifdef FIXED_ATARI_JOYSTICK
341 atari_joystick_interrupt(kb_state.buf);
342#endif
343 break;
344
345 case CLOCK:
346 kb_state.buf[kb_state.len++] = scancode;
347 if (kb_state.len == 6) {
348 kb_state.state = KEYBOARD;
349 /* wake up someone waiting for this.
350 But will this ever be used, as Linux keeps its own time.
351 Perhaps for synchronization purposes? */
352 /* wake_up_interruptible(&clock_wait); */
353 }
354 break;
355
356 case RESYNC:
357 if (kb_state.len <= 0 || IS_SYNC_CODE(scancode)) {
358 kb_state.state = KEYBOARD;
359 goto interpret_scancode;
360 }
361 kb_state.len--;
362 break;
363 }
364 }
365
366#if 0
367 if (acia_stat & ACIA_CTS)
368 /* cannot happen */;
369#endif
370
371 if (acia_stat & (ACIA_FE | ACIA_PE)) {
372 printk("Error in keyboard communication\n");
373 }
374
375 /* handle_scancode() can take a lot of time, so check again if
376 * some character arrived
377 */
378 goto repeat;
379}
380
381/*
382 * I write to the keyboard without using interrupts, I poll instead.
383 * This takes for the maximum length string allowed (7) at 7812.5 baud
384 * 8 data 1 start 1 stop bit: 9.0 ms
385 * If this takes too long for normal operation, interrupt driven writing
386 * is the solution. (I made a feeble attempt in that direction but I
387 * kept it simple for now.)
388 */
389void ikbd_write(const char *str, int len)
390{
391 u_char acia_stat;
392
393 if ((len < 1) || (len > 7))
394 panic("ikbd: maximum string length exceeded");
395 while (len) {
396 acia_stat = acia.key_ctrl;
397 if (acia_stat & ACIA_TDRE) {
398 acia.key_data = *str++;
399 len--;
400 }
401 }
402}
403
404/* Reset (without touching the clock) */
405void ikbd_reset(void)
406{
407 static const char cmd[2] = { 0x80, 0x01 };
408
409 ikbd_write(cmd, 2);
410
411 /*
412 * if all's well code 0xF1 is returned, else the break codes of
413 * all keys making contact
414 */
415}
416
417/* Set mouse button action */
418void ikbd_mouse_button_action(int mode)
419{
420 char cmd[2] = { 0x07, mode };
421
422 ikbd_write(cmd, 2);
423}
424
425/* Set relative mouse position reporting */
426void ikbd_mouse_rel_pos(void)
427{
428 static const char cmd[1] = { 0x08 };
429
430 ikbd_write(cmd, 1);
431}
432
433/* Set absolute mouse position reporting */
434void ikbd_mouse_abs_pos(int xmax, int ymax)
435{
436 char cmd[5] = { 0x09, xmax>>8, xmax&0xFF, ymax>>8, ymax&0xFF };
437
438 ikbd_write(cmd, 5);
439}
440
441/* Set mouse keycode mode */
442void ikbd_mouse_kbd_mode(int dx, int dy)
443{
444 char cmd[3] = { 0x0A, dx, dy };
445
446 ikbd_write(cmd, 3);
447}
448
449/* Set mouse threshold */
450void ikbd_mouse_thresh(int x, int y)
451{
452 char cmd[3] = { 0x0B, x, y };
453
454 ikbd_write(cmd, 3);
455}
456
457/* Set mouse scale */
458void ikbd_mouse_scale(int x, int y)
459{
460 char cmd[3] = { 0x0C, x, y };
461
462 ikbd_write(cmd, 3);
463}
464
465/* Interrogate mouse position */
466void ikbd_mouse_pos_get(int *x, int *y)
467{
468 static const char cmd[1] = { 0x0D };
469
470 ikbd_write(cmd, 1);
471
472 /* wait for returning bytes */
473}
474
475/* Load mouse position */
476void ikbd_mouse_pos_set(int x, int y)
477{
478 char cmd[6] = { 0x0E, 0x00, x>>8, x&0xFF, y>>8, y&0xFF };
479
480 ikbd_write(cmd, 6);
481}
482
483/* Set Y=0 at bottom */
484void ikbd_mouse_y0_bot(void)
485{
486 static const char cmd[1] = { 0x0F };
487
488 ikbd_write(cmd, 1);
489}
490
491/* Set Y=0 at top */
492void ikbd_mouse_y0_top(void)
493{
494 static const char cmd[1] = { 0x10 };
495
496 ikbd_write(cmd, 1);
497}
498
499/* Resume */
500void ikbd_resume(void)
501{
502 static const char cmd[1] = { 0x11 };
503
504 ikbd_write(cmd, 1);
505}
506
507/* Disable mouse */
508void ikbd_mouse_disable(void)
509{
510 static const char cmd[1] = { 0x12 };
511
512 ikbd_write(cmd, 1);
513}
514
515/* Pause output */
516void ikbd_pause(void)
517{
518 static const char cmd[1] = { 0x13 };
519
520 ikbd_write(cmd, 1);
521}
522
523/* Set joystick event reporting */
524void ikbd_joystick_event_on(void)
525{
526 static const char cmd[1] = { 0x14 };
527
528 ikbd_write(cmd, 1);
529}
530
531/* Set joystick interrogation mode */
532void ikbd_joystick_event_off(void)
533{
534 static const char cmd[1] = { 0x15 };
535
536 ikbd_write(cmd, 1);
537}
538
539/* Joystick interrogation */
540void ikbd_joystick_get_state(void)
541{
542 static const char cmd[1] = { 0x16 };
543
544 ikbd_write(cmd, 1);
545}
546
547#if 0
548/* This disables all other ikbd activities !!!! */
549/* Set joystick monitoring */
550void ikbd_joystick_monitor(int rate)
551{
552 static const char cmd[2] = { 0x17, rate };
553
554 ikbd_write(cmd, 2);
555
556 kb_state.state = JOYSTICK_MONITOR;
557}
558#endif
559
560/* some joystick routines not in yet (0x18-0x19) */
561
562/* Disable joysticks */
563void ikbd_joystick_disable(void)
564{
565 static const char cmd[1] = { 0x1A };
566
567 ikbd_write(cmd, 1);
568}
569
570/* Time-of-day clock set */
571void ikbd_clock_set(int year, int month, int day, int hour, int minute, int second)
572{
573 char cmd[7] = { 0x1B, year, month, day, hour, minute, second };
574
575 ikbd_write(cmd, 7);
576}
577
578/* Interrogate time-of-day clock */
579void ikbd_clock_get(int *year, int *month, int *day, int *hour, int *minute, int second)
580{
581 static const char cmd[1] = { 0x1C };
582
583 ikbd_write(cmd, 1);
584}
585
586/* Memory load */
587void ikbd_mem_write(int address, int size, char *data)
588{
589 panic("Attempt to write data into keyboard memory");
590}
591
592/* Memory read */
593void ikbd_mem_read(int address, char data[6])
594{
595 char cmd[3] = { 0x21, address>>8, address&0xFF };
596
597 ikbd_write(cmd, 3);
598
599 /* receive data and put it in data */
600}
601
602/* Controller execute */
603void ikbd_exec(int address)
604{
605 char cmd[3] = { 0x22, address>>8, address&0xFF };
606
607 ikbd_write(cmd, 3);
608}
609
610/* Status inquiries (0x87-0x9A) not yet implemented */
611
612/* Set the state of the caps lock led. */
613void atari_kbd_leds(unsigned int leds)
614{
615 char cmd[6] = {32, 0, 4, 1, 254 + ((leds & 4) != 0), 0};
616
617 ikbd_write(cmd, 6);
618}
619
620/*
621 * The original code sometimes left the interrupt line of
622 * the ACIAs low forever. I hope, it is fixed now.
623 *
624 * Martin Rogge, 20 Aug 1995
625 */
626
627static int atari_keyb_done = 0;
628
629int __init atari_keyb_init(void)
630{
631 if (atari_keyb_done)
632 return 0;
633
634 /* setup key map */
635 memcpy(key_maps[0], ataplain_map, sizeof(plain_map));
636
637 kb_state.state = KEYBOARD;
638 kb_state.len = 0;
639
640 request_irq(IRQ_MFP_ACIA, atari_keyboard_interrupt, IRQ_TYPE_SLOW,
641 "keyboard/mouse/MIDI", atari_keyboard_interrupt);
642
643 atari_turnoff_irq(IRQ_MFP_ACIA);
644 do {
645 /* reset IKBD ACIA */
646 acia.key_ctrl = ACIA_RESET |
647 (atari_switches & ATARI_SWITCH_IKBD) ? ACIA_RHTID : 0;
648 (void)acia.key_ctrl;
649 (void)acia.key_data;
650
651 /* reset MIDI ACIA */
652 acia.mid_ctrl = ACIA_RESET |
653 (atari_switches & ATARI_SWITCH_MIDI) ? ACIA_RHTID : 0;
654 (void)acia.mid_ctrl;
655 (void)acia.mid_data;
656
657 /* divide 500kHz by 64 gives 7812.5 baud */
658 /* 8 data no parity 1 start 1 stop bit */
659 /* receive interrupt enabled */
660 /* RTS low (except if switch selected), transmit interrupt disabled */
661 acia.key_ctrl = (ACIA_DIV64|ACIA_D8N1S|ACIA_RIE) |
662 ((atari_switches & ATARI_SWITCH_IKBD) ?
663 ACIA_RHTID : ACIA_RLTID);
664
665 acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S |
666 (atari_switches & ATARI_SWITCH_MIDI) ? ACIA_RHTID : 0;
667
668 /* make sure the interrupt line is up */
669 } while ((mfp.par_dt_reg & 0x10) == 0);
670
671 /* enable ACIA Interrupts */
672 mfp.active_edge &= ~0x10;
673 atari_turnon_irq(IRQ_MFP_ACIA);
674
675 ikbd_self_test = 1;
676 ikbd_reset();
677 /* wait for a period of inactivity (here: 0.25s), then assume the IKBD's
678 * self-test is finished */
679 self_test_last_rcv = jiffies;
680 while (time_before(jiffies, self_test_last_rcv + HZ/4))
681 barrier();
682 /* if not incremented: no 0xf1 received */
683 if (ikbd_self_test == 1)
684 printk(KERN_ERR "WARNING: keyboard self test failed!\n");
685 ikbd_self_test = 0;
686
687 ikbd_mouse_disable();
688 ikbd_joystick_disable();
689
690#ifdef FIXED_ATARI_JOYSTICK
691 atari_joystick_init();
692#endif
693
694 // flag init done
695 atari_keyb_done = 1;
696 return 0;
697}
698
699
700int atari_kbdrate(struct kbd_repeat *k)
701{
702 if (k->delay > 0) {
703 /* convert from msec to jiffies */
704 key_repeat_delay = (k->delay * HZ + 500) / 1000;
705 if (key_repeat_delay < 1)
706 key_repeat_delay = 1;
707 }
708 if (k->period > 0) {
709 key_repeat_rate = (k->period * HZ + 500) / 1000;
710 if (key_repeat_rate < 1)
711 key_repeat_rate = 1;
712 }
713
714 k->delay = key_repeat_delay * 1000 / HZ;
715 k->period = key_repeat_rate * 1000 / HZ;
716
717 return 0;
718}
719
720int atari_kbd_translate(unsigned char keycode, unsigned char *keycodep, char raw_mode)
721{
722#ifdef CONFIG_MAGIC_SYSRQ
723 /* ALT+HELP pressed? */
724 if ((keycode == 98) && ((shift_state & 0xff) == 8))
725 *keycodep = 0xff;
726 else
727#endif
728 *keycodep = keycode;
729 return 1;
730}
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index ca5cd4344e3d..e40e5dcaa347 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -50,70 +50,25 @@ int atari_dont_touch_floppy_select;
50int atari_rtc_year_offset; 50int atari_rtc_year_offset;
51 51
52/* local function prototypes */ 52/* local function prototypes */
53static void atari_reset( void ); 53static void atari_reset(void);
54static void atari_get_model(char *model); 54static void atari_get_model(char *model);
55static int atari_get_hardware_list(char *buffer); 55static int atari_get_hardware_list(char *buffer);
56 56
57/* atari specific irq functions */ 57/* atari specific irq functions */
58extern void atari_init_IRQ (void); 58extern void atari_init_IRQ (void);
59extern void atari_mksound( unsigned int count, unsigned int ticks ); 59extern void atari_mksound(unsigned int count, unsigned int ticks);
60#ifdef CONFIG_HEARTBEAT 60#ifdef CONFIG_HEARTBEAT
61static void atari_heartbeat( int on ); 61static void atari_heartbeat(int on);
62#endif 62#endif
63 63
64/* atari specific timer functions (in time.c) */ 64/* atari specific timer functions (in time.c) */
65extern void atari_sched_init(irq_handler_t ); 65extern void atari_sched_init(irq_handler_t);
66extern unsigned long atari_gettimeoffset (void); 66extern unsigned long atari_gettimeoffset (void);
67extern int atari_mste_hwclk (int, struct rtc_time *); 67extern int atari_mste_hwclk (int, struct rtc_time *);
68extern int atari_tt_hwclk (int, struct rtc_time *); 68extern int atari_tt_hwclk (int, struct rtc_time *);
69extern int atari_mste_set_clock_mmss (unsigned long); 69extern int atari_mste_set_clock_mmss (unsigned long);
70extern int atari_tt_set_clock_mmss (unsigned long); 70extern int atari_tt_set_clock_mmss (unsigned long);
71 71
72/* atari specific debug functions (in debug.c) */
73extern void atari_debug_init(void);
74
75
76/* I've moved hwreg_present() and hwreg_present_bywrite() out into
77 * mm/hwtest.c, to avoid having multiple copies of the same routine
78 * in the kernel [I wanted them in hp300 and they were already used
79 * in the nubus code. NB: I don't have an Atari so this might (just
80 * conceivably) break something.
81 * I've preserved the #if 0 version of hwreg_present_bywrite() here
82 * for posterity.
83 * -- Peter Maydell <pmaydell@chiark.greenend.org.uk>, 05/1998
84 */
85
86#if 0
87static int __init
88hwreg_present_bywrite(volatile void *regp, unsigned char val)
89{
90 int ret;
91 long save_sp, save_vbr;
92 static long tmp_vectors[3] = { [2] = (long)&&after_test };
93
94 __asm__ __volatile__
95 ( "movec %/vbr,%2\n\t" /* save vbr value */
96 "movec %4,%/vbr\n\t" /* set up temporary vectors */
97 "movel %/sp,%1\n\t" /* save sp */
98 "moveq #0,%0\n\t" /* assume not present */
99 "moveb %5,%3@\n\t" /* write the hardware reg */
100 "cmpb %3@,%5\n\t" /* compare it */
101 "seq %0" /* comes here only if reg */
102 /* is present */
103 : "=d&" (ret), "=r&" (save_sp), "=r&" (save_vbr)
104 : "a" (regp), "r" (tmp_vectors), "d" (val)
105 );
106 after_test:
107 __asm__ __volatile__
108 ( "movel %0,%/sp\n\t" /* restore sp */
109 "movec %1,%/vbr" /* restore vbr */
110 : : "r" (save_sp), "r" (save_vbr) : "sp"
111 );
112
113 return( ret );
114}
115#endif
116
117 72
118/* ++roman: This is a more elaborate test for an SCC chip, since the plain 73/* ++roman: This is a more elaborate test for an SCC chip, since the plain
119 * Medusa board generates DTACK at the SCC's standard addresses, but a SCC 74 * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
@@ -123,26 +78,34 @@ hwreg_present_bywrite(volatile void *regp, unsigned char val)
123 * should be readable without trouble (from channel A!). 78 * should be readable without trouble (from channel A!).
124 */ 79 */
125 80
126static int __init scc_test( volatile char *ctla ) 81static int __init scc_test(volatile char *ctla)
127{ 82{
128 if (!hwreg_present( ctla )) 83 if (!hwreg_present(ctla))
129 return( 0 ); 84 return 0;
130 MFPDELAY(); 85 MFPDELAY();
131 86
132 *ctla = 2; MFPDELAY(); 87 *ctla = 2;
133 *ctla = 0x40; MFPDELAY(); 88 MFPDELAY();
89 *ctla = 0x40;
90 MFPDELAY();
134 91
135 *ctla = 2; MFPDELAY(); 92 *ctla = 2;
136 if (*ctla != 0x40) return( 0 ); 93 MFPDELAY();
94 if (*ctla != 0x40)
95 return 0;
137 MFPDELAY(); 96 MFPDELAY();
138 97
139 *ctla = 2; MFPDELAY(); 98 *ctla = 2;
140 *ctla = 0x60; MFPDELAY(); 99 MFPDELAY();
100 *ctla = 0x60;
101 MFPDELAY();
141 102
142 *ctla = 2; MFPDELAY(); 103 *ctla = 2;
143 if (*ctla != 0x60) return( 0 ); 104 MFPDELAY();
105 if (*ctla != 0x60)
106 return 0;
144 107
145 return( 1 ); 108 return 1;
146} 109}
147 110
148 111
@@ -152,61 +115,66 @@ static int __init scc_test( volatile char *ctla )
152 115
153int __init atari_parse_bootinfo(const struct bi_record *record) 116int __init atari_parse_bootinfo(const struct bi_record *record)
154{ 117{
155 int unknown = 0; 118 int unknown = 0;
156 const u_long *data = record->data; 119 const u_long *data = record->data;
157 120
158 switch (record->tag) { 121 switch (record->tag) {
159 case BI_ATARI_MCH_COOKIE: 122 case BI_ATARI_MCH_COOKIE:
160 atari_mch_cookie = *data; 123 atari_mch_cookie = *data;
161 break; 124 break;
162 case BI_ATARI_MCH_TYPE: 125 case BI_ATARI_MCH_TYPE:
163 atari_mch_type = *data; 126 atari_mch_type = *data;
164 break; 127 break;
165 default: 128 default:
166 unknown = 1; 129 unknown = 1;
167 } 130 break;
168 return(unknown); 131 }
132 return unknown;
169} 133}
170 134
171 135
172/* Parse the Atari-specific switches= option. */ 136/* Parse the Atari-specific switches= option. */
173void __init atari_switches_setup( const char *str, unsigned len ) 137static int __init atari_switches_setup(char *str)
174{ 138{
175 char switches[len+1]; 139 char switches[strlen(str) + 1];
176 char *p; 140 char *p;
177 int ovsc_shift; 141 int ovsc_shift;
178 char *args = switches; 142 char *args = switches;
179 143
180 /* copy string to local array, strsep works destructively... */ 144 if (!MACH_IS_ATARI)
181 strlcpy( switches, str, sizeof(switches) ); 145 return 0;
182 atari_switches = 0; 146
183 147 /* copy string to local array, strsep works destructively... */
184 /* parse the options */ 148 strcpy(switches, str);
185 while ((p = strsep(&args, ",")) != NULL) { 149 atari_switches = 0;
186 if (!*p) continue; 150
187 ovsc_shift = 0; 151 /* parse the options */
188 if (strncmp( p, "ov_", 3 ) == 0) { 152 while ((p = strsep(&args, ",")) != NULL) {
189 p += 3; 153 if (!*p)
190 ovsc_shift = ATARI_SWITCH_OVSC_SHIFT; 154 continue;
191 } 155 ovsc_shift = 0;
192 156 if (strncmp(p, "ov_", 3) == 0) {
193 if (strcmp( p, "ikbd" ) == 0) { 157 p += 3;
194 /* RTS line of IKBD ACIA */ 158 ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
195 atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift; 159 }
196 } 160
197 else if (strcmp( p, "midi" ) == 0) { 161 if (strcmp(p, "ikbd") == 0) {
198 /* RTS line of MIDI ACIA */ 162 /* RTS line of IKBD ACIA */
199 atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift; 163 atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
164 } else if (strcmp(p, "midi") == 0) {
165 /* RTS line of MIDI ACIA */
166 atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
167 } else if (strcmp(p, "snd6") == 0) {
168 atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
169 } else if (strcmp(p, "snd7") == 0) {
170 atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
171 }
200 } 172 }
201 else if (strcmp( p, "snd6" ) == 0) { 173 return 0;
202 atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
203 }
204 else if (strcmp( p, "snd7" ) == 0) {
205 atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
206 }
207 }
208} 174}
209 175
176early_param("switches", atari_switches_setup);
177
210 178
211 /* 179 /*
212 * Setup the Atari configuration info 180 * Setup the Atari configuration info
@@ -214,284 +182,281 @@ void __init atari_switches_setup( const char *str, unsigned len )
214 182
215void __init config_atari(void) 183void __init config_atari(void)
216{ 184{
217 unsigned short tos_version; 185 unsigned short tos_version;
218 186
219 memset(&atari_hw_present, 0, sizeof(atari_hw_present)); 187 memset(&atari_hw_present, 0, sizeof(atari_hw_present));
220 188
221 atari_debug_init(); 189 /* Change size of I/O space from 64KB to 4GB. */
190 ioport_resource.end = 0xFFFFFFFF;
222 191
223 ioport_resource.end = 0xFFFFFFFF; /* Change size of I/O space from 64KB 192 mach_sched_init = atari_sched_init;
224 to 4GB. */ 193 mach_init_IRQ = atari_init_IRQ;
225 194 mach_get_model = atari_get_model;
226 mach_sched_init = atari_sched_init; 195 mach_get_hardware_list = atari_get_hardware_list;
227 mach_init_IRQ = atari_init_IRQ; 196 mach_gettimeoffset = atari_gettimeoffset;
228 mach_get_model = atari_get_model; 197 mach_reset = atari_reset;
229 mach_get_hardware_list = atari_get_hardware_list; 198 mach_max_dma_address = 0xffffff;
230 mach_gettimeoffset = atari_gettimeoffset;
231 mach_reset = atari_reset;
232 mach_max_dma_address = 0xffffff;
233#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 199#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
234 mach_beep = atari_mksound; 200 mach_beep = atari_mksound;
235#endif 201#endif
236#ifdef CONFIG_HEARTBEAT 202#ifdef CONFIG_HEARTBEAT
237 mach_heartbeat = atari_heartbeat; 203 mach_heartbeat = atari_heartbeat;
238#endif 204#endif
239 205
240 /* Set switches as requested by the user */ 206 /* Set switches as requested by the user */
241 if (atari_switches & ATARI_SWITCH_IKBD) 207 if (atari_switches & ATARI_SWITCH_IKBD)
242 acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID; 208 acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
243 if (atari_switches & ATARI_SWITCH_MIDI) 209 if (atari_switches & ATARI_SWITCH_MIDI)
244 acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; 210 acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
245 if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) { 211 if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
246 sound_ym.rd_data_reg_sel = 14; 212 sound_ym.rd_data_reg_sel = 14;
247 sound_ym.wd_data = sound_ym.rd_data_reg_sel | 213 sound_ym.wd_data = sound_ym.rd_data_reg_sel |
248 ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) | 214 ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
249 ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0); 215 ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
250 } 216 }
251
252 /* ++bjoern:
253 * Determine hardware present
254 */
255 217
256 printk( "Atari hardware found: " ); 218 /* ++bjoern:
257 if (MACH_IS_MEDUSA || MACH_IS_HADES) { 219 * Determine hardware present
258 /* There's no Atari video hardware on the Medusa, but all the 220 */
259 * addresses below generate a DTACK so no bus error occurs! */ 221
260 } 222 printk("Atari hardware found: ");
261 else if (hwreg_present( f030_xreg )) { 223 if (MACH_IS_MEDUSA || MACH_IS_HADES) {
262 ATARIHW_SET(VIDEL_SHIFTER); 224 /* There's no Atari video hardware on the Medusa, but all the
263 printk( "VIDEL " ); 225 * addresses below generate a DTACK so no bus error occurs! */
264 /* This is a temporary hack: If there is Falcon video 226 } else if (hwreg_present(f030_xreg)) {
265 * hardware, we assume that the ST-DMA serves SCSI instead of 227 ATARIHW_SET(VIDEL_SHIFTER);
266 * ACSI. In the future, there should be a better method for 228 printk("VIDEL ");
267 * this... 229 /* This is a temporary hack: If there is Falcon video
268 */ 230 * hardware, we assume that the ST-DMA serves SCSI instead of
269 ATARIHW_SET(ST_SCSI); 231 * ACSI. In the future, there should be a better method for
270 printk( "STDMA-SCSI " ); 232 * this...
271 } 233 */
272 else if (hwreg_present( tt_palette )) { 234 ATARIHW_SET(ST_SCSI);
273 ATARIHW_SET(TT_SHIFTER); 235 printk("STDMA-SCSI ");
274 printk( "TT_SHIFTER " ); 236 } else if (hwreg_present(tt_palette)) {
275 } 237 ATARIHW_SET(TT_SHIFTER);
276 else if (hwreg_present( &shifter.bas_hi )) { 238 printk("TT_SHIFTER ");
277 if (hwreg_present( &shifter.bas_lo ) && 239 } else if (hwreg_present(&shifter.bas_hi)) {
278 (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) { 240 if (hwreg_present(&shifter.bas_lo) &&
279 ATARIHW_SET(EXTD_SHIFTER); 241 (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) {
280 printk( "EXTD_SHIFTER " ); 242 ATARIHW_SET(EXTD_SHIFTER);
281 } 243 printk("EXTD_SHIFTER ");
282 else { 244 } else {
283 ATARIHW_SET(STND_SHIFTER); 245 ATARIHW_SET(STND_SHIFTER);
284 printk( "STND_SHIFTER " ); 246 printk("STND_SHIFTER ");
285 } 247 }
286 } 248 }
287 if (hwreg_present( &mfp.par_dt_reg )) { 249 if (hwreg_present(&mfp.par_dt_reg)) {
288 ATARIHW_SET(ST_MFP); 250 ATARIHW_SET(ST_MFP);
289 printk( "ST_MFP " ); 251 printk("ST_MFP ");
290 } 252 }
291 if (hwreg_present( &tt_mfp.par_dt_reg )) { 253 if (hwreg_present(&tt_mfp.par_dt_reg)) {
292 ATARIHW_SET(TT_MFP); 254 ATARIHW_SET(TT_MFP);
293 printk( "TT_MFP " ); 255 printk("TT_MFP ");
294 } 256 }
295 if (hwreg_present( &tt_scsi_dma.dma_addr_hi )) { 257 if (hwreg_present(&tt_scsi_dma.dma_addr_hi)) {
296 ATARIHW_SET(SCSI_DMA); 258 ATARIHW_SET(SCSI_DMA);
297 printk( "TT_SCSI_DMA " ); 259 printk("TT_SCSI_DMA ");
298 } 260 }
299 if (!MACH_IS_HADES && hwreg_present( &st_dma.dma_hi )) { 261 if (!MACH_IS_HADES && hwreg_present(&st_dma.dma_hi)) {
300 ATARIHW_SET(STND_DMA); 262 ATARIHW_SET(STND_DMA);
301 printk( "STND_DMA " ); 263 printk("STND_DMA ");
302 } 264 }
303 if (MACH_IS_MEDUSA || /* The ST-DMA address registers aren't readable 265 /*
304 * on all Medusas, so the test below may fail */ 266 * The ST-DMA address registers aren't readable
305 (hwreg_present( &st_dma.dma_vhi ) && 267 * on all Medusas, so the test below may fail
306 (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) && 268 */
307 st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa && 269 if (MACH_IS_MEDUSA ||
308 (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) && 270 (hwreg_present(&st_dma.dma_vhi) &&
309 st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) { 271 (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
310 ATARIHW_SET(EXTD_DMA); 272 st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
311 printk( "EXTD_DMA " ); 273 (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) &&
312 } 274 st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) {
313 if (hwreg_present( &tt_scsi.scsi_data )) { 275 ATARIHW_SET(EXTD_DMA);
314 ATARIHW_SET(TT_SCSI); 276 printk("EXTD_DMA ");
315 printk( "TT_SCSI " ); 277 }
316 } 278 if (hwreg_present(&tt_scsi.scsi_data)) {
317 if (hwreg_present( &sound_ym.rd_data_reg_sel )) { 279 ATARIHW_SET(TT_SCSI);
318 ATARIHW_SET(YM_2149); 280 printk("TT_SCSI ");
319 printk( "YM2149 " ); 281 }
320 } 282 if (hwreg_present(&sound_ym.rd_data_reg_sel)) {
321 if (!MACH_IS_MEDUSA && !MACH_IS_HADES && 283 ATARIHW_SET(YM_2149);
322 hwreg_present( &tt_dmasnd.ctrl )) { 284 printk("YM2149 ");
323 ATARIHW_SET(PCM_8BIT); 285 }
324 printk( "PCM " ); 286 if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
325 } 287 hwreg_present(&tt_dmasnd.ctrl)) {
326 if (!MACH_IS_HADES && hwreg_present( &falcon_codec.unused5 )) { 288 ATARIHW_SET(PCM_8BIT);
327 ATARIHW_SET(CODEC); 289 printk("PCM ");
328 printk( "CODEC " ); 290 }
329 } 291 if (!MACH_IS_HADES && hwreg_present(&falcon_codec.unused5)) {
330 if (hwreg_present( &dsp56k_host_interface.icr )) { 292 ATARIHW_SET(CODEC);
331 ATARIHW_SET(DSP56K); 293 printk("CODEC ");
332 printk( "DSP56K " ); 294 }
333 } 295 if (hwreg_present(&dsp56k_host_interface.icr)) {
334 if (hwreg_present( &tt_scc_dma.dma_ctrl ) && 296 ATARIHW_SET(DSP56K);
297 printk("DSP56K ");
298 }
299 if (hwreg_present(&tt_scc_dma.dma_ctrl) &&
335#if 0 300#if 0
336 /* This test sucks! Who knows some better? */ 301 /* This test sucks! Who knows some better? */
337 (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) && 302 (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
338 (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0) 303 (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
339#else 304#else
340 !MACH_IS_MEDUSA && !MACH_IS_HADES 305 !MACH_IS_MEDUSA && !MACH_IS_HADES
341#endif 306#endif
342 ) { 307 ) {
343 ATARIHW_SET(SCC_DMA); 308 ATARIHW_SET(SCC_DMA);
344 printk( "SCC_DMA " ); 309 printk("SCC_DMA ");
345 } 310 }
346 if (scc_test( &scc.cha_a_ctrl )) { 311 if (scc_test(&scc.cha_a_ctrl)) {
347 ATARIHW_SET(SCC); 312 ATARIHW_SET(SCC);
348 printk( "SCC " ); 313 printk("SCC ");
349 } 314 }
350 if (scc_test( &st_escc.cha_b_ctrl )) { 315 if (scc_test(&st_escc.cha_b_ctrl)) {
351 ATARIHW_SET( ST_ESCC ); 316 ATARIHW_SET(ST_ESCC);
352 printk( "ST_ESCC " ); 317 printk("ST_ESCC ");
353 } 318 }
354 if (MACH_IS_HADES) 319 if (MACH_IS_HADES) {
355 { 320 ATARIHW_SET(VME);
356 ATARIHW_SET( VME ); 321 printk("VME ");
357 printk( "VME " ); 322 } else if (hwreg_present(&tt_scu.sys_mask)) {
358 } 323 ATARIHW_SET(SCU);
359 else if (hwreg_present( &tt_scu.sys_mask )) { 324 /* Assume a VME bus if there's a SCU */
360 ATARIHW_SET(SCU); 325 ATARIHW_SET(VME);
361 /* Assume a VME bus if there's a SCU */ 326 printk("VME SCU ");
362 ATARIHW_SET( VME ); 327 }
363 printk( "VME SCU " ); 328 if (hwreg_present((void *)(0xffff9210))) {
364 } 329 ATARIHW_SET(ANALOG_JOY);
365 if (hwreg_present( (void *)(0xffff9210) )) { 330 printk("ANALOG_JOY ");
366 ATARIHW_SET(ANALOG_JOY); 331 }
367 printk( "ANALOG_JOY " ); 332 if (!MACH_IS_HADES && hwreg_present(blitter.halftone)) {
368 } 333 ATARIHW_SET(BLITTER);
369 if (!MACH_IS_HADES && hwreg_present( blitter.halftone )) { 334 printk("BLITTER ");
370 ATARIHW_SET(BLITTER); 335 }
371 printk( "BLITTER " ); 336 if (hwreg_present((void *)0xfff00039)) {
372 } 337 ATARIHW_SET(IDE);
373 if (hwreg_present((void *)0xfff00039)) { 338 printk("IDE ");
374 ATARIHW_SET(IDE); 339 }
375 printk( "IDE " );
376 }
377#if 1 /* This maybe wrong */ 340#if 1 /* This maybe wrong */
378 if (!MACH_IS_MEDUSA && !MACH_IS_HADES && 341 if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
379 hwreg_present( &tt_microwire.data ) && 342 hwreg_present(&tt_microwire.data) &&
380 hwreg_present( &tt_microwire.mask ) && 343 hwreg_present(&tt_microwire.mask) &&
381 (tt_microwire.mask = 0x7ff, 344 (tt_microwire.mask = 0x7ff,
382 udelay(1), 345 udelay(1),
383 tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR, 346 tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
384 udelay(1), 347 udelay(1),
385 tt_microwire.data != 0)) { 348 tt_microwire.data != 0)) {
386 ATARIHW_SET(MICROWIRE); 349 ATARIHW_SET(MICROWIRE);
387 while (tt_microwire.mask != 0x7ff) ; 350 while (tt_microwire.mask != 0x7ff)
388 printk( "MICROWIRE " ); 351 ;
389 } 352 printk("MICROWIRE ");
353 }
390#endif 354#endif
391 if (hwreg_present( &tt_rtc.regsel )) { 355 if (hwreg_present(&tt_rtc.regsel)) {
392 ATARIHW_SET(TT_CLK); 356 ATARIHW_SET(TT_CLK);
393 printk( "TT_CLK " ); 357 printk("TT_CLK ");
394 mach_hwclk = atari_tt_hwclk; 358 mach_hwclk = atari_tt_hwclk;
395 mach_set_clock_mmss = atari_tt_set_clock_mmss; 359 mach_set_clock_mmss = atari_tt_set_clock_mmss;
396 } 360 }
397 if (!MACH_IS_HADES && hwreg_present( &mste_rtc.sec_ones)) { 361 if (!MACH_IS_HADES && hwreg_present(&mste_rtc.sec_ones)) {
398 ATARIHW_SET(MSTE_CLK); 362 ATARIHW_SET(MSTE_CLK);
399 printk( "MSTE_CLK "); 363 printk("MSTE_CLK ");
400 mach_hwclk = atari_mste_hwclk; 364 mach_hwclk = atari_mste_hwclk;
401 mach_set_clock_mmss = atari_mste_set_clock_mmss; 365 mach_set_clock_mmss = atari_mste_set_clock_mmss;
402 } 366 }
403 if (!MACH_IS_MEDUSA && !MACH_IS_HADES && 367 if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
404 hwreg_present( &dma_wd.fdc_speed ) && 368 hwreg_present(&dma_wd.fdc_speed) &&
405 hwreg_write( &dma_wd.fdc_speed, 0 )) { 369 hwreg_write(&dma_wd.fdc_speed, 0)) {
406 ATARIHW_SET(FDCSPEED); 370 ATARIHW_SET(FDCSPEED);
407 printk( "FDC_SPEED "); 371 printk("FDC_SPEED ");
408 } 372 }
409 if (!MACH_IS_HADES && !ATARIHW_PRESENT(ST_SCSI)) { 373 if (!MACH_IS_HADES && !ATARIHW_PRESENT(ST_SCSI)) {
410 ATARIHW_SET(ACSI); 374 ATARIHW_SET(ACSI);
411 printk( "ACSI " ); 375 printk("ACSI ");
412 } 376 }
413 printk("\n"); 377 printk("\n");
414 378
415 if (CPU_IS_040_OR_060) 379 if (CPU_IS_040_OR_060)
416 /* Now it seems to be safe to turn of the tt0 transparent 380 /* Now it seems to be safe to turn of the tt0 transparent
417 * translation (the one that must not be turned off in 381 * translation (the one that must not be turned off in
418 * head.S...) 382 * head.S...)
419 */ 383 */
420 __asm__ volatile ("moveq #0,%/d0\n\t" 384 asm volatile ("\n"
421 ".chip 68040\n\t" 385 " moveq #0,%%d0\n"
422 "movec %%d0,%%itt0\n\t" 386 " .chip 68040\n"
423 "movec %%d0,%%dtt0\n\t" 387 " movec %%d0,%%itt0\n"
424 ".chip 68k" 388 " movec %%d0,%%dtt0\n"
425 : /* no outputs */ 389 " .chip 68k"
426 : /* no inputs */ 390 : /* no outputs */
427 : "d0"); 391 : /* no inputs */
428 392 : "d0");
429 /* allocator for memory that must reside in st-ram */ 393
430 atari_stram_init (); 394 /* allocator for memory that must reside in st-ram */
431 395 atari_stram_init();
432 /* Set up a mapping for the VMEbus address region: 396
433 * 397 /* Set up a mapping for the VMEbus address region:
434 * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff 398 *
435 * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at 399 * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff
436 * 0xfe000000 virt., because this can be done with a single 400 * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at
437 * transparent translation. On the 68040, lots of often unused 401 * 0xfe000000 virt., because this can be done with a single
438 * page tables would be needed otherwise. On a MegaSTE or similar, 402 * transparent translation. On the 68040, lots of often unused
439 * the highest byte is stripped off by hardware due to the 24 bit 403 * page tables would be needed otherwise. On a MegaSTE or similar,
440 * design of the bus. 404 * the highest byte is stripped off by hardware due to the 24 bit
441 */ 405 * design of the bus.
406 */
407
408 if (CPU_IS_020_OR_030) {
409 unsigned long tt1_val;
410 tt1_val = 0xfe008543; /* Translate 0xfexxxxxx, enable, cache
411 * inhibit, read and write, FDC mask = 3,
412 * FDC val = 4 -> Supervisor only */
413 asm volatile ("\n"
414 " .chip 68030\n"
415 " pmove %0@,%/tt1\n"
416 " .chip 68k"
417 : : "a" (&tt1_val));
418 } else {
419 asm volatile ("\n"
420 " .chip 68040\n"
421 " movec %0,%%itt1\n"
422 " movec %0,%%dtt1\n"
423 " .chip 68k"
424 :
425 : "d" (0xfe00a040)); /* Translate 0xfexxxxxx, enable,
426 * supervisor only, non-cacheable/
427 * serialized, writable */
428
429 }
442 430
443 if (CPU_IS_020_OR_030) { 431 /* Fetch tos version at Physical 2 */
444 unsigned long tt1_val; 432 /*
445 tt1_val = 0xfe008543; /* Translate 0xfexxxxxx, enable, cache 433 * We my not be able to access this address if the kernel is
446 * inhibit, read and write, FDC mask = 3, 434 * loaded to st ram, since the first page is unmapped. On the
447 * FDC val = 4 -> Supervisor only */ 435 * Medusa this is always the case and there is nothing we can do
448 __asm__ __volatile__ ( ".chip 68030\n\t" 436 * about this, so we just assume the smaller offset. For the TT
449 "pmove %0@,%/tt1\n\t" 437 * we use the fact that in head.S we have set up a mapping
450 ".chip 68k" 438 * 0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
451 : : "a" (&tt1_val) ); 439 * in the last 16MB of the address space.
452 } 440 */
453 else { 441 tos_version = (MACH_IS_MEDUSA || MACH_IS_HADES) ?
454 __asm__ __volatile__ 442 0xfff : *(unsigned short *)0xff000002;
455 ( "movel %0,%/d0\n\t" 443 atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
456 ".chip 68040\n\t"
457 "movec %%d0,%%itt1\n\t"
458 "movec %%d0,%%dtt1\n\t"
459 ".chip 68k"
460 :
461 : "g" (0xfe00a040) /* Translate 0xfexxxxxx, enable,
462 * supervisor only, non-cacheable/
463 * serialized, writable */
464 : "d0" );
465
466 }
467
468 /* Fetch tos version at Physical 2 */
469 /* We my not be able to access this address if the kernel is
470 loaded to st ram, since the first page is unmapped. On the
471 Medusa this is always the case and there is nothing we can do
472 about this, so we just assume the smaller offset. For the TT
473 we use the fact that in head.S we have set up a mapping
474 0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
475 in the last 16MB of the address space. */
476 tos_version = (MACH_IS_MEDUSA || MACH_IS_HADES) ?
477 0xfff : *(unsigned short *)0xff000002;
478 atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
479} 444}
480 445
481#ifdef CONFIG_HEARTBEAT 446#ifdef CONFIG_HEARTBEAT
482static void atari_heartbeat( int on ) 447static void atari_heartbeat(int on)
483{ 448{
484 unsigned char tmp; 449 unsigned char tmp;
485 unsigned long flags; 450 unsigned long flags;
486 451
487 if (atari_dont_touch_floppy_select) 452 if (atari_dont_touch_floppy_select)
488 return; 453 return;
489 454
490 local_irq_save(flags); 455 local_irq_save(flags);
491 sound_ym.rd_data_reg_sel = 14; /* Select PSG Port A */ 456 sound_ym.rd_data_reg_sel = 14; /* Select PSG Port A */
492 tmp = sound_ym.rd_data_reg_sel; 457 tmp = sound_ym.rd_data_reg_sel;
493 sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02); 458 sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
494 local_irq_restore(flags); 459 local_irq_restore(flags);
495} 460}
496#endif 461#endif
497 462
@@ -526,180 +491,171 @@ static void atari_heartbeat( int on )
526 491
527/* ++andreas: no need for complicated code, just depend on prefetch */ 492/* ++andreas: no need for complicated code, just depend on prefetch */
528 493
529static void atari_reset (void) 494static void atari_reset(void)
530{ 495{
531 long tc_val = 0; 496 long tc_val = 0;
532 long reset_addr; 497 long reset_addr;
533 498
534 /* On the Medusa, phys. 0x4 may contain garbage because it's no 499 /*
535 ROM. See above for explanation why we cannot use PTOV(4). */ 500 * On the Medusa, phys. 0x4 may contain garbage because it's no
536 reset_addr = MACH_IS_HADES ? 0x7fe00030 : 501 * ROM. See above for explanation why we cannot use PTOV(4).
537 MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 : 502 */
538 *(unsigned long *) 0xff000004; 503 reset_addr = MACH_IS_HADES ? 0x7fe00030 :
539 504 MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
540 /* reset ACIA for switch off OverScan, if it's active */ 505 *(unsigned long *) 0xff000004;
541 if (atari_switches & ATARI_SWITCH_OVSC_IKBD) 506
542 acia.key_ctrl = ACIA_RESET; 507 /* reset ACIA for switch off OverScan, if it's active */
543 if (atari_switches & ATARI_SWITCH_OVSC_MIDI) 508 if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
544 acia.mid_ctrl = ACIA_RESET; 509 acia.key_ctrl = ACIA_RESET;
545 510 if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
546 /* processor independent: turn off interrupts and reset the VBR; 511 acia.mid_ctrl = ACIA_RESET;
547 * the caches must be left enabled, else prefetching the final jump 512
548 * instruction doesn't work. */ 513 /* processor independent: turn off interrupts and reset the VBR;
549 local_irq_disable(); 514 * the caches must be left enabled, else prefetching the final jump
550 __asm__ __volatile__ 515 * instruction doesn't work.
551 ("moveq #0,%/d0\n\t" 516 */
552 "movec %/d0,%/vbr" 517 local_irq_disable();
553 : : : "d0" ); 518 asm volatile ("movec %0,%%vbr"
554 519 : : "d" (0));
555 if (CPU_IS_040_OR_060) { 520
556 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040); 521 if (CPU_IS_040_OR_060) {
557 if (CPU_IS_060) { 522 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
558 /* 68060: clear PCR to turn off superscalar operation */ 523 if (CPU_IS_060) {
559 __asm__ __volatile__ 524 /* 68060: clear PCR to turn off superscalar operation */
560 ("moveq #0,%/d0\n\t" 525 asm volatile ("\n"
561 ".chip 68060\n\t" 526 " .chip 68060\n"
562 "movec %%d0,%%pcr\n\t" 527 " movec %0,%%pcr\n"
563 ".chip 68k" 528 " .chip 68k"
564 : : : "d0" ); 529 : : "d" (0));
565 } 530 }
566 531
567 __asm__ __volatile__ 532 asm volatile ("\n"
568 ("movel %0,%/d0\n\t" 533 " move.l %0,%%d0\n"
569 "andl #0xff000000,%/d0\n\t" 534 " and.l #0xff000000,%%d0\n"
570 "orw #0xe020,%/d0\n\t" /* map 16 MB, enable, cacheable */ 535 " or.w #0xe020,%%d0\n" /* map 16 MB, enable, cacheable */
571 ".chip 68040\n\t" 536 " .chip 68040\n"
572 "movec %%d0,%%itt0\n\t" 537 " movec %%d0,%%itt0\n"
573 "movec %%d0,%%dtt0\n\t" 538 " movec %%d0,%%dtt0\n"
574 ".chip 68k\n\t" 539 " .chip 68k\n"
575 "jmp %0@\n\t" 540 " jmp %0@"
576 : /* no outputs */ 541 : : "a" (jmp_addr040)
577 : "a" (jmp_addr040) 542 : "d0");
578 : "d0" ); 543 jmp_addr_label040:
579 jmp_addr_label040: 544 asm volatile ("\n"
580 __asm__ __volatile__ 545 " moveq #0,%%d0\n"
581 ("moveq #0,%/d0\n\t" 546 " nop\n"
582 "nop\n\t" 547 " .chip 68040\n"
583 ".chip 68040\n\t" 548 " cinva %%bc\n"
584 "cinva %%bc\n\t" 549 " nop\n"
585 "nop\n\t" 550 " pflusha\n"
586 "pflusha\n\t" 551 " nop\n"
587 "nop\n\t" 552 " movec %%d0,%%tc\n"
588 "movec %%d0,%%tc\n\t" 553 " nop\n"
589 "nop\n\t" 554 /* the following setup of transparent translations is needed on the
590 /* the following setup of transparent translations is needed on the 555 * Afterburner040 to successfully reboot. Other machines shouldn't
591 * Afterburner040 to successfully reboot. Other machines shouldn't 556 * care about a different tt regs setup, they also didn't care in
592 * care about a different tt regs setup, they also didn't care in 557 * the past that the regs weren't turned off. */
593 * the past that the regs weren't turned off. */ 558 " move.l #0xffc000,%%d0\n" /* whole insn space cacheable */
594 "movel #0xffc000,%%d0\n\t" /* whole insn space cacheable */ 559 " movec %%d0,%%itt0\n"
595 "movec %%d0,%%itt0\n\t" 560 " movec %%d0,%%itt1\n"
596 "movec %%d0,%%itt1\n\t" 561 " or.w #0x40,%/d0\n" /* whole data space non-cacheable/ser. */
597 "orw #0x40,%/d0\n\t" /* whole data space non-cacheable/ser. */ 562 " movec %%d0,%%dtt0\n"
598 "movec %%d0,%%dtt0\n\t" 563 " movec %%d0,%%dtt1\n"
599 "movec %%d0,%%dtt1\n\t" 564 " .chip 68k\n"
600 ".chip 68k\n\t" 565 " jmp %0@"
601 "jmp %0@" 566 : /* no outputs */
602 : /* no outputs */ 567 : "a" (reset_addr)
603 : "a" (reset_addr) 568 : "d0");
604 : "d0"); 569 } else
605 } 570 asm volatile ("\n"
606 else 571 " pmove %0@,%%tc\n"
607 __asm__ __volatile__ 572 " jmp %1@"
608 ("pmove %0@,%/tc\n\t" 573 : /* no outputs */
609 "jmp %1@" 574 : "a" (&tc_val), "a" (reset_addr));
610 : /* no outputs */
611 : "a" (&tc_val), "a" (reset_addr));
612} 575}
613 576
614 577
615static void atari_get_model(char *model) 578static void atari_get_model(char *model)
616{ 579{
617 strcpy(model, "Atari "); 580 strcpy(model, "Atari ");
618 switch (atari_mch_cookie >> 16) { 581 switch (atari_mch_cookie >> 16) {
619 case ATARI_MCH_ST: 582 case ATARI_MCH_ST:
620 if (ATARIHW_PRESENT(MSTE_CLK)) 583 if (ATARIHW_PRESENT(MSTE_CLK))
621 strcat (model, "Mega ST"); 584 strcat(model, "Mega ST");
622 else 585 else
623 strcat (model, "ST"); 586 strcat(model, "ST");
624 break; 587 break;
625 case ATARI_MCH_STE: 588 case ATARI_MCH_STE:
626 if (MACH_IS_MSTE) 589 if (MACH_IS_MSTE)
627 strcat (model, "Mega STE"); 590 strcat(model, "Mega STE");
628 else 591 else
629 strcat (model, "STE"); 592 strcat(model, "STE");
630 break; 593 break;
631 case ATARI_MCH_TT: 594 case ATARI_MCH_TT:
632 if (MACH_IS_MEDUSA) 595 if (MACH_IS_MEDUSA)
633 /* Medusa has TT _MCH cookie */ 596 /* Medusa has TT _MCH cookie */
634 strcat (model, "Medusa"); 597 strcat(model, "Medusa");
635 else if (MACH_IS_HADES) 598 else if (MACH_IS_HADES)
636 strcat(model, "Hades"); 599 strcat(model, "Hades");
637 else 600 else
638 strcat (model, "TT"); 601 strcat(model, "TT");
639 break; 602 break;
640 case ATARI_MCH_FALCON: 603 case ATARI_MCH_FALCON:
641 strcat (model, "Falcon"); 604 strcat(model, "Falcon");
642 if (MACH_IS_AB40) 605 if (MACH_IS_AB40)
643 strcat (model, " (with Afterburner040)"); 606 strcat(model, " (with Afterburner040)");
644 break; 607 break;
645 default: 608 default:
646 sprintf (model + strlen (model), "(unknown mach cookie 0x%lx)", 609 sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)",
647 atari_mch_cookie); 610 atari_mch_cookie);
648 break; 611 break;
649 } 612 }
650} 613}
651 614
652 615
653static int atari_get_hardware_list(char *buffer) 616static int atari_get_hardware_list(char *buffer)
654{ 617{
655 int len = 0, i; 618 int len = 0, i;
656 619
657 for (i = 0; i < m68k_num_memory; i++) 620 for (i = 0; i < m68k_num_memory; i++)
658 len += sprintf (buffer+len, "\t%3ld MB at 0x%08lx (%s)\n", 621 len += sprintf(buffer+len, "\t%3ld MB at 0x%08lx (%s)\n",
659 m68k_memory[i].size >> 20, m68k_memory[i].addr, 622 m68k_memory[i].size >> 20, m68k_memory[i].addr,
660 (m68k_memory[i].addr & 0xff000000 ? 623 (m68k_memory[i].addr & 0xff000000 ?
661 "alternate RAM" : "ST-RAM")); 624 "alternate RAM" : "ST-RAM"));
662 625
663#define ATARIHW_ANNOUNCE(name,str) \ 626#define ATARIHW_ANNOUNCE(name, str) \
664 if (ATARIHW_PRESENT(name)) \ 627 if (ATARIHW_PRESENT(name)) \
665 len += sprintf (buffer + len, "\t%s\n", str) 628 len += sprintf(buffer + len, "\t%s\n", str)
666 629
667 len += sprintf (buffer + len, "Detected hardware:\n"); 630 len += sprintf(buffer + len, "Detected hardware:\n");
668 ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter"); 631 ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter");
669 ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter"); 632 ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter");
670 ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter"); 633 ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter");
671 ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter"); 634 ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter");
672 ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator"); 635 ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator");
673 ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound"); 636 ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound");
674 ATARIHW_ANNOUNCE(CODEC, "CODEC Sound"); 637 ATARIHW_ANNOUNCE(CODEC, "CODEC Sound");
675 ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)"); 638 ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)");
676 ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)"); 639 ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)");
677 ATARIHW_ANNOUNCE(ACSI, "ACSI Interface"); 640 ATARIHW_ANNOUNCE(ACSI, "ACSI Interface");
678 ATARIHW_ANNOUNCE(IDE, "IDE Interface"); 641 ATARIHW_ANNOUNCE(IDE, "IDE Interface");
679 ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC"); 642 ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC");
680 ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901"); 643 ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901");
681 ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901"); 644 ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901");
682 ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530"); 645 ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530");
683 ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230"); 646 ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230");
684 ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface"); 647 ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface");
685 ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface"); 648 ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface");
686 ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)"); 649 ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)");
687 ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)"); 650 ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)");
688 ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380"); 651 ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380");
689 ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC"); 652 ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC");
690 ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A"); 653 ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A");
691 ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15"); 654 ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15");
692 ATARIHW_ANNOUNCE(SCU, "System Control Unit"); 655 ATARIHW_ANNOUNCE(SCU, "System Control Unit");
693 ATARIHW_ANNOUNCE(BLITTER, "Blitter"); 656 ATARIHW_ANNOUNCE(BLITTER, "Blitter");
694 ATARIHW_ANNOUNCE(VME, "VME Bus"); 657 ATARIHW_ANNOUNCE(VME, "VME Bus");
695 ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor"); 658 ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor");
696 659
697 return(len); 660 return len;
698} 661}
699
700/*
701 * Local variables:
702 * c-indent-level: 4
703 * tab-width: 8
704 * End:
705 */
diff --git a/arch/m68k/atari/debug.c b/arch/m68k/atari/debug.c
index 4ae01004d8dd..fbeed8c8ecbc 100644
--- a/arch/m68k/atari/debug.c
+++ b/arch/m68k/atari/debug.c
@@ -19,8 +19,6 @@
19#include <asm/atarihw.h> 19#include <asm/atarihw.h>
20#include <asm/atariints.h> 20#include <asm/atariints.h>
21 21
22extern char m68k_debug_device[];
23
24/* Flag that Modem1 port is already initialized and used */ 22/* Flag that Modem1 port is already initialized and used */
25int atari_MFP_init_done; 23int atari_MFP_init_done;
26/* Flag that Modem1 port is already initialized and used */ 24/* Flag that Modem1 port is already initialized and used */
@@ -30,317 +28,317 @@ int atari_SCC_init_done;
30int atari_SCC_reset_done; 28int atari_SCC_reset_done;
31 29
32static struct console atari_console_driver = { 30static struct console atari_console_driver = {
33 .name = "debug", 31 .name = "debug",
34 .flags = CON_PRINTBUFFER, 32 .flags = CON_PRINTBUFFER,
35 .index = -1, 33 .index = -1,
36}; 34};
37 35
38 36
39static inline void ata_mfp_out (char c) 37static inline void ata_mfp_out(char c)
40{ 38{
41 while (!(mfp.trn_stat & 0x80)) /* wait for tx buf empty */ 39 while (!(mfp.trn_stat & 0x80)) /* wait for tx buf empty */
42 barrier (); 40 barrier();
43 mfp.usart_dta = c; 41 mfp.usart_dta = c;
44} 42}
45 43
46void atari_mfp_console_write (struct console *co, const char *str, 44void atari_mfp_console_write(struct console *co, const char *str,
47 unsigned int count) 45 unsigned int count)
48{ 46{
49 while (count--) { 47 while (count--) {
50 if (*str == '\n') 48 if (*str == '\n')
51 ata_mfp_out( '\r' ); 49 ata_mfp_out('\r');
52 ata_mfp_out( *str++ ); 50 ata_mfp_out(*str++);
53 } 51 }
54} 52}
55 53
56static inline void ata_scc_out (char c) 54static inline void ata_scc_out(char c)
57{ 55{
58 do { 56 do {
57 MFPDELAY();
58 } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */
59 MFPDELAY(); 59 MFPDELAY();
60 } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */ 60 scc.cha_b_data = c;
61 MFPDELAY();
62 scc.cha_b_data = c;
63} 61}
64 62
65void atari_scc_console_write (struct console *co, const char *str, 63void atari_scc_console_write(struct console *co, const char *str,
66 unsigned int count) 64 unsigned int count)
67{ 65{
68 while (count--) { 66 while (count--) {
69 if (*str == '\n') 67 if (*str == '\n')
70 ata_scc_out( '\r' ); 68 ata_scc_out('\r');
71 ata_scc_out( *str++ ); 69 ata_scc_out(*str++);
72 } 70 }
73} 71}
74 72
75static inline void ata_midi_out (char c) 73static inline void ata_midi_out(char c)
76{ 74{
77 while (!(acia.mid_ctrl & ACIA_TDRE)) /* wait for tx buf empty */ 75 while (!(acia.mid_ctrl & ACIA_TDRE)) /* wait for tx buf empty */
78 barrier (); 76 barrier();
79 acia.mid_data = c; 77 acia.mid_data = c;
80} 78}
81 79
82void atari_midi_console_write (struct console *co, const char *str, 80void atari_midi_console_write(struct console *co, const char *str,
83 unsigned int count) 81 unsigned int count)
84{ 82{
85 while (count--) { 83 while (count--) {
86 if (*str == '\n') 84 if (*str == '\n')
87 ata_midi_out( '\r' ); 85 ata_midi_out('\r');
88 ata_midi_out( *str++ ); 86 ata_midi_out(*str++);
89 } 87 }
90} 88}
91 89
92static int ata_par_out (char c) 90static int ata_par_out(char c)
93{ 91{
94 unsigned char tmp; 92 unsigned char tmp;
95 /* This a some-seconds timeout in case no printer is connected */ 93 /* This a some-seconds timeout in case no printer is connected */
96 unsigned long i = loops_per_jiffy > 1 ? loops_per_jiffy : 10000000/HZ; 94 unsigned long i = loops_per_jiffy > 1 ? loops_per_jiffy : 10000000/HZ;
97 95
98 while( (mfp.par_dt_reg & 1) && --i ) /* wait for BUSY == L */ 96 while ((mfp.par_dt_reg & 1) && --i) /* wait for BUSY == L */
99 ; 97 ;
100 if (!i) return( 0 ); 98 if (!i)
101 99 return 0;
102 sound_ym.rd_data_reg_sel = 15; /* select port B */ 100
103 sound_ym.wd_data = c; /* put char onto port */ 101 sound_ym.rd_data_reg_sel = 15; /* select port B */
104 sound_ym.rd_data_reg_sel = 14; /* select port A */ 102 sound_ym.wd_data = c; /* put char onto port */
105 tmp = sound_ym.rd_data_reg_sel; 103 sound_ym.rd_data_reg_sel = 14; /* select port A */
106 sound_ym.wd_data = tmp & ~0x20; /* set strobe L */ 104 tmp = sound_ym.rd_data_reg_sel;
107 MFPDELAY(); /* wait a bit */ 105 sound_ym.wd_data = tmp & ~0x20; /* set strobe L */
108 sound_ym.wd_data = tmp | 0x20; /* set strobe H */ 106 MFPDELAY(); /* wait a bit */
109 return( 1 ); 107 sound_ym.wd_data = tmp | 0x20; /* set strobe H */
108 return 1;
110} 109}
111 110
112static void atari_par_console_write (struct console *co, const char *str, 111static void atari_par_console_write(struct console *co, const char *str,
113 unsigned int count) 112 unsigned int count)
114{ 113{
115 static int printer_present = 1; 114 static int printer_present = 1;
116 115
117 if (!printer_present) 116 if (!printer_present)
118 return;
119
120 while (count--) {
121 if (*str == '\n')
122 if (!ata_par_out( '\r' )) {
123 printer_present = 0;
124 return; 117 return;
125 } 118
126 if (!ata_par_out( *str++ )) { 119 while (count--) {
127 printer_present = 0; 120 if (*str == '\n') {
128 return; 121 if (!ata_par_out('\r')) {
122 printer_present = 0;
123 return;
124 }
125 }
126 if (!ata_par_out(*str++)) {
127 printer_present = 0;
128 return;
129 }
129 } 130 }
130 }
131} 131}
132 132
133#ifdef CONFIG_SERIAL_CONSOLE 133#ifdef CONFIG_SERIAL_CONSOLE
134int atari_mfp_console_wait_key(struct console *co) 134int atari_mfp_console_wait_key(struct console *co)
135{ 135{
136 while( !(mfp.rcv_stat & 0x80) ) /* wait for rx buf filled */ 136 while (!(mfp.rcv_stat & 0x80)) /* wait for rx buf filled */
137 barrier(); 137 barrier();
138 return( mfp.usart_dta ); 138 return mfp.usart_dta;
139} 139}
140 140
141int atari_scc_console_wait_key(struct console *co) 141int atari_scc_console_wait_key(struct console *co)
142{ 142{
143 do { 143 do {
144 MFPDELAY();
145 } while (!(scc.cha_b_ctrl & 0x01)); /* wait for rx buf filled */
144 MFPDELAY(); 146 MFPDELAY();
145 } while( !(scc.cha_b_ctrl & 0x01) ); /* wait for rx buf filled */ 147 return scc.cha_b_data;
146 MFPDELAY();
147 return( scc.cha_b_data );
148} 148}
149 149
150int atari_midi_console_wait_key(struct console *co) 150int atari_midi_console_wait_key(struct console *co)
151{ 151{
152 while( !(acia.mid_ctrl & ACIA_RDRF) ) /* wait for rx buf filled */ 152 while (!(acia.mid_ctrl & ACIA_RDRF)) /* wait for rx buf filled */
153 barrier(); 153 barrier();
154 return( acia.mid_data ); 154 return acia.mid_data;
155} 155}
156#endif 156#endif
157 157
158/* The following two functions do a quick'n'dirty initialization of the MFP or 158/*
159 * The following two functions do a quick'n'dirty initialization of the MFP or
159 * SCC serial ports. They're used by the debugging interface, kgdb, and the 160 * SCC serial ports. They're used by the debugging interface, kgdb, and the
160 * serial console code. */ 161 * serial console code.
162 */
161#ifndef CONFIG_SERIAL_CONSOLE 163#ifndef CONFIG_SERIAL_CONSOLE
162static void __init atari_init_mfp_port( int cflag ) 164static void __init atari_init_mfp_port(int cflag)
163#else 165#else
164void atari_init_mfp_port( int cflag ) 166void atari_init_mfp_port(int cflag)
165#endif 167#endif
166{ 168{
167 /* timer values for 1200...115200 bps; > 38400 select 110, 134, or 150 169 /*
168 * bps, resp., and work only correct if there's a RSVE or RSSPEED */ 170 * timer values for 1200...115200 bps; > 38400 select 110, 134, or 150
169 static int baud_table[9] = { 16, 11, 8, 4, 2, 1, 175, 143, 128 }; 171 * bps, resp., and work only correct if there's a RSVE or RSSPEED
170 int baud = cflag & CBAUD; 172 */
171 int parity = (cflag & PARENB) ? ((cflag & PARODD) ? 0x04 : 0x06) : 0; 173 static int baud_table[9] = { 16, 11, 8, 4, 2, 1, 175, 143, 128 };
172 int csize = ((cflag & CSIZE) == CS7) ? 0x20 : 0x00; 174 int baud = cflag & CBAUD;
173 175 int parity = (cflag & PARENB) ? ((cflag & PARODD) ? 0x04 : 0x06) : 0;
174 if (cflag & CBAUDEX) 176 int csize = ((cflag & CSIZE) == CS7) ? 0x20 : 0x00;
175 baud += B38400; 177
176 if (baud < B1200 || baud > B38400+2) 178 if (cflag & CBAUDEX)
177 baud = B9600; /* use default 9600bps for non-implemented rates */ 179 baud += B38400;
178 baud -= B1200; /* baud_table[] starts at 1200bps */ 180 if (baud < B1200 || baud > B38400+2)
179 181 baud = B9600; /* use default 9600bps for non-implemented rates */
180 mfp.trn_stat &= ~0x01; /* disable TX */ 182 baud -= B1200; /* baud_table[] starts at 1200bps */
181 mfp.usart_ctr = parity | csize | 0x88; /* 1:16 clk mode, 1 stop bit */ 183
182 mfp.tim_ct_cd &= 0x70; /* stop timer D */ 184 mfp.trn_stat &= ~0x01; /* disable TX */
183 mfp.tim_dt_d = baud_table[baud]; 185 mfp.usart_ctr = parity | csize | 0x88; /* 1:16 clk mode, 1 stop bit */
184 mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */ 186 mfp.tim_ct_cd &= 0x70; /* stop timer D */
185 mfp.trn_stat |= 0x01; /* enable TX */ 187 mfp.tim_dt_d = baud_table[baud];
186 188 mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */
187 atari_MFP_init_done = 1; 189 mfp.trn_stat |= 0x01; /* enable TX */
190
191 atari_MFP_init_done = 1;
188} 192}
189 193
190#define SCC_WRITE(reg,val) \ 194#define SCC_WRITE(reg, val) \
191 do { \ 195 do { \
192 scc.cha_b_ctrl = (reg); \ 196 scc.cha_b_ctrl = (reg); \
193 MFPDELAY(); \ 197 MFPDELAY(); \
194 scc.cha_b_ctrl = (val); \ 198 scc.cha_b_ctrl = (val); \
195 MFPDELAY(); \ 199 MFPDELAY(); \
196 } while(0) 200 } while (0)
197 201
198/* loops_per_jiffy isn't initialized yet, so we can't use udelay(). This does a 202/* loops_per_jiffy isn't initialized yet, so we can't use udelay(). This does a
199 * delay of ~ 60us. */ 203 * delay of ~ 60us. */
200#define LONG_DELAY() \ 204#define LONG_DELAY() \
201 do { \ 205 do { \
202 int i; \ 206 int i; \
203 for( i = 100; i > 0; --i ) \ 207 for (i = 100; i > 0; --i) \
204 MFPDELAY(); \ 208 MFPDELAY(); \
205 } while(0) 209 } while (0)
206 210
207#ifndef CONFIG_SERIAL_CONSOLE 211#ifndef CONFIG_SERIAL_CONSOLE
208static void __init atari_init_scc_port( int cflag ) 212static void __init atari_init_scc_port(int cflag)
209#else 213#else
210void atari_init_scc_port( int cflag ) 214void atari_init_scc_port(int cflag)
211#endif 215#endif
212{ 216{
213 extern int atari_SCC_reset_done; 217 extern int atari_SCC_reset_done;
214 static int clksrc_table[9] = 218 static int clksrc_table[9] =
215 /* reg 11: 0x50 = BRG, 0x00 = RTxC, 0x28 = TRxC */ 219 /* reg 11: 0x50 = BRG, 0x00 = RTxC, 0x28 = TRxC */
216 { 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00 }; 220 { 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00 };
217 static int brgsrc_table[9] = 221 static int brgsrc_table[9] =
218 /* reg 14: 0 = RTxC, 2 = PCLK */ 222 /* reg 14: 0 = RTxC, 2 = PCLK */
219 { 2, 2, 2, 2, 2, 2, 0, 2, 2 }; 223 { 2, 2, 2, 2, 2, 2, 0, 2, 2 };
220 static int clkmode_table[9] = 224 static int clkmode_table[9] =
221 /* reg 4: 0x40 = x16, 0x80 = x32, 0xc0 = x64 */ 225 /* reg 4: 0x40 = x16, 0x80 = x32, 0xc0 = x64 */
222 { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80 }; 226 { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80 };
223 static int div_table[9] = 227 static int div_table[9] =
224 /* reg12 (BRG low) */ 228 /* reg12 (BRG low) */
225 { 208, 138, 103, 50, 24, 11, 1, 0, 0 }; 229 { 208, 138, 103, 50, 24, 11, 1, 0, 0 };
226 230
227 int baud = cflag & CBAUD; 231 int baud = cflag & CBAUD;
228 int clksrc, clkmode, div, reg3, reg5; 232 int clksrc, clkmode, div, reg3, reg5;
229 233
230 if (cflag & CBAUDEX) 234 if (cflag & CBAUDEX)
231 baud += B38400; 235 baud += B38400;
232 if (baud < B1200 || baud > B38400+2) 236 if (baud < B1200 || baud > B38400+2)
233 baud = B9600; /* use default 9600bps for non-implemented rates */ 237 baud = B9600; /* use default 9600bps for non-implemented rates */
234 baud -= B1200; /* tables starts at 1200bps */ 238 baud -= B1200; /* tables starts at 1200bps */
235 239
236 clksrc = clksrc_table[baud]; 240 clksrc = clksrc_table[baud];
237 clkmode = clkmode_table[baud]; 241 clkmode = clkmode_table[baud];
238 div = div_table[baud]; 242 div = div_table[baud];
239 if (ATARIHW_PRESENT(TT_MFP) && baud >= 6) { 243 if (ATARIHW_PRESENT(TT_MFP) && baud >= 6) {
240 /* special treatment for TT, where rates >= 38400 are done via TRxC */ 244 /* special treatment for TT, where rates >= 38400 are done via TRxC */
241 clksrc = 0x28; /* TRxC */ 245 clksrc = 0x28; /* TRxC */
242 clkmode = baud == 6 ? 0xc0 : 246 clkmode = baud == 6 ? 0xc0 :
243 baud == 7 ? 0x80 : /* really 76800bps */ 247 baud == 7 ? 0x80 : /* really 76800bps */
244 0x40; /* really 153600bps */ 248 0x40; /* really 153600bps */
245 div = 0; 249 div = 0;
246 } 250 }
247 251
248 reg3 = (cflag & CSIZE) == CS8 ? 0xc0 : 0x40; 252 reg3 = (cflag & CSIZE) == CS8 ? 0xc0 : 0x40;
249 reg5 = (cflag & CSIZE) == CS8 ? 0x60 : 0x20 | 0x82 /* assert DTR/RTS */; 253 reg5 = (cflag & CSIZE) == CS8 ? 0x60 : 0x20 | 0x82 /* assert DTR/RTS */;
250 254
251 (void)scc.cha_b_ctrl; /* reset reg pointer */ 255 (void)scc.cha_b_ctrl; /* reset reg pointer */
252 SCC_WRITE( 9, 0xc0 ); /* reset */ 256 SCC_WRITE(9, 0xc0); /* reset */
253 LONG_DELAY(); /* extra delay after WR9 access */ 257 LONG_DELAY(); /* extra delay after WR9 access */
254 SCC_WRITE( 4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 | 258 SCC_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03)
255 0x04 /* 1 stopbit */ | 259 : 0 | 0x04 /* 1 stopbit */ | clkmode);
256 clkmode ); 260 SCC_WRITE(3, reg3);
257 SCC_WRITE( 3, reg3 ); 261 SCC_WRITE(5, reg5);
258 SCC_WRITE( 5, reg5 ); 262 SCC_WRITE(9, 0); /* no interrupts */
259 SCC_WRITE( 9, 0 ); /* no interrupts */ 263 LONG_DELAY(); /* extra delay after WR9 access */
260 LONG_DELAY(); /* extra delay after WR9 access */ 264 SCC_WRITE(10, 0); /* NRZ mode */
261 SCC_WRITE( 10, 0 ); /* NRZ mode */ 265 SCC_WRITE(11, clksrc); /* main clock source */
262 SCC_WRITE( 11, clksrc ); /* main clock source */ 266 SCC_WRITE(12, div); /* BRG value */
263 SCC_WRITE( 12, div ); /* BRG value */ 267 SCC_WRITE(13, 0); /* BRG high byte */
264 SCC_WRITE( 13, 0 ); /* BRG high byte */ 268 SCC_WRITE(14, brgsrc_table[baud]);
265 SCC_WRITE( 14, brgsrc_table[baud] ); 269 SCC_WRITE(14, brgsrc_table[baud] | (div ? 1 : 0));
266 SCC_WRITE( 14, brgsrc_table[baud] | (div ? 1 : 0) ); 270 SCC_WRITE(3, reg3 | 1);
267 SCC_WRITE( 3, reg3 | 1 ); 271 SCC_WRITE(5, reg5 | 8);
268 SCC_WRITE( 5, reg5 | 8 ); 272
269 273 atari_SCC_reset_done = 1;
270 atari_SCC_reset_done = 1; 274 atari_SCC_init_done = 1;
271 atari_SCC_init_done = 1;
272} 275}
273 276
274#ifndef CONFIG_SERIAL_CONSOLE 277#ifndef CONFIG_SERIAL_CONSOLE
275static void __init atari_init_midi_port( int cflag ) 278static void __init atari_init_midi_port(int cflag)
276#else 279#else
277void atari_init_midi_port( int cflag ) 280void atari_init_midi_port(int cflag)
278#endif 281#endif
279{ 282{
280 int baud = cflag & CBAUD; 283 int baud = cflag & CBAUD;
281 int csize = ((cflag & CSIZE) == CS8) ? 0x10 : 0x00; 284 int csize = ((cflag & CSIZE) == CS8) ? 0x10 : 0x00;
282 /* warning 7N1 isn't possible! (instead 7O2 is used...) */ 285 /* warning 7N1 isn't possible! (instead 7O2 is used...) */
283 int parity = (cflag & PARENB) ? ((cflag & PARODD) ? 0x0c : 0x08) : 0x04; 286 int parity = (cflag & PARENB) ? ((cflag & PARODD) ? 0x0c : 0x08) : 0x04;
284 int div; 287 int div;
285 288
286 /* 4800 selects 7812.5, 115200 selects 500000, all other (incl. 9600 as 289 /* 4800 selects 7812.5, 115200 selects 500000, all other (incl. 9600 as
287 * default) the standard MIDI speed 31250. */ 290 * default) the standard MIDI speed 31250. */
288 if (cflag & CBAUDEX) 291 if (cflag & CBAUDEX)
289 baud += B38400; 292 baud += B38400;
290 if (baud == B4800) 293 if (baud == B4800)
291 div = ACIA_DIV64; /* really 7812.5 bps */ 294 div = ACIA_DIV64; /* really 7812.5 bps */
292 else if (baud == B38400+2 /* 115200 */) 295 else if (baud == B38400+2 /* 115200 */)
293 div = ACIA_DIV1; /* really 500 kbps (does that work??) */ 296 div = ACIA_DIV1; /* really 500 kbps (does that work??) */
294 else 297 else
295 div = ACIA_DIV16; /* 31250 bps, standard for MIDI */ 298 div = ACIA_DIV16; /* 31250 bps, standard for MIDI */
296 299
297 /* RTS low, ints disabled */ 300 /* RTS low, ints disabled */
298 acia.mid_ctrl = div | csize | parity | 301 acia.mid_ctrl = div | csize | parity |
299 ((atari_switches & ATARI_SWITCH_MIDI) ? 302 ((atari_switches & ATARI_SWITCH_MIDI) ?
300 ACIA_RHTID : ACIA_RLTID); 303 ACIA_RHTID : ACIA_RLTID);
301} 304}
302 305
303void __init atari_debug_init(void) 306static int __init atari_debug_setup(char *arg)
304{ 307{
305 if (!strcmp( m68k_debug_device, "ser" )) { 308 if (!MACH_IS_ATARI)
306 /* defaults to ser2 for a Falcon and ser1 otherwise */ 309 return 0;
307 strcpy( m68k_debug_device, MACH_IS_FALCON ? "ser2" : "ser1" ); 310
308 311 if (!strcmp(arg, "ser"))
309 } 312 /* defaults to ser2 for a Falcon and ser1 otherwise */
310 313 arg = MACH_IS_FALCON ? "ser2" : "ser1";
311 if (!strcmp( m68k_debug_device, "ser1" )) { 314
312 /* ST-MFP Modem1 serial port */ 315 if (!strcmp(arg, "ser1")) {
313 atari_init_mfp_port( B9600|CS8 ); 316 /* ST-MFP Modem1 serial port */
314 atari_console_driver.write = atari_mfp_console_write; 317 atari_init_mfp_port(B9600|CS8);
315 } 318 atari_console_driver.write = atari_mfp_console_write;
316 else if (!strcmp( m68k_debug_device, "ser2" )) { 319 } else if (!strcmp(arg, "ser2")) {
317 /* SCC Modem2 serial port */ 320 /* SCC Modem2 serial port */
318 atari_init_scc_port( B9600|CS8 ); 321 atari_init_scc_port(B9600|CS8);
319 atari_console_driver.write = atari_scc_console_write; 322 atari_console_driver.write = atari_scc_console_write;
320 } 323 } else if (!strcmp(arg, "midi")) {
321 else if (!strcmp( m68k_debug_device, "midi" )) { 324 /* MIDI port */
322 /* MIDI port */ 325 atari_init_midi_port(B9600|CS8);
323 atari_init_midi_port( B9600|CS8 ); 326 atari_console_driver.write = atari_midi_console_write;
324 atari_console_driver.write = atari_midi_console_write; 327 } else if (!strcmp(arg, "par")) {
325 } 328 /* parallel printer */
326 else if (!strcmp( m68k_debug_device, "par" )) { 329 atari_turnoff_irq(IRQ_MFP_BUSY); /* avoid ints */
327 /* parallel printer */ 330 sound_ym.rd_data_reg_sel = 7; /* select mixer control */
328 atari_turnoff_irq( IRQ_MFP_BUSY ); /* avoid ints */ 331 sound_ym.wd_data = 0xff; /* sound off, ports are output */
329 sound_ym.rd_data_reg_sel = 7; /* select mixer control */ 332 sound_ym.rd_data_reg_sel = 15; /* select port B */
330 sound_ym.wd_data = 0xff; /* sound off, ports are output */ 333 sound_ym.wd_data = 0; /* no char */
331 sound_ym.rd_data_reg_sel = 15; /* select port B */ 334 sound_ym.rd_data_reg_sel = 14; /* select port A */
332 sound_ym.wd_data = 0; /* no char */ 335 sound_ym.wd_data = sound_ym.rd_data_reg_sel | 0x20; /* strobe H */
333 sound_ym.rd_data_reg_sel = 14; /* select port A */ 336 atari_console_driver.write = atari_par_console_write;
334 sound_ym.wd_data = sound_ym.rd_data_reg_sel | 0x20; /* strobe H */ 337 }
335 atari_console_driver.write = atari_par_console_write; 338 if (atari_console_driver.write)
336 } 339 register_console(&atari_console_driver);
337 if (atari_console_driver.write) 340
338 register_console(&atari_console_driver); 341 return 0;
339} 342}
340 343
341/* 344early_param("debug", atari_debug_setup);
342 * Local variables:
343 * c-indent-level: 4
344 * tab-width: 8
345 * End:
346 */
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 222ce4244564..e162ee685d20 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -692,7 +692,7 @@ sys_call_table:
692 .long sys_tgkill /* 265 */ 692 .long sys_tgkill /* 265 */
693 .long sys_utimes 693 .long sys_utimes
694 .long sys_fadvise64_64 694 .long sys_fadvise64_64
695 .long sys_mbind 695 .long sys_mbind
696 .long sys_get_mempolicy 696 .long sys_get_mempolicy
697 .long sys_set_mempolicy /* 270 */ 697 .long sys_set_mempolicy /* 270 */
698 .long sys_mq_open 698 .long sys_mq_open
diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
index 6739e87fe825..05741f233567 100644
--- a/arch/m68k/kernel/head.S
+++ b/arch/m68k/kernel/head.S
@@ -3195,7 +3195,7 @@ func_start serial_putc,%d0/%d1/%a0/%a1
3195 jbra L(serial_putc_done) 3195 jbra L(serial_putc_done)
31963: 31963:
3197#endif 3197#endif
3198 3198
3199L(serial_putc_done): 3199L(serial_putc_done):
3200func_return serial_putc 3200func_return serial_putc
3201 3201
diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
index 42b8fd09ea8f..610319356691 100644
--- a/arch/m68k/kernel/setup.c
+++ b/arch/m68k/kernel/setup.c
@@ -71,9 +71,6 @@ static struct mem_info m68k_ramdisk;
71 71
72static char m68k_command_line[CL_SIZE]; 72static char m68k_command_line[CL_SIZE];
73 73
74char m68k_debug_device[6] = "";
75EXPORT_SYMBOL(m68k_debug_device);
76
77void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL; 74void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL;
78/* machine dependent irq functions */ 75/* machine dependent irq functions */
79void (*mach_init_IRQ) (void) __initdata = NULL; 76void (*mach_init_IRQ) (void) __initdata = NULL;
@@ -133,78 +130,78 @@ extern void config_hp300(void);
133extern void config_q40(void); 130extern void config_q40(void);
134extern void config_sun3x(void); 131extern void config_sun3x(void);
135 132
136extern void mac_debugging_short (int, short);
137extern void mac_debugging_long (int, long);
138
139#define MASK_256K 0xfffc0000 133#define MASK_256K 0xfffc0000
140 134
141extern void paging_init(void); 135extern void paging_init(void);
142 136
143static void __init m68k_parse_bootinfo(const struct bi_record *record) 137static void __init m68k_parse_bootinfo(const struct bi_record *record)
144{ 138{
145 while (record->tag != BI_LAST) { 139 while (record->tag != BI_LAST) {
146 int unknown = 0; 140 int unknown = 0;
147 const unsigned long *data = record->data; 141 const unsigned long *data = record->data;
148 switch (record->tag) { 142
149 case BI_MACHTYPE: 143 switch (record->tag) {
150 case BI_CPUTYPE: 144 case BI_MACHTYPE:
151 case BI_FPUTYPE: 145 case BI_CPUTYPE:
152 case BI_MMUTYPE: 146 case BI_FPUTYPE:
153 /* Already set up by head.S */ 147 case BI_MMUTYPE:
154 break; 148 /* Already set up by head.S */
155 149 break;
156 case BI_MEMCHUNK: 150
157 if (m68k_num_memory < NUM_MEMINFO) { 151 case BI_MEMCHUNK:
158 m68k_memory[m68k_num_memory].addr = data[0]; 152 if (m68k_num_memory < NUM_MEMINFO) {
159 m68k_memory[m68k_num_memory].size = data[1]; 153 m68k_memory[m68k_num_memory].addr = data[0];
160 m68k_num_memory++; 154 m68k_memory[m68k_num_memory].size = data[1];
161 } else 155 m68k_num_memory++;
162 printk("m68k_parse_bootinfo: too many memory chunks\n"); 156 } else
163 break; 157 printk("m68k_parse_bootinfo: too many memory chunks\n");
164 158 break;
165 case BI_RAMDISK: 159
166 m68k_ramdisk.addr = data[0]; 160 case BI_RAMDISK:
167 m68k_ramdisk.size = data[1]; 161 m68k_ramdisk.addr = data[0];
168 break; 162 m68k_ramdisk.size = data[1];
169 163 break;
170 case BI_COMMAND_LINE: 164
171 strlcpy(m68k_command_line, (const char *)data, sizeof(m68k_command_line)); 165 case BI_COMMAND_LINE:
172 break; 166 strlcpy(m68k_command_line, (const char *)data,
173 167 sizeof(m68k_command_line));
174 default: 168 break;
175 if (MACH_IS_AMIGA) 169
176 unknown = amiga_parse_bootinfo(record); 170 default:
177 else if (MACH_IS_ATARI) 171 if (MACH_IS_AMIGA)
178 unknown = atari_parse_bootinfo(record); 172 unknown = amiga_parse_bootinfo(record);
179 else if (MACH_IS_MAC) 173 else if (MACH_IS_ATARI)
180 unknown = mac_parse_bootinfo(record); 174 unknown = atari_parse_bootinfo(record);
181 else if (MACH_IS_Q40) 175 else if (MACH_IS_MAC)
182 unknown = q40_parse_bootinfo(record); 176 unknown = mac_parse_bootinfo(record);
183 else if (MACH_IS_BVME6000) 177 else if (MACH_IS_Q40)
184 unknown = bvme6000_parse_bootinfo(record); 178 unknown = q40_parse_bootinfo(record);
185 else if (MACH_IS_MVME16x) 179 else if (MACH_IS_BVME6000)
186 unknown = mvme16x_parse_bootinfo(record); 180 unknown = bvme6000_parse_bootinfo(record);
187 else if (MACH_IS_MVME147) 181 else if (MACH_IS_MVME16x)
188 unknown = mvme147_parse_bootinfo(record); 182 unknown = mvme16x_parse_bootinfo(record);
189 else if (MACH_IS_HP300) 183 else if (MACH_IS_MVME147)
190 unknown = hp300_parse_bootinfo(record); 184 unknown = mvme147_parse_bootinfo(record);
191 else 185 else if (MACH_IS_HP300)
192 unknown = 1; 186 unknown = hp300_parse_bootinfo(record);
187 else
188 unknown = 1;
189 }
190 if (unknown)
191 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
192 record->tag);
193 record = (struct bi_record *)((unsigned long)record +
194 record->size);
193 } 195 }
194 if (unknown)
195 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
196 record->tag);
197 record = (struct bi_record *)((unsigned long)record+record->size);
198 }
199 196
200 m68k_realnum_memory = m68k_num_memory; 197 m68k_realnum_memory = m68k_num_memory;
201#ifdef CONFIG_SINGLE_MEMORY_CHUNK 198#ifdef CONFIG_SINGLE_MEMORY_CHUNK
202 if (m68k_num_memory > 1) { 199 if (m68k_num_memory > 1) {
203 printk("Ignoring last %i chunks of physical memory\n", 200 printk("Ignoring last %i chunks of physical memory\n",
204 (m68k_num_memory - 1)); 201 (m68k_num_memory - 1));
205 m68k_num_memory = 1; 202 m68k_num_memory = 1;
206 } 203 }
207 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET; 204 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET;
208#endif 205#endif
209} 206}
210 207
@@ -215,7 +212,6 @@ void __init setup_arch(char **cmdline_p)
215 unsigned long endmem, startmem; 212 unsigned long endmem, startmem;
216#endif 213#endif
217 int i; 214 int i;
218 char *p, *q;
219 215
220 /* The bootinfo is located right after the kernel bss */ 216 /* The bootinfo is located right after the kernel bss */
221 m68k_parse_bootinfo((const struct bi_record *)&_end); 217 m68k_parse_bootinfo((const struct bi_record *)&_end);
@@ -234,7 +230,7 @@ void __init setup_arch(char **cmdline_p)
234 /* clear the fpu if we have one */ 230 /* clear the fpu if we have one */
235 if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) { 231 if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
236 volatile int zero = 0; 232 volatile int zero = 0;
237 asm __volatile__ ("frestore %0" : : "m" (zero)); 233 asm volatile ("frestore %0" : : "m" (zero));
238 } 234 }
239#endif 235#endif
240 236
@@ -258,37 +254,7 @@ void __init setup_arch(char **cmdline_p)
258 *cmdline_p = m68k_command_line; 254 *cmdline_p = m68k_command_line;
259 memcpy(boot_command_line, *cmdline_p, CL_SIZE); 255 memcpy(boot_command_line, *cmdline_p, CL_SIZE);
260 256
261 /* Parse the command line for arch-specific options. 257 parse_early_param();
262 * For the m68k, this is currently only "debug=xxx" to enable printing
263 * certain kernel messages to some machine-specific device.
264 */
265 for( p = *cmdline_p; p && *p; ) {
266 i = 0;
267 if (!strncmp( p, "debug=", 6 )) {
268 strlcpy( m68k_debug_device, p+6, sizeof(m68k_debug_device) );
269 if ((q = strchr( m68k_debug_device, ' ' ))) *q = 0;
270 i = 1;
271 }
272#ifdef CONFIG_ATARI
273 /* This option must be parsed very early */
274 if (!strncmp( p, "switches=", 9 )) {
275 extern void atari_switches_setup( const char *, int );
276 atari_switches_setup( p+9, (q = strchr( p+9, ' ' )) ?
277 (q - (p+9)) : strlen(p+9) );
278 i = 1;
279 }
280#endif
281
282 if (i) {
283 /* option processed, delete it */
284 if ((q = strchr( p, ' ' )))
285 strcpy( p, q+1 );
286 else
287 *p = 0;
288 } else {
289 if ((p = strchr( p, ' ' ))) ++p;
290 }
291 }
292 258
293#ifdef CONFIG_DUMMY_CONSOLE 259#ifdef CONFIG_DUMMY_CONSOLE
294 conswitchp = &dummy_con; 260 conswitchp = &dummy_con;
@@ -296,62 +262,62 @@ void __init setup_arch(char **cmdline_p)
296 262
297 switch (m68k_machtype) { 263 switch (m68k_machtype) {
298#ifdef CONFIG_AMIGA 264#ifdef CONFIG_AMIGA
299 case MACH_AMIGA: 265 case MACH_AMIGA:
300 config_amiga(); 266 config_amiga();
301 break; 267 break;
302#endif 268#endif
303#ifdef CONFIG_ATARI 269#ifdef CONFIG_ATARI
304 case MACH_ATARI: 270 case MACH_ATARI:
305 config_atari(); 271 config_atari();
306 break; 272 break;
307#endif 273#endif
308#ifdef CONFIG_MAC 274#ifdef CONFIG_MAC
309 case MACH_MAC: 275 case MACH_MAC:
310 config_mac(); 276 config_mac();
311 break; 277 break;
312#endif 278#endif
313#ifdef CONFIG_SUN3 279#ifdef CONFIG_SUN3
314 case MACH_SUN3: 280 case MACH_SUN3:
315 config_sun3(); 281 config_sun3();
316 break; 282 break;
317#endif 283#endif
318#ifdef CONFIG_APOLLO 284#ifdef CONFIG_APOLLO
319 case MACH_APOLLO: 285 case MACH_APOLLO:
320 config_apollo(); 286 config_apollo();
321 break; 287 break;
322#endif 288#endif
323#ifdef CONFIG_MVME147 289#ifdef CONFIG_MVME147
324 case MACH_MVME147: 290 case MACH_MVME147:
325 config_mvme147(); 291 config_mvme147();
326 break; 292 break;
327#endif 293#endif
328#ifdef CONFIG_MVME16x 294#ifdef CONFIG_MVME16x
329 case MACH_MVME16x: 295 case MACH_MVME16x:
330 config_mvme16x(); 296 config_mvme16x();
331 break; 297 break;
332#endif 298#endif
333#ifdef CONFIG_BVME6000 299#ifdef CONFIG_BVME6000
334 case MACH_BVME6000: 300 case MACH_BVME6000:
335 config_bvme6000(); 301 config_bvme6000();
336 break; 302 break;
337#endif 303#endif
338#ifdef CONFIG_HP300 304#ifdef CONFIG_HP300
339 case MACH_HP300: 305 case MACH_HP300:
340 config_hp300(); 306 config_hp300();
341 break; 307 break;
342#endif 308#endif
343#ifdef CONFIG_Q40 309#ifdef CONFIG_Q40
344 case MACH_Q40: 310 case MACH_Q40:
345 config_q40(); 311 config_q40();
346 break; 312 break;
347#endif 313#endif
348#ifdef CONFIG_SUN3X 314#ifdef CONFIG_SUN3X
349 case MACH_SUN3X: 315 case MACH_SUN3X:
350 config_sun3x(); 316 config_sun3x();
351 break; 317 break;
352#endif 318#endif
353 default: 319 default:
354 panic ("No configuration setup"); 320 panic("No configuration setup");
355 } 321 }
356 322
357#ifndef CONFIG_SUN3 323#ifndef CONFIG_SUN3
@@ -380,7 +346,7 @@ void __init setup_arch(char **cmdline_p)
380 reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size); 346 reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size);
381 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr); 347 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
382 initrd_end = initrd_start + m68k_ramdisk.size; 348 initrd_end = initrd_start + m68k_ramdisk.size;
383 printk ("initrd: %08lx - %08lx\n", initrd_start, initrd_end); 349 printk("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
384 } 350 }
385#endif 351#endif
386 352
@@ -402,18 +368,18 @@ void __init setup_arch(char **cmdline_p)
402#if defined(CONFIG_ISA) && defined(MULTI_ISA) 368#if defined(CONFIG_ISA) && defined(MULTI_ISA)
403#if defined(CONFIG_Q40) 369#if defined(CONFIG_Q40)
404 if (MACH_IS_Q40) { 370 if (MACH_IS_Q40) {
405 isa_type = Q40_ISA; 371 isa_type = Q40_ISA;
406 isa_sex = 0; 372 isa_sex = 0;
407 } 373 }
408#elif defined(CONFIG_GG2) 374#elif defined(CONFIG_GG2)
409 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)){ 375 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)) {
410 isa_type = GG2_ISA; 376 isa_type = GG2_ISA;
411 isa_sex = 0; 377 isa_sex = 0;
412 } 378 }
413#elif defined(CONFIG_AMIGA_PCMCIA) 379#elif defined(CONFIG_AMIGA_PCMCIA)
414 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)){ 380 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)) {
415 isa_type = AG_ISA; 381 isa_type = AG_ISA;
416 isa_sex = 1; 382 isa_sex = 1;
417 } 383 }
418#endif 384#endif
419#endif 385#endif
@@ -421,66 +387,66 @@ void __init setup_arch(char **cmdline_p)
421 387
422static int show_cpuinfo(struct seq_file *m, void *v) 388static int show_cpuinfo(struct seq_file *m, void *v)
423{ 389{
424 const char *cpu, *mmu, *fpu; 390 const char *cpu, *mmu, *fpu;
425 unsigned long clockfreq, clockfactor; 391 unsigned long clockfreq, clockfactor;
426 392
427#define LOOP_CYCLES_68020 (8) 393#define LOOP_CYCLES_68020 (8)
428#define LOOP_CYCLES_68030 (8) 394#define LOOP_CYCLES_68030 (8)
429#define LOOP_CYCLES_68040 (3) 395#define LOOP_CYCLES_68040 (3)
430#define LOOP_CYCLES_68060 (1) 396#define LOOP_CYCLES_68060 (1)
431 397
432 if (CPU_IS_020) { 398 if (CPU_IS_020) {
433 cpu = "68020"; 399 cpu = "68020";
434 clockfactor = LOOP_CYCLES_68020; 400 clockfactor = LOOP_CYCLES_68020;
435 } else if (CPU_IS_030) { 401 } else if (CPU_IS_030) {
436 cpu = "68030"; 402 cpu = "68030";
437 clockfactor = LOOP_CYCLES_68030; 403 clockfactor = LOOP_CYCLES_68030;
438 } else if (CPU_IS_040) { 404 } else if (CPU_IS_040) {
439 cpu = "68040"; 405 cpu = "68040";
440 clockfactor = LOOP_CYCLES_68040; 406 clockfactor = LOOP_CYCLES_68040;
441 } else if (CPU_IS_060) { 407 } else if (CPU_IS_060) {
442 cpu = "68060"; 408 cpu = "68060";
443 clockfactor = LOOP_CYCLES_68060; 409 clockfactor = LOOP_CYCLES_68060;
444 } else { 410 } else {
445 cpu = "680x0"; 411 cpu = "680x0";
446 clockfactor = 0; 412 clockfactor = 0;
447 } 413 }
448 414
449#ifdef CONFIG_M68KFPU_EMU_ONLY 415#ifdef CONFIG_M68KFPU_EMU_ONLY
450 fpu="none(soft float)"; 416 fpu = "none(soft float)";
451#else 417#else
452 if (m68k_fputype & FPU_68881) 418 if (m68k_fputype & FPU_68881)
453 fpu = "68881"; 419 fpu = "68881";
454 else if (m68k_fputype & FPU_68882) 420 else if (m68k_fputype & FPU_68882)
455 fpu = "68882"; 421 fpu = "68882";
456 else if (m68k_fputype & FPU_68040) 422 else if (m68k_fputype & FPU_68040)
457 fpu = "68040"; 423 fpu = "68040";
458 else if (m68k_fputype & FPU_68060) 424 else if (m68k_fputype & FPU_68060)
459 fpu = "68060"; 425 fpu = "68060";
460 else if (m68k_fputype & FPU_SUNFPA) 426 else if (m68k_fputype & FPU_SUNFPA)
461 fpu = "Sun FPA"; 427 fpu = "Sun FPA";
462 else 428 else
463 fpu = "none"; 429 fpu = "none";
464#endif 430#endif
465 431
466 if (m68k_mmutype & MMU_68851) 432 if (m68k_mmutype & MMU_68851)
467 mmu = "68851"; 433 mmu = "68851";
468 else if (m68k_mmutype & MMU_68030) 434 else if (m68k_mmutype & MMU_68030)
469 mmu = "68030"; 435 mmu = "68030";
470 else if (m68k_mmutype & MMU_68040) 436 else if (m68k_mmutype & MMU_68040)
471 mmu = "68040"; 437 mmu = "68040";
472 else if (m68k_mmutype & MMU_68060) 438 else if (m68k_mmutype & MMU_68060)
473 mmu = "68060"; 439 mmu = "68060";
474 else if (m68k_mmutype & MMU_SUN3) 440 else if (m68k_mmutype & MMU_SUN3)
475 mmu = "Sun-3"; 441 mmu = "Sun-3";
476 else if (m68k_mmutype & MMU_APOLLO) 442 else if (m68k_mmutype & MMU_APOLLO)
477 mmu = "Apollo"; 443 mmu = "Apollo";
478 else 444 else
479 mmu = "unknown"; 445 mmu = "unknown";
480 446
481 clockfreq = loops_per_jiffy*HZ*clockfactor; 447 clockfreq = loops_per_jiffy * HZ * clockfactor;
482 448
483 seq_printf(m, "CPU:\t\t%s\n" 449 seq_printf(m, "CPU:\t\t%s\n"
484 "MMU:\t\t%s\n" 450 "MMU:\t\t%s\n"
485 "FPU:\t\t%s\n" 451 "FPU:\t\t%s\n"
486 "Clocking:\t%lu.%1luMHz\n" 452 "Clocking:\t%lu.%1luMHz\n"
@@ -490,7 +456,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
490 clockfreq/1000000,(clockfreq/100000)%10, 456 clockfreq/1000000,(clockfreq/100000)%10,
491 loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100, 457 loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
492 loops_per_jiffy); 458 loops_per_jiffy);
493 return 0; 459 return 0;
494} 460}
495 461
496static void *c_start(struct seq_file *m, loff_t *pos) 462static void *c_start(struct seq_file *m, loff_t *pos)
@@ -506,44 +472,54 @@ static void c_stop(struct seq_file *m, void *v)
506{ 472{
507} 473}
508struct seq_operations cpuinfo_op = { 474struct seq_operations cpuinfo_op = {
509 .start = c_start, 475 .start = c_start,
510 .next = c_next, 476 .next = c_next,
511 .stop = c_stop, 477 .stop = c_stop,
512 .show = show_cpuinfo, 478 .show = show_cpuinfo,
513}; 479};
514 480
515int get_hardware_list(char *buffer) 481int get_hardware_list(char *buffer)
516{ 482{
517 int len = 0; 483 int len = 0;
518 char model[80]; 484 char model[80];
519 unsigned long mem; 485 unsigned long mem;
520 int i; 486 int i;
521 487
522 if (mach_get_model) 488 if (mach_get_model)
523 mach_get_model(model); 489 mach_get_model(model);
524 else 490 else
525 strcpy(model, "Unknown m68k"); 491 strcpy(model, "Unknown m68k");
526 492
527 len += sprintf(buffer+len, "Model:\t\t%s\n", model); 493 len += sprintf(buffer + len, "Model:\t\t%s\n", model);
528 for (mem = 0, i = 0; i < m68k_num_memory; i++) 494 for (mem = 0, i = 0; i < m68k_num_memory; i++)
529 mem += m68k_memory[i].size; 495 mem += m68k_memory[i].size;
530 len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10); 496 len += sprintf(buffer + len, "System Memory:\t%ldK\n", mem >> 10);
531 497
532 if (mach_get_hardware_list) 498 if (mach_get_hardware_list)
533 len += mach_get_hardware_list(buffer+len); 499 len += mach_get_hardware_list(buffer + len);
534 500
535 return(len); 501 return len;
536} 502}
537 503
538void check_bugs(void) 504void check_bugs(void)
539{ 505{
540#ifndef CONFIG_M68KFPU_EMU 506#ifndef CONFIG_M68KFPU_EMU
541 if (m68k_fputype == 0) { 507 if (m68k_fputype == 0) {
542 printk( KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, " 508 printk(KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
543 "WHICH IS REQUIRED BY LINUX/M68K ***\n" ); 509 "WHICH IS REQUIRED BY LINUX/M68K ***\n");
544 printk( KERN_EMERG "Upgrade your hardware or join the FPU " 510 printk(KERN_EMERG "Upgrade your hardware or join the FPU "
545 "emulation project\n" ); 511 "emulation project\n");
546 panic( "no FPU" ); 512 panic("no FPU");
547 } 513 }
548#endif /* !CONFIG_M68KFPU_EMU */ 514#endif /* !CONFIG_M68KFPU_EMU */
549} 515}
516
517#ifdef CONFIG_ADB
518static int __init adb_probe_sync_enable (char *str) {
519 extern int __adb_probe_sync;
520 __adb_probe_sync = 1;
521 return 1;
522}
523
524__setup("adb_sync", adb_probe_sync_enable);
525#endif /* CONFIG_ADB */
diff --git a/arch/m68k/lib/checksum.c b/arch/m68k/lib/checksum.c
index aed3be29e06b..cf6bb51945a2 100644
--- a/arch/m68k/lib/checksum.c
+++ b/arch/m68k/lib/checksum.c
@@ -320,6 +320,9 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
320 return(sum); 320 return(sum);
321} 321}
322 322
323EXPORT_SYMBOL(csum_partial_copy_from_user);
324
325
323/* 326/*
324 * copy from kernel space while checksumming, otherwise like csum_partial 327 * copy from kernel space while checksumming, otherwise like csum_partial
325 */ 328 */
diff --git a/arch/m68k/mac/baboon.c b/arch/m68k/mac/baboon.c
index a1c7ec706741..673a1085984d 100644
--- a/arch/m68k/mac/baboon.c
+++ b/arch/m68k/mac/baboon.c
@@ -22,7 +22,7 @@
22/* #define DEBUG_BABOON */ 22/* #define DEBUG_BABOON */
23/* #define DEBUG_IRQS */ 23/* #define DEBUG_IRQS */
24 24
25int baboon_present,baboon_active; 25int baboon_present;
26volatile struct baboon *baboon; 26volatile struct baboon *baboon;
27 27
28irqreturn_t baboon_irq(int, void *); 28irqreturn_t baboon_irq(int, void *);
@@ -45,7 +45,6 @@ void __init baboon_init(void)
45 45
46 baboon = (struct baboon *) BABOON_BASE; 46 baboon = (struct baboon *) BABOON_BASE;
47 baboon_present = 1; 47 baboon_present = 1;
48 baboon_active = 0;
49 48
50 printk("Baboon detected at %p\n", baboon); 49 printk("Baboon detected at %p\n", baboon);
51} 50}
@@ -66,26 +65,28 @@ void __init baboon_register_interrupts(void)
66 65
67irqreturn_t baboon_irq(int irq, void *dev_id) 66irqreturn_t baboon_irq(int irq, void *dev_id)
68{ 67{
69 int irq_bit,i; 68 int irq_bit, irq_num;
70 unsigned char events; 69 unsigned char events;
71 70
72#ifdef DEBUG_IRQS 71#ifdef DEBUG_IRQS
73 printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X active %02X\n", 72 printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X\n",
74 (uint) baboon->mb_control, (uint) baboon->mb_ifr, 73 (uint) baboon->mb_control, (uint) baboon->mb_ifr,
75 (uint) baboon->mb_status, baboon_active); 74 (uint) baboon->mb_status);
76#endif 75#endif
77 76
78 if (!(events = baboon->mb_ifr & 0x07)) 77 if (!(events = baboon->mb_ifr & 0x07))
79 return IRQ_NONE; 78 return IRQ_NONE;
80 79
81 for (i = 0, irq_bit = 1 ; i < 3 ; i++, irq_bit <<= 1) { 80 irq_num = IRQ_BABOON_0;
82 if (events & irq_bit/* & baboon_active*/) { 81 irq_bit = 1;
83 baboon_active &= ~irq_bit; 82 do {
84 m68k_handle_int(IRQ_BABOON_0 + i); 83 if (events & irq_bit) {
85 baboon_active |= irq_bit;
86 baboon->mb_ifr &= ~irq_bit; 84 baboon->mb_ifr &= ~irq_bit;
85 m68k_handle_int(irq_num);
87 } 86 }
88 } 87 irq_bit <<= 1;
88 irq_num++;
89 } while(events >= irq_bit);
89#if 0 90#if 0
90 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL); 91 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
91 /* for now we need to smash all interrupts */ 92 /* for now we need to smash all interrupts */
@@ -95,21 +96,18 @@ irqreturn_t baboon_irq(int irq, void *dev_id)
95} 96}
96 97
97void baboon_irq_enable(int irq) { 98void baboon_irq_enable(int irq) {
98 int irq_idx = IRQ_IDX(irq);
99
100#ifdef DEBUG_IRQUSE 99#ifdef DEBUG_IRQUSE
101 printk("baboon_irq_enable(%d)\n", irq); 100 printk("baboon_irq_enable(%d)\n", irq);
102#endif 101#endif
103 baboon_active |= (1 << irq_idx); 102 /* FIXME: figure out how to mask and unmask baboon interrupt sources */
103 enable_irq(IRQ_NUBUS_C);
104} 104}
105 105
106void baboon_irq_disable(int irq) { 106void baboon_irq_disable(int irq) {
107 int irq_idx = IRQ_IDX(irq);
108
109#ifdef DEBUG_IRQUSE 107#ifdef DEBUG_IRQUSE
110 printk("baboon_irq_disable(%d)\n", irq); 108 printk("baboon_irq_disable(%d)\n", irq);
111#endif 109#endif
112 baboon_active &= ~(1 << irq_idx); 110 disable_irq(IRQ_NUBUS_C);
113} 111}
114 112
115void baboon_irq_clear(int irq) { 113void baboon_irq_clear(int irq) {
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 562b38d00180..5fd413246f89 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -59,15 +59,15 @@ extern struct mem_info m68k_ramdisk;
59 59
60extern char m68k_command_line[CL_SIZE]; 60extern char m68k_command_line[CL_SIZE];
61 61
62void *mac_env; /* Loaded by the boot asm */ 62void *mac_env; /* Loaded by the boot asm */
63 63
64/* The phys. video addr. - might be bogus on some machines */ 64/* The phys. video addr. - might be bogus on some machines */
65unsigned long mac_orig_videoaddr; 65unsigned long mac_orig_videoaddr;
66 66
67/* Mac specific timer functions */ 67/* Mac specific timer functions */
68extern unsigned long mac_gettimeoffset (void); 68extern unsigned long mac_gettimeoffset(void);
69extern int mac_hwclk (int, struct rtc_time *); 69extern int mac_hwclk(int, struct rtc_time *);
70extern int mac_set_clock_mmss (unsigned long); 70extern int mac_set_clock_mmss(unsigned long);
71extern int show_mac_interrupts(struct seq_file *, void *); 71extern int show_mac_interrupts(struct seq_file *, void *);
72extern void iop_preinit(void); 72extern void iop_preinit(void);
73extern void iop_init(void); 73extern void iop_init(void);
@@ -82,10 +82,6 @@ extern void mac_mksound(unsigned int, unsigned int);
82 82
83extern void nubus_sweep_video(void); 83extern void nubus_sweep_video(void);
84 84
85/* Mac specific debug functions (in debug.c) */
86extern void mac_debug_init(void);
87extern void mac_debugging_long(int, long);
88
89static void mac_get_model(char *str); 85static void mac_get_model(char *str);
90 86
91static void mac_sched_init(irq_handler_t vector) 87static void mac_sched_init(irq_handler_t vector)
@@ -99,51 +95,52 @@ static void mac_sched_init(irq_handler_t vector)
99 95
100int __init mac_parse_bootinfo(const struct bi_record *record) 96int __init mac_parse_bootinfo(const struct bi_record *record)
101{ 97{
102 int unknown = 0; 98 int unknown = 0;
103 const u_long *data = record->data; 99 const u_long *data = record->data;
104 100
105 switch (record->tag) { 101 switch (record->tag) {
106 case BI_MAC_MODEL: 102 case BI_MAC_MODEL:
107 mac_bi_data.id = *data; 103 mac_bi_data.id = *data;
108 break; 104 break;
109 case BI_MAC_VADDR: 105 case BI_MAC_VADDR:
110 mac_bi_data.videoaddr = *data; 106 mac_bi_data.videoaddr = *data;
111 break; 107 break;
112 case BI_MAC_VDEPTH: 108 case BI_MAC_VDEPTH:
113 mac_bi_data.videodepth = *data; 109 mac_bi_data.videodepth = *data;
114 break; 110 break;
115 case BI_MAC_VROW: 111 case BI_MAC_VROW:
116 mac_bi_data.videorow = *data; 112 mac_bi_data.videorow = *data;
117 break; 113 break;
118 case BI_MAC_VDIM: 114 case BI_MAC_VDIM:
119 mac_bi_data.dimensions = *data; 115 mac_bi_data.dimensions = *data;
120 break; 116 break;
121 case BI_MAC_VLOGICAL: 117 case BI_MAC_VLOGICAL:
122 mac_bi_data.videological = VIDEOMEMBASE + (*data & ~VIDEOMEMMASK); 118 mac_bi_data.videological = VIDEOMEMBASE + (*data & ~VIDEOMEMMASK);
123 mac_orig_videoaddr = *data; 119 mac_orig_videoaddr = *data;
124 break; 120 break;
125 case BI_MAC_SCCBASE: 121 case BI_MAC_SCCBASE:
126 mac_bi_data.sccbase = *data; 122 mac_bi_data.sccbase = *data;
127 break; 123 break;
128 case BI_MAC_BTIME: 124 case BI_MAC_BTIME:
129 mac_bi_data.boottime = *data; 125 mac_bi_data.boottime = *data;
130 break; 126 break;
131 case BI_MAC_GMTBIAS: 127 case BI_MAC_GMTBIAS:
132 mac_bi_data.gmtbias = *data; 128 mac_bi_data.gmtbias = *data;
133 break; 129 break;
134 case BI_MAC_MEMSIZE: 130 case BI_MAC_MEMSIZE:
135 mac_bi_data.memsize = *data; 131 mac_bi_data.memsize = *data;
136 break; 132 break;
137 case BI_MAC_CPUID: 133 case BI_MAC_CPUID:
138 mac_bi_data.cpuid = *data; 134 mac_bi_data.cpuid = *data;
139 break; 135 break;
140 case BI_MAC_ROMBASE: 136 case BI_MAC_ROMBASE:
141 mac_bi_data.rombase = *data; 137 mac_bi_data.rombase = *data;
142 break; 138 break;
143 default: 139 default:
144 unknown = 1; 140 unknown = 1;
145 } 141 break;
146 return(unknown); 142 }
143 return unknown;
147} 144}
148 145
149/* 146/*
@@ -155,6 +152,7 @@ int __init mac_parse_bootinfo(const struct bi_record *record)
155static void mac_cache_card_flush(int writeback) 152static void mac_cache_card_flush(int writeback)
156{ 153{
157 unsigned long flags; 154 unsigned long flags;
155
158 local_irq_save(flags); 156 local_irq_save(flags);
159 via_flush_cache(); 157 via_flush_cache();
160 local_irq_restore(flags); 158 local_irq_restore(flags);
@@ -162,28 +160,24 @@ static void mac_cache_card_flush(int writeback)
162 160
163void __init config_mac(void) 161void __init config_mac(void)
164{ 162{
165 if (!MACH_IS_MAC) { 163 if (!MACH_IS_MAC)
166 printk(KERN_ERR "ERROR: no Mac, but config_mac() called!! \n"); 164 printk(KERN_ERR "ERROR: no Mac, but config_mac() called!! \n");
167 }
168 165
169 mach_sched_init = mac_sched_init; 166 mach_sched_init = mac_sched_init;
170 mach_init_IRQ = mac_init_IRQ; 167 mach_init_IRQ = mac_init_IRQ;
171 mach_get_model = mac_get_model; 168 mach_get_model = mac_get_model;
172 mach_gettimeoffset = mac_gettimeoffset; 169 mach_gettimeoffset = mac_gettimeoffset;
173#warning move to adb/via init 170#warning move to adb/via init
174#if 0 171#if 0
175 mach_hwclk = mac_hwclk; 172 mach_hwclk = mac_hwclk;
176#endif 173#endif
177 mach_set_clock_mmss = mac_set_clock_mmss; 174 mach_set_clock_mmss = mac_set_clock_mmss;
178 mach_reset = mac_reset; 175 mach_reset = mac_reset;
179 mach_halt = mac_poweroff; 176 mach_halt = mac_poweroff;
180 mach_power_off = mac_poweroff; 177 mach_power_off = mac_poweroff;
181 mach_max_dma_address = 0xffffffff; 178 mach_max_dma_address = 0xffffffff;
182#if 0
183 mach_debug_init = mac_debug_init;
184#endif
185#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 179#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
186 mach_beep = mac_mksound; 180 mach_beep = mac_mksound;
187#endif 181#endif
188#ifdef CONFIG_HEARTBEAT 182#ifdef CONFIG_HEARTBEAT
189#if 0 183#if 0
@@ -199,21 +193,22 @@ void __init config_mac(void)
199 mac_identify(); 193 mac_identify();
200 mac_report_hardware(); 194 mac_report_hardware();
201 195
202 /* AFAIK only the IIci takes a cache card. The IIfx has onboard 196 /*
203 cache ... someone needs to figure out how to tell if it's on or 197 * AFAIK only the IIci takes a cache card. The IIfx has onboard
204 not. */ 198 * cache ... someone needs to figure out how to tell if it's on or
199 * not.
200 */
205 201
206 if (macintosh_config->ident == MAC_MODEL_IICI 202 if (macintosh_config->ident == MAC_MODEL_IICI
207 || macintosh_config->ident == MAC_MODEL_IIFX) { 203 || macintosh_config->ident == MAC_MODEL_IIFX)
208 mach_l2_flush = mac_cache_card_flush; 204 mach_l2_flush = mac_cache_card_flush;
209 }
210 205
211 /* 206 /*
212 * Check for machine specific fixups. 207 * Check for machine specific fixups.
213 */ 208 */
214 209
215#ifdef OLD_NUBUS_CODE 210#ifdef OLD_NUBUS_CODE
216 nubus_sweep_video(); 211 nubus_sweep_video();
217#endif 212#endif
218} 213}
219 214
@@ -233,8 +228,7 @@ void __init config_mac(void)
233struct mac_model *macintosh_config; 228struct mac_model *macintosh_config;
234EXPORT_SYMBOL(macintosh_config); 229EXPORT_SYMBOL(macintosh_config);
235 230
236static struct mac_model mac_data_table[]= 231static struct mac_model mac_data_table[] = {
237{
238 /* 232 /*
239 * We'll pretend to be a Macintosh II, that's pretty safe. 233 * We'll pretend to be a Macintosh II, that's pretty safe.
240 */ 234 */
@@ -784,12 +778,12 @@ void mac_identify(void)
784 if (!model) { 778 if (!model) {
785 /* no bootinfo model id -> NetBSD booter was used! */ 779 /* no bootinfo model id -> NetBSD booter was used! */
786 /* XXX FIXME: breaks for model > 31 */ 780 /* XXX FIXME: breaks for model > 31 */
787 model=(mac_bi_data.cpuid>>2)&63; 781 model = (mac_bi_data.cpuid >> 2) & 63;
788 printk (KERN_WARNING "No bootinfo model ID, using cpuid instead (hey, use Penguin!)\n"); 782 printk(KERN_WARNING "No bootinfo model ID, using cpuid instead (hey, use Penguin!)\n");
789 } 783 }
790 784
791 macintosh_config = mac_data_table; 785 macintosh_config = mac_data_table;
792 for (m = macintosh_config ; m->ident != -1 ; m++) { 786 for (m = macintosh_config; m->ident != -1; m++) {
793 if (m->ident == model) { 787 if (m->ident == model) {
794 macintosh_config = m; 788 macintosh_config = m;
795 break; 789 break;
@@ -801,27 +795,26 @@ void mac_identify(void)
801 /* the serial ports set to "Faster" mode in MacOS. */ 795 /* the serial ports set to "Faster" mode in MacOS. */
802 796
803 iop_preinit(); 797 iop_preinit();
804 mac_debug_init();
805 798
806 printk (KERN_INFO "Detected Macintosh model: %d \n", model); 799 printk(KERN_INFO "Detected Macintosh model: %d \n", model);
807 800
808 /* 801 /*
809 * Report booter data: 802 * Report booter data:
810 */ 803 */
811 printk (KERN_DEBUG " Penguin bootinfo data:\n"); 804 printk(KERN_DEBUG " Penguin bootinfo data:\n");
812 printk (KERN_DEBUG " Video: addr 0x%lx row 0x%lx depth %lx dimensions %ld x %ld\n", 805 printk(KERN_DEBUG " Video: addr 0x%lx row 0x%lx depth %lx dimensions %ld x %ld\n",
813 mac_bi_data.videoaddr, mac_bi_data.videorow, 806 mac_bi_data.videoaddr, mac_bi_data.videorow,
814 mac_bi_data.videodepth, mac_bi_data.dimensions & 0xFFFF, 807 mac_bi_data.videodepth, mac_bi_data.dimensions & 0xFFFF,
815 mac_bi_data.dimensions >> 16); 808 mac_bi_data.dimensions >> 16);
816 printk (KERN_DEBUG " Videological 0x%lx phys. 0x%lx, SCC at 0x%lx \n", 809 printk(KERN_DEBUG " Videological 0x%lx phys. 0x%lx, SCC at 0x%lx \n",
817 mac_bi_data.videological, mac_orig_videoaddr, 810 mac_bi_data.videological, mac_orig_videoaddr,
818 mac_bi_data.sccbase); 811 mac_bi_data.sccbase);
819 printk (KERN_DEBUG " Boottime: 0x%lx GMTBias: 0x%lx \n", 812 printk(KERN_DEBUG " Boottime: 0x%lx GMTBias: 0x%lx \n",
820 mac_bi_data.boottime, mac_bi_data.gmtbias); 813 mac_bi_data.boottime, mac_bi_data.gmtbias);
821 printk (KERN_DEBUG " Machine ID: %ld CPUid: 0x%lx memory size: 0x%lx \n", 814 printk(KERN_DEBUG " Machine ID: %ld CPUid: 0x%lx memory size: 0x%lx \n",
822 mac_bi_data.id, mac_bi_data.cpuid, mac_bi_data.memsize); 815 mac_bi_data.id, mac_bi_data.cpuid, mac_bi_data.memsize);
823#if 0 816#if 0
824 printk ("Ramdisk: addr 0x%lx size 0x%lx\n", 817 printk("Ramdisk: addr 0x%lx size 0x%lx\n",
825 m68k_ramdisk.addr, m68k_ramdisk.size); 818 m68k_ramdisk.addr, m68k_ramdisk.size);
826#endif 819#endif
827 820
@@ -830,22 +823,22 @@ void mac_identify(void)
830 */ 823 */
831 switch (macintosh_config->scsi_type) { 824 switch (macintosh_config->scsi_type) {
832 case MAC_SCSI_OLD: 825 case MAC_SCSI_OLD:
833 MACHW_SET(MAC_SCSI_80); 826 MACHW_SET(MAC_SCSI_80);
834 break; 827 break;
835 case MAC_SCSI_QUADRA: 828 case MAC_SCSI_QUADRA:
836 case MAC_SCSI_QUADRA2: 829 case MAC_SCSI_QUADRA2:
837 case MAC_SCSI_QUADRA3: 830 case MAC_SCSI_QUADRA3:
838 MACHW_SET(MAC_SCSI_96); 831 MACHW_SET(MAC_SCSI_96);
839 if ((macintosh_config->ident == MAC_MODEL_Q900) || 832 if ((macintosh_config->ident == MAC_MODEL_Q900) ||
840 (macintosh_config->ident == MAC_MODEL_Q950)) 833 (macintosh_config->ident == MAC_MODEL_Q950))
841 MACHW_SET(MAC_SCSI_96_2); 834 MACHW_SET(MAC_SCSI_96_2);
842 break; 835 break;
843 default: 836 default:
844 printk(KERN_WARNING "config.c: wtf: unknown scsi, using 53c80\n"); 837 printk(KERN_WARNING "config.c: wtf: unknown scsi, using 53c80\n");
845 MACHW_SET(MAC_SCSI_80); 838 MACHW_SET(MAC_SCSI_80);
846 break; 839 break;
847
848 } 840 }
841
849 iop_init(); 842 iop_init();
850 via_init(); 843 via_init();
851 oss_init(); 844 oss_init();
@@ -860,6 +853,6 @@ void mac_report_hardware(void)
860 853
861static void mac_get_model(char *str) 854static void mac_get_model(char *str)
862{ 855{
863 strcpy(str,"Macintosh "); 856 strcpy(str, "Macintosh ");
864 strcat(str, macintosh_config->name); 857 strcat(str, macintosh_config->name);
865} 858}
diff --git a/arch/m68k/mac/debug.c b/arch/m68k/mac/debug.c
index 4eeb09dc0e8f..7a5bed5bdc57 100644
--- a/arch/m68k/mac/debug.c
+++ b/arch/m68k/mac/debug.c
@@ -27,10 +27,6 @@
27#include <asm/machw.h> 27#include <asm/machw.h>
28#include <asm/macints.h> 28#include <asm/macints.h>
29 29
30extern char m68k_debug_device[];
31
32extern struct compat_bootinfo compat_boot_info;
33
34extern unsigned long mac_videobase; 30extern unsigned long mac_videobase;
35extern unsigned long mac_videodepth; 31extern unsigned long mac_videodepth;
36extern unsigned long mac_rowbytes; 32extern unsigned long mac_rowbytes;
@@ -52,7 +48,7 @@ extern void mac_serial_print(const char *);
52 */ 48 */
53 49
54#ifdef DEBUG_SCREEN 50#ifdef DEBUG_SCREEN
55static int peng=0, line=0; 51static int peng, line;
56#endif 52#endif
57 53
58void mac_debugging_short(int pos, short num) 54void mac_debugging_short(int pos, short num)
@@ -74,15 +70,14 @@ void mac_debugging_short(int pos, short num)
74 } 70 }
75 71
76 /* calculate current offset */ 72 /* calculate current offset */
77 pengoffset=(unsigned char *)(mac_videobase+(150+line*2)*mac_rowbytes) 73 pengoffset = (unsigned char *)mac_videobase +
78 +80*peng; 74 (150+line*2) * mac_rowbytes) + 80 * peng;
79 75
80 pptr=pengoffset; 76 pptr = pengoffset;
81 77
82 for(i=0;i<8*sizeof(short);i++) /* # of bits */ 78 for (i = 0; i < 8 * sizeof(short); i++) { /* # of bits */
83 {
84 /* value mask for bit i, reverse order */ 79 /* value mask for bit i, reverse order */
85 *pptr++ = (num & ( 1 << (8*sizeof(short)-i-1) ) ? 0xFF : 0x00); 80 *pptr++ = (num & (1 << (8*sizeof(short)-i-1)) ? 0xFF : 0x00);
86 } 81 }
87 82
88 peng++; 83 peng++;
@@ -115,11 +110,10 @@ void mac_debugging_long(int pos, long addr)
115 pengoffset=(unsigned char *)(mac_videobase+(150+line*2)*mac_rowbytes) 110 pengoffset=(unsigned char *)(mac_videobase+(150+line*2)*mac_rowbytes)
116 +80*peng; 111 +80*peng;
117 112
118 pptr=pengoffset; 113 pptr = pengoffset;
119 114
120 for(i=0;i<8*sizeof(long);i++) /* # of bits */ 115 for (i = 0; i < 8 * sizeof(long); i++) { /* # of bits */
121 { 116 *pptr++ = (addr & (1 << (8*sizeof(long)-i-1)) ? 0xFF : 0x00);
122 *pptr++ = (addr & ( 1 << (8*sizeof(long)-i-1) ) ? 0xFF : 0x00);
123 } 117 }
124 118
125 peng++; 119 peng++;
@@ -136,16 +130,15 @@ void mac_debugging_long(int pos, long addr)
136 * TODO: serial debug code 130 * TODO: serial debug code
137 */ 131 */
138 132
139struct mac_SCC 133struct mac_SCC {
140 { 134 u_char cha_b_ctrl;
141 u_char cha_b_ctrl; 135 u_char char_dummy1;
142 u_char char_dummy1; 136 u_char cha_a_ctrl;
143 u_char cha_a_ctrl; 137 u_char char_dummy2;
144 u_char char_dummy2; 138 u_char cha_b_data;
145 u_char cha_b_data; 139 u_char char_dummy3;
146 u_char char_dummy3; 140 u_char cha_a_data;
147 u_char cha_a_data; 141};
148 };
149 142
150# define scc (*((volatile struct mac_SCC*)mac_bi_data.sccbase)) 143# define scc (*((volatile struct mac_SCC*)mac_bi_data.sccbase))
151 144
@@ -158,9 +151,9 @@ int mac_SCC_reset_done;
158static int scc_port = -1; 151static int scc_port = -1;
159 152
160static struct console mac_console_driver = { 153static struct console mac_console_driver = {
161 .name = "debug", 154 .name = "debug",
162 .flags = CON_PRINTBUFFER, 155 .flags = CON_PRINTBUFFER,
163 .index = -1, 156 .index = -1,
164}; 157};
165 158
166/* 159/*
@@ -178,8 +171,8 @@ static struct console mac_console_driver = {
178 * this driver if Mac. 171 * this driver if Mac.
179 */ 172 */
180 173
181void mac_debug_console_write (struct console *co, const char *str, 174void mac_debug_console_write(struct console *co, const char *str,
182 unsigned int count) 175 unsigned int count)
183{ 176{
184 mac_serial_print(str); 177 mac_serial_print(str);
185} 178}
@@ -190,48 +183,50 @@ void mac_debug_console_write (struct console *co, const char *str,
190 183
191#define uSEC 1 184#define uSEC 1
192 185
193static inline void mac_sccb_out (char c) 186static inline void mac_sccb_out(char c)
194{ 187{
195 int i; 188 int i;
196 do { 189
197 for( i = uSEC; i > 0; --i ) 190 do {
191 for (i = uSEC; i > 0; --i)
192 barrier();
193 } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */
194 for (i = uSEC; i > 0; --i)
198 barrier(); 195 barrier();
199 } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */ 196 scc.cha_b_data = c;
200 for( i = uSEC; i > 0; --i )
201 barrier();
202 scc.cha_b_data = c;
203} 197}
204 198
205static inline void mac_scca_out (char c) 199static inline void mac_scca_out(char c)
206{ 200{
207 int i; 201 int i;
208 do { 202
209 for( i = uSEC; i > 0; --i ) 203 do {
204 for (i = uSEC; i > 0; --i)
205 barrier();
206 } while (!(scc.cha_a_ctrl & 0x04)); /* wait for tx buf empty */
207 for (i = uSEC; i > 0; --i)
210 barrier(); 208 barrier();
211 } while (!(scc.cha_a_ctrl & 0x04)); /* wait for tx buf empty */ 209 scc.cha_a_data = c;
212 for( i = uSEC; i > 0; --i )
213 barrier();
214 scc.cha_a_data = c;
215} 210}
216 211
217void mac_sccb_console_write (struct console *co, const char *str, 212void mac_sccb_console_write(struct console *co, const char *str,
218 unsigned int count) 213 unsigned int count)
219{ 214{
220 while (count--) { 215 while (count--) {
221 if (*str == '\n') 216 if (*str == '\n')
222 mac_sccb_out( '\r' ); 217 mac_sccb_out('\r');
223 mac_sccb_out( *str++ ); 218 mac_sccb_out(*str++);
224 } 219 }
225} 220}
226 221
227void mac_scca_console_write (struct console *co, const char *str, 222void mac_scca_console_write(struct console *co, const char *str,
228 unsigned int count) 223 unsigned int count)
229{ 224{
230 while (count--) { 225 while (count--) {
231 if (*str == '\n') 226 if (*str == '\n')
232 mac_scca_out( '\r' ); 227 mac_scca_out('\r');
233 mac_scca_out( *str++ ); 228 mac_scca_out(*str++);
234 } 229 }
235} 230}
236 231
237 232
@@ -239,41 +234,41 @@ void mac_scca_console_write (struct console *co, const char *str,
239 * SCC serial ports. They're used by the debugging interface, kgdb, and the 234 * SCC serial ports. They're used by the debugging interface, kgdb, and the
240 * serial console code. */ 235 * serial console code. */
241#define SCCB_WRITE(reg,val) \ 236#define SCCB_WRITE(reg,val) \
242 do { \ 237 do { \
243 int i; \ 238 int i; \
244 scc.cha_b_ctrl = (reg); \ 239 scc.cha_b_ctrl = (reg); \
245 for( i = uSEC; i > 0; --i ) \ 240 for (i = uSEC; i > 0; --i) \
246 barrier(); \ 241 barrier(); \
247 scc.cha_b_ctrl = (val); \ 242 scc.cha_b_ctrl = (val); \
248 for( i = uSEC; i > 0; --i ) \ 243 for (i = uSEC; i > 0; --i) \
249 barrier(); \ 244 barrier(); \
250 } while(0) 245 } while(0)
251 246
252#define SCCA_WRITE(reg,val) \ 247#define SCCA_WRITE(reg,val) \
253 do { \ 248 do { \
254 int i; \ 249 int i; \
255 scc.cha_a_ctrl = (reg); \ 250 scc.cha_a_ctrl = (reg); \
256 for( i = uSEC; i > 0; --i ) \ 251 for (i = uSEC; i > 0; --i) \
257 barrier(); \ 252 barrier(); \
258 scc.cha_a_ctrl = (val); \ 253 scc.cha_a_ctrl = (val); \
259 for( i = uSEC; i > 0; --i ) \ 254 for (i = uSEC; i > 0; --i) \
260 barrier(); \ 255 barrier(); \
261 } while(0) 256 } while(0)
262 257
263/* loops_per_jiffy isn't initialized yet, so we can't use udelay(). This does a 258/* loops_per_jiffy isn't initialized yet, so we can't use udelay(). This does a
264 * delay of ~ 60us. */ 259 * delay of ~ 60us. */
265/* Mac: loops_per_jiffy min. 19000 ^= .5 us; MFPDELAY was 0.6 us*/ 260/* Mac: loops_per_jiffy min. 19000 ^= .5 us; MFPDELAY was 0.6 us*/
266#define LONG_DELAY() \ 261#define LONG_DELAY() \
267 do { \ 262 do { \
268 int i; \ 263 int i; \
269 for( i = 60*uSEC; i > 0; --i ) \ 264 for (i = 60*uSEC; i > 0; --i) \
270 barrier(); \ 265 barrier(); \
271 } while(0) 266 } while(0)
272 267
273#ifndef CONFIG_SERIAL_CONSOLE 268#ifndef CONFIG_SERIAL_CONSOLE
274static void __init mac_init_scc_port( int cflag, int port ) 269static void __init mac_init_scc_port(int cflag, int port)
275#else 270#else
276void mac_init_scc_port( int cflag, int port ) 271void mac_init_scc_port(int cflag, int port)
277#endif 272#endif
278{ 273{
279 extern int mac_SCC_reset_done; 274 extern int mac_SCC_reset_done;
@@ -292,106 +287,102 @@ void mac_init_scc_port( int cflag, int port )
292 /* reg12 (BRG low) */ 287 /* reg12 (BRG low) */
293 { 94, 62, 46, 22, 10, 4, 1, 0, 0 }; 288 { 94, 62, 46, 22, 10, 4, 1, 0, 0 };
294 289
295 int baud = cflag & CBAUD; 290 int baud = cflag & CBAUD;
296 int clksrc, clkmode, div, reg3, reg5; 291 int clksrc, clkmode, div, reg3, reg5;
297 292
298 if (cflag & CBAUDEX) 293 if (cflag & CBAUDEX)
299 baud += B38400; 294 baud += B38400;
300 if (baud < B1200 || baud > B38400+2) 295 if (baud < B1200 || baud > B38400+2)
301 baud = B9600; /* use default 9600bps for non-implemented rates */ 296 baud = B9600; /* use default 9600bps for non-implemented rates */
302 baud -= B1200; /* tables starts at 1200bps */ 297 baud -= B1200; /* tables starts at 1200bps */
303 298
304 clksrc = clksrc_table[baud]; 299 clksrc = clksrc_table[baud];
305 clkmode = clkmode_table[baud]; 300 clkmode = clkmode_table[baud];
306 div = div_table[baud]; 301 div = div_table[baud];
307 302
308 reg3 = (((cflag & CSIZE) == CS8) ? 0xc0 : 0x40); 303 reg3 = (((cflag & CSIZE) == CS8) ? 0xc0 : 0x40);
309 reg5 = (((cflag & CSIZE) == CS8) ? 0x60 : 0x20) | 0x82 /* assert DTR/RTS */; 304 reg5 = (((cflag & CSIZE) == CS8) ? 0x60 : 0x20) | 0x82 /* assert DTR/RTS */;
310 305
311 if (port == 1) { 306 if (port == 1) {
312 (void)scc.cha_b_ctrl; /* reset reg pointer */ 307 (void)scc.cha_b_ctrl; /* reset reg pointer */
313 SCCB_WRITE( 9, 0xc0 ); /* reset */ 308 SCCB_WRITE(9, 0xc0); /* reset */
314 LONG_DELAY(); /* extra delay after WR9 access */ 309 LONG_DELAY(); /* extra delay after WR9 access */
315 SCCB_WRITE( 4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 | 310 SCCB_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 |
311 0x04 /* 1 stopbit */ |
312 clkmode);
313 SCCB_WRITE(3, reg3);
314 SCCB_WRITE(5, reg5);
315 SCCB_WRITE(9, 0); /* no interrupts */
316 LONG_DELAY(); /* extra delay after WR9 access */
317 SCCB_WRITE(10, 0); /* NRZ mode */
318 SCCB_WRITE(11, clksrc); /* main clock source */
319 SCCB_WRITE(12, div); /* BRG value */
320 SCCB_WRITE(13, 0); /* BRG high byte */
321 SCCB_WRITE(14, 1);
322 SCCB_WRITE(3, reg3 | 1);
323 SCCB_WRITE(5, reg5 | 8);
324 } else if (port == 0) {
325 (void)scc.cha_a_ctrl; /* reset reg pointer */
326 SCCA_WRITE(9, 0xc0); /* reset */
327 LONG_DELAY(); /* extra delay after WR9 access */
328 SCCA_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 |
316 0x04 /* 1 stopbit */ | 329 0x04 /* 1 stopbit */ |
317 clkmode ); 330 clkmode);
318 SCCB_WRITE( 3, reg3 ); 331 SCCA_WRITE(3, reg3);
319 SCCB_WRITE( 5, reg5 ); 332 SCCA_WRITE(5, reg5);
320 SCCB_WRITE( 9, 0 ); /* no interrupts */ 333 SCCA_WRITE(9, 0); /* no interrupts */
321 LONG_DELAY(); /* extra delay after WR9 access */ 334 LONG_DELAY(); /* extra delay after WR9 access */
322 SCCB_WRITE( 10, 0 ); /* NRZ mode */ 335 SCCA_WRITE(10, 0); /* NRZ mode */
323 SCCB_WRITE( 11, clksrc ); /* main clock source */ 336 SCCA_WRITE(11, clksrc); /* main clock source */
324 SCCB_WRITE( 12, div ); /* BRG value */ 337 SCCA_WRITE(12, div); /* BRG value */
325 SCCB_WRITE( 13, 0 ); /* BRG high byte */ 338 SCCA_WRITE(13, 0); /* BRG high byte */
326 SCCB_WRITE( 14, 1 ); 339 SCCA_WRITE(14, 1);
327 SCCB_WRITE( 3, reg3 | 1 ); 340 SCCA_WRITE(3, reg3 | 1);
328 SCCB_WRITE( 5, reg5 | 8 ); 341 SCCA_WRITE(5, reg5 | 8);
329 } else if (port == 0) { 342 }
330 (void)scc.cha_a_ctrl; /* reset reg pointer */ 343
331 SCCA_WRITE( 9, 0xc0 ); /* reset */ 344 mac_SCC_reset_done = 1;
332 LONG_DELAY(); /* extra delay after WR9 access */ 345 mac_SCC_init_done = 1;
333 SCCA_WRITE( 4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 |
334 0x04 /* 1 stopbit */ |
335 clkmode );
336 SCCA_WRITE( 3, reg3 );
337 SCCA_WRITE( 5, reg5 );
338 SCCA_WRITE( 9, 0 ); /* no interrupts */
339 LONG_DELAY(); /* extra delay after WR9 access */
340 SCCA_WRITE( 10, 0 ); /* NRZ mode */
341 SCCA_WRITE( 11, clksrc ); /* main clock source */
342 SCCA_WRITE( 12, div ); /* BRG value */
343 SCCA_WRITE( 13, 0 ); /* BRG high byte */
344 SCCA_WRITE( 14, 1 );
345 SCCA_WRITE( 3, reg3 | 1 );
346 SCCA_WRITE( 5, reg5 | 8 );
347 }
348
349 mac_SCC_reset_done = 1;
350 mac_SCC_init_done = 1;
351} 346}
352#endif /* DEBUG_SERIAL */ 347#endif /* DEBUG_SERIAL */
353 348
354void mac_init_scca_port( int cflag ) 349void mac_init_scca_port(int cflag)
355{ 350{
356 mac_init_scc_port(cflag, 0); 351 mac_init_scc_port(cflag, 0);
357} 352}
358 353
359void mac_init_sccb_port( int cflag ) 354void mac_init_sccb_port(int cflag)
360{ 355{
361 mac_init_scc_port(cflag, 1); 356 mac_init_scc_port(cflag, 1);
362} 357}
363 358
364void __init mac_debug_init(void) 359static int __init mac_debug_setup(char *arg)
365{ 360{
361 if (!MACH_IS_MAC)
362 return 0;
363
366#ifdef DEBUG_SERIAL 364#ifdef DEBUG_SERIAL
367 if ( !strcmp( m68k_debug_device, "ser" ) 365 if (!strcmp(arg, "ser") || !strcmp(arg, "ser1")) {
368 || !strcmp( m68k_debug_device, "ser1" )) { 366 /* Mac modem port */
369 /* Mac modem port */ 367 mac_init_scc_port(B9600|CS8, 0);
370 mac_init_scc_port( B9600|CS8, 0 ); 368 mac_console_driver.write = mac_scca_console_write;
371 mac_console_driver.write = mac_scca_console_write; 369 scc_port = 0;
372 scc_port = 0; 370 } else if (!strcmp(arg, "ser2")) {
373 } 371 /* Mac printer port */
374 else if (!strcmp( m68k_debug_device, "ser2" )) { 372 mac_init_scc_port(B9600|CS8, 1);
375 /* Mac printer port */ 373 mac_console_driver.write = mac_sccb_console_write;
376 mac_init_scc_port( B9600|CS8, 1 ); 374 scc_port = 1;
377 mac_console_driver.write = mac_sccb_console_write; 375 }
378 scc_port = 1;
379 }
380#endif 376#endif
381#ifdef DEBUG_HEADS 377#ifdef DEBUG_HEADS
382 if ( !strcmp( m68k_debug_device, "scn" ) 378 if (!strcmp(arg, "scn") || !strcmp(arg, "con")) {
383 || !strcmp( m68k_debug_device, "con" )) { 379 /* display, using head.S console routines */
384 /* display, using head.S console routines */ 380 mac_console_driver.write = mac_debug_console_write;
385 mac_console_driver.write = mac_debug_console_write; 381 }
386 }
387#endif 382#endif
388 if (mac_console_driver.write) 383 if (mac_console_driver.write)
389 register_console(&mac_console_driver); 384 register_console(&mac_console_driver);
385 return 0;
390} 386}
391 387
392/* 388early_param("debug", mac_debug_setup);
393 * Local variables:
394 * c-indent-level: 4
395 * tab-width: 8
396 * End:
397 */
diff --git a/arch/m68k/mac/oss.c b/arch/m68k/mac/oss.c
index 63690819565a..d7be16917efd 100644
--- a/arch/m68k/mac/oss.c
+++ b/arch/m68k/mac/oss.c
@@ -109,13 +109,11 @@ irqreturn_t oss_irq(int irq, void *dev_id)
109 /* FIXME: how do you clear a pending IRQ? */ 109 /* FIXME: how do you clear a pending IRQ? */
110 110
111 if (events & OSS_IP_SOUND) { 111 if (events & OSS_IP_SOUND) {
112 /* FIXME: call sound handler */
113 oss->irq_pending &= ~OSS_IP_SOUND; 112 oss->irq_pending &= ~OSS_IP_SOUND;
113 /* FIXME: call sound handler */
114 } else if (events & OSS_IP_SCSI) { 114 } else if (events & OSS_IP_SCSI) {
115 oss->irq_level[OSS_SCSI] = OSS_IRQLEV_DISABLED;
116 m68k_handle_int(IRQ_MAC_SCSI);
117 oss->irq_pending &= ~OSS_IP_SCSI; 115 oss->irq_pending &= ~OSS_IP_SCSI;
118 oss->irq_level[OSS_SCSI] = OSS_IRQLEV_SCSI; 116 m68k_handle_int(IRQ_MAC_SCSI);
119 } else { 117 } else {
120 /* FIXME: error check here? */ 118 /* FIXME: error check here? */
121 } 119 }
@@ -143,14 +141,16 @@ irqreturn_t oss_nubus_irq(int irq, void *dev_id)
143#endif 141#endif
144 /* There are only six slots on the OSS, not seven */ 142 /* There are only six slots on the OSS, not seven */
145 143
146 for (i = 0, irq_bit = 1 ; i < 6 ; i++, irq_bit <<= 1) { 144 i = 6;
145 irq_bit = 0x40;
146 do {
147 --i;
148 irq_bit >>= 1;
147 if (events & irq_bit) { 149 if (events & irq_bit) {
148 oss->irq_level[i] = OSS_IRQLEV_DISABLED;
149 m68k_handle_int(NUBUS_SOURCE_BASE + i);
150 oss->irq_pending &= ~irq_bit; 150 oss->irq_pending &= ~irq_bit;
151 oss->irq_level[i] = OSS_IRQLEV_NUBUS; 151 m68k_handle_int(NUBUS_SOURCE_BASE + i);
152 } 152 }
153 } 153 } while(events & (irq_bit - 1));
154 return IRQ_HANDLED; 154 return IRQ_HANDLED;
155} 155}
156 156
diff --git a/arch/m68k/mac/psc.c b/arch/m68k/mac/psc.c
index 15378a5878c9..d66f723b17c3 100644
--- a/arch/m68k/mac/psc.c
+++ b/arch/m68k/mac/psc.c
@@ -131,11 +131,8 @@ irqreturn_t psc_irq(int irq, void *dev_id)
131{ 131{
132 int pIFR = pIFRbase + ((int) dev_id); 132 int pIFR = pIFRbase + ((int) dev_id);
133 int pIER = pIERbase + ((int) dev_id); 133 int pIER = pIERbase + ((int) dev_id);
134 int base_irq; 134 int irq_num;
135 int irq_bit,i; 135 unsigned char irq_bit, events;
136 unsigned char events;
137
138 base_irq = irq << 3;
139 136
140#ifdef DEBUG_IRQS 137#ifdef DEBUG_IRQS
141 printk("psc_irq: irq %d pIFR = 0x%02X pIER = 0x%02X\n", 138 printk("psc_irq: irq %d pIFR = 0x%02X pIER = 0x%02X\n",
@@ -146,14 +143,16 @@ irqreturn_t psc_irq(int irq, void *dev_id)
146 if (!events) 143 if (!events)
147 return IRQ_NONE; 144 return IRQ_NONE;
148 145
149 for (i = 0, irq_bit = 1 ; i < 4 ; i++, irq_bit <<= 1) { 146 irq_num = irq << 3;
150 if (events & irq_bit) { 147 irq_bit = 1;
151 psc_write_byte(pIER, irq_bit); 148 do {
152 m68k_handle_int(base_irq + i); 149 if (events & irq_bit) {
153 psc_write_byte(pIFR, irq_bit); 150 psc_write_byte(pIFR, irq_bit);
154 psc_write_byte(pIER, irq_bit | 0x80); 151 m68k_handle_int(irq_num);
155 } 152 }
156 } 153 irq_num++;
154 irq_bit <<= 1;
155 } while (events >= irq_bit);
157 return IRQ_HANDLED; 156 return IRQ_HANDLED;
158} 157}
159 158
diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c
index e27735be2924..d5cac72eb3db 100644
--- a/arch/m68k/mac/via.c
+++ b/arch/m68k/mac/via.c
@@ -13,6 +13,10 @@
13 * for info. A full-text web search on 6522 AND VIA will probably also 13 * for info. A full-text web search on 6522 AND VIA will probably also
14 * net some usefulness. <cananian@alumni.princeton.edu> 20apr1999 14 * net some usefulness. <cananian@alumni.princeton.edu> 20apr1999
15 * 15 *
16 * Additional data is here (the SY6522 was used in the Mac II etc):
17 * http://www.6502.org/documents/datasheets/synertek/synertek_sy6522.pdf
18 * http://www.6502.org/documents/datasheets/synertek/synertek_sy6522_programming_reference.pdf
19 *
16 * PRAM/RTC access algorithms are from the NetBSD RTC toolkit version 1.08b 20 * PRAM/RTC access algorithms are from the NetBSD RTC toolkit version 1.08b
17 * by Erik Vogan and adapted to Linux by Joshua M. Thompson (funaho@jurai.org) 21 * by Erik Vogan and adapted to Linux by Joshua M. Thompson (funaho@jurai.org)
18 * 22 *
@@ -37,7 +41,7 @@ volatile __u8 *via1, *via2;
37/* See note in mac_via.h about how this is possibly not useful */ 41/* See note in mac_via.h about how this is possibly not useful */
38volatile long *via_memory_bogon=(long *)&via_memory_bogon; 42volatile long *via_memory_bogon=(long *)&via_memory_bogon;
39#endif 43#endif
40int rbv_present,via_alt_mapping; 44int rbv_present, via_alt_mapping;
41__u8 rbv_clear; 45__u8 rbv_clear;
42 46
43/* 47/*
@@ -60,7 +64,19 @@ static int gIER,gIFR,gBufA,gBufB;
60#define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF) 64#define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF)
61#define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8) 65#define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8)
62 66
63static int nubus_active; 67/* To disable a NuBus slot on Quadras we make the slot IRQ lines outputs, set
68 * high. On RBV we just use the slot interrupt enable register. On Macs with
69 * genuine VIA chips we must use nubus_disabled to keep track of disabled slot
70 * interrupts. When any slot IRQ is disabled we mask the (edge triggered) CA1
71 * or "SLOTS" interrupt. When no slot is disabled, we unmask the CA1 interrupt.
72 * So, on genuine VIAs, having more than one NuBus IRQ can mean trouble,
73 * because closing one of those drivers can mask all of the NuBus interrupts.
74 * Also, since we can't mask the unregistered slot IRQs on genuine VIAs, it's
75 * possible to get interrupts from cards that MacOS or the ROM has configured
76 * but we have not. FWIW, "Designing Cards and Drivers for Macintosh II and
77 * Macintosh SE", page 9-8, says, a slot IRQ with no driver would crash MacOS.
78 */
79static u8 nubus_disabled;
64 80
65void via_debug_dump(void); 81void via_debug_dump(void);
66irqreturn_t via1_irq(int, void *); 82irqreturn_t via1_irq(int, void *);
@@ -138,11 +154,11 @@ void __init via_init(void)
138 154
139 printk(KERN_INFO "VIA2 at %p is ", via2); 155 printk(KERN_INFO "VIA2 at %p is ", via2);
140 if (rbv_present) { 156 if (rbv_present) {
141 printk(KERN_INFO "an RBV\n"); 157 printk("an RBV\n");
142 } else if (oss_present) { 158 } else if (oss_present) {
143 printk(KERN_INFO "an OSS\n"); 159 printk("an OSS\n");
144 } else { 160 } else {
145 printk(KERN_INFO "a 6522 or clone\n"); 161 printk("a 6522 or clone\n");
146 } 162 }
147 163
148#ifdef DEBUG_VIA 164#ifdef DEBUG_VIA
@@ -163,6 +179,7 @@ void __init via_init(void)
163 via1[vT2CL] = 0; 179 via1[vT2CL] = 0;
164 via1[vT2CH] = 0; 180 via1[vT2CH] = 0;
165 via1[vACR] &= 0x3F; 181 via1[vACR] &= 0x3F;
182 via1[vACR] &= ~0x03; /* disable port A & B latches */
166 183
167 /* 184 /*
168 * SE/30: disable video IRQ 185 * SE/30: disable video IRQ
@@ -193,8 +210,14 @@ void __init via_init(void)
193 /* that the IIfx emulates this alternate mapping using the OSS. */ 210 /* that the IIfx emulates this alternate mapping using the OSS. */
194 211
195 switch(macintosh_config->ident) { 212 switch(macintosh_config->ident) {
213 case MAC_MODEL_P475:
214 case MAC_MODEL_P475F:
215 case MAC_MODEL_P575:
216 case MAC_MODEL_Q605:
217 case MAC_MODEL_Q605_ACC:
196 case MAC_MODEL_C610: 218 case MAC_MODEL_C610:
197 case MAC_MODEL_Q610: 219 case MAC_MODEL_Q610:
220 case MAC_MODEL_Q630:
198 case MAC_MODEL_C650: 221 case MAC_MODEL_C650:
199 case MAC_MODEL_Q650: 222 case MAC_MODEL_Q650:
200 case MAC_MODEL_Q700: 223 case MAC_MODEL_Q700:
@@ -228,6 +251,22 @@ void __init via_init(void)
228 via2[vT2CL] = 0; 251 via2[vT2CL] = 0;
229 via2[vT2CH] = 0; 252 via2[vT2CH] = 0;
230 via2[vACR] &= 0x3F; 253 via2[vACR] &= 0x3F;
254 via2[vACR] &= ~0x03; /* disable port A & B latches */
255 }
256
257 /*
258 * Set vPCR for SCSI interrupts (but not on RBV)
259 */
260 if (!rbv_present) {
261 if (macintosh_config->scsi_type == MAC_SCSI_OLD) {
262 /* CB2 (IRQ) indep. input, positive edge */
263 /* CA2 (DRQ) indep. input, positive edge */
264 via2[vPCR] = 0x66;
265 } else {
266 /* CB2 (IRQ) indep. input, negative edge */
267 /* CA2 (DRQ) indep. input, negative edge */
268 via2[vPCR] = 0x22;
269 }
231 } 270 }
232} 271}
233 272
@@ -356,78 +395,75 @@ int via_get_cache_disable(void)
356 395
357void __init via_nubus_init(void) 396void __init via_nubus_init(void)
358{ 397{
359 /* don't set nubus_active = 0 here, it kills the Baboon */
360 /* interrupt that we've already registered. */
361
362 /* unlock nubus transactions */ 398 /* unlock nubus transactions */
363 399
364 if (!rbv_present) { 400 if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
401 (macintosh_config->adb_type != MAC_ADB_PB2)) {
365 /* set the line to be an output on non-RBV machines */ 402 /* set the line to be an output on non-RBV machines */
366 if ((macintosh_config->adb_type != MAC_ADB_PB1) && 403 if (!rbv_present)
367 (macintosh_config->adb_type != MAC_ADB_PB2)) {
368 via2[vDirB] |= 0x02; 404 via2[vDirB] |= 0x02;
369 }
370 }
371 405
372 /* this seems to be an ADB bit on PMU machines */ 406 /* this seems to be an ADB bit on PMU machines */
373 /* according to MkLinux. -- jmt */ 407 /* according to MkLinux. -- jmt */
374
375 if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
376 (macintosh_config->adb_type != MAC_ADB_PB2)) {
377 via2[gBufB] |= 0x02; 408 via2[gBufB] |= 0x02;
378 } 409 }
379 410
380 /* disable nubus slot interrupts. */ 411 /* Disable all the slot interrupts (where possible). */
381 if (rbv_present) { 412
413 switch (macintosh_config->via_type) {
414 case MAC_VIA_II:
415 /* Just make the port A lines inputs. */
416 switch(macintosh_config->ident) {
417 case MAC_MODEL_II:
418 case MAC_MODEL_IIX:
419 case MAC_MODEL_IICX:
420 case MAC_MODEL_SE30:
421 /* The top two bits are RAM size outputs. */
422 via2[vDirA] &= 0xC0;
423 break;
424 default:
425 via2[vDirA] &= 0x80;
426 }
427 break;
428 case MAC_VIA_IIci:
429 /* RBV. Disable all the slot interrupts. SIER works like IER. */
382 via2[rSIER] = 0x7F; 430 via2[rSIER] = 0x7F;
383 via2[rSIER] = nubus_active | 0x80; 431 break;
384 } else { 432 case MAC_VIA_QUADRA:
385 /* These are ADB bits on PMU */ 433 /* Disable the inactive slot interrupts by making those lines outputs. */
386 if ((macintosh_config->adb_type != MAC_ADB_PB1) && 434 if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
387 (macintosh_config->adb_type != MAC_ADB_PB2)) { 435 (macintosh_config->adb_type != MAC_ADB_PB2)) {
388 switch(macintosh_config->ident) 436 via2[vBufA] |= 0x7F;
389 { 437 via2[vDirA] |= 0x7F;
390 case MAC_MODEL_II:
391 case MAC_MODEL_IIX:
392 case MAC_MODEL_IICX:
393 case MAC_MODEL_SE30:
394 via2[vBufA] |= 0x3F;
395 via2[vDirA] = ~nubus_active | 0xc0;
396 break;
397 default:
398 via2[vBufA] = 0xFF;
399 via2[vDirA] = ~nubus_active;
400 }
401 } 438 }
439 break;
402 } 440 }
403} 441}
404 442
405/* 443/*
406 * The generic VIA interrupt routines (shamelessly stolen from Alan Cox's 444 * The generic VIA interrupt routines (shamelessly stolen from Alan Cox's
407 * via6522.c :-), disable/pending masks added. 445 * via6522.c :-), disable/pending masks added.
408 *
409 * The new interrupt architecture in macints.c takes care of a lot of the
410 * gruntwork for us, including tallying the interrupts and calling the
411 * handlers on the linked list. All we need to do here is basically generate
412 * the machspec interrupt number after clearing the interrupt.
413 */ 446 */
414 447
415irqreturn_t via1_irq(int irq, void *dev_id) 448irqreturn_t via1_irq(int irq, void *dev_id)
416{ 449{
417 int irq_bit, i; 450 int irq_num;
418 unsigned char events, mask; 451 unsigned char irq_bit, events;
419 452
420 mask = via1[vIER] & 0x7F; 453 events = via1[vIFR] & via1[vIER] & 0x7F;
421 if (!(events = via1[vIFR] & mask)) 454 if (!events)
422 return IRQ_NONE; 455 return IRQ_NONE;
423 456
424 for (i = 0, irq_bit = 1 ; i < 7 ; i++, irq_bit <<= 1) 457 irq_num = VIA1_SOURCE_BASE;
458 irq_bit = 1;
459 do {
425 if (events & irq_bit) { 460 if (events & irq_bit) {
426 via1[vIER] = irq_bit;
427 m68k_handle_int(VIA1_SOURCE_BASE + i);
428 via1[vIFR] = irq_bit; 461 via1[vIFR] = irq_bit;
429 via1[vIER] = irq_bit | 0x80; 462 m68k_handle_int(irq_num);
430 } 463 }
464 ++irq_num;
465 irq_bit <<= 1;
466 } while (events >= irq_bit);
431 467
432#if 0 /* freakin' pmu is doing weird stuff */ 468#if 0 /* freakin' pmu is doing weird stuff */
433 if (!oss_present) { 469 if (!oss_present) {
@@ -448,20 +484,23 @@ irqreturn_t via1_irq(int irq, void *dev_id)
448 484
449irqreturn_t via2_irq(int irq, void *dev_id) 485irqreturn_t via2_irq(int irq, void *dev_id)
450{ 486{
451 int irq_bit, i; 487 int irq_num;
452 unsigned char events, mask; 488 unsigned char irq_bit, events;
453 489
454 mask = via2[gIER] & 0x7F; 490 events = via2[gIFR] & via2[gIER] & 0x7F;
455 if (!(events = via2[gIFR] & mask)) 491 if (!events)
456 return IRQ_NONE; 492 return IRQ_NONE;
457 493
458 for (i = 0, irq_bit = 1 ; i < 7 ; i++, irq_bit <<= 1) 494 irq_num = VIA2_SOURCE_BASE;
495 irq_bit = 1;
496 do {
459 if (events & irq_bit) { 497 if (events & irq_bit) {
460 via2[gIER] = irq_bit;
461 via2[gIFR] = irq_bit | rbv_clear; 498 via2[gIFR] = irq_bit | rbv_clear;
462 m68k_handle_int(VIA2_SOURCE_BASE + i); 499 m68k_handle_int(irq_num);
463 via2[gIER] = irq_bit | 0x80;
464 } 500 }
501 ++irq_num;
502 irq_bit <<= 1;
503 } while (events >= irq_bit);
465 return IRQ_HANDLED; 504 return IRQ_HANDLED;
466} 505}
467 506
@@ -472,71 +511,75 @@ irqreturn_t via2_irq(int irq, void *dev_id)
472 511
473irqreturn_t via_nubus_irq(int irq, void *dev_id) 512irqreturn_t via_nubus_irq(int irq, void *dev_id)
474{ 513{
475 int irq_bit, i; 514 int slot_irq;
476 unsigned char events; 515 unsigned char slot_bit, events;
477 516
478 if (!(events = ~via2[gBufA] & nubus_active)) 517 events = ~via2[gBufA] & 0x7F;
518 if (rbv_present)
519 events &= via2[rSIER];
520 else
521 events &= ~via2[vDirA];
522 if (!events)
479 return IRQ_NONE; 523 return IRQ_NONE;
480 524
481 for (i = 0, irq_bit = 1 ; i < 7 ; i++, irq_bit <<= 1) { 525 do {
482 if (events & irq_bit) { 526 slot_irq = IRQ_NUBUS_F;
483 via_irq_disable(NUBUS_SOURCE_BASE + i); 527 slot_bit = 0x40;
484 m68k_handle_int(NUBUS_SOURCE_BASE + i); 528 do {
485 via_irq_enable(NUBUS_SOURCE_BASE + i); 529 if (events & slot_bit) {
486 } 530 events &= ~slot_bit;
487 } 531 m68k_handle_int(slot_irq);
532 }
533 --slot_irq;
534 slot_bit >>= 1;
535 } while (events);
536
537 /* clear the CA1 interrupt and make certain there's no more. */
538 via2[gIFR] = 0x02 | rbv_clear;
539 events = ~via2[gBufA] & 0x7F;
540 if (rbv_present)
541 events &= via2[rSIER];
542 else
543 events &= ~via2[vDirA];
544 } while (events);
488 return IRQ_HANDLED; 545 return IRQ_HANDLED;
489} 546}
490 547
491void via_irq_enable(int irq) { 548void via_irq_enable(int irq) {
492 int irq_src = IRQ_SRC(irq); 549 int irq_src = IRQ_SRC(irq);
493 int irq_idx = IRQ_IDX(irq); 550 int irq_idx = IRQ_IDX(irq);
494 int irq_bit = 1 << irq_idx;
495 551
496#ifdef DEBUG_IRQUSE 552#ifdef DEBUG_IRQUSE
497 printk(KERN_DEBUG "via_irq_enable(%d)\n", irq); 553 printk(KERN_DEBUG "via_irq_enable(%d)\n", irq);
498#endif 554#endif
499 555
500 if (irq_src == 1) { 556 if (irq_src == 1) {
501 via1[vIER] = irq_bit | 0x80; 557 via1[vIER] = IER_SET_BIT(irq_idx);
502 } else if (irq_src == 2) { 558 } else if (irq_src == 2) {
503 /* 559 if (irq != IRQ_MAC_NUBUS || nubus_disabled == 0)
504 * Set vPCR for SCSI interrupts (but not on RBV) 560 via2[gIER] = IER_SET_BIT(irq_idx);
505 */
506 if ((irq_idx == 0) && !rbv_present) {
507 if (macintosh_config->scsi_type == MAC_SCSI_OLD) {
508 /* CB2 (IRQ) indep. input, positive edge */
509 /* CA2 (DRQ) indep. input, positive edge */
510 via2[vPCR] = 0x66;
511 } else {
512 /* CB2 (IRQ) indep. input, negative edge */
513 /* CA2 (DRQ) indep. input, negative edge */
514 via2[vPCR] = 0x22;
515 }
516 }
517 via2[gIER] = irq_bit | 0x80;
518 } else if (irq_src == 7) { 561 } else if (irq_src == 7) {
519 nubus_active |= irq_bit; 562 switch (macintosh_config->via_type) {
520 if (rbv_present) { 563 case MAC_VIA_II:
521 /* enable the slot interrupt. SIER works like IER. */ 564 nubus_disabled &= ~(1 << irq_idx);
565 /* Enable the CA1 interrupt when no slot is disabled. */
566 if (!nubus_disabled)
567 via2[gIER] = IER_SET_BIT(1);
568 break;
569 case MAC_VIA_IIci:
570 /* On RBV, enable the slot interrupt.
571 * SIER works like IER.
572 */
522 via2[rSIER] = IER_SET_BIT(irq_idx); 573 via2[rSIER] = IER_SET_BIT(irq_idx);
523 } else { 574 break;
524 /* Make sure the bit is an input, to enable the irq */ 575 case MAC_VIA_QUADRA:
525 /* But not on PowerBooks, that's ADB... */ 576 /* Make the port A line an input to enable the slot irq.
577 * But not on PowerBooks, that's ADB.
578 */
526 if ((macintosh_config->adb_type != MAC_ADB_PB1) && 579 if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
527 (macintosh_config->adb_type != MAC_ADB_PB2)) { 580 (macintosh_config->adb_type != MAC_ADB_PB2))
528 switch(macintosh_config->ident) 581 via2[vDirA] &= ~(1 << irq_idx);
529 { 582 break;
530 case MAC_MODEL_II:
531 case MAC_MODEL_IIX:
532 case MAC_MODEL_IICX:
533 case MAC_MODEL_SE30:
534 via2[vDirA] &= (~irq_bit | 0xc0);
535 break;
536 default:
537 via2[vDirA] &= ~irq_bit;
538 }
539 }
540 } 583 }
541 } 584 }
542} 585}
@@ -544,29 +587,31 @@ void via_irq_enable(int irq) {
544void via_irq_disable(int irq) { 587void via_irq_disable(int irq) {
545 int irq_src = IRQ_SRC(irq); 588 int irq_src = IRQ_SRC(irq);
546 int irq_idx = IRQ_IDX(irq); 589 int irq_idx = IRQ_IDX(irq);
547 int irq_bit = 1 << irq_idx;
548 590
549#ifdef DEBUG_IRQUSE 591#ifdef DEBUG_IRQUSE
550 printk(KERN_DEBUG "via_irq_disable(%d)\n", irq); 592 printk(KERN_DEBUG "via_irq_disable(%d)\n", irq);
551#endif 593#endif
552 594
553 if (irq_src == 1) { 595 if (irq_src == 1) {
554 via1[vIER] = irq_bit; 596 via1[vIER] = IER_CLR_BIT(irq_idx);
555 } else if (irq_src == 2) { 597 } else if (irq_src == 2) {
556 via2[gIER] = irq_bit; 598 via2[gIER] = IER_CLR_BIT(irq_idx);
557 } else if (irq_src == 7) { 599 } else if (irq_src == 7) {
558 if (rbv_present) { 600 switch (macintosh_config->via_type) {
559 /* disable the slot interrupt. SIER works like IER. */ 601 case MAC_VIA_II:
602 nubus_disabled |= 1 << irq_idx;
603 if (nubus_disabled)
604 via2[gIER] = IER_CLR_BIT(1);
605 break;
606 case MAC_VIA_IIci:
560 via2[rSIER] = IER_CLR_BIT(irq_idx); 607 via2[rSIER] = IER_CLR_BIT(irq_idx);
561 } else { 608 break;
562 /* disable the nubus irq by changing dir to output */ 609 case MAC_VIA_QUADRA:
563 /* except on PMU */
564 if ((macintosh_config->adb_type != MAC_ADB_PB1) && 610 if ((macintosh_config->adb_type != MAC_ADB_PB1) &&
565 (macintosh_config->adb_type != MAC_ADB_PB2)) { 611 (macintosh_config->adb_type != MAC_ADB_PB2))
566 via2[vDirA] |= irq_bit; 612 via2[vDirA] |= 1 << irq_idx;
567 } 613 break;
568 } 614 }
569 nubus_active &= ~irq_bit;
570 } 615 }
571} 616}
572 617
@@ -580,7 +625,9 @@ void via_irq_clear(int irq) {
580 } else if (irq_src == 2) { 625 } else if (irq_src == 2) {
581 via2[gIFR] = irq_bit | rbv_clear; 626 via2[gIFR] = irq_bit | rbv_clear;
582 } else if (irq_src == 7) { 627 } else if (irq_src == 7) {
583 /* FIXME: hmm.. */ 628 /* FIXME: There is no way to clear an individual nubus slot
629 * IRQ flag, other than getting the device to do it.
630 */
584 } 631 }
585} 632}
586 633
@@ -600,6 +647,7 @@ int via_irq_pending(int irq)
600 } else if (irq_src == 2) { 647 } else if (irq_src == 2) {
601 return via2[gIFR] & irq_bit; 648 return via2[gIFR] & irq_bit;
602 } else if (irq_src == 7) { 649 } else if (irq_src == 7) {
650 /* Always 0 for MAC_VIA_QUADRA if the slot irq is disabled. */
603 return ~via2[gBufA] & irq_bit; 651 return ~via2[gBufA] & irq_bit;
604 } 652 }
605 return 0; 653 return 0;
diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c
index 92f873cc7060..476e18eca758 100644
--- a/arch/m68k/q40/config.c
+++ b/arch/m68k/q40/config.c
@@ -35,35 +35,35 @@
35#include <asm/machdep.h> 35#include <asm/machdep.h>
36#include <asm/q40_master.h> 36#include <asm/q40_master.h>
37 37
38extern irqreturn_t q40_process_int (int level, struct pt_regs *regs); 38extern irqreturn_t q40_process_int(int level, struct pt_regs *regs);
39extern void q40_init_IRQ (void); 39extern void q40_init_IRQ(void);
40static void q40_get_model(char *model); 40static void q40_get_model(char *model);
41static int q40_get_hardware_list(char *buffer); 41static int q40_get_hardware_list(char *buffer);
42extern void q40_sched_init(irq_handler_t handler); 42extern void q40_sched_init(irq_handler_t handler);
43 43
44extern unsigned long q40_gettimeoffset (void); 44extern unsigned long q40_gettimeoffset(void);
45extern int q40_hwclk (int, struct rtc_time *); 45extern int q40_hwclk(int, struct rtc_time *);
46extern unsigned int q40_get_ss (void); 46extern unsigned int q40_get_ss(void);
47extern int q40_set_clock_mmss (unsigned long); 47extern int q40_set_clock_mmss(unsigned long);
48static int q40_get_rtc_pll(struct rtc_pll_info *pll); 48static int q40_get_rtc_pll(struct rtc_pll_info *pll);
49static int q40_set_rtc_pll(struct rtc_pll_info *pll); 49static int q40_set_rtc_pll(struct rtc_pll_info *pll);
50extern void q40_reset (void); 50extern void q40_reset(void);
51void q40_halt(void); 51void q40_halt(void);
52extern void q40_waitbut(void); 52extern void q40_waitbut(void);
53void q40_set_vectors (void); 53void q40_set_vectors(void);
54 54
55extern void q40_mksound(unsigned int /*freq*/, unsigned int /*ticks*/ ); 55extern void q40_mksound(unsigned int /*freq*/, unsigned int /*ticks*/);
56 56
57extern char m68k_debug_device[];
58static void q40_mem_console_write(struct console *co, const char *b, 57static void q40_mem_console_write(struct console *co, const char *b,
59 unsigned int count); 58 unsigned int count);
60 59
61extern int ql_ticks; 60extern int ql_ticks;
62 61
63static struct console q40_console_driver = { 62static struct console q40_console_driver = {
64 .name = "debug", 63 .name = "debug",
65 .flags = CON_PRINTBUFFER, 64 .write = q40_mem_console_write,
66 .index = -1, 65 .flags = CON_PRINTBUFFER,
66 .index = -1,
67}; 67};
68 68
69 69
@@ -74,150 +74,162 @@ static int _cpleft;
74static void q40_mem_console_write(struct console *co, const char *s, 74static void q40_mem_console_write(struct console *co, const char *s,
75 unsigned int count) 75 unsigned int count)
76{ 76{
77 char *p=(char *)s; 77 const char *p = s;
78 78
79 if (count<_cpleft) 79 if (count < _cpleft) {
80 while (count-- >0){ 80 while (count-- > 0) {
81 *q40_mem_cptr=*p++; 81 *q40_mem_cptr = *p++;
82 q40_mem_cptr+=4; 82 q40_mem_cptr += 4;
83 _cpleft--; 83 _cpleft--;
84 } 84 }
85 }
86}
87
88static int __init q40_debug_setup(char *arg)
89{
90 /* useful for early debugging stages - writes kernel messages into SRAM */
91 if (MACH_IS_Q40 && !strncmp(arg, "mem", 3)) {
92 /*printk("using NVRAM debug, q40_mem_cptr=%p\n",q40_mem_cptr);*/
93 _cpleft = 2000 - ((long)q40_mem_cptr-0xff020000) / 4;
94 register_console(&q40_console_driver);
95 }
96 return 0;
85} 97}
98
99early_param("debug", q40_debug_setup);
100
86#if 0 101#if 0
87void printq40(char *str) 102void printq40(char *str)
88{ 103{
89 int l=strlen(str); 104 int l = strlen(str);
90 char *p=q40_mem_cptr; 105 char *p = q40_mem_cptr;
91 106
92 while (l-- >0 && _cpleft-- >0) 107 while (l-- > 0 && _cpleft-- > 0) {
93 { 108 *p = *str++;
94 *p=*str++; 109 p += 4;
95 p+=4; 110 }
96 } 111 q40_mem_cptr = p;
97 q40_mem_cptr=p;
98} 112}
99#endif 113#endif
100 114
101static int halted=0; 115static int halted;
102 116
103#ifdef CONFIG_HEARTBEAT 117#ifdef CONFIG_HEARTBEAT
104static void q40_heartbeat(int on) 118static void q40_heartbeat(int on)
105{ 119{
106 if (halted) return; 120 if (halted)
121 return;
107 122
108 if (on) 123 if (on)
109 Q40_LED_ON(); 124 Q40_LED_ON();
110 else 125 else
111 Q40_LED_OFF(); 126 Q40_LED_OFF();
112} 127}
113#endif 128#endif
114 129
115void q40_reset(void) 130void q40_reset(void)
116{ 131{
117 halted=1; 132 halted = 1;
118 printk ("\n\n*******************************************\n" 133 printk("\n\n*******************************************\n"
119 "Called q40_reset : press the RESET button!! \n" 134 "Called q40_reset : press the RESET button!! \n"
120 "*******************************************\n"); 135 "*******************************************\n");
121 Q40_LED_ON(); 136 Q40_LED_ON();
122 while(1) ; 137 while (1)
138 ;
123} 139}
124void q40_halt(void) 140void q40_halt(void)
125{ 141{
126 halted=1; 142 halted = 1;
127 printk ("\n\n*******************\n" 143 printk("\n\n*******************\n"
128 " Called q40_halt\n" 144 " Called q40_halt\n"
129 "*******************\n"); 145 "*******************\n");
130 Q40_LED_ON(); 146 Q40_LED_ON();
131 while(1) ; 147 while (1)
148 ;
132} 149}
133 150
134static void q40_get_model(char *model) 151static void q40_get_model(char *model)
135{ 152{
136 sprintf(model, "Q40"); 153 sprintf(model, "Q40");
137} 154}
138 155
139/* No hardware options on Q40? */ 156/* No hardware options on Q40? */
140 157
141static int q40_get_hardware_list(char *buffer) 158static int q40_get_hardware_list(char *buffer)
142{ 159{
143 *buffer = '\0'; 160 *buffer = '\0';
144 return 0; 161 return 0;
145} 162}
146 163
147static unsigned int serports[]={0x3f8,0x2f8,0x3e8,0x2e8,0}; 164static unsigned int serports[] =
165{
166 0x3f8,0x2f8,0x3e8,0x2e8,0
167};
148void q40_disable_irqs(void) 168void q40_disable_irqs(void)
149{ 169{
150 unsigned i,j; 170 unsigned i, j;
151 171
152 j=0; 172 j = 0;
153 while((i=serports[j++])) outb(0,i+UART_IER); 173 while ((i = serports[j++]))
154 master_outb(0,EXT_ENABLE_REG); 174 outb(0, i + UART_IER);
155 master_outb(0,KEY_IRQ_ENABLE_REG); 175 master_outb(0, EXT_ENABLE_REG);
176 master_outb(0, KEY_IRQ_ENABLE_REG);
156} 177}
157 178
158void __init config_q40(void) 179void __init config_q40(void)
159{ 180{
160 mach_sched_init = q40_sched_init; 181 mach_sched_init = q40_sched_init;
161 182
162 mach_init_IRQ = q40_init_IRQ; 183 mach_init_IRQ = q40_init_IRQ;
163 mach_gettimeoffset = q40_gettimeoffset; 184 mach_gettimeoffset = q40_gettimeoffset;
164 mach_hwclk = q40_hwclk; 185 mach_hwclk = q40_hwclk;
165 mach_get_ss = q40_get_ss; 186 mach_get_ss = q40_get_ss;
166 mach_get_rtc_pll = q40_get_rtc_pll; 187 mach_get_rtc_pll = q40_get_rtc_pll;
167 mach_set_rtc_pll = q40_set_rtc_pll; 188 mach_set_rtc_pll = q40_set_rtc_pll;
168 mach_set_clock_mmss = q40_set_clock_mmss; 189 mach_set_clock_mmss = q40_set_clock_mmss;
169 190
170 mach_reset = q40_reset; 191 mach_reset = q40_reset;
171 mach_get_model = q40_get_model; 192 mach_get_model = q40_get_model;
172 mach_get_hardware_list = q40_get_hardware_list; 193 mach_get_hardware_list = q40_get_hardware_list;
173 194
174#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 195#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
175 mach_beep = q40_mksound; 196 mach_beep = q40_mksound;
176#endif 197#endif
177#ifdef CONFIG_HEARTBEAT 198#ifdef CONFIG_HEARTBEAT
178 mach_heartbeat = q40_heartbeat; 199 mach_heartbeat = q40_heartbeat;
179#endif 200#endif
180 mach_halt = q40_halt; 201 mach_halt = q40_halt;
181 202
182 /* disable a few things that SMSQ might have left enabled */ 203 /* disable a few things that SMSQ might have left enabled */
183 q40_disable_irqs(); 204 q40_disable_irqs();
184 205
185 /* no DMA at all, but ide-scsi requires it.. make sure 206 /* no DMA at all, but ide-scsi requires it.. make sure
186 * all physical RAM fits into the boundary - otherwise 207 * all physical RAM fits into the boundary - otherwise
187 * allocator may play costly and useless tricks */ 208 * allocator may play costly and useless tricks */
188 mach_max_dma_address = 1024*1024*1024; 209 mach_max_dma_address = 1024*1024*1024;
189
190 /* useful for early debugging stages - writes kernel messages into SRAM */
191 if (!strncmp( m68k_debug_device,"mem",3 ))
192 {
193 /*printk("using NVRAM debug, q40_mem_cptr=%p\n",q40_mem_cptr);*/
194 _cpleft=2000-((long)q40_mem_cptr-0xff020000)/4;
195 q40_console_driver.write = q40_mem_console_write;
196 register_console(&q40_console_driver);
197 }
198} 210}
199 211
200 212
201int q40_parse_bootinfo(const struct bi_record *rec) 213int q40_parse_bootinfo(const struct bi_record *rec)
202{ 214{
203 return 1; 215 return 1;
204} 216}
205 217
206 218
207static inline unsigned char bcd2bin (unsigned char b) 219static inline unsigned char bcd2bin(unsigned char b)
208{ 220{
209 return ((b>>4)*10 + (b&15)); 221 return (b >> 4) * 10 + (b & 15);
210} 222}
211 223
212static inline unsigned char bin2bcd (unsigned char b) 224static inline unsigned char bin2bcd(unsigned char b)
213{ 225{
214 return (((b/10)*16) + (b%10)); 226 return (b / 10) * 16 + (b % 10);
215} 227}
216 228
217 229
218unsigned long q40_gettimeoffset (void) 230unsigned long q40_gettimeoffset(void)
219{ 231{
220 return 5000*(ql_ticks!=0); 232 return 5000 * (ql_ticks != 0);
221} 233}
222 234
223 235
@@ -238,9 +250,9 @@ unsigned long q40_gettimeoffset (void)
238 250
239int q40_hwclk(int op, struct rtc_time *t) 251int q40_hwclk(int op, struct rtc_time *t)
240{ 252{
241 if (op) 253 if (op) {
242 { /* Write.... */ 254 /* Write.... */
243 Q40_RTC_CTRL |= Q40_RTC_WRITE; 255 Q40_RTC_CTRL |= Q40_RTC_WRITE;
244 256
245 Q40_RTC_SECS = bin2bcd(t->tm_sec); 257 Q40_RTC_SECS = bin2bcd(t->tm_sec);
246 Q40_RTC_MINS = bin2bcd(t->tm_min); 258 Q40_RTC_MINS = bin2bcd(t->tm_min);
@@ -251,25 +263,23 @@ int q40_hwclk(int op, struct rtc_time *t)
251 if (t->tm_wday >= 0) 263 if (t->tm_wday >= 0)
252 Q40_RTC_DOW = bin2bcd(t->tm_wday+1); 264 Q40_RTC_DOW = bin2bcd(t->tm_wday+1);
253 265
254 Q40_RTC_CTRL &= ~(Q40_RTC_WRITE); 266 Q40_RTC_CTRL &= ~(Q40_RTC_WRITE);
255 } 267 } else {
256 else 268 /* Read.... */
257 { /* Read.... */ 269 Q40_RTC_CTRL |= Q40_RTC_READ;
258 Q40_RTC_CTRL |= Q40_RTC_READ; 270
259 271 t->tm_year = bcd2bin (Q40_RTC_YEAR);
260 t->tm_year = bcd2bin (Q40_RTC_YEAR); 272 t->tm_mon = bcd2bin (Q40_RTC_MNTH)-1;
261 t->tm_mon = bcd2bin (Q40_RTC_MNTH)-1; 273 t->tm_mday = bcd2bin (Q40_RTC_DATE);
262 t->tm_mday = bcd2bin (Q40_RTC_DATE); 274 t->tm_hour = bcd2bin (Q40_RTC_HOUR);
263 t->tm_hour = bcd2bin (Q40_RTC_HOUR); 275 t->tm_min = bcd2bin (Q40_RTC_MINS);
264 t->tm_min = bcd2bin (Q40_RTC_MINS); 276 t->tm_sec = bcd2bin (Q40_RTC_SECS);
265 t->tm_sec = bcd2bin (Q40_RTC_SECS); 277
266 278 Q40_RTC_CTRL &= ~(Q40_RTC_READ);
267 Q40_RTC_CTRL &= ~(Q40_RTC_READ); 279
268 280 if (t->tm_year < 70)
269 if (t->tm_year < 70) 281 t->tm_year += 100;
270 t->tm_year += 100; 282 t->tm_wday = bcd2bin(Q40_RTC_DOW)-1;
271 t->tm_wday = bcd2bin(Q40_RTC_DOW)-1;
272
273 } 283 }
274 284
275 return 0; 285 return 0;
@@ -285,29 +295,25 @@ unsigned int q40_get_ss(void)
285 * clock is out by > 30 minutes. Logic lifted from atari code. 295 * clock is out by > 30 minutes. Logic lifted from atari code.
286 */ 296 */
287 297
288int q40_set_clock_mmss (unsigned long nowtime) 298int q40_set_clock_mmss(unsigned long nowtime)
289{ 299{
290 int retval = 0; 300 int retval = 0;
291 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; 301 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
292 302
293 int rtc_minutes; 303 int rtc_minutes;
294 304
305 rtc_minutes = bcd2bin(Q40_RTC_MINS);
295 306
296 rtc_minutes = bcd2bin (Q40_RTC_MINS); 307 if ((rtc_minutes < real_minutes ?
297 308 real_minutes - rtc_minutes :
298 if ((rtc_minutes < real_minutes 309 rtc_minutes - real_minutes) < 30) {
299 ? real_minutes - rtc_minutes 310 Q40_RTC_CTRL |= Q40_RTC_WRITE;
300 : rtc_minutes - real_minutes) < 30)
301 {
302 Q40_RTC_CTRL |= Q40_RTC_WRITE;
303 Q40_RTC_MINS = bin2bcd(real_minutes); 311 Q40_RTC_MINS = bin2bcd(real_minutes);
304 Q40_RTC_SECS = bin2bcd(real_seconds); 312 Q40_RTC_SECS = bin2bcd(real_seconds);
305 Q40_RTC_CTRL &= ~(Q40_RTC_WRITE); 313 Q40_RTC_CTRL &= ~(Q40_RTC_WRITE);
306 } 314 } else
307 else
308 retval = -1; 315 retval = -1;
309 316
310
311 return retval; 317 return retval;
312} 318}
313 319
@@ -318,21 +324,23 @@ int q40_set_clock_mmss (unsigned long nowtime)
318 324
319static int q40_get_rtc_pll(struct rtc_pll_info *pll) 325static int q40_get_rtc_pll(struct rtc_pll_info *pll)
320{ 326{
321 int tmp=Q40_RTC_CTRL; 327 int tmp = Q40_RTC_CTRL;
328
322 pll->pll_value = tmp & Q40_RTC_PLL_MASK; 329 pll->pll_value = tmp & Q40_RTC_PLL_MASK;
323 if (tmp & Q40_RTC_PLL_SIGN) 330 if (tmp & Q40_RTC_PLL_SIGN)
324 pll->pll_value = -pll->pll_value; 331 pll->pll_value = -pll->pll_value;
325 pll->pll_max=31; 332 pll->pll_max = 31;
326 pll->pll_min=-31; 333 pll->pll_min = -31;
327 pll->pll_posmult=512; 334 pll->pll_posmult = 512;
328 pll->pll_negmult=256; 335 pll->pll_negmult = 256;
329 pll->pll_clock=125829120; 336 pll->pll_clock = 125829120;
337
330 return 0; 338 return 0;
331} 339}
332 340
333static int q40_set_rtc_pll(struct rtc_pll_info *pll) 341static int q40_set_rtc_pll(struct rtc_pll_info *pll)
334{ 342{
335 if (!pll->pll_ctrl){ 343 if (!pll->pll_ctrl) {
336 /* the docs are a bit unclear so I am doublesetting */ 344 /* the docs are a bit unclear so I am doublesetting */
337 /* RTC_WRITE here ... */ 345 /* RTC_WRITE here ... */
338 int tmp = (pll->pll_value & 31) | (pll->pll_value<0 ? 32 : 0) | 346 int tmp = (pll->pll_value & 31) | (pll->pll_value<0 ? 32 : 0) |
diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c
index baf74e8de8b5..4232a2c2fae9 100644
--- a/arch/m68k/sun3/sun3ints.c
+++ b/arch/m68k/sun3/sun3ints.c
@@ -103,7 +103,7 @@ void sun3_init_IRQ(void)
103 103
104 m68k_setup_auto_interrupt(sun3_inthandle); 104 m68k_setup_auto_interrupt(sun3_inthandle);
105 m68k_setup_irq_controller(&sun3_irq_controller, IRQ_AUTO_1, 7); 105 m68k_setup_irq_controller(&sun3_irq_controller, IRQ_AUTO_1, 7);
106 m68k_setup_user_interrupt(VEC_USER, 192, NULL); 106 m68k_setup_user_interrupt(VEC_USER, 128, NULL);
107 107
108 request_irq(IRQ_AUTO_5, sun3_int5, 0, "int5", NULL); 108 request_irq(IRQ_AUTO_5, sun3_int5, 0, "int5", NULL);
109 request_irq(IRQ_AUTO_7, sun3_int7, 0, "int7", NULL); 109 request_irq(IRQ_AUTO_7, sun3_int7, 0, "int7", NULL);
diff --git a/arch/m68k/sun3x/prom.c b/arch/m68k/sun3x/prom.c
index 574cf06df9e4..48f8eb7b1565 100644
--- a/arch/m68k/sun3x/prom.c
+++ b/arch/m68k/sun3x/prom.c
@@ -34,100 +34,101 @@ e_vector *sun3x_prom_vbr;
34/* Handle returning to the prom */ 34/* Handle returning to the prom */
35void sun3x_halt(void) 35void sun3x_halt(void)
36{ 36{
37 unsigned long flags; 37 unsigned long flags;
38 38
39 /* Disable interrupts while we mess with things */ 39 /* Disable interrupts while we mess with things */
40 local_irq_save(flags); 40 local_irq_save(flags);
41 41
42 /* Restore prom vbr */ 42 /* Restore prom vbr */
43 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr)); 43 asm volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr));
44 44
45 /* Restore prom NMI clock */ 45 /* Restore prom NMI clock */
46// sun3x_disable_intreg(5); 46// sun3x_disable_intreg(5);
47 sun3_enable_irq(7); 47 sun3_enable_irq(7);
48 48
49 /* Let 'er rip */ 49 /* Let 'er rip */
50 __asm__ volatile ("trap #14" : : ); 50 asm volatile ("trap #14");
51 51
52 /* Restore everything */ 52 /* Restore everything */
53 sun3_disable_irq(7); 53 sun3_disable_irq(7);
54 sun3_enable_irq(5); 54 sun3_enable_irq(5);
55 55
56 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors)); 56 asm volatile ("movec %0,%%vbr" : : "r" ((void*)vectors));
57 local_irq_restore(flags); 57 local_irq_restore(flags);
58} 58}
59 59
60void sun3x_reboot(void) 60void sun3x_reboot(void)
61{ 61{
62 /* This never returns, don't bother saving things */ 62 /* This never returns, don't bother saving things */
63 local_irq_disable(); 63 local_irq_disable();
64 64
65 /* Restore prom vbr */ 65 /* Restore prom vbr */
66 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr)); 66 asm volatile ("movec %0,%%vbr" : : "r" ((void*)sun3x_prom_vbr));
67 67
68 /* Restore prom NMI clock */ 68 /* Restore prom NMI clock */
69 sun3_disable_irq(5); 69 sun3_disable_irq(5);
70 sun3_enable_irq(7); 70 sun3_enable_irq(7);
71 71
72 /* Let 'er rip */ 72 /* Let 'er rip */
73 (*romvec->pv_reboot)("vmlinux"); 73 (*romvec->pv_reboot)("vmlinux");
74} 74}
75 75
76extern char m68k_debug_device[];
77
78static void sun3x_prom_write(struct console *co, const char *s, 76static void sun3x_prom_write(struct console *co, const char *s,
79 unsigned int count) 77 unsigned int count)
80{ 78{
81 while (count--) { 79 while (count--) {
82 if (*s == '\n') 80 if (*s == '\n')
83 sun3x_putchar('\r'); 81 sun3x_putchar('\r');
84 sun3x_putchar(*s++); 82 sun3x_putchar(*s++);
85 } 83 }
86} 84}
87 85
88/* debug console - write-only */ 86/* debug console - write-only */
89 87
90static struct console sun3x_debug = { 88static struct console sun3x_debug = {
91 .name = "debug", 89 .name = "debug",
92 .write = sun3x_prom_write, 90 .write = sun3x_prom_write,
93 .flags = CON_PRINTBUFFER, 91 .flags = CON_PRINTBUFFER,
94 .index = -1, 92 .index = -1,
95}; 93};
96 94
97void sun3x_prom_init(void) 95void sun3x_prom_init(void)
98{ 96{
99 /* Read the vector table */ 97 /* Read the vector table */
100 98
101 sun3x_putchar = *(void (**)(int)) (SUN3X_P_PUTCHAR); 99 sun3x_putchar = *(void (**)(int)) (SUN3X_P_PUTCHAR);
102 sun3x_getchar = *(int (**)(void)) (SUN3X_P_GETCHAR); 100 sun3x_getchar = *(int (**)(void)) (SUN3X_P_GETCHAR);
103 sun3x_mayget = *(int (**)(void)) (SUN3X_P_MAYGET); 101 sun3x_mayget = *(int (**)(void)) (SUN3X_P_MAYGET);
104 sun3x_mayput = *(int (**)(int)) (SUN3X_P_MAYPUT); 102 sun3x_mayput = *(int (**)(int)) (SUN3X_P_MAYPUT);
105 sun3x_prom_reboot = *(void (**)(void)) (SUN3X_P_REBOOT); 103 sun3x_prom_reboot = *(void (**)(void)) (SUN3X_P_REBOOT);
106 sun3x_prom_abort = *(e_vector *) (SUN3X_P_ABORT); 104 sun3x_prom_abort = *(e_vector *) (SUN3X_P_ABORT);
107 romvec = (struct linux_romvec *)SUN3X_PROM_BASE; 105 romvec = (struct linux_romvec *)SUN3X_PROM_BASE;
108 106
109 idprom_init(); 107 idprom_init();
110 108
111 if(!((idprom->id_machtype & SM_ARCH_MASK) == SM_SUN3X)) { 109 if (!((idprom->id_machtype & SM_ARCH_MASK) == SM_SUN3X)) {
112 printk("Warning: machine reports strange type %02x\n", 110 printk("Warning: machine reports strange type %02x\n",
113 idprom->id_machtype); 111 idprom->id_machtype);
114 printk("Pretending it's a 3/80, but very afraid...\n"); 112 printk("Pretending it's a 3/80, but very afraid...\n");
115 idprom->id_machtype = SM_SUN3X | SM_3_80; 113 idprom->id_machtype = SM_SUN3X | SM_3_80;
116 } 114 }
117 115
118 /* point trap #14 at abort. 116 /* point trap #14 at abort.
119 * XXX this is futile since we restore the vbr first - oops 117 * XXX this is futile since we restore the vbr first - oops
120 */ 118 */
121 vectors[VEC_TRAP14] = sun3x_prom_abort; 119 vectors[VEC_TRAP14] = sun3x_prom_abort;
122 120}
123 /* If debug=prom was specified, start the debug console */
124
125 if (!strcmp(m68k_debug_device, "prom"))
126 register_console(&sun3x_debug);
127
128 121
122static int __init sun3x_debug_setup(char *arg)
123{
124 /* If debug=prom was specified, start the debug console */
125 if (MACH_IS_SUN3X && !strcmp(arg, "prom"))
126 register_console(&sun3x_debug);
127 return 0;
129} 128}
130 129
130early_param("debug", sun3x_debug_setup);
131
131/* some prom functions to export */ 132/* some prom functions to export */
132int prom_getintdefault(int node, char *property, int deflt) 133int prom_getintdefault(int node, char *property, int deflt)
133{ 134{
@@ -141,7 +142,6 @@ int prom_getbool (int node, char *prop)
141 142
142void prom_printf(char *fmt, ...) 143void prom_printf(char *fmt, ...)
143{ 144{
144
145} 145}
146 146
147void prom_halt (void) 147void prom_halt (void)
@@ -159,7 +159,7 @@ prom_get_idprom(char *idbuf, int num_bytes)
159 int i; 159 int i;
160 160
161 /* make a copy of the idprom structure */ 161 /* make a copy of the idprom structure */
162 for(i = 0; i < num_bytes; i++) 162 for (i = 0; i < num_bytes; i++)
163 idbuf[i] = ((char *)SUN3X_IDPROM)[i]; 163 idbuf[i] = ((char *)SUN3X_IDPROM)[i];
164 164
165 return idbuf[0]; 165 return idbuf[0];
diff --git a/arch/m68knommu/kernel/dma.c b/arch/m68knommu/kernel/dma.c
index 14b19c4161f4..0a25874a2aae 100644
--- a/arch/m68knommu/kernel/dma.c
+++ b/arch/m68knommu/kernel/dma.c
@@ -8,7 +8,6 @@
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/pci.h>
12#include <asm/io.h> 11#include <asm/io.h>
13 12
14void *dma_alloc_coherent(struct device *dev, size_t size, 13void *dma_alloc_coherent(struct device *dev, size_t size,
diff --git a/arch/mips/cobalt/Makefile b/arch/mips/cobalt/Makefile
index de017c11f9b7..9565b2104dcd 100644
--- a/arch/mips/cobalt/Makefile
+++ b/arch/mips/cobalt/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Cobalt micro systems family specific parts of the kernel 2# Makefile for the Cobalt micro systems family specific parts of the kernel
3# 3#
4 4
5obj-y := irq.o reset.o setup.o 5obj-y := irq.o reset.o setup.o buttons.o
6 6
7obj-$(CONFIG_PCI) += pci.o 7obj-$(CONFIG_PCI) += pci.o
8obj-$(CONFIG_EARLY_PRINTK) += console.o 8obj-$(CONFIG_EARLY_PRINTK) += console.o
diff --git a/arch/mips/cobalt/buttons.c b/arch/mips/cobalt/buttons.c
new file mode 100644
index 000000000000..9e143989c7b8
--- /dev/null
+++ b/arch/mips/cobalt/buttons.c
@@ -0,0 +1,54 @@
1/*
2 * Cobalt buttons platform device.
3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <linux/platform_device.h>
22#include <linux/errno.h>
23#include <linux/init.h>
24
25static struct resource cobalt_buttons_resource __initdata = {
26 .start = 0x1d000000,
27 .end = 0x1d000003,
28 .flags = IORESOURCE_MEM,
29};
30
31static __init int cobalt_add_buttons(void)
32{
33 struct platform_device *pd;
34 int error;
35
36 pd = platform_device_alloc("Cobalt buttons", -1);
37 if (!pd)
38 return -ENOMEM;
39
40 error = platform_device_add_resources(pd, &cobalt_buttons_resource, 1);
41 if (error)
42 goto err_free_device;
43
44 error = platform_device_add(pd);
45 if (error)
46 goto err_free_device;
47
48 return 0;
49
50 err_free_device:
51 platform_device_put(pd);
52 return error;
53}
54device_initcall(cobalt_add_buttons);
diff --git a/arch/mips/lib/iomap.c b/arch/mips/lib/iomap.c
index d51d5cb0a4a9..e3acb2dad33a 100644
--- a/arch/mips/lib/iomap.c
+++ b/arch/mips/lib/iomap.c
@@ -6,7 +6,6 @@
6 * (C) Copyright 2007 MIPS Technologies, Inc. 6 * (C) Copyright 2007 MIPS Technologies, Inc.
7 * written by Ralf Baechle <ralf@linux-mips.org> 7 * written by Ralf Baechle <ralf@linux-mips.org>
8 */ 8 */
9#include <linux/pci.h>
10#include <linux/module.h> 9#include <linux/module.h>
11#include <asm/io.h> 10#include <asm/io.h>
12 11
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 60d7d4baa227..7138092826aa 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -340,7 +340,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
340 struct pci_dev *dev; 340 struct pci_dev *dev;
341 const char *type; 341 const char *type;
342 342
343 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 343 dev = alloc_pci_dev();
344 if (!dev) 344 if (!dev)
345 return NULL; 345 return NULL;
346 type = of_get_property(node, "device_type", NULL); 346 type = of_get_property(node, "device_type", NULL);
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 9eaefac5053f..b2c1b67a10a7 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -37,7 +37,7 @@
37#include <asm/iseries/hv_call_xm.h> 37#include <asm/iseries/hv_call_xm.h>
38#include <asm/iseries/iommu.h> 38#include <asm/iseries/iommu.h>
39 39
40extern struct subsystem devices_subsys; /* needed for vio_find_name() */ 40extern struct kset devices_subsys; /* needed for vio_find_name() */
41 41
42static struct vio_dev vio_bus_device = { /* fake "parent" device */ 42static struct vio_dev vio_bus_device = { /* fake "parent" device */
43 .name = vio_bus_device.dev.bus_id, 43 .name = vio_bus_device.dev.bus_id,
@@ -427,7 +427,7 @@ static struct vio_dev *vio_find_name(const char *kobj_name)
427{ 427{
428 struct kobject *found; 428 struct kobject *found;
429 429
430 found = kset_find_obj(&devices_subsys.kset, kobj_name); 430 found = kset_find_obj(&devices_subsys, kobj_name);
431 if (!found) 431 if (!found)
432 return NULL; 432 return NULL;
433 433
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index 8943a9456bb7..1fe35dab0e9e 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_32.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_32.c
@@ -25,7 +25,6 @@
25#include <linux/cpufreq.h> 25#include <linux/cpufreq.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/i2c.h>
29#include <linux/hardirq.h> 28#include <linux/hardirq.h>
30#include <asm/prom.h> 29#include <asm/prom.h>
31#include <asm/machdep.h> 30#include <asm/machdep.h>
diff --git a/arch/powerpc/platforms/pseries/power.c b/arch/powerpc/platforms/pseries/power.c
index 2624b71df73d..73e69023d90a 100644
--- a/arch/powerpc/platforms/pseries/power.c
+++ b/arch/powerpc/platforms/pseries/power.c
@@ -28,13 +28,13 @@
28 28
29unsigned long rtas_poweron_auto; /* default and normal state is 0 */ 29unsigned long rtas_poweron_auto; /* default and normal state is 0 */
30 30
31static ssize_t auto_poweron_show(struct subsystem *subsys, char *buf) 31static ssize_t auto_poweron_show(struct kset *kset, char *buf)
32{ 32{
33 return sprintf(buf, "%lu\n", rtas_poweron_auto); 33 return sprintf(buf, "%lu\n", rtas_poweron_auto);
34} 34}
35 35
36static ssize_t 36static ssize_t
37auto_poweron_store(struct subsystem *subsys, const char *buf, size_t n) 37auto_poweron_store(struct kset *kset, const char *buf, size_t n)
38{ 38{
39 int ret; 39 int ret;
40 unsigned long ups_restart; 40 unsigned long ups_restart;
@@ -72,12 +72,12 @@ static int __init pm_init(void)
72{ 72{
73 int error = subsystem_register(&power_subsys); 73 int error = subsystem_register(&power_subsys);
74 if (!error) 74 if (!error)
75 error = sysfs_create_group(&power_subsys.kset.kobj,&attr_group); 75 error = sysfs_create_group(&power_subsys.kobj, &attr_group);
76 return error; 76 return error;
77} 77}
78core_initcall(pm_init); 78core_initcall(pm_init);
79#else 79#else
80extern struct subsystem power_subsys; 80extern struct kset power_subsys;
81 81
82static int __init apo_pm_init(void) 82static int __init apo_pm_init(void)
83{ 83{
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 53aa04101ced..3a393c7f390e 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -31,7 +31,6 @@
31#include <linux/timex.h> 31#include <linux/timex.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/pci.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/irq.h> 35#include <linux/irq.h>
37#include <linux/random.h> 36#include <linux/random.h>
diff --git a/arch/ppc/8260_io/enet.c b/arch/ppc/8260_io/enet.c
index 48ce84f5be93..4c0a7d732f69 100644
--- a/arch/ppc/8260_io/enet.c
+++ b/arch/ppc/8260_io/enet.c
@@ -32,7 +32,6 @@
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/pci.h>
36#include <linux/init.h> 35#include <linux/init.h>
37#include <linux/delay.h> 36#include <linux/delay.h>
38#include <linux/netdevice.h> 37#include <linux/netdevice.h>
diff --git a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c
index 9db825fe37f0..cab395da25da 100644
--- a/arch/ppc/8260_io/fcc_enet.c
+++ b/arch/ppc/8260_io/fcc_enet.c
@@ -29,7 +29,6 @@
29#include <linux/ioport.h> 29#include <linux/ioport.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/pci.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
35#include <linux/netdevice.h> 34#include <linux/netdevice.h>
diff --git a/arch/ppc/8xx_io/enet.c b/arch/ppc/8xx_io/enet.c
index bfa3f52996d1..e58288e14369 100644
--- a/arch/ppc/8xx_io/enet.c
+++ b/arch/ppc/8xx_io/enet.c
@@ -30,7 +30,6 @@
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/pci.h>
34#include <linux/init.h> 33#include <linux/init.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/netdevice.h> 35#include <linux/netdevice.h>
diff --git a/arch/ppc/syslib/ppc4xx_sgdma.c b/arch/ppc/syslib/ppc4xx_sgdma.c
index 939abe3c1f45..5dadca3e0d61 100644
--- a/arch/ppc/syslib/ppc4xx_sgdma.c
+++ b/arch/ppc/syslib/ppc4xx_sgdma.c
@@ -23,7 +23,6 @@
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/pci.h>
27 26
28#include <asm/system.h> 27#include <asm/system.h>
29#include <asm/io.h> 28#include <asm/io.h>
diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c
index a43f3488fecf..2180ac105b05 100644
--- a/arch/s390/appldata/appldata_net_sum.c
+++ b/arch/s390/appldata/appldata_net_sum.c
@@ -107,7 +107,7 @@ static void appldata_get_net_sum_data(void *data)
107 tx_dropped = 0; 107 tx_dropped = 0;
108 collisions = 0; 108 collisions = 0;
109 read_lock(&dev_base_lock); 109 read_lock(&dev_base_lock);
110 for (dev = dev_base; dev != NULL; dev = dev->next) { 110 for_each_netdev(dev) {
111 stats = dev->get_stats(dev); 111 stats = dev->get_stats(dev);
112 rx_packets += stats->rx_packets; 112 rx_packets += stats->rx_packets;
113 tx_packets += stats->tx_packets; 113 tx_packets += stats->tx_packets;
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index 91636353f6f0..3660ca6a3306 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -119,7 +119,8 @@ static struct crypto_alg aes_alg = {
119 .cra_name = "aes", 119 .cra_name = "aes",
120 .cra_driver_name = "aes-s390", 120 .cra_driver_name = "aes-s390",
121 .cra_priority = CRYPT_S390_PRIORITY, 121 .cra_priority = CRYPT_S390_PRIORITY,
122 .cra_flags = CRYPTO_ALG_TYPE_CIPHER, 122 .cra_flags = CRYPTO_ALG_TYPE_CIPHER |
123 CRYPTO_ALG_NEED_FALLBACK,
123 .cra_blocksize = AES_BLOCK_SIZE, 124 .cra_blocksize = AES_BLOCK_SIZE,
124 .cra_ctxsize = sizeof(struct s390_aes_ctx), 125 .cra_ctxsize = sizeof(struct s390_aes_ctx),
125 .cra_module = THIS_MODULE, 126 .cra_module = THIS_MODULE,
@@ -206,7 +207,8 @@ static struct crypto_alg ecb_aes_alg = {
206 .cra_name = "ecb(aes)", 207 .cra_name = "ecb(aes)",
207 .cra_driver_name = "ecb-aes-s390", 208 .cra_driver_name = "ecb-aes-s390",
208 .cra_priority = CRYPT_S390_COMPOSITE_PRIORITY, 209 .cra_priority = CRYPT_S390_COMPOSITE_PRIORITY,
209 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, 210 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER |
211 CRYPTO_ALG_NEED_FALLBACK,
210 .cra_blocksize = AES_BLOCK_SIZE, 212 .cra_blocksize = AES_BLOCK_SIZE,
211 .cra_ctxsize = sizeof(struct s390_aes_ctx), 213 .cra_ctxsize = sizeof(struct s390_aes_ctx),
212 .cra_type = &crypto_blkcipher_type, 214 .cra_type = &crypto_blkcipher_type,
@@ -300,7 +302,8 @@ static struct crypto_alg cbc_aes_alg = {
300 .cra_name = "cbc(aes)", 302 .cra_name = "cbc(aes)",
301 .cra_driver_name = "cbc-aes-s390", 303 .cra_driver_name = "cbc-aes-s390",
302 .cra_priority = CRYPT_S390_COMPOSITE_PRIORITY, 304 .cra_priority = CRYPT_S390_COMPOSITE_PRIORITY,
303 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, 305 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER |
306 CRYPTO_ALG_NEED_FALLBACK,
304 .cra_blocksize = AES_BLOCK_SIZE, 307 .cra_blocksize = AES_BLOCK_SIZE,
305 .cra_ctxsize = sizeof(struct s390_aes_ctx), 308 .cra_ctxsize = sizeof(struct s390_aes_ctx),
306 .cra_type = &crypto_blkcipher_type, 309 .cra_type = &crypto_blkcipher_type,
@@ -333,10 +336,14 @@ static int __init aes_init(void)
333 return -EOPNOTSUPP; 336 return -EOPNOTSUPP;
334 337
335 /* z9 109 and z9 BC/EC only support 128 bit key length */ 338 /* z9 109 and z9 BC/EC only support 128 bit key length */
336 if (keylen_flag == AES_KEYLEN_128) 339 if (keylen_flag == AES_KEYLEN_128) {
340 aes_alg.cra_u.cipher.cia_max_keysize = AES_MIN_KEY_SIZE;
341 ecb_aes_alg.cra_u.blkcipher.max_keysize = AES_MIN_KEY_SIZE;
342 cbc_aes_alg.cra_u.blkcipher.max_keysize = AES_MIN_KEY_SIZE;
337 printk(KERN_INFO 343 printk(KERN_INFO
338 "aes_s390: hardware acceleration only available for" 344 "aes_s390: hardware acceleration only available for"
339 "128 bit keys\n"); 345 "128 bit keys\n");
346 }
340 347
341 ret = crypto_register_alg(&aes_alg); 348 ret = crypto_register_alg(&aes_alg);
342 if (ret) 349 if (ret)
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 06833ac2b115..0ea048d350d8 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -164,7 +164,7 @@ EXPORT_SYMBOL_GPL(diag308);
164/* SYSFS */ 164/* SYSFS */
165 165
166#define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \ 166#define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
167static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \ 167static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
168 char *page) \ 168 char *page) \
169{ \ 169{ \
170 return sprintf(page, _format, _value); \ 170 return sprintf(page, _format, _value); \
@@ -173,13 +173,13 @@ static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
173 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL); 173 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
174 174
175#define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \ 175#define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
176static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \ 176static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
177 char *page) \ 177 char *page) \
178{ \ 178{ \
179 return sprintf(page, _fmt_out, \ 179 return sprintf(page, _fmt_out, \
180 (unsigned long long) _value); \ 180 (unsigned long long) _value); \
181} \ 181} \
182static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\ 182static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
183 const char *buf, size_t len) \ 183 const char *buf, size_t len) \
184{ \ 184{ \
185 unsigned long long value; \ 185 unsigned long long value; \
@@ -194,12 +194,12 @@ static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
194 sys_##_prefix##_##_name##_store); 194 sys_##_prefix##_##_name##_store);
195 195
196#define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\ 196#define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
197static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \ 197static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
198 char *page) \ 198 char *page) \
199{ \ 199{ \
200 return sprintf(page, _fmt_out, _value); \ 200 return sprintf(page, _fmt_out, _value); \
201} \ 201} \
202static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\ 202static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
203 const char *buf, size_t len) \ 203 const char *buf, size_t len) \
204{ \ 204{ \
205 if (sscanf(buf, _fmt_in, _value) != 1) \ 205 if (sscanf(buf, _fmt_in, _value) != 1) \
@@ -272,14 +272,14 @@ void __init setup_ipl_info(void)
272struct ipl_info ipl_info; 272struct ipl_info ipl_info;
273EXPORT_SYMBOL_GPL(ipl_info); 273EXPORT_SYMBOL_GPL(ipl_info);
274 274
275static ssize_t ipl_type_show(struct subsystem *subsys, char *page) 275static ssize_t ipl_type_show(struct kset *kset, char *page)
276{ 276{
277 return sprintf(page, "%s\n", ipl_type_str(ipl_info.type)); 277 return sprintf(page, "%s\n", ipl_type_str(ipl_info.type));
278} 278}
279 279
280static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type); 280static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
281 281
282static ssize_t sys_ipl_device_show(struct subsystem *subsys, char *page) 282static ssize_t sys_ipl_device_show(struct kset *kset, char *page)
283{ 283{
284 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; 284 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
285 285
@@ -371,7 +371,7 @@ static struct attribute_group ipl_fcp_attr_group = {
371 371
372/* CCW ipl device attributes */ 372/* CCW ipl device attributes */
373 373
374static ssize_t ipl_ccw_loadparm_show(struct subsystem *subsys, char *page) 374static ssize_t ipl_ccw_loadparm_show(struct kset *kset, char *page)
375{ 375{
376 char loadparm[LOADPARM_LEN + 1] = {}; 376 char loadparm[LOADPARM_LEN + 1] = {};
377 377
@@ -469,7 +469,7 @@ static void reipl_get_ascii_loadparm(char *loadparm)
469 strstrip(loadparm); 469 strstrip(loadparm);
470} 470}
471 471
472static ssize_t reipl_ccw_loadparm_show(struct subsystem *subsys, char *page) 472static ssize_t reipl_ccw_loadparm_show(struct kset *kset, char *page)
473{ 473{
474 char buf[LOADPARM_LEN + 1]; 474 char buf[LOADPARM_LEN + 1];
475 475
@@ -477,7 +477,7 @@ static ssize_t reipl_ccw_loadparm_show(struct subsystem *subsys, char *page)
477 return sprintf(page, "%s\n", buf); 477 return sprintf(page, "%s\n", buf);
478} 478}
479 479
480static ssize_t reipl_ccw_loadparm_store(struct subsystem *subsys, 480static ssize_t reipl_ccw_loadparm_store(struct kset *kset,
481 const char *buf, size_t len) 481 const char *buf, size_t len)
482{ 482{
483 int i, lp_len; 483 int i, lp_len;
@@ -572,12 +572,12 @@ static int reipl_set_type(enum ipl_type type)
572 return 0; 572 return 0;
573} 573}
574 574
575static ssize_t reipl_type_show(struct subsystem *subsys, char *page) 575static ssize_t reipl_type_show(struct kset *kset, char *page)
576{ 576{
577 return sprintf(page, "%s\n", ipl_type_str(reipl_type)); 577 return sprintf(page, "%s\n", ipl_type_str(reipl_type));
578} 578}
579 579
580static ssize_t reipl_type_store(struct subsystem *subsys, const char *buf, 580static ssize_t reipl_type_store(struct kset *kset, const char *buf,
581 size_t len) 581 size_t len)
582{ 582{
583 int rc = -EINVAL; 583 int rc = -EINVAL;
@@ -665,12 +665,12 @@ static int dump_set_type(enum dump_type type)
665 return 0; 665 return 0;
666} 666}
667 667
668static ssize_t dump_type_show(struct subsystem *subsys, char *page) 668static ssize_t dump_type_show(struct kset *kset, char *page)
669{ 669{
670 return sprintf(page, "%s\n", dump_type_str(dump_type)); 670 return sprintf(page, "%s\n", dump_type_str(dump_type));
671} 671}
672 672
673static ssize_t dump_type_store(struct subsystem *subsys, const char *buf, 673static ssize_t dump_type_store(struct kset *kset, const char *buf,
674 size_t len) 674 size_t len)
675{ 675{
676 int rc = -EINVAL; 676 int rc = -EINVAL;
@@ -697,12 +697,12 @@ static decl_subsys(shutdown_actions, NULL, NULL);
697 697
698/* on panic */ 698/* on panic */
699 699
700static ssize_t on_panic_show(struct subsystem *subsys, char *page) 700static ssize_t on_panic_show(struct kset *kset, char *page)
701{ 701{
702 return sprintf(page, "%s\n", shutdown_action_str(on_panic_action)); 702 return sprintf(page, "%s\n", shutdown_action_str(on_panic_action));
703} 703}
704 704
705static ssize_t on_panic_store(struct subsystem *subsys, const char *buf, 705static ssize_t on_panic_store(struct kset *kset, const char *buf,
706 size_t len) 706 size_t len)
707{ 707{
708 if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0) 708 if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0)
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 993f35381496..23c61f6d965b 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -516,7 +516,7 @@ out:
516 return 1; 516 return 1;
517} 517}
518 518
519static int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) 519int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
520{ 520{
521 struct kprobe *cur = kprobe_running(); 521 struct kprobe *cur = kprobe_running();
522 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 522 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
@@ -603,7 +603,6 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
603 ret = NOTIFY_STOP; 603 ret = NOTIFY_STOP;
604 break; 604 break;
605 case DIE_TRAP: 605 case DIE_TRAP:
606 case DIE_PAGE_FAULT:
607 /* kprobe_running() needs smp_processor_id() */ 606 /* kprobe_running() needs smp_processor_id() */
608 preempt_disable(); 607 preempt_disable();
609 if (kprobe_running() && 608 if (kprobe_running() &&
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 3dfd0985861c..6bfb0889eb10 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -65,7 +65,7 @@ long psw_user_bits = (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_HOME |
65 * User copy operations. 65 * User copy operations.
66 */ 66 */
67struct uaccess_ops uaccess; 67struct uaccess_ops uaccess;
68EXPORT_SYMBOL_GPL(uaccess); 68EXPORT_SYMBOL(uaccess);
69 69
70/* 70/*
71 * Machine setup.. 71 * Machine setup..
@@ -74,6 +74,8 @@ unsigned int console_mode = 0;
74unsigned int console_devno = -1; 74unsigned int console_devno = -1;
75unsigned int console_irq = -1; 75unsigned int console_irq = -1;
76unsigned long machine_flags = 0; 76unsigned long machine_flags = 0;
77unsigned long elf_hwcap = 0;
78char elf_platform[ELF_PLATFORM_SIZE];
77 79
78struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS]; 80struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS];
79volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */ 81volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
@@ -749,6 +751,98 @@ setup_memory(void)
749#endif 751#endif
750} 752}
751 753
754static __init unsigned int stfl(void)
755{
756 asm volatile(
757 " .insn s,0xb2b10000,0(0)\n" /* stfl */
758 "0:\n"
759 EX_TABLE(0b,0b));
760 return S390_lowcore.stfl_fac_list;
761}
762
763static __init int stfle(unsigned long long *list, int doublewords)
764{
765 typedef struct { unsigned long long _[doublewords]; } addrtype;
766 register unsigned long __nr asm("0") = doublewords - 1;
767
768 asm volatile(".insn s,0xb2b00000,%0" /* stfle */
769 : "=m" (*(addrtype *) list), "+d" (__nr) : : "cc");
770 return __nr + 1;
771}
772
773/*
774 * Setup hardware capabilities.
775 */
776static void __init setup_hwcaps(void)
777{
778 static const int stfl_bits[6] = { 0, 2, 7, 17, 19, 21 };
779 struct cpuinfo_S390 *cpuinfo = &S390_lowcore.cpu_data;
780 unsigned long long facility_list_extended;
781 unsigned int facility_list;
782 int i;
783
784 facility_list = stfl();
785 /*
786 * The store facility list bits numbers as found in the principles
787 * of operation are numbered with bit 1UL<<31 as number 0 to
788 * bit 1UL<<0 as number 31.
789 * Bit 0: instructions named N3, "backported" to esa-mode
790 * Bit 2: z/Architecture mode is active
791 * Bit 7: the store-facility-list-extended facility is installed
792 * Bit 17: the message-security assist is installed
793 * Bit 19: the long-displacement facility is installed
794 * Bit 21: the extended-immediate facility is installed
795 * These get translated to:
796 * HWCAP_S390_ESAN3 bit 0, HWCAP_S390_ZARCH bit 1,
797 * HWCAP_S390_STFLE bit 2, HWCAP_S390_MSA bit 3,
798 * HWCAP_S390_LDISP bit 4, and HWCAP_S390_EIMM bit 5.
799 */
800 for (i = 0; i < 6; i++)
801 if (facility_list & (1UL << (31 - stfl_bits[i])))
802 elf_hwcap |= 1UL << i;
803
804 /*
805 * Check for additional facilities with store-facility-list-extended.
806 * stfle stores doublewords (8 byte) with bit 1ULL<<63 as bit 0
807 * and 1ULL<<0 as bit 63. Bits 0-31 contain the same information
808 * as stored by stfl, bits 32-xxx contain additional facilities.
809 * How many facility words are stored depends on the number of
810 * doublewords passed to the instruction. The additional facilites
811 * are:
812 * Bit 43: decimal floating point facility is installed
813 * translated to:
814 * HWCAP_S390_DFP bit 6.
815 */
816 if ((elf_hwcap & (1UL << 2)) &&
817 stfle(&facility_list_extended, 1) > 0) {
818 if (facility_list_extended & (1ULL << (64 - 43)))
819 elf_hwcap |= 1UL << 6;
820 }
821
822 switch (cpuinfo->cpu_id.machine) {
823 case 0x9672:
824#if !defined(CONFIG_64BIT)
825 default: /* Use "g5" as default for 31 bit kernels. */
826#endif
827 strcpy(elf_platform, "g5");
828 break;
829 case 0x2064:
830 case 0x2066:
831#if defined(CONFIG_64BIT)
832 default: /* Use "z900" as default for 64 bit kernels. */
833#endif
834 strcpy(elf_platform, "z900");
835 break;
836 case 0x2084:
837 case 0x2086:
838 strcpy(elf_platform, "z990");
839 break;
840 case 0x2094:
841 strcpy(elf_platform, "z9-109");
842 break;
843 }
844}
845
752/* 846/*
753 * Setup function called from init/main.c just after the banner 847 * Setup function called from init/main.c just after the banner
754 * was printed. 848 * was printed.
@@ -805,6 +899,11 @@ setup_arch(char **cmdline_p)
805 smp_setup_cpu_possible_map(); 899 smp_setup_cpu_possible_map();
806 900
807 /* 901 /*
902 * Setup capabilities (ELF_HWCAP & ELF_PLATFORM).
903 */
904 setup_hwcaps();
905
906 /*
808 * Create kernel page tables and switch to virtual addressing. 907 * Create kernel page tables and switch to virtual addressing.
809 */ 908 */
810 paging_init(); 909 paging_init();
@@ -839,8 +938,12 @@ void print_cpu_info(struct cpuinfo_S390 *cpuinfo)
839 938
840static int show_cpuinfo(struct seq_file *m, void *v) 939static int show_cpuinfo(struct seq_file *m, void *v)
841{ 940{
941 static const char *hwcap_str[7] = {
942 "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp"
943 };
842 struct cpuinfo_S390 *cpuinfo; 944 struct cpuinfo_S390 *cpuinfo;
843 unsigned long n = (unsigned long) v - 1; 945 unsigned long n = (unsigned long) v - 1;
946 int i;
844 947
845 s390_adjust_jiffies(); 948 s390_adjust_jiffies();
846 preempt_disable(); 949 preempt_disable();
@@ -850,7 +953,13 @@ static int show_cpuinfo(struct seq_file *m, void *v)
850 "bogomips per cpu: %lu.%02lu\n", 953 "bogomips per cpu: %lu.%02lu\n",
851 num_online_cpus(), loops_per_jiffy/(500000/HZ), 954 num_online_cpus(), loops_per_jiffy/(500000/HZ),
852 (loops_per_jiffy/(5000/HZ))%100); 955 (loops_per_jiffy/(5000/HZ))%100);
956 seq_puts(m, "features\t: ");
957 for (i = 0; i < 7; i++)
958 if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
959 seq_printf(m, "%s ", hwcap_str[i]);
960 seq_puts(m, "\n");
853 } 961 }
962
854 if (cpu_online(n)) { 963 if (cpu_online(n)) {
855#ifdef CONFIG_SMP 964#ifdef CONFIG_SMP
856 if (smp_processor_id() == n) 965 if (smp_processor_id() == n)
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 2b76a879a7b5..91f705adc3f9 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -52,38 +52,24 @@ extern int sysctl_userprocess_debug;
52extern void die(const char *,struct pt_regs *,long); 52extern void die(const char *,struct pt_regs *,long);
53 53
54#ifdef CONFIG_KPROBES 54#ifdef CONFIG_KPROBES
55static ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
56int register_page_fault_notifier(struct notifier_block *nb)
57{
58 return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
59}
60
61int unregister_page_fault_notifier(struct notifier_block *nb)
62{
63 return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
64}
65
66static int __kprobes __notify_page_fault(struct pt_regs *regs, long err)
67{
68 struct die_args args = { .str = "page fault",
69 .trapnr = 14,
70 .signr = SIGSEGV };
71 args.regs = regs;
72 args.err = err;
73 return atomic_notifier_call_chain(&notify_page_fault_chain,
74 DIE_PAGE_FAULT, &args);
75}
76
77static inline int notify_page_fault(struct pt_regs *regs, long err) 55static inline int notify_page_fault(struct pt_regs *regs, long err)
78{ 56{
79 if (unlikely(kprobe_running())) 57 int ret = 0;
80 return __notify_page_fault(regs, err); 58
81 return NOTIFY_DONE; 59 /* kprobe_running() needs smp_processor_id() */
60 if (!user_mode(regs)) {
61 preempt_disable();
62 if (kprobe_running() && kprobe_fault_handler(regs, 14))
63 ret = 1;
64 preempt_enable();
65 }
66
67 return ret;
82} 68}
83#else 69#else
84static inline int notify_page_fault(struct pt_regs *regs, long err) 70static inline int notify_page_fault(struct pt_regs *regs, long err)
85{ 71{
86 return NOTIFY_DONE; 72 return 0;
87} 73}
88#endif 74#endif
89 75
@@ -319,7 +305,7 @@ do_exception(struct pt_regs *regs, unsigned long error_code, int write)
319 int space; 305 int space;
320 int si_code; 306 int si_code;
321 307
322 if (notify_page_fault(regs, error_code) == NOTIFY_STOP) 308 if (notify_page_fault(regs, error_code))
323 return; 309 return;
324 310
325 tsk = current; 311 tsk = current;
diff --git a/arch/sh64/mach-cayman/iomap.c b/arch/sh64/mach-cayman/iomap.c
index 2d06e9a55137..a5c645f02d57 100644
--- a/arch/sh64/mach-cayman/iomap.c
+++ b/arch/sh64/mach-cayman/iomap.c
@@ -9,7 +9,6 @@
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details. 10 * for more details.
11 */ 11 */
12#include <linux/pci.h>
13#include <asm/io.h> 12#include <asm/io.h>
14#include <asm/cayman.h> 13#include <asm/cayman.h>
15 14
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 590a41b864b9..be9e10b94ef8 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -306,6 +306,7 @@ config SUN_IO
306 306
307config PCI 307config PCI
308 bool "PCI support" 308 bool "PCI support"
309 select ARCH_SUPPORTS_MSI
309 help 310 help
310 Find out whether you have a PCI motherboard. PCI is the name of a 311 Find out whether you have a PCI motherboard. PCI is the name of a
311 bus system, i.e. the way the CPU talks to the other stuff inside 312 bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 023af41ad68d..9a549547cb2b 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -1092,10 +1092,10 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1092 return -EINVAL; 1092 return -EINVAL;
1093 1093
1094 err = p->setup_msi_irq(&virt_irq, pdev, desc); 1094 err = p->setup_msi_irq(&virt_irq, pdev, desc);
1095 if (err < 0) 1095 if (err)
1096 return err; 1096 return err;
1097 1097
1098 return virt_irq; 1098 return 0;
1099} 1099}
1100 1100
1101void arch_teardown_msi_irq(unsigned int virt_irq) 1101void arch_teardown_msi_irq(unsigned int virt_irq)
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 94295c219329..1ccf4c9a9a43 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -1169,8 +1169,6 @@ static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p,
1169 if (!devino) 1169 if (!devino)
1170 goto out_err; 1170 goto out_err;
1171 1171
1172 set_irq_msi(*virt_irq_p, entry);
1173
1174 msiqid = ((devino - pbm->msiq_first_devino) + 1172 msiqid = ((devino - pbm->msiq_first_devino) +
1175 pbm->msiq_first); 1173 pbm->msiq_first);
1176 1174
@@ -1204,6 +1202,8 @@ static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p,
1204 msg.address_lo = pbm->msi32_start; 1202 msg.address_lo = pbm->msi32_start;
1205 } 1203 }
1206 msg.data = msi_num; 1204 msg.data = msi_num;
1205
1206 set_irq_msi(*virt_irq_p, entry);
1207 write_msi_msg(*virt_irq_p, &msg); 1207 write_msi_msg(*virt_irq_p, &msg);
1208 1208
1209 irq_install_pre_handler(*virt_irq_p, 1209 irq_install_pre_handler(*virt_irq_p,
diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c
index 330743c5b3d8..18352a498628 100644
--- a/arch/sparc64/solaris/ioctl.c
+++ b/arch/sparc64/solaris/ioctl.c
@@ -686,7 +686,8 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg)
686 int i = 0; 686 int i = 0;
687 687
688 read_lock_bh(&dev_base_lock); 688 read_lock_bh(&dev_base_lock);
689 for (d = dev_base; d; d = d->next) i++; 689 for_each_netdev(d)
690 i++;
690 read_unlock_bh(&dev_base_lock); 691 read_unlock_bh(&dev_base_lock);
691 692
692 if (put_user (i, (int __user *)A(arg))) 693 if (put_user (i, (int __user *)A(arg)))
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 1cad418373c3..145bb824b2a8 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -701,6 +701,7 @@ menu "Bus options (PCI etc.)"
701 701
702config PCI 702config PCI
703 bool "PCI support" 703 bool "PCI support"
704 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
704 705
705# x86-64 doesn't support PCI BIOS access from long mode so always go direct. 706# x86-64 doesn't support PCI BIOS access from long mode so always go direct.
706config PCI_DIRECT 707config PCI_DIRECT
diff --git a/arch/x86_64/kernel/cpufreq/Kconfig b/arch/x86_64/kernel/cpufreq/Kconfig
index 40acb67fb882..c0749d2479f5 100644
--- a/arch/x86_64/kernel/cpufreq/Kconfig
+++ b/arch/x86_64/kernel/cpufreq/Kconfig
@@ -16,6 +16,9 @@ config X86_POWERNOW_K8
16 help 16 help
17 This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors. 17 This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.
18 18
19 To compile this driver as a module, choose M here: the
20 module will be called powernow-k8.
21
19 For details, take a look at <file:Documentation/cpu-freq/>. 22 For details, take a look at <file:Documentation/cpu-freq/>.
20 23
21 If in doubt, say N. 24 If in doubt, say N.
@@ -38,6 +41,9 @@ config X86_SPEEDSTEP_CENTRINO
38 mobile CPUs. This means Intel Pentium M (Centrino) CPUs 41 mobile CPUs. This means Intel Pentium M (Centrino) CPUs
39 or 64bit enabled Intel Xeons. 42 or 64bit enabled Intel Xeons.
40 43
44 To compile this driver as a module, choose M here: the
45 module will be called speedstep-centrino.
46
41 For details, take a look at <file:Documentation/cpu-freq/>. 47 For details, take a look at <file:Documentation/cpu-freq/>.
42 48
43 If in doubt, say N. 49 If in doubt, say N.
@@ -55,6 +61,9 @@ config X86_ACPI_CPUFREQ
55 Processor Performance States. 61 Processor Performance States.
56 This driver also supports Intel Enhanced Speedstep. 62 This driver also supports Intel Enhanced Speedstep.
57 63
64 To compile this driver as a module, choose M here: the
65 module will be called acpi-cpufreq.
66
58 For details, take a look at <file:Documentation/cpu-freq/>. 67 For details, take a look at <file:Documentation/cpu-freq/>.
59 68
60 If in doubt, say N. 69 If in doubt, say N.
@@ -62,7 +71,7 @@ config X86_ACPI_CPUFREQ
62comment "shared options" 71comment "shared options"
63 72
64config X86_ACPI_CPUFREQ_PROC_INTF 73config X86_ACPI_CPUFREQ_PROC_INTF
65 bool "/proc/acpi/processor/../performance interface (deprecated)" 74 bool "/proc/acpi/processor/../performance interface (deprecated)"
66 depends on PROC_FS 75 depends on PROC_FS
67 depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K8_ACPI 76 depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K8_ACPI
68 help 77 help
@@ -86,16 +95,18 @@ config X86_P4_CLOCKMOD
86 slowdowns and noticeable latencies. Normally Speedstep should be used 95 slowdowns and noticeable latencies. Normally Speedstep should be used
87 instead. 96 instead.
88 97
98 To compile this driver as a module, choose M here: the
99 module will be called p4-clockmod.
100
89 For details, take a look at <file:Documentation/cpu-freq/>. 101 For details, take a look at <file:Documentation/cpu-freq/>.
90 102
91 Unless you are absolutely sure say N. 103 Unless you are absolutely sure say N.
92 104
93 105
94config X86_SPEEDSTEP_LIB 106config X86_SPEEDSTEP_LIB
95 tristate 107 tristate
96 default X86_P4_CLOCKMOD 108 default X86_P4_CLOCKMOD
97 109
98endif 110endif
99 111
100endmenu 112endmenu
101
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index dd14ffa565b1..2a2df14dab7e 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -1954,18 +1954,18 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
1954 if (irq < 0) 1954 if (irq < 0)
1955 return irq; 1955 return irq;
1956 1956
1957 set_irq_msi(irq, desc);
1958 ret = msi_compose_msg(dev, irq, &msg); 1957 ret = msi_compose_msg(dev, irq, &msg);
1959 if (ret < 0) { 1958 if (ret < 0) {
1960 destroy_irq(irq); 1959 destroy_irq(irq);
1961 return ret; 1960 return ret;
1962 } 1961 }
1963 1962
1963 set_irq_msi(irq, desc);
1964 write_msi_msg(irq, &msg); 1964 write_msi_msg(irq, &msg);
1965 1965
1966 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); 1966 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge");
1967 1967
1968 return irq; 1968 return 0;
1969} 1969}
1970 1970
1971void arch_teardown_msi_irq(unsigned int irq) 1971void arch_teardown_msi_irq(unsigned int irq)
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 0b4cb93db5a3..cd7e6a020602 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -18,7 +18,6 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <asm/irq.h> 19#include <asm/irq.h>
20#include <linux/in6.h> 20#include <linux/in6.h>
21#include <linux/pci.h>
22#include <linux/ide.h> 21#include <linux/ide.h>
23 22
24#include <asm/uaccess.h> 23#include <asm/uaccess.h>
diff --git a/arch/xtensa/platform-iss/setup.c b/arch/xtensa/platform-iss/setup.c
index c8a42b60c57a..f60c8cf6dfbe 100644
--- a/arch/xtensa/platform-iss/setup.c
+++ b/arch/xtensa/platform-iss/setup.c
@@ -20,7 +20,6 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/reboot.h> 22#include <linux/reboot.h>
23#include <linux/pci.h>
24#include <linux/kdev_t.h> 23#include <linux/kdev_t.h>
25#include <linux/types.h> 24#include <linux/types.h>
26#include <linux/major.h> 25#include <linux/major.h>
diff --git a/block/genhd.c b/block/genhd.c
index 441432a142f2..b5664440896c 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -17,7 +17,7 @@
17#include <linux/buffer_head.h> 17#include <linux/buffer_head.h>
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19 19
20struct subsystem block_subsys; 20struct kset block_subsys;
21static DEFINE_MUTEX(block_subsys_lock); 21static DEFINE_MUTEX(block_subsys_lock);
22 22
23/* 23/*
@@ -221,7 +221,7 @@ static void *part_start(struct seq_file *part, loff_t *pos)
221 loff_t l = *pos; 221 loff_t l = *pos;
222 222
223 mutex_lock(&block_subsys_lock); 223 mutex_lock(&block_subsys_lock);
224 list_for_each(p, &block_subsys.kset.list) 224 list_for_each(p, &block_subsys.list)
225 if (!l--) 225 if (!l--)
226 return list_entry(p, struct gendisk, kobj.entry); 226 return list_entry(p, struct gendisk, kobj.entry);
227 return NULL; 227 return NULL;
@@ -231,7 +231,7 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
231{ 231{
232 struct list_head *p = ((struct gendisk *)v)->kobj.entry.next; 232 struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
233 ++*pos; 233 ++*pos;
234 return p==&block_subsys.kset.list ? NULL : 234 return p==&block_subsys.list ? NULL :
235 list_entry(p, struct gendisk, kobj.entry); 235 list_entry(p, struct gendisk, kobj.entry);
236} 236}
237 237
@@ -246,7 +246,7 @@ static int show_partition(struct seq_file *part, void *v)
246 int n; 246 int n;
247 char buf[BDEVNAME_SIZE]; 247 char buf[BDEVNAME_SIZE];
248 248
249 if (&sgp->kobj.entry == block_subsys.kset.list.next) 249 if (&sgp->kobj.entry == block_subsys.list.next)
250 seq_puts(part, "major minor #blocks name\n\n"); 250 seq_puts(part, "major minor #blocks name\n\n");
251 251
252 /* Don't show non-partitionable removeable devices or empty devices */ 252 /* Don't show non-partitionable removeable devices or empty devices */
@@ -565,7 +565,7 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos)
565 struct list_head *p; 565 struct list_head *p;
566 566
567 mutex_lock(&block_subsys_lock); 567 mutex_lock(&block_subsys_lock);
568 list_for_each(p, &block_subsys.kset.list) 568 list_for_each(p, &block_subsys.list)
569 if (!k--) 569 if (!k--)
570 return list_entry(p, struct gendisk, kobj.entry); 570 return list_entry(p, struct gendisk, kobj.entry);
571 return NULL; 571 return NULL;
@@ -575,7 +575,7 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
575{ 575{
576 struct list_head *p = ((struct gendisk *)v)->kobj.entry.next; 576 struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
577 ++*pos; 577 ++*pos;
578 return p==&block_subsys.kset.list ? NULL : 578 return p==&block_subsys.list ? NULL :
579 list_entry(p, struct gendisk, kobj.entry); 579 list_entry(p, struct gendisk, kobj.entry);
580} 580}
581 581
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 123003a90477..5873861e1dbb 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1925,6 +1925,8 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
1925 blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS); 1925 blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
1926 blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS); 1926 blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
1927 1927
1928 q->sg_reserved_size = INT_MAX;
1929
1928 /* 1930 /*
1929 * all done 1931 * all done
1930 */ 1932 */
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 65c6a3cba6d6..e83f1dbf7c29 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -78,7 +78,9 @@ static int sg_set_timeout(request_queue_t *q, int __user *p)
78 78
79static int sg_get_reserved_size(request_queue_t *q, int __user *p) 79static int sg_get_reserved_size(request_queue_t *q, int __user *p)
80{ 80{
81 return put_user(q->sg_reserved_size, p); 81 unsigned val = min(q->sg_reserved_size, q->max_sectors << 9);
82
83 return put_user(val, p);
82} 84}
83 85
84static int sg_set_reserved_size(request_queue_t *q, int __user *p) 86static int sg_set_reserved_size(request_queue_t *q, int __user *p)
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 086fcec44720..620e14cabdc6 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -16,6 +16,10 @@ config CRYPTO_ALGAPI
16 help 16 help
17 This option provides the API for cryptographic algorithms. 17 This option provides the API for cryptographic algorithms.
18 18
19config CRYPTO_ABLKCIPHER
20 tristate
21 select CRYPTO_BLKCIPHER
22
19config CRYPTO_BLKCIPHER 23config CRYPTO_BLKCIPHER
20 tristate 24 tristate
21 select CRYPTO_ALGAPI 25 select CRYPTO_ALGAPI
@@ -171,6 +175,15 @@ config CRYPTO_LRW
171 The first 128, 192 or 256 bits in the key are used for AES and the 175 The first 128, 192 or 256 bits in the key are used for AES and the
172 rest is used to tie each cipher block to its logical position. 176 rest is used to tie each cipher block to its logical position.
173 177
178config CRYPTO_CRYPTD
179 tristate "Software async crypto daemon"
180 select CRYPTO_ABLKCIPHER
181 select CRYPTO_MANAGER
182 help
183 This is a generic software asynchronous crypto daemon that
184 converts an arbitrary synchronous software crypto algorithm
185 into an asynchronous algorithm that executes in a kernel thread.
186
174config CRYPTO_DES 187config CRYPTO_DES
175 tristate "DES and Triple DES EDE cipher algorithms" 188 tristate "DES and Triple DES EDE cipher algorithms"
176 select CRYPTO_ALGAPI 189 select CRYPTO_ALGAPI
diff --git a/crypto/Makefile b/crypto/Makefile
index 12f93f578171..cce46a1c9dc7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -8,6 +8,7 @@ crypto_algapi-$(CONFIG_PROC_FS) += proc.o
8crypto_algapi-objs := algapi.o $(crypto_algapi-y) 8crypto_algapi-objs := algapi.o $(crypto_algapi-y)
9obj-$(CONFIG_CRYPTO_ALGAPI) += crypto_algapi.o 9obj-$(CONFIG_CRYPTO_ALGAPI) += crypto_algapi.o
10 10
11obj-$(CONFIG_CRYPTO_ABLKCIPHER) += ablkcipher.o
11obj-$(CONFIG_CRYPTO_BLKCIPHER) += blkcipher.o 12obj-$(CONFIG_CRYPTO_BLKCIPHER) += blkcipher.o
12 13
13crypto_hash-objs := hash.o 14crypto_hash-objs := hash.o
@@ -29,6 +30,7 @@ obj-$(CONFIG_CRYPTO_ECB) += ecb.o
29obj-$(CONFIG_CRYPTO_CBC) += cbc.o 30obj-$(CONFIG_CRYPTO_CBC) += cbc.o
30obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o 31obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
31obj-$(CONFIG_CRYPTO_LRW) += lrw.o 32obj-$(CONFIG_CRYPTO_LRW) += lrw.o
33obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
32obj-$(CONFIG_CRYPTO_DES) += des.o 34obj-$(CONFIG_CRYPTO_DES) += des.o
33obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o 35obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
34obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o 36obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
new file mode 100644
index 000000000000..9348ddd84a56
--- /dev/null
+++ b/crypto/ablkcipher.c
@@ -0,0 +1,83 @@
1/*
2 * Asynchronous block chaining cipher operations.
3 *
4 * This is the asynchronous version of blkcipher.c indicating completion
5 * via a callback.
6 *
7 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 */
15
16#include <crypto/algapi.h>
17#include <linux/errno.h>
18#include <linux/init.h>
19#include <linux/module.h>
20#include <linux/seq_file.h>
21
22static int setkey(struct crypto_ablkcipher *tfm, const u8 *key,
23 unsigned int keylen)
24{
25 struct ablkcipher_alg *cipher = crypto_ablkcipher_alg(tfm);
26
27 if (keylen < cipher->min_keysize || keylen > cipher->max_keysize) {
28 crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
29 return -EINVAL;
30 }
31
32 return cipher->setkey(tfm, key, keylen);
33}
34
35static unsigned int crypto_ablkcipher_ctxsize(struct crypto_alg *alg, u32 type,
36 u32 mask)
37{
38 return alg->cra_ctxsize;
39}
40
41static int crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type,
42 u32 mask)
43{
44 struct ablkcipher_alg *alg = &tfm->__crt_alg->cra_ablkcipher;
45 struct ablkcipher_tfm *crt = &tfm->crt_ablkcipher;
46
47 if (alg->ivsize > PAGE_SIZE / 8)
48 return -EINVAL;
49
50 crt->setkey = setkey;
51 crt->encrypt = alg->encrypt;
52 crt->decrypt = alg->decrypt;
53 crt->ivsize = alg->ivsize;
54
55 return 0;
56}
57
58static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
59 __attribute__ ((unused));
60static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
61{
62 struct ablkcipher_alg *ablkcipher = &alg->cra_ablkcipher;
63
64 seq_printf(m, "type : ablkcipher\n");
65 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
66 seq_printf(m, "min keysize : %u\n", ablkcipher->min_keysize);
67 seq_printf(m, "max keysize : %u\n", ablkcipher->max_keysize);
68 seq_printf(m, "ivsize : %u\n", ablkcipher->ivsize);
69 seq_printf(m, "qlen : %u\n", ablkcipher->queue->qlen);
70 seq_printf(m, "max qlen : %u\n", ablkcipher->queue->max_qlen);
71}
72
73const struct crypto_type crypto_ablkcipher_type = {
74 .ctxsize = crypto_ablkcipher_ctxsize,
75 .init = crypto_init_ablkcipher_ops,
76#ifdef CONFIG_PROC_FS
77 .show = crypto_ablkcipher_show,
78#endif
79};
80EXPORT_SYMBOL_GPL(crypto_ablkcipher_type);
81
82MODULE_LICENSE("GPL");
83MODULE_DESCRIPTION("Asynchronous block chaining cipher type");
diff --git a/crypto/algapi.c b/crypto/algapi.c
index f7d2185b2c8f..f137a432061f 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -84,36 +84,47 @@ static void crypto_destroy_instance(struct crypto_alg *alg)
84 crypto_tmpl_put(tmpl); 84 crypto_tmpl_put(tmpl);
85} 85}
86 86
87static void crypto_remove_spawns(struct list_head *spawns, 87static void crypto_remove_spawn(struct crypto_spawn *spawn,
88 struct list_head *list) 88 struct list_head *list,
89 struct list_head *secondary_spawns)
89{ 90{
90 struct crypto_spawn *spawn, *n; 91 struct crypto_instance *inst = spawn->inst;
92 struct crypto_template *tmpl = inst->tmpl;
91 93
92 list_for_each_entry_safe(spawn, n, spawns, list) { 94 list_del_init(&spawn->list);
93 struct crypto_instance *inst = spawn->inst; 95 spawn->alg = NULL;
94 struct crypto_template *tmpl = inst->tmpl;
95 96
96 list_del_init(&spawn->list); 97 if (crypto_is_dead(&inst->alg))
97 spawn->alg = NULL; 98 return;
98 99
99 if (crypto_is_dead(&inst->alg)) 100 inst->alg.cra_flags |= CRYPTO_ALG_DEAD;
100 continue; 101 if (!tmpl || !crypto_tmpl_get(tmpl))
102 return;
101 103
102 inst->alg.cra_flags |= CRYPTO_ALG_DEAD; 104 crypto_notify(CRYPTO_MSG_ALG_UNREGISTER, &inst->alg);
103 if (!tmpl || !crypto_tmpl_get(tmpl)) 105 list_move(&inst->alg.cra_list, list);
106 hlist_del(&inst->list);
107 inst->alg.cra_destroy = crypto_destroy_instance;
108
109 list_splice(&inst->alg.cra_users, secondary_spawns);
110}
111
112static void crypto_remove_spawns(struct list_head *spawns,
113 struct list_head *list, u32 new_type)
114{
115 struct crypto_spawn *spawn, *n;
116 LIST_HEAD(secondary_spawns);
117
118 list_for_each_entry_safe(spawn, n, spawns, list) {
119 if ((spawn->alg->cra_flags ^ new_type) & spawn->mask)
104 continue; 120 continue;
105 121
106 crypto_notify(CRYPTO_MSG_ALG_UNREGISTER, &inst->alg); 122 crypto_remove_spawn(spawn, list, &secondary_spawns);
107 list_move(&inst->alg.cra_list, list); 123 }
108 hlist_del(&inst->list);
109 inst->alg.cra_destroy = crypto_destroy_instance;
110 124
111 if (!list_empty(&inst->alg.cra_users)) { 125 while (!list_empty(&secondary_spawns)) {
112 if (&n->list == spawns) 126 list_for_each_entry_safe(spawn, n, &secondary_spawns, list)
113 n = list_entry(inst->alg.cra_users.next, 127 crypto_remove_spawn(spawn, list, &secondary_spawns);
114 typeof(*n), list);
115 __list_splice(&inst->alg.cra_users, spawns->prev);
116 }
117 } 128 }
118} 129}
119 130
@@ -164,7 +175,7 @@ static int __crypto_register_alg(struct crypto_alg *alg,
164 q->cra_priority > alg->cra_priority) 175 q->cra_priority > alg->cra_priority)
165 continue; 176 continue;
166 177
167 crypto_remove_spawns(&q->cra_users, list); 178 crypto_remove_spawns(&q->cra_users, list, alg->cra_flags);
168 } 179 }
169 180
170 list_add(&alg->cra_list, &crypto_alg_list); 181 list_add(&alg->cra_list, &crypto_alg_list);
@@ -214,7 +225,7 @@ static int crypto_remove_alg(struct crypto_alg *alg, struct list_head *list)
214 225
215 crypto_notify(CRYPTO_MSG_ALG_UNREGISTER, alg); 226 crypto_notify(CRYPTO_MSG_ALG_UNREGISTER, alg);
216 list_del_init(&alg->cra_list); 227 list_del_init(&alg->cra_list);
217 crypto_remove_spawns(&alg->cra_users, list); 228 crypto_remove_spawns(&alg->cra_users, list, alg->cra_flags);
218 229
219 return 0; 230 return 0;
220} 231}
@@ -351,11 +362,12 @@ err:
351EXPORT_SYMBOL_GPL(crypto_register_instance); 362EXPORT_SYMBOL_GPL(crypto_register_instance);
352 363
353int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, 364int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
354 struct crypto_instance *inst) 365 struct crypto_instance *inst, u32 mask)
355{ 366{
356 int err = -EAGAIN; 367 int err = -EAGAIN;
357 368
358 spawn->inst = inst; 369 spawn->inst = inst;
370 spawn->mask = mask;
359 371
360 down_write(&crypto_alg_sem); 372 down_write(&crypto_alg_sem);
361 if (!crypto_is_moribund(alg)) { 373 if (!crypto_is_moribund(alg)) {
@@ -425,15 +437,45 @@ int crypto_unregister_notifier(struct notifier_block *nb)
425} 437}
426EXPORT_SYMBOL_GPL(crypto_unregister_notifier); 438EXPORT_SYMBOL_GPL(crypto_unregister_notifier);
427 439
428struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len, 440struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb)
429 u32 type, u32 mask) 441{
442 struct rtattr *rta = tb[CRYPTOA_TYPE - 1];
443 struct crypto_attr_type *algt;
444
445 if (!rta)
446 return ERR_PTR(-ENOENT);
447 if (RTA_PAYLOAD(rta) < sizeof(*algt))
448 return ERR_PTR(-EINVAL);
449
450 algt = RTA_DATA(rta);
451
452 return algt;
453}
454EXPORT_SYMBOL_GPL(crypto_get_attr_type);
455
456int crypto_check_attr_type(struct rtattr **tb, u32 type)
430{ 457{
431 struct rtattr *rta = param; 458 struct crypto_attr_type *algt;
459
460 algt = crypto_get_attr_type(tb);
461 if (IS_ERR(algt))
462 return PTR_ERR(algt);
463
464 if ((algt->type ^ type) & algt->mask)
465 return -EINVAL;
466
467 return 0;
468}
469EXPORT_SYMBOL_GPL(crypto_check_attr_type);
470
471struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask)
472{
473 struct rtattr *rta = tb[CRYPTOA_ALG - 1];
432 struct crypto_attr_alg *alga; 474 struct crypto_attr_alg *alga;
433 475
434 if (!RTA_OK(rta, len)) 476 if (!rta)
435 return ERR_PTR(-EBADR); 477 return ERR_PTR(-ENOENT);
436 if (rta->rta_type != CRYPTOA_ALG || RTA_PAYLOAD(rta) < sizeof(*alga)) 478 if (RTA_PAYLOAD(rta) < sizeof(*alga))
437 return ERR_PTR(-EINVAL); 479 return ERR_PTR(-EINVAL);
438 480
439 alga = RTA_DATA(rta); 481 alga = RTA_DATA(rta);
@@ -464,7 +506,8 @@ struct crypto_instance *crypto_alloc_instance(const char *name,
464 goto err_free_inst; 506 goto err_free_inst;
465 507
466 spawn = crypto_instance_ctx(inst); 508 spawn = crypto_instance_ctx(inst);
467 err = crypto_init_spawn(spawn, alg, inst); 509 err = crypto_init_spawn(spawn, alg, inst,
510 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
468 511
469 if (err) 512 if (err)
470 goto err_free_inst; 513 goto err_free_inst;
@@ -477,6 +520,68 @@ err_free_inst:
477} 520}
478EXPORT_SYMBOL_GPL(crypto_alloc_instance); 521EXPORT_SYMBOL_GPL(crypto_alloc_instance);
479 522
523void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen)
524{
525 INIT_LIST_HEAD(&queue->list);
526 queue->backlog = &queue->list;
527 queue->qlen = 0;
528 queue->max_qlen = max_qlen;
529}
530EXPORT_SYMBOL_GPL(crypto_init_queue);
531
532int crypto_enqueue_request(struct crypto_queue *queue,
533 struct crypto_async_request *request)
534{
535 int err = -EINPROGRESS;
536
537 if (unlikely(queue->qlen >= queue->max_qlen)) {
538 err = -EBUSY;
539 if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG))
540 goto out;
541 if (queue->backlog == &queue->list)
542 queue->backlog = &request->list;
543 }
544
545 queue->qlen++;
546 list_add_tail(&request->list, &queue->list);
547
548out:
549 return err;
550}
551EXPORT_SYMBOL_GPL(crypto_enqueue_request);
552
553struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue)
554{
555 struct list_head *request;
556
557 if (unlikely(!queue->qlen))
558 return NULL;
559
560 queue->qlen--;
561
562 if (queue->backlog != &queue->list)
563 queue->backlog = queue->backlog->next;
564
565 request = queue->list.next;
566 list_del(request);
567
568 return list_entry(request, struct crypto_async_request, list);
569}
570EXPORT_SYMBOL_GPL(crypto_dequeue_request);
571
572int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm)
573{
574 struct crypto_async_request *req;
575
576 list_for_each_entry(req, &queue->list, list) {
577 if (req->tfm == tfm)
578 return 1;
579 }
580
581 return 0;
582}
583EXPORT_SYMBOL_GPL(crypto_tfm_in_queue);
584
480static int __init crypto_algapi_init(void) 585static int __init crypto_algapi_init(void)
481{ 586{
482 crypto_init_proc(); 587 crypto_init_proc();
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index b5befe8c3a96..8edf40c835a7 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -349,13 +349,48 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key,
349 return cipher->setkey(tfm, key, keylen); 349 return cipher->setkey(tfm, key, keylen);
350} 350}
351 351
352static int async_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
353 unsigned int keylen)
354{
355 return setkey(crypto_ablkcipher_tfm(tfm), key, keylen);
356}
357
358static int async_encrypt(struct ablkcipher_request *req)
359{
360 struct crypto_tfm *tfm = req->base.tfm;
361 struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
362 struct blkcipher_desc desc = {
363 .tfm = __crypto_blkcipher_cast(tfm),
364 .info = req->info,
365 .flags = req->base.flags,
366 };
367
368
369 return alg->encrypt(&desc, req->dst, req->src, req->nbytes);
370}
371
372static int async_decrypt(struct ablkcipher_request *req)
373{
374 struct crypto_tfm *tfm = req->base.tfm;
375 struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
376 struct blkcipher_desc desc = {
377 .tfm = __crypto_blkcipher_cast(tfm),
378 .info = req->info,
379 .flags = req->base.flags,
380 };
381
382 return alg->decrypt(&desc, req->dst, req->src, req->nbytes);
383}
384
352static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type, 385static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type,
353 u32 mask) 386 u32 mask)
354{ 387{
355 struct blkcipher_alg *cipher = &alg->cra_blkcipher; 388 struct blkcipher_alg *cipher = &alg->cra_blkcipher;
356 unsigned int len = alg->cra_ctxsize; 389 unsigned int len = alg->cra_ctxsize;
357 390
358 if (cipher->ivsize) { 391 type ^= CRYPTO_ALG_ASYNC;
392 mask &= CRYPTO_ALG_ASYNC;
393 if ((type & mask) && cipher->ivsize) {
359 len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1); 394 len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);
360 len += cipher->ivsize; 395 len += cipher->ivsize;
361 } 396 }
@@ -363,16 +398,26 @@ static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type,
363 return len; 398 return len;
364} 399}
365 400
366static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask) 401static int crypto_init_blkcipher_ops_async(struct crypto_tfm *tfm)
402{
403 struct ablkcipher_tfm *crt = &tfm->crt_ablkcipher;
404 struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
405
406 crt->setkey = async_setkey;
407 crt->encrypt = async_encrypt;
408 crt->decrypt = async_decrypt;
409 crt->ivsize = alg->ivsize;
410
411 return 0;
412}
413
414static int crypto_init_blkcipher_ops_sync(struct crypto_tfm *tfm)
367{ 415{
368 struct blkcipher_tfm *crt = &tfm->crt_blkcipher; 416 struct blkcipher_tfm *crt = &tfm->crt_blkcipher;
369 struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher; 417 struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
370 unsigned long align = crypto_tfm_alg_alignmask(tfm) + 1; 418 unsigned long align = crypto_tfm_alg_alignmask(tfm) + 1;
371 unsigned long addr; 419 unsigned long addr;
372 420
373 if (alg->ivsize > PAGE_SIZE / 8)
374 return -EINVAL;
375
376 crt->setkey = setkey; 421 crt->setkey = setkey;
377 crt->encrypt = alg->encrypt; 422 crt->encrypt = alg->encrypt;
378 crt->decrypt = alg->decrypt; 423 crt->decrypt = alg->decrypt;
@@ -385,8 +430,23 @@ static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
385 return 0; 430 return 0;
386} 431}
387 432
433static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
434{
435 struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
436
437 if (alg->ivsize > PAGE_SIZE / 8)
438 return -EINVAL;
439
440 type ^= CRYPTO_ALG_ASYNC;
441 mask &= CRYPTO_ALG_ASYNC;
442 if (type & mask)
443 return crypto_init_blkcipher_ops_sync(tfm);
444 else
445 return crypto_init_blkcipher_ops_async(tfm);
446}
447
388static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg) 448static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
389 __attribute_used__; 449 __attribute__ ((unused));
390static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg) 450static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
391{ 451{
392 seq_printf(m, "type : blkcipher\n"); 452 seq_printf(m, "type : blkcipher\n");
diff --git a/crypto/cbc.c b/crypto/cbc.c
index 136fea7e7000..1f2649e13b42 100644
--- a/crypto/cbc.c
+++ b/crypto/cbc.c
@@ -275,13 +275,18 @@ static void crypto_cbc_exit_tfm(struct crypto_tfm *tfm)
275 crypto_free_cipher(ctx->child); 275 crypto_free_cipher(ctx->child);
276} 276}
277 277
278static struct crypto_instance *crypto_cbc_alloc(void *param, unsigned int len) 278static struct crypto_instance *crypto_cbc_alloc(struct rtattr **tb)
279{ 279{
280 struct crypto_instance *inst; 280 struct crypto_instance *inst;
281 struct crypto_alg *alg; 281 struct crypto_alg *alg;
282 int err;
283
284 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER);
285 if (err)
286 return ERR_PTR(err);
282 287
283 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER, 288 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
284 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); 289 CRYPTO_ALG_TYPE_MASK);
285 if (IS_ERR(alg)) 290 if (IS_ERR(alg))
286 return ERR_PTR(PTR_ERR(alg)); 291 return ERR_PTR(PTR_ERR(alg));
287 292
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
new file mode 100644
index 000000000000..3ff4e1f0f032
--- /dev/null
+++ b/crypto/cryptd.c
@@ -0,0 +1,375 @@
1/*
2 * Software async crypto daemon.
3 *
4 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
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 Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#include <crypto/algapi.h>
14#include <linux/err.h>
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/kthread.h>
18#include <linux/list.h>
19#include <linux/module.h>
20#include <linux/mutex.h>
21#include <linux/scatterlist.h>
22#include <linux/sched.h>
23#include <linux/slab.h>
24#include <linux/spinlock.h>
25
26#define CRYPTD_MAX_QLEN 100
27
28struct cryptd_state {
29 spinlock_t lock;
30 struct mutex mutex;
31 struct crypto_queue queue;
32 struct task_struct *task;
33};
34
35struct cryptd_instance_ctx {
36 struct crypto_spawn spawn;
37 struct cryptd_state *state;
38};
39
40struct cryptd_blkcipher_ctx {
41 struct crypto_blkcipher *child;
42};
43
44struct cryptd_blkcipher_request_ctx {
45 crypto_completion_t complete;
46};
47
48
49static inline struct cryptd_state *cryptd_get_state(struct crypto_tfm *tfm)
50{
51 struct crypto_instance *inst = crypto_tfm_alg_instance(tfm);
52 struct cryptd_instance_ctx *ictx = crypto_instance_ctx(inst);
53 return ictx->state;
54}
55
56static int cryptd_blkcipher_setkey(struct crypto_ablkcipher *parent,
57 const u8 *key, unsigned int keylen)
58{
59 struct cryptd_blkcipher_ctx *ctx = crypto_ablkcipher_ctx(parent);
60 struct crypto_blkcipher *child = ctx->child;
61 int err;
62
63 crypto_blkcipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
64 crypto_blkcipher_set_flags(child, crypto_ablkcipher_get_flags(parent) &
65 CRYPTO_TFM_REQ_MASK);
66 err = crypto_blkcipher_setkey(child, key, keylen);
67 crypto_ablkcipher_set_flags(parent, crypto_blkcipher_get_flags(child) &
68 CRYPTO_TFM_RES_MASK);
69 return err;
70}
71
72static void cryptd_blkcipher_crypt(struct ablkcipher_request *req,
73 struct crypto_blkcipher *child,
74 int err,
75 int (*crypt)(struct blkcipher_desc *desc,
76 struct scatterlist *dst,
77 struct scatterlist *src,
78 unsigned int len))
79{
80 struct cryptd_blkcipher_request_ctx *rctx;
81 struct blkcipher_desc desc;
82
83 rctx = ablkcipher_request_ctx(req);
84
85 if (unlikely(err == -EINPROGRESS)) {
86 rctx->complete(&req->base, err);
87 return;
88 }
89
90 desc.tfm = child;
91 desc.info = req->info;
92 desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
93
94 err = crypt(&desc, req->dst, req->src, req->nbytes);
95
96 req->base.complete = rctx->complete;
97
98 local_bh_disable();
99 req->base.complete(&req->base, err);
100 local_bh_enable();
101}
102
103static void cryptd_blkcipher_encrypt(struct crypto_async_request *req, int err)
104{
105 struct cryptd_blkcipher_ctx *ctx = crypto_tfm_ctx(req->tfm);
106 struct crypto_blkcipher *child = ctx->child;
107
108 cryptd_blkcipher_crypt(ablkcipher_request_cast(req), child, err,
109 crypto_blkcipher_crt(child)->encrypt);
110}
111
112static void cryptd_blkcipher_decrypt(struct crypto_async_request *req, int err)
113{
114 struct cryptd_blkcipher_ctx *ctx = crypto_tfm_ctx(req->tfm);
115 struct crypto_blkcipher *child = ctx->child;
116
117 cryptd_blkcipher_crypt(ablkcipher_request_cast(req), child, err,
118 crypto_blkcipher_crt(child)->decrypt);
119}
120
121static int cryptd_blkcipher_enqueue(struct ablkcipher_request *req,
122 crypto_completion_t complete)
123{
124 struct cryptd_blkcipher_request_ctx *rctx = ablkcipher_request_ctx(req);
125 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
126 struct cryptd_state *state =
127 cryptd_get_state(crypto_ablkcipher_tfm(tfm));
128 int err;
129
130 rctx->complete = req->base.complete;
131 req->base.complete = complete;
132
133 spin_lock_bh(&state->lock);
134 err = ablkcipher_enqueue_request(crypto_ablkcipher_alg(tfm), req);
135 spin_unlock_bh(&state->lock);
136
137 wake_up_process(state->task);
138 return err;
139}
140
141static int cryptd_blkcipher_encrypt_enqueue(struct ablkcipher_request *req)
142{
143 return cryptd_blkcipher_enqueue(req, cryptd_blkcipher_encrypt);
144}
145
146static int cryptd_blkcipher_decrypt_enqueue(struct ablkcipher_request *req)
147{
148 return cryptd_blkcipher_enqueue(req, cryptd_blkcipher_decrypt);
149}
150
151static int cryptd_blkcipher_init_tfm(struct crypto_tfm *tfm)
152{
153 struct crypto_instance *inst = crypto_tfm_alg_instance(tfm);
154 struct cryptd_instance_ctx *ictx = crypto_instance_ctx(inst);
155 struct crypto_spawn *spawn = &ictx->spawn;
156 struct cryptd_blkcipher_ctx *ctx = crypto_tfm_ctx(tfm);
157 struct crypto_blkcipher *cipher;
158
159 cipher = crypto_spawn_blkcipher(spawn);
160 if (IS_ERR(cipher))
161 return PTR_ERR(cipher);
162
163 ctx->child = cipher;
164 tfm->crt_ablkcipher.reqsize =
165 sizeof(struct cryptd_blkcipher_request_ctx);
166 return 0;
167}
168
169static void cryptd_blkcipher_exit_tfm(struct crypto_tfm *tfm)
170{
171 struct cryptd_blkcipher_ctx *ctx = crypto_tfm_ctx(tfm);
172 struct cryptd_state *state = cryptd_get_state(tfm);
173 int active;
174
175 mutex_lock(&state->mutex);
176 active = ablkcipher_tfm_in_queue(__crypto_ablkcipher_cast(tfm));
177 mutex_unlock(&state->mutex);
178
179 BUG_ON(active);
180
181 crypto_free_blkcipher(ctx->child);
182}
183
184static struct crypto_instance *cryptd_alloc_instance(struct crypto_alg *alg,
185 struct cryptd_state *state)
186{
187 struct crypto_instance *inst;
188 struct cryptd_instance_ctx *ctx;
189 int err;
190
191 inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
192 if (IS_ERR(inst))
193 goto out;
194
195 err = -ENAMETOOLONG;
196 if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
197 "cryptd(%s)", alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
198 goto out_free_inst;
199
200 ctx = crypto_instance_ctx(inst);
201 err = crypto_init_spawn(&ctx->spawn, alg, inst,
202 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
203 if (err)
204 goto out_free_inst;
205
206 ctx->state = state;
207
208 memcpy(inst->alg.cra_name, alg->cra_name, CRYPTO_MAX_ALG_NAME);
209
210 inst->alg.cra_priority = alg->cra_priority + 50;
211 inst->alg.cra_blocksize = alg->cra_blocksize;
212 inst->alg.cra_alignmask = alg->cra_alignmask;
213
214out:
215 return inst;
216
217out_free_inst:
218 kfree(inst);
219 inst = ERR_PTR(err);
220 goto out;
221}
222
223static struct crypto_instance *cryptd_alloc_blkcipher(
224 struct rtattr **tb, struct cryptd_state *state)
225{
226 struct crypto_instance *inst;
227 struct crypto_alg *alg;
228
229 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_BLKCIPHER,
230 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
231 if (IS_ERR(alg))
232 return ERR_PTR(PTR_ERR(alg));
233
234 inst = cryptd_alloc_instance(alg, state);
235 if (IS_ERR(inst))
236 goto out_put_alg;
237
238 inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_ASYNC;
239 inst->alg.cra_type = &crypto_ablkcipher_type;
240
241 inst->alg.cra_ablkcipher.ivsize = alg->cra_blkcipher.ivsize;
242 inst->alg.cra_ablkcipher.min_keysize = alg->cra_blkcipher.min_keysize;
243 inst->alg.cra_ablkcipher.max_keysize = alg->cra_blkcipher.max_keysize;
244
245 inst->alg.cra_ctxsize = sizeof(struct cryptd_blkcipher_ctx);
246
247 inst->alg.cra_init = cryptd_blkcipher_init_tfm;
248 inst->alg.cra_exit = cryptd_blkcipher_exit_tfm;
249
250 inst->alg.cra_ablkcipher.setkey = cryptd_blkcipher_setkey;
251 inst->alg.cra_ablkcipher.encrypt = cryptd_blkcipher_encrypt_enqueue;
252 inst->alg.cra_ablkcipher.decrypt = cryptd_blkcipher_decrypt_enqueue;
253
254 inst->alg.cra_ablkcipher.queue = &state->queue;
255
256out_put_alg:
257 crypto_mod_put(alg);
258 return inst;
259}
260
261static struct cryptd_state state;
262
263static struct crypto_instance *cryptd_alloc(struct rtattr **tb)
264{
265 struct crypto_attr_type *algt;
266
267 algt = crypto_get_attr_type(tb);
268 if (IS_ERR(algt))
269 return ERR_PTR(PTR_ERR(algt));
270
271 switch (algt->type & algt->mask & CRYPTO_ALG_TYPE_MASK) {
272 case CRYPTO_ALG_TYPE_BLKCIPHER:
273 return cryptd_alloc_blkcipher(tb, &state);
274 }
275
276 return ERR_PTR(-EINVAL);
277}
278
279static void cryptd_free(struct crypto_instance *inst)
280{
281 struct cryptd_instance_ctx *ctx = crypto_instance_ctx(inst);
282
283 crypto_drop_spawn(&ctx->spawn);
284 kfree(inst);
285}
286
287static struct crypto_template cryptd_tmpl = {
288 .name = "cryptd",
289 .alloc = cryptd_alloc,
290 .free = cryptd_free,
291 .module = THIS_MODULE,
292};
293
294static inline int cryptd_create_thread(struct cryptd_state *state,
295 int (*fn)(void *data), const char *name)
296{
297 spin_lock_init(&state->lock);
298 mutex_init(&state->mutex);
299 crypto_init_queue(&state->queue, CRYPTD_MAX_QLEN);
300
301 state->task = kthread_create(fn, state, name);
302 if (IS_ERR(state->task))
303 return PTR_ERR(state->task);
304
305 return 0;
306}
307
308static inline void cryptd_stop_thread(struct cryptd_state *state)
309{
310 BUG_ON(state->queue.qlen);
311 kthread_stop(state->task);
312}
313
314static int cryptd_thread(void *data)
315{
316 struct cryptd_state *state = data;
317 int stop;
318
319 do {
320 struct crypto_async_request *req, *backlog;
321
322 mutex_lock(&state->mutex);
323 __set_current_state(TASK_INTERRUPTIBLE);
324
325 spin_lock_bh(&state->lock);
326 backlog = crypto_get_backlog(&state->queue);
327 req = crypto_dequeue_request(&state->queue);
328 spin_unlock_bh(&state->lock);
329
330 stop = kthread_should_stop();
331
332 if (stop || req) {
333 __set_current_state(TASK_RUNNING);
334 if (req) {
335 if (backlog)
336 backlog->complete(backlog,
337 -EINPROGRESS);
338 req->complete(req, 0);
339 }
340 }
341
342 mutex_unlock(&state->mutex);
343
344 schedule();
345 } while (!stop);
346
347 return 0;
348}
349
350static int __init cryptd_init(void)
351{
352 int err;
353
354 err = cryptd_create_thread(&state, cryptd_thread, "cryptd");
355 if (err)
356 return err;
357
358 err = crypto_register_template(&cryptd_tmpl);
359 if (err)
360 kthread_stop(state.task);
361
362 return err;
363}
364
365static void __exit cryptd_exit(void)
366{
367 cryptd_stop_thread(&state);
368 crypto_unregister_template(&cryptd_tmpl);
369}
370
371module_init(cryptd_init);
372module_exit(cryptd_exit);
373
374MODULE_LICENSE("GPL");
375MODULE_DESCRIPTION("Software async crypto daemon");
diff --git a/crypto/cryptomgr.c b/crypto/cryptomgr.c
index 2ebffb84f1d9..6958ea83ee44 100644
--- a/crypto/cryptomgr.c
+++ b/crypto/cryptomgr.c
@@ -14,17 +14,24 @@
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/kthread.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/notifier.h> 19#include <linux/notifier.h>
19#include <linux/rtnetlink.h> 20#include <linux/rtnetlink.h>
20#include <linux/sched.h> 21#include <linux/sched.h>
21#include <linux/string.h> 22#include <linux/string.h>
22#include <linux/workqueue.h>
23 23
24#include "internal.h" 24#include "internal.h"
25 25
26struct cryptomgr_param { 26struct cryptomgr_param {
27 struct work_struct work; 27 struct task_struct *thread;
28
29 struct rtattr *tb[CRYPTOA_MAX];
30
31 struct {
32 struct rtattr attr;
33 struct crypto_attr_type data;
34 } type;
28 35
29 struct { 36 struct {
30 struct rtattr attr; 37 struct rtattr attr;
@@ -32,18 +39,15 @@ struct cryptomgr_param {
32 } alg; 39 } alg;
33 40
34 struct { 41 struct {
35 u32 type;
36 u32 mask;
37 char name[CRYPTO_MAX_ALG_NAME]; 42 char name[CRYPTO_MAX_ALG_NAME];
38 } larval; 43 } larval;
39 44
40 char template[CRYPTO_MAX_ALG_NAME]; 45 char template[CRYPTO_MAX_ALG_NAME];
41}; 46};
42 47
43static void cryptomgr_probe(struct work_struct *work) 48static int cryptomgr_probe(void *data)
44{ 49{
45 struct cryptomgr_param *param = 50 struct cryptomgr_param *param = data;
46 container_of(work, struct cryptomgr_param, work);
47 struct crypto_template *tmpl; 51 struct crypto_template *tmpl;
48 struct crypto_instance *inst; 52 struct crypto_instance *inst;
49 int err; 53 int err;
@@ -53,7 +57,7 @@ static void cryptomgr_probe(struct work_struct *work)
53 goto err; 57 goto err;
54 58
55 do { 59 do {
56 inst = tmpl->alloc(&param->alg, sizeof(param->alg)); 60 inst = tmpl->alloc(param->tb);
57 if (IS_ERR(inst)) 61 if (IS_ERR(inst))
58 err = PTR_ERR(inst); 62 err = PTR_ERR(inst);
59 else if ((err = crypto_register_instance(tmpl, inst))) 63 else if ((err = crypto_register_instance(tmpl, inst)))
@@ -67,11 +71,11 @@ static void cryptomgr_probe(struct work_struct *work)
67 71
68out: 72out:
69 kfree(param); 73 kfree(param);
70 return; 74 module_put_and_exit(0);
71 75
72err: 76err:
73 crypto_larval_error(param->larval.name, param->larval.type, 77 crypto_larval_error(param->larval.name, param->type.data.type,
74 param->larval.mask); 78 param->type.data.mask);
75 goto out; 79 goto out;
76} 80}
77 81
@@ -82,10 +86,13 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
82 const char *p; 86 const char *p;
83 unsigned int len; 87 unsigned int len;
84 88
85 param = kmalloc(sizeof(*param), GFP_KERNEL); 89 if (!try_module_get(THIS_MODULE))
86 if (!param)
87 goto err; 90 goto err;
88 91
92 param = kzalloc(sizeof(*param), GFP_KERNEL);
93 if (!param)
94 goto err_put_module;
95
89 for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++) 96 for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++)
90 ; 97 ;
91 98
@@ -94,32 +101,45 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
94 goto err_free_param; 101 goto err_free_param;
95 102
96 memcpy(param->template, name, len); 103 memcpy(param->template, name, len);
97 param->template[len] = 0;
98 104
99 name = p + 1; 105 name = p + 1;
100 for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++) 106 len = 0;
101 ; 107 for (p = name; *p; p++) {
108 for (; isalnum(*p) || *p == '-' || *p == '_' || *p == '('; p++)
109 ;
102 110
103 len = p - name; 111 if (*p != ')')
104 if (!len || *p != ')' || p[1]) 112 goto err_free_param;
113
114 len = p - name;
115 }
116
117 if (!len || name[len + 1])
105 goto err_free_param; 118 goto err_free_param;
106 119
120 param->type.attr.rta_len = sizeof(param->type);
121 param->type.attr.rta_type = CRYPTOA_TYPE;
122 param->type.data.type = larval->alg.cra_flags;
123 param->type.data.mask = larval->mask;
124 param->tb[CRYPTOA_TYPE - 1] = &param->type.attr;
125
107 param->alg.attr.rta_len = sizeof(param->alg); 126 param->alg.attr.rta_len = sizeof(param->alg);
108 param->alg.attr.rta_type = CRYPTOA_ALG; 127 param->alg.attr.rta_type = CRYPTOA_ALG;
109 memcpy(param->alg.data.name, name, len); 128 memcpy(param->alg.data.name, name, len);
110 param->alg.data.name[len] = 0; 129 param->tb[CRYPTOA_ALG - 1] = &param->alg.attr;
111 130
112 memcpy(param->larval.name, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME); 131 memcpy(param->larval.name, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME);
113 param->larval.type = larval->alg.cra_flags;
114 param->larval.mask = larval->mask;
115 132
116 INIT_WORK(&param->work, cryptomgr_probe); 133 param->thread = kthread_run(cryptomgr_probe, param, "cryptomgr");
117 schedule_work(&param->work); 134 if (IS_ERR(param->thread))
135 goto err_free_param;
118 136
119 return NOTIFY_STOP; 137 return NOTIFY_STOP;
120 138
121err_free_param: 139err_free_param:
122 kfree(param); 140 kfree(param);
141err_put_module:
142 module_put(THIS_MODULE);
123err: 143err:
124 return NOTIFY_OK; 144 return NOTIFY_OK;
125} 145}
diff --git a/crypto/ecb.c b/crypto/ecb.c
index 839a0aed8c22..6310387a872c 100644
--- a/crypto/ecb.c
+++ b/crypto/ecb.c
@@ -115,13 +115,18 @@ static void crypto_ecb_exit_tfm(struct crypto_tfm *tfm)
115 crypto_free_cipher(ctx->child); 115 crypto_free_cipher(ctx->child);
116} 116}
117 117
118static struct crypto_instance *crypto_ecb_alloc(void *param, unsigned int len) 118static struct crypto_instance *crypto_ecb_alloc(struct rtattr **tb)
119{ 119{
120 struct crypto_instance *inst; 120 struct crypto_instance *inst;
121 struct crypto_alg *alg; 121 struct crypto_alg *alg;
122 int err;
123
124 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER);
125 if (err)
126 return ERR_PTR(err);
122 127
123 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER, 128 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
124 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); 129 CRYPTO_ALG_TYPE_MASK);
125 if (IS_ERR(alg)) 130 if (IS_ERR(alg))
126 return ERR_PTR(PTR_ERR(alg)); 131 return ERR_PTR(PTR_ERR(alg));
127 132
diff --git a/crypto/hash.c b/crypto/hash.c
index 12c4514f3478..4ccd22deef39 100644
--- a/crypto/hash.c
+++ b/crypto/hash.c
@@ -41,7 +41,7 @@ static int crypto_init_hash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
41} 41}
42 42
43static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg) 43static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg)
44 __attribute_used__; 44 __attribute__ ((unused));
45static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg) 45static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg)
46{ 46{
47 seq_printf(m, "type : hash\n"); 47 seq_printf(m, "type : hash\n");
diff --git a/crypto/hmac.c b/crypto/hmac.c
index 44187c5ee593..8802fb6dd5a6 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -197,13 +197,18 @@ static void hmac_free(struct crypto_instance *inst)
197 kfree(inst); 197 kfree(inst);
198} 198}
199 199
200static struct crypto_instance *hmac_alloc(void *param, unsigned int len) 200static struct crypto_instance *hmac_alloc(struct rtattr **tb)
201{ 201{
202 struct crypto_instance *inst; 202 struct crypto_instance *inst;
203 struct crypto_alg *alg; 203 struct crypto_alg *alg;
204 int err;
205
206 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_HASH);
207 if (err)
208 return ERR_PTR(err);
204 209
205 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_HASH, 210 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_HASH,
206 CRYPTO_ALG_TYPE_HASH_MASK | CRYPTO_ALG_ASYNC); 211 CRYPTO_ALG_TYPE_HASH_MASK);
207 if (IS_ERR(alg)) 212 if (IS_ERR(alg))
208 return ERR_PTR(PTR_ERR(alg)); 213 return ERR_PTR(PTR_ERR(alg));
209 214
diff --git a/crypto/lrw.c b/crypto/lrw.c
index b4105080ac7a..621095db28b3 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -228,13 +228,18 @@ static void exit_tfm(struct crypto_tfm *tfm)
228 crypto_free_cipher(ctx->child); 228 crypto_free_cipher(ctx->child);
229} 229}
230 230
231static struct crypto_instance *alloc(void *param, unsigned int len) 231static struct crypto_instance *alloc(struct rtattr **tb)
232{ 232{
233 struct crypto_instance *inst; 233 struct crypto_instance *inst;
234 struct crypto_alg *alg; 234 struct crypto_alg *alg;
235 int err;
236
237 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER);
238 if (err)
239 return ERR_PTR(err);
235 240
236 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER, 241 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
237 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); 242 CRYPTO_ALG_TYPE_MASK);
238 if (IS_ERR(alg)) 243 if (IS_ERR(alg))
239 return ERR_PTR(PTR_ERR(alg)); 244 return ERR_PTR(PTR_ERR(alg));
240 245
diff --git a/crypto/pcbc.c b/crypto/pcbc.c
index 5174d7fdad6e..c3ed8a1c9f46 100644
--- a/crypto/pcbc.c
+++ b/crypto/pcbc.c
@@ -279,13 +279,18 @@ static void crypto_pcbc_exit_tfm(struct crypto_tfm *tfm)
279 crypto_free_cipher(ctx->child); 279 crypto_free_cipher(ctx->child);
280} 280}
281 281
282static struct crypto_instance *crypto_pcbc_alloc(void *param, unsigned int len) 282static struct crypto_instance *crypto_pcbc_alloc(struct rtattr **tb)
283{ 283{
284 struct crypto_instance *inst; 284 struct crypto_instance *inst;
285 struct crypto_alg *alg; 285 struct crypto_alg *alg;
286 int err;
287
288 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER);
289 if (err)
290 return ERR_PTR(err);
286 291
287 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER, 292 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
288 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); 293 CRYPTO_ALG_TYPE_MASK);
289 if (IS_ERR(alg)) 294 if (IS_ERR(alg))
290 return ERR_PTR(PTR_ERR(alg)); 295 return ERR_PTR(PTR_ERR(alg));
291 296
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 8eaa5aa210b0..f0aed0106adb 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -57,6 +57,11 @@
57#define ENCRYPT 1 57#define ENCRYPT 1
58#define DECRYPT 0 58#define DECRYPT 0
59 59
60struct tcrypt_result {
61 struct completion completion;
62 int err;
63};
64
60static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 }; 65static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
61 66
62/* 67/*
@@ -84,6 +89,17 @@ static void hexdump(unsigned char *buf, unsigned int len)
84 printk("\n"); 89 printk("\n");
85} 90}
86 91
92static void tcrypt_complete(struct crypto_async_request *req, int err)
93{
94 struct tcrypt_result *res = req->data;
95
96 if (err == -EINPROGRESS)
97 return;
98
99 res->err = err;
100 complete(&res->completion);
101}
102
87static void test_hash(char *algo, struct hash_testvec *template, 103static void test_hash(char *algo, struct hash_testvec *template,
88 unsigned int tcount) 104 unsigned int tcount)
89{ 105{
@@ -203,15 +219,14 @@ static void test_cipher(char *algo, int enc,
203{ 219{
204 unsigned int ret, i, j, k, temp; 220 unsigned int ret, i, j, k, temp;
205 unsigned int tsize; 221 unsigned int tsize;
206 unsigned int iv_len;
207 unsigned int len;
208 char *q; 222 char *q;
209 struct crypto_blkcipher *tfm; 223 struct crypto_ablkcipher *tfm;
210 char *key; 224 char *key;
211 struct cipher_testvec *cipher_tv; 225 struct cipher_testvec *cipher_tv;
212 struct blkcipher_desc desc; 226 struct ablkcipher_request *req;
213 struct scatterlist sg[8]; 227 struct scatterlist sg[8];
214 const char *e; 228 const char *e;
229 struct tcrypt_result result;
215 230
216 if (enc == ENCRYPT) 231 if (enc == ENCRYPT)
217 e = "encryption"; 232 e = "encryption";
@@ -232,15 +247,24 @@ static void test_cipher(char *algo, int enc,
232 memcpy(tvmem, template, tsize); 247 memcpy(tvmem, template, tsize);
233 cipher_tv = (void *)tvmem; 248 cipher_tv = (void *)tvmem;
234 249
235 tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC); 250 init_completion(&result.completion);
251
252 tfm = crypto_alloc_ablkcipher(algo, 0, 0);
236 253
237 if (IS_ERR(tfm)) { 254 if (IS_ERR(tfm)) {
238 printk("failed to load transform for %s: %ld\n", algo, 255 printk("failed to load transform for %s: %ld\n", algo,
239 PTR_ERR(tfm)); 256 PTR_ERR(tfm));
240 return; 257 return;
241 } 258 }
242 desc.tfm = tfm; 259
243 desc.flags = 0; 260 req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
261 if (!req) {
262 printk("failed to allocate request for %s\n", algo);
263 goto out;
264 }
265
266 ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
267 tcrypt_complete, &result);
244 268
245 j = 0; 269 j = 0;
246 for (i = 0; i < tcount; i++) { 270 for (i = 0; i < tcount; i++) {
@@ -249,17 +273,17 @@ static void test_cipher(char *algo, int enc,
249 printk("test %u (%d bit key):\n", 273 printk("test %u (%d bit key):\n",
250 j, cipher_tv[i].klen * 8); 274 j, cipher_tv[i].klen * 8);
251 275
252 crypto_blkcipher_clear_flags(tfm, ~0); 276 crypto_ablkcipher_clear_flags(tfm, ~0);
253 if (cipher_tv[i].wk) 277 if (cipher_tv[i].wk)
254 crypto_blkcipher_set_flags( 278 crypto_ablkcipher_set_flags(
255 tfm, CRYPTO_TFM_REQ_WEAK_KEY); 279 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
256 key = cipher_tv[i].key; 280 key = cipher_tv[i].key;
257 281
258 ret = crypto_blkcipher_setkey(tfm, key, 282 ret = crypto_ablkcipher_setkey(tfm, key,
259 cipher_tv[i].klen); 283 cipher_tv[i].klen);
260 if (ret) { 284 if (ret) {
261 printk("setkey() failed flags=%x\n", 285 printk("setkey() failed flags=%x\n",
262 crypto_blkcipher_get_flags(tfm)); 286 crypto_ablkcipher_get_flags(tfm));
263 287
264 if (!cipher_tv[i].fail) 288 if (!cipher_tv[i].fail)
265 goto out; 289 goto out;
@@ -268,19 +292,28 @@ static void test_cipher(char *algo, int enc,
268 sg_set_buf(&sg[0], cipher_tv[i].input, 292 sg_set_buf(&sg[0], cipher_tv[i].input,
269 cipher_tv[i].ilen); 293 cipher_tv[i].ilen);
270 294
271 iv_len = crypto_blkcipher_ivsize(tfm); 295 ablkcipher_request_set_crypt(req, sg, sg,
272 if (iv_len) 296 cipher_tv[i].ilen,
273 crypto_blkcipher_set_iv(tfm, cipher_tv[i].iv, 297 cipher_tv[i].iv);
274 iv_len);
275 298
276 len = cipher_tv[i].ilen;
277 ret = enc ? 299 ret = enc ?
278 crypto_blkcipher_encrypt(&desc, sg, sg, len) : 300 crypto_ablkcipher_encrypt(req) :
279 crypto_blkcipher_decrypt(&desc, sg, sg, len); 301 crypto_ablkcipher_decrypt(req);
280 302
281 if (ret) { 303 switch (ret) {
282 printk("%s () failed flags=%x\n", e, 304 case 0:
283 desc.flags); 305 break;
306 case -EINPROGRESS:
307 case -EBUSY:
308 ret = wait_for_completion_interruptible(
309 &result.completion);
310 if (!ret && !((ret = result.err))) {
311 INIT_COMPLETION(result.completion);
312 break;
313 }
314 /* fall through */
315 default:
316 printk("%s () failed err=%d\n", e, -ret);
284 goto out; 317 goto out;
285 } 318 }
286 319
@@ -303,17 +336,17 @@ static void test_cipher(char *algo, int enc,
303 printk("test %u (%d bit key):\n", 336 printk("test %u (%d bit key):\n",
304 j, cipher_tv[i].klen * 8); 337 j, cipher_tv[i].klen * 8);
305 338
306 crypto_blkcipher_clear_flags(tfm, ~0); 339 crypto_ablkcipher_clear_flags(tfm, ~0);
307 if (cipher_tv[i].wk) 340 if (cipher_tv[i].wk)
308 crypto_blkcipher_set_flags( 341 crypto_ablkcipher_set_flags(
309 tfm, CRYPTO_TFM_REQ_WEAK_KEY); 342 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
310 key = cipher_tv[i].key; 343 key = cipher_tv[i].key;
311 344
312 ret = crypto_blkcipher_setkey(tfm, key, 345 ret = crypto_ablkcipher_setkey(tfm, key,
313 cipher_tv[i].klen); 346 cipher_tv[i].klen);
314 if (ret) { 347 if (ret) {
315 printk("setkey() failed flags=%x\n", 348 printk("setkey() failed flags=%x\n",
316 crypto_blkcipher_get_flags(tfm)); 349 crypto_ablkcipher_get_flags(tfm));
317 350
318 if (!cipher_tv[i].fail) 351 if (!cipher_tv[i].fail)
319 goto out; 352 goto out;
@@ -329,19 +362,28 @@ static void test_cipher(char *algo, int enc,
329 cipher_tv[i].tap[k]); 362 cipher_tv[i].tap[k]);
330 } 363 }
331 364
332 iv_len = crypto_blkcipher_ivsize(tfm); 365 ablkcipher_request_set_crypt(req, sg, sg,
333 if (iv_len) 366 cipher_tv[i].ilen,
334 crypto_blkcipher_set_iv(tfm, cipher_tv[i].iv, 367 cipher_tv[i].iv);
335 iv_len);
336 368
337 len = cipher_tv[i].ilen;
338 ret = enc ? 369 ret = enc ?
339 crypto_blkcipher_encrypt(&desc, sg, sg, len) : 370 crypto_ablkcipher_encrypt(req) :
340 crypto_blkcipher_decrypt(&desc, sg, sg, len); 371 crypto_ablkcipher_decrypt(req);
341 372
342 if (ret) { 373 switch (ret) {
343 printk("%s () failed flags=%x\n", e, 374 case 0:
344 desc.flags); 375 break;
376 case -EINPROGRESS:
377 case -EBUSY:
378 ret = wait_for_completion_interruptible(
379 &result.completion);
380 if (!ret && !((ret = result.err))) {
381 INIT_COMPLETION(result.completion);
382 break;
383 }
384 /* fall through */
385 default:
386 printk("%s () failed err=%d\n", e, -ret);
345 goto out; 387 goto out;
346 } 388 }
347 389
@@ -360,7 +402,8 @@ static void test_cipher(char *algo, int enc,
360 } 402 }
361 403
362out: 404out:
363 crypto_free_blkcipher(tfm); 405 crypto_free_ablkcipher(tfm);
406 ablkcipher_request_free(req);
364} 407}
365 408
366static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p, 409static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p,
@@ -832,7 +875,7 @@ static void test_available(void)
832 875
833 while (*name) { 876 while (*name) {
834 printk("alg %s ", *name); 877 printk("alg %s ", *name);
835 printk(crypto_has_alg(*name, 0, CRYPTO_ALG_ASYNC) ? 878 printk(crypto_has_alg(*name, 0, 0) ?
836 "found\n" : "not found\n"); 879 "found\n" : "not found\n");
837 name++; 880 name++;
838 } 881 }
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 53e8ccbf0f5f..9f502b86e0ea 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -288,12 +288,18 @@ static void xcbc_exit_tfm(struct crypto_tfm *tfm)
288 crypto_free_cipher(ctx->child); 288 crypto_free_cipher(ctx->child);
289} 289}
290 290
291static struct crypto_instance *xcbc_alloc(void *param, unsigned int len) 291static struct crypto_instance *xcbc_alloc(struct rtattr **tb)
292{ 292{
293 struct crypto_instance *inst; 293 struct crypto_instance *inst;
294 struct crypto_alg *alg; 294 struct crypto_alg *alg;
295 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER, 295 int err;
296 CRYPTO_ALG_TYPE_HASH_MASK | CRYPTO_ALG_ASYNC); 296
297 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_HASH);
298 if (err)
299 return ERR_PTR(err);
300
301 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
302 CRYPTO_ALG_TYPE_MASK);
297 if (IS_ERR(alg)) 303 if (IS_ERR(alg))
298 return ERR_PTR(PTR_ERR(alg)); 304 return ERR_PTR(PTR_ERR(alg));
299 305
diff --git a/drivers/Makefile b/drivers/Makefile
index 920c975bb6d4..26ca9031ea49 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -58,7 +58,7 @@ obj-$(CONFIG_GAMEPORT) += input/gameport/
58obj-$(CONFIG_INPUT) += input/ 58obj-$(CONFIG_INPUT) += input/
59obj-$(CONFIG_I2O) += message/ 59obj-$(CONFIG_I2O) += message/
60obj-$(CONFIG_RTC_LIB) += rtc/ 60obj-$(CONFIG_RTC_LIB) += rtc/
61obj-$(CONFIG_I2C) += i2c/ 61obj-y += i2c/
62obj-$(CONFIG_W1) += w1/ 62obj-$(CONFIG_W1) += w1/
63obj-$(CONFIG_HWMON) += hwmon/ 63obj-$(CONFIG_HWMON) += hwmon/
64obj-$(CONFIG_PHONE) += telephony/ 64obj-$(CONFIG_PHONE) += telephony/
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 2f2e7964226d..c4efc0c17f8f 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -433,49 +433,6 @@ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
433 PDE(inode)->data); 433 PDE(inode)->data);
434} 434}
435 435
436static ssize_t
437acpi_processor_write_performance(struct file *file,
438 const char __user * buffer,
439 size_t count, loff_t * data)
440{
441 int result = 0;
442 struct seq_file *m = file->private_data;
443 struct acpi_processor *pr = m->private;
444 struct acpi_processor_performance *perf;
445 char state_string[12] = { '\0' };
446 unsigned int new_state = 0;
447 struct cpufreq_policy policy;
448
449
450 if (!pr || (count > sizeof(state_string) - 1))
451 return -EINVAL;
452
453 perf = pr->performance;
454 if (!perf)
455 return -EINVAL;
456
457 if (copy_from_user(state_string, buffer, count))
458 return -EFAULT;
459
460 state_string[count] = '\0';
461 new_state = simple_strtoul(state_string, NULL, 0);
462
463 if (new_state >= perf->state_count)
464 return -EINVAL;
465
466 cpufreq_get_policy(&policy, pr->id);
467
468 policy.cpu = pr->id;
469 policy.min = perf->states[new_state].core_frequency * 1000;
470 policy.max = perf->states[new_state].core_frequency * 1000;
471
472 result = cpufreq_set_policy(&policy);
473 if (result)
474 return result;
475
476 return count;
477}
478
479static void acpi_cpufreq_add_file(struct acpi_processor *pr) 436static void acpi_cpufreq_add_file(struct acpi_processor *pr)
480{ 437{
481 struct proc_dir_entry *entry = NULL; 438 struct proc_dir_entry *entry = NULL;
@@ -487,10 +444,9 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
487 444
488 /* add file 'performance' [R/W] */ 445 /* add file 'performance' [R/W] */
489 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 446 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
490 S_IFREG | S_IRUGO | S_IWUSR, 447 S_IFREG | S_IRUGO,
491 acpi_device_dir(device)); 448 acpi_device_dir(device));
492 if (entry){ 449 if (entry){
493 acpi_processor_perf_fops.write = acpi_processor_write_performance;
494 entry->proc_fops = &acpi_processor_perf_fops; 450 entry->proc_fops = &acpi_processor_perf_fops;
495 entry->data = acpi_driver_data(device); 451 entry->data = acpi_driver_data(device);
496 entry->owner = THIS_MODULE; 452 entry->owner = THIS_MODULE;
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 8d60c4eb54fe..2ebd07f2ef81 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -6,7 +6,6 @@
6#include <linux/version.h> 6#include <linux/version.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/skbuff.h> 8#include <linux/skbuff.h>
9#include <linux/pci.h>
10#include <linux/errno.h> 9#include <linux/errno.h>
11#include <linux/types.h> 10#include <linux/types.h>
12#include <linux/string.h> 11#include <linux/string.h>
diff --git a/drivers/base/base.h b/drivers/base/base.h
index d597f2659b23..5512d84452f2 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -45,3 +45,5 @@ struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
45extern char *make_class_name(const char *name, struct kobject *kobj); 45extern char *make_class_name(const char *name, struct kobject *kobj);
46 46
47extern void devres_release_all(struct device *dev); 47extern void devres_release_all(struct device *dev);
48
49extern struct kset devices_subsys;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 1d76e2349654..dca734819e50 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -17,7 +17,7 @@
17#include "power/power.h" 17#include "power/power.h"
18 18
19#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) 19#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
20#define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj) 20#define to_bus(obj) container_of(obj, struct bus_type, subsys.kobj)
21 21
22/* 22/*
23 * sysfs bindings for drivers 23 * sysfs bindings for drivers
@@ -123,7 +123,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
123{ 123{
124 int error; 124 int error;
125 if (get_bus(bus)) { 125 if (get_bus(bus)) {
126 error = sysfs_create_file(&bus->subsys.kset.kobj, &attr->attr); 126 error = sysfs_create_file(&bus->subsys.kobj, &attr->attr);
127 put_bus(bus); 127 put_bus(bus);
128 } else 128 } else
129 error = -EINVAL; 129 error = -EINVAL;
@@ -133,7 +133,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
133void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr) 133void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
134{ 134{
135 if (get_bus(bus)) { 135 if (get_bus(bus)) {
136 sysfs_remove_file(&bus->subsys.kset.kobj, &attr->attr); 136 sysfs_remove_file(&bus->subsys.kobj, &attr->attr);
137 put_bus(bus); 137 put_bus(bus);
138 } 138 }
139} 139}
@@ -397,7 +397,7 @@ static void device_remove_attrs(struct bus_type * bus, struct device * dev)
397static int make_deprecated_bus_links(struct device *dev) 397static int make_deprecated_bus_links(struct device *dev)
398{ 398{
399 return sysfs_create_link(&dev->kobj, 399 return sysfs_create_link(&dev->kobj,
400 &dev->bus->subsys.kset.kobj, "bus"); 400 &dev->bus->subsys.kobj, "bus");
401} 401}
402 402
403static void remove_deprecated_bus_links(struct device *dev) 403static void remove_deprecated_bus_links(struct device *dev)
@@ -431,7 +431,7 @@ int bus_add_device(struct device * dev)
431 if (error) 431 if (error)
432 goto out_id; 432 goto out_id;
433 error = sysfs_create_link(&dev->kobj, 433 error = sysfs_create_link(&dev->kobj,
434 &dev->bus->subsys.kset.kobj, "subsystem"); 434 &dev->bus->subsys.kobj, "subsystem");
435 if (error) 435 if (error)
436 goto out_subsys; 436 goto out_subsys;
437 error = make_deprecated_bus_links(dev); 437 error = make_deprecated_bus_links(dev);
@@ -810,7 +810,7 @@ int bus_register(struct bus_type * bus)
810 810
811 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier); 811 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);
812 812
813 retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name); 813 retval = kobject_set_name(&bus->subsys.kobj, "%s", bus->name);
814 if (retval) 814 if (retval)
815 goto out; 815 goto out;
816 816
@@ -820,13 +820,13 @@ int bus_register(struct bus_type * bus)
820 goto out; 820 goto out;
821 821
822 kobject_set_name(&bus->devices.kobj, "devices"); 822 kobject_set_name(&bus->devices.kobj, "devices");
823 bus->devices.subsys = &bus->subsys; 823 bus->devices.kobj.parent = &bus->subsys.kobj;
824 retval = kset_register(&bus->devices); 824 retval = kset_register(&bus->devices);
825 if (retval) 825 if (retval)
826 goto bus_devices_fail; 826 goto bus_devices_fail;
827 827
828 kobject_set_name(&bus->drivers.kobj, "drivers"); 828 kobject_set_name(&bus->drivers.kobj, "drivers");
829 bus->drivers.subsys = &bus->subsys; 829 bus->drivers.kobj.parent = &bus->subsys.kobj;
830 bus->drivers.ktype = &ktype_driver; 830 bus->drivers.ktype = &ktype_driver;
831 retval = kset_register(&bus->drivers); 831 retval = kset_register(&bus->drivers);
832 if (retval) 832 if (retval)
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 80bbb2074636..20c4ea6eb50d 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -19,10 +19,8 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include "base.h" 20#include "base.h"
21 21
22extern struct subsystem devices_subsys;
23
24#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) 22#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
25#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj) 23#define to_class(obj) container_of(obj, struct class, subsys.kobj)
26 24
27static ssize_t 25static ssize_t
28class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 26class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
@@ -80,7 +78,7 @@ int class_create_file(struct class * cls, const struct class_attribute * attr)
80{ 78{
81 int error; 79 int error;
82 if (cls) { 80 if (cls) {
83 error = sysfs_create_file(&cls->subsys.kset.kobj, &attr->attr); 81 error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
84 } else 82 } else
85 error = -EINVAL; 83 error = -EINVAL;
86 return error; 84 return error;
@@ -89,7 +87,7 @@ int class_create_file(struct class * cls, const struct class_attribute * attr)
89void class_remove_file(struct class * cls, const struct class_attribute * attr) 87void class_remove_file(struct class * cls, const struct class_attribute * attr)
90{ 88{
91 if (cls) 89 if (cls)
92 sysfs_remove_file(&cls->subsys.kset.kobj, &attr->attr); 90 sysfs_remove_file(&cls->subsys.kobj, &attr->attr);
93} 91}
94 92
95static struct class *class_get(struct class *cls) 93static struct class *class_get(struct class *cls)
@@ -147,7 +145,7 @@ int class_register(struct class * cls)
147 INIT_LIST_HEAD(&cls->interfaces); 145 INIT_LIST_HEAD(&cls->interfaces);
148 kset_init(&cls->class_dirs); 146 kset_init(&cls->class_dirs);
149 init_MUTEX(&cls->sem); 147 init_MUTEX(&cls->sem);
150 error = kobject_set_name(&cls->subsys.kset.kobj, "%s", cls->name); 148 error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
151 if (error) 149 if (error)
152 return error; 150 return error;
153 151
@@ -611,7 +609,7 @@ int class_device_add(struct class_device *class_dev)
611 if (parent_class_dev) 609 if (parent_class_dev)
612 class_dev->kobj.parent = &parent_class_dev->kobj; 610 class_dev->kobj.parent = &parent_class_dev->kobj;
613 else 611 else
614 class_dev->kobj.parent = &parent_class->subsys.kset.kobj; 612 class_dev->kobj.parent = &parent_class->subsys.kobj;
615 613
616 error = kobject_add(&class_dev->kobj); 614 error = kobject_add(&class_dev->kobj);
617 if (error) 615 if (error)
@@ -619,7 +617,7 @@ int class_device_add(struct class_device *class_dev)
619 617
620 /* add the needed attributes to this device */ 618 /* add the needed attributes to this device */
621 error = sysfs_create_link(&class_dev->kobj, 619 error = sysfs_create_link(&class_dev->kobj,
622 &parent_class->subsys.kset.kobj, "subsystem"); 620 &parent_class->subsys.kobj, "subsystem");
623 if (error) 621 if (error)
624 goto out3; 622 goto out3;
625 class_dev->uevent_attr.attr.name = "uevent"; 623 class_dev->uevent_attr.attr.name = "uevent";
@@ -917,8 +915,8 @@ int __init classes_init(void)
917 /* ick, this is ugly, the things we go through to keep from showing up 915 /* ick, this is ugly, the things we go through to keep from showing up
918 * in sysfs... */ 916 * in sysfs... */
919 subsystem_init(&class_obj_subsys); 917 subsystem_init(&class_obj_subsys);
920 if (!class_obj_subsys.kset.subsys) 918 if (!class_obj_subsys.kobj.parent)
921 class_obj_subsys.kset.subsys = &class_obj_subsys; 919 class_obj_subsys.kobj.parent = &class_obj_subsys.kobj;
922 return 0; 920 return 0;
923} 921}
924 922
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8aa090da1cd7..b78fc1e68264 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -252,7 +252,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
252 struct kobject *top_kobj; 252 struct kobject *top_kobj;
253 struct kset *kset; 253 struct kset *kset;
254 char *envp[32]; 254 char *envp[32];
255 char data[PAGE_SIZE]; 255 char *data = NULL;
256 char *pos; 256 char *pos;
257 int i; 257 int i;
258 size_t count = 0; 258 size_t count = 0;
@@ -276,6 +276,10 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
276 if (!kset->uevent_ops->filter(kset, &dev->kobj)) 276 if (!kset->uevent_ops->filter(kset, &dev->kobj))
277 goto out; 277 goto out;
278 278
279 data = (char *)get_zeroed_page(GFP_KERNEL);
280 if (!data)
281 return -ENOMEM;
282
279 /* let the kset specific function add its keys */ 283 /* let the kset specific function add its keys */
280 pos = data; 284 pos = data;
281 retval = kset->uevent_ops->uevent(kset, &dev->kobj, 285 retval = kset->uevent_ops->uevent(kset, &dev->kobj,
@@ -290,6 +294,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
290 count += sprintf(pos, "%s\n", envp[i]); 294 count += sprintf(pos, "%s\n", envp[i]);
291 } 295 }
292out: 296out:
297 free_page((unsigned long)data);
293 return count; 298 return count;
294} 299}
295 300
@@ -560,7 +565,7 @@ static struct kobject * get_device_parent(struct device *dev,
560 /* Set the parent to the class, not the parent device */ 565 /* Set the parent to the class, not the parent device */
561 /* this keeps sysfs from having a symlink to make old udevs happy */ 566 /* this keeps sysfs from having a symlink to make old udevs happy */
562 if (dev->class) 567 if (dev->class)
563 return &dev->class->subsys.kset.kobj; 568 return &dev->class->subsys.kobj;
564 else if (parent) 569 else if (parent)
565 return &parent->kobj; 570 return &parent->kobj;
566 571
@@ -572,7 +577,7 @@ static struct kobject *virtual_device_parent(struct device *dev)
572 static struct kobject *virtual_dir = NULL; 577 static struct kobject *virtual_dir = NULL;
573 578
574 if (!virtual_dir) 579 if (!virtual_dir)
575 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual"); 580 virtual_dir = kobject_add_dir(&devices_subsys.kobj, "virtual");
576 581
577 return virtual_dir; 582 return virtual_dir;
578} 583}
@@ -706,12 +711,12 @@ int device_add(struct device *dev)
706 } 711 }
707 712
708 if (dev->class) { 713 if (dev->class) {
709 sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj, 714 sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
710 "subsystem"); 715 "subsystem");
711 /* If this is not a "fake" compatible device, then create the 716 /* If this is not a "fake" compatible device, then create the
712 * symlink from the class to the device. */ 717 * symlink from the class to the device. */
713 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 718 if (dev->kobj.parent != &dev->class->subsys.kobj)
714 sysfs_create_link(&dev->class->subsys.kset.kobj, 719 sysfs_create_link(&dev->class->subsys.kobj,
715 &dev->kobj, dev->bus_id); 720 &dev->kobj, dev->bus_id);
716 if (parent) { 721 if (parent) {
717 sysfs_create_link(&dev->kobj, &dev->parent->kobj, 722 sysfs_create_link(&dev->kobj, &dev->parent->kobj,
@@ -769,8 +774,8 @@ int device_add(struct device *dev)
769 sysfs_remove_link(&dev->kobj, "subsystem"); 774 sysfs_remove_link(&dev->kobj, "subsystem");
770 /* If this is not a "fake" compatible device, remove the 775 /* If this is not a "fake" compatible device, remove the
771 * symlink from the class to the device. */ 776 * symlink from the class to the device. */
772 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 777 if (dev->kobj.parent != &dev->class->subsys.kobj)
773 sysfs_remove_link(&dev->class->subsys.kset.kobj, 778 sysfs_remove_link(&dev->class->subsys.kobj,
774 dev->bus_id); 779 dev->bus_id);
775 if (parent) { 780 if (parent) {
776#ifdef CONFIG_SYSFS_DEPRECATED 781#ifdef CONFIG_SYSFS_DEPRECATED
@@ -870,8 +875,8 @@ void device_del(struct device * dev)
870 sysfs_remove_link(&dev->kobj, "subsystem"); 875 sysfs_remove_link(&dev->kobj, "subsystem");
871 /* If this is not a "fake" compatible device, remove the 876 /* If this is not a "fake" compatible device, remove the
872 * symlink from the class to the device. */ 877 * symlink from the class to the device. */
873 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 878 if (dev->kobj.parent != &dev->class->subsys.kobj)
874 sysfs_remove_link(&dev->class->subsys.kset.kobj, 879 sysfs_remove_link(&dev->class->subsys.kobj,
875 dev->bus_id); 880 dev->bus_id);
876 if (parent) { 881 if (parent) {
877#ifdef CONFIG_SYSFS_DEPRECATED 882#ifdef CONFIG_SYSFS_DEPRECATED
@@ -1187,9 +1192,9 @@ int device_rename(struct device *dev, char *new_name)
1187#endif 1192#endif
1188 1193
1189 if (dev->class) { 1194 if (dev->class) {
1190 sysfs_remove_link(&dev->class->subsys.kset.kobj, 1195 sysfs_remove_link(&dev->class->subsys.kobj,
1191 old_symlink_name); 1196 old_symlink_name);
1192 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, 1197 sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
1193 dev->bus_id); 1198 dev->bus_id);
1194 } 1199 }
1195 put_device(dev); 1200 put_device(dev);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 18dba8e78da7..92428e55b0c2 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -226,12 +226,10 @@ static int device_probe_drivers(void *data)
226 * 226 *
227 * Walk the list of drivers that the bus has and call 227 * Walk the list of drivers that the bus has and call
228 * driver_probe_device() for each pair. If a compatible 228 * driver_probe_device() for each pair. If a compatible
229 * pair is found, break out and return. If the bus specifies 229 * pair is found, break out and return.
230 * multithreaded probing, walking the list of drivers is done
231 * on a probing thread.
232 * 230 *
233 * Returns 1 if the device was bound to a driver; 231 * Returns 1 if the device was bound to a driver;
234 * 0 if no matching device was found or multithreaded probing is done; 232 * 0 if no matching device was found;
235 * -ENODEV if the device is not registered. 233 * -ENODEV if the device is not registered.
236 * 234 *
237 * When called for a USB interface, @dev->parent->sem must be held. 235 * When called for a USB interface, @dev->parent->sem must be held.
@@ -239,7 +237,6 @@ static int device_probe_drivers(void *data)
239int device_attach(struct device * dev) 237int device_attach(struct device * dev)
240{ 238{
241 int ret = 0; 239 int ret = 0;
242 struct task_struct *probe_task = ERR_PTR(-ENOMEM);
243 240
244 down(&dev->sem); 241 down(&dev->sem);
245 if (dev->driver) { 242 if (dev->driver) {
@@ -251,12 +248,7 @@ int device_attach(struct device * dev)
251 ret = 0; 248 ret = 0;
252 } 249 }
253 } else { 250 } else {
254 if (dev->bus->multithread_probe) 251 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
255 probe_task = kthread_run(device_probe_drivers, dev,
256 "probe-%s", dev->bus_id);
257 if(IS_ERR(probe_task))
258 ret = bus_for_each_drv(dev->bus, NULL, dev,
259 __device_attach);
260 } 252 }
261 up(&dev->sem); 253 up(&dev->sem);
262 return ret; 254 return ret;
@@ -383,33 +375,6 @@ void driver_detach(struct device_driver * drv)
383 } 375 }
384} 376}
385 377
386#ifdef CONFIG_PCI_MULTITHREAD_PROBE
387static int __init wait_for_probes(void)
388{
389 DEFINE_WAIT(wait);
390
391 printk(KERN_INFO "%s: waiting for %d threads\n", __FUNCTION__,
392 atomic_read(&probe_count));
393 if (!atomic_read(&probe_count))
394 return 0;
395 while (atomic_read(&probe_count)) {
396 prepare_to_wait(&probe_waitqueue, &wait, TASK_UNINTERRUPTIBLE);
397 if (atomic_read(&probe_count))
398 schedule();
399 }
400 finish_wait(&probe_waitqueue, &wait);
401 return 0;
402}
403
404core_initcall_sync(wait_for_probes);
405postcore_initcall_sync(wait_for_probes);
406arch_initcall_sync(wait_for_probes);
407subsys_initcall_sync(wait_for_probes);
408fs_initcall_sync(wait_for_probes);
409device_initcall_sync(wait_for_probes);
410late_initcall_sync(wait_for_probes);
411#endif
412
413EXPORT_SYMBOL_GPL(device_bind_driver); 378EXPORT_SYMBOL_GPL(device_bind_driver);
414EXPORT_SYMBOL_GPL(device_release_driver); 379EXPORT_SYMBOL_GPL(device_release_driver);
415EXPORT_SYMBOL_GPL(device_attach); 380EXPORT_SYMBOL_GPL(device_attach);
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index cb1b98ae0d58..90c862932169 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -17,13 +17,13 @@
17 17
18static decl_subsys(firmware, NULL, NULL); 18static decl_subsys(firmware, NULL, NULL);
19 19
20int firmware_register(struct subsystem * s) 20int firmware_register(struct kset *s)
21{ 21{
22 kset_set_kset_s(s, firmware_subsys); 22 kobj_set_kset_s(s, firmware_subsys);
23 return subsystem_register(s); 23 return subsystem_register(s);
24} 24}
25 25
26void firmware_unregister(struct subsystem * s) 26void firmware_unregister(struct kset *s)
27{ 27{
28 subsystem_unregister(s); 28 subsystem_unregister(s);
29} 29}
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 30480f6f2af2..17b5ece8f82c 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -292,20 +292,22 @@ EXPORT_SYMBOL_GPL(platform_device_add);
292 * @pdev: platform device we're removing 292 * @pdev: platform device we're removing
293 * 293 *
294 * Note that this function will also release all memory- and port-based 294 * Note that this function will also release all memory- and port-based
295 * resources owned by the device (@dev->resource). 295 * resources owned by the device (@dev->resource). This function
296 * must _only_ be externally called in error cases. All other usage
297 * is a bug.
296 */ 298 */
297void platform_device_del(struct platform_device *pdev) 299void platform_device_del(struct platform_device *pdev)
298{ 300{
299 int i; 301 int i;
300 302
301 if (pdev) { 303 if (pdev) {
304 device_del(&pdev->dev);
305
302 for (i = 0; i < pdev->num_resources; i++) { 306 for (i = 0; i < pdev->num_resources; i++) {
303 struct resource *r = &pdev->resource[i]; 307 struct resource *r = &pdev->resource[i];
304 if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO)) 308 if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO))
305 release_resource(r); 309 release_resource(r);
306 } 310 }
307
308 device_del(&pdev->dev);
309 } 311 }
310} 312}
311EXPORT_SYMBOL_GPL(platform_device_del); 313EXPORT_SYMBOL_GPL(platform_device_del);
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index 58b6f77a1b34..a47ee1b70d20 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -16,8 +16,6 @@
16 16
17#define to_dev(node) container_of(node, struct device, kobj.entry) 17#define to_dev(node) container_of(node, struct device, kobj.entry)
18 18
19extern struct subsystem devices_subsys;
20
21 19
22/** 20/**
23 * We handle system devices differently - we suspend and shut them 21 * We handle system devices differently - we suspend and shut them
@@ -36,7 +34,7 @@ void device_shutdown(void)
36{ 34{
37 struct device * dev, *devn; 35 struct device * dev, *devn;
38 36
39 list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list, 37 list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.list,
40 kobj.entry) { 38 kobj.entry) {
41 if (dev->bus && dev->bus->shutdown) { 39 if (dev->bus && dev->bus->shutdown) {
42 dev_dbg(dev, "shutdown\n"); 40 dev_dbg(dev, "shutdown\n");
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 04e5db445c74..29f1291966c1 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -25,7 +25,7 @@
25 25
26#include "base.h" 26#include "base.h"
27 27
28extern struct subsystem devices_subsys; 28extern struct kset devices_subsys;
29 29
30#define to_sysdev(k) container_of(k, struct sys_device, kobj) 30#define to_sysdev(k) container_of(k, struct sys_device, kobj)
31#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr) 31#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)
@@ -138,7 +138,7 @@ int sysdev_class_register(struct sysdev_class * cls)
138 pr_debug("Registering sysdev class '%s'\n", 138 pr_debug("Registering sysdev class '%s'\n",
139 kobject_name(&cls->kset.kobj)); 139 kobject_name(&cls->kset.kobj));
140 INIT_LIST_HEAD(&cls->drivers); 140 INIT_LIST_HEAD(&cls->drivers);
141 cls->kset.subsys = &system_subsys; 141 cls->kset.kobj.parent = &system_subsys.kobj;
142 kset_set_kset_s(cls, system_subsys); 142 kset_set_kset_s(cls, system_subsys);
143 return kset_register(&cls->kset); 143 return kset_register(&cls->kset);
144} 144}
@@ -309,7 +309,7 @@ void sysdev_shutdown(void)
309 pr_debug("Shutting Down System Devices\n"); 309 pr_debug("Shutting Down System Devices\n");
310 310
311 down(&sysdev_drivers_lock); 311 down(&sysdev_drivers_lock);
312 list_for_each_entry_reverse(cls, &system_subsys.kset.list, 312 list_for_each_entry_reverse(cls, &system_subsys.list,
313 kset.kobj.entry) { 313 kset.kobj.entry) {
314 struct sys_device * sysdev; 314 struct sys_device * sysdev;
315 315
@@ -384,7 +384,7 @@ int sysdev_suspend(pm_message_t state)
384 384
385 pr_debug("Suspending System Devices\n"); 385 pr_debug("Suspending System Devices\n");
386 386
387 list_for_each_entry_reverse(cls, &system_subsys.kset.list, 387 list_for_each_entry_reverse(cls, &system_subsys.list,
388 kset.kobj.entry) { 388 kset.kobj.entry) {
389 389
390 pr_debug("Suspending type '%s':\n", 390 pr_debug("Suspending type '%s':\n",
@@ -457,7 +457,7 @@ gbl_driver:
457 } 457 }
458 458
459 /* resume other classes */ 459 /* resume other classes */
460 list_for_each_entry_continue(cls, &system_subsys.kset.list, 460 list_for_each_entry_continue(cls, &system_subsys.list,
461 kset.kobj.entry) { 461 kset.kobj.entry) {
462 list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) { 462 list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
463 pr_debug(" %s\n", kobject_name(&err_dev->kobj)); 463 pr_debug(" %s\n", kobject_name(&err_dev->kobj));
@@ -483,7 +483,7 @@ int sysdev_resume(void)
483 483
484 pr_debug("Resuming System Devices\n"); 484 pr_debug("Resuming System Devices\n");
485 485
486 list_for_each_entry(cls, &system_subsys.kset.list, kset.kobj.entry) { 486 list_for_each_entry(cls, &system_subsys.list, kset.kobj.entry) {
487 struct sys_device * sysdev; 487 struct sys_device * sysdev;
488 488
489 pr_debug("Resuming type '%s':\n", 489 pr_debug("Resuming type '%s':\n",
@@ -501,7 +501,7 @@ int sysdev_resume(void)
501 501
502int __init system_bus_init(void) 502int __init system_bus_init(void)
503{ 503{
504 system_subsys.kset.kobj.parent = &devices_subsys.kset.kobj; 504 system_subsys.kobj.parent = &devices_subsys.kobj;
505 return subsystem_register(&system_subsys); 505 return subsystem_register(&system_subsys);
506} 506}
507 507
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 1a6aeac5a1c3..01fbdd38e3be 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -194,15 +194,15 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
194 sl = sl_tail = NULL; 194 sl = sl_tail = NULL;
195 195
196 read_lock(&dev_base_lock); 196 read_lock(&dev_base_lock);
197 for (ifp = dev_base; ifp; dev_put(ifp), ifp = ifp->next) { 197 for_each_netdev(ifp) {
198 dev_hold(ifp); 198 dev_hold(ifp);
199 if (!is_aoe_netif(ifp)) 199 if (!is_aoe_netif(ifp))
200 continue; 200 goto cont;
201 201
202 skb = new_skb(sizeof *h + sizeof *ch); 202 skb = new_skb(sizeof *h + sizeof *ch);
203 if (skb == NULL) { 203 if (skb == NULL) {
204 printk(KERN_INFO "aoe: skb alloc failure\n"); 204 printk(KERN_INFO "aoe: skb alloc failure\n");
205 continue; 205 goto cont;
206 } 206 }
207 skb_put(skb, sizeof *h + sizeof *ch); 207 skb_put(skb, sizeof *h + sizeof *ch);
208 skb->dev = ifp; 208 skb->dev = ifp;
@@ -221,6 +221,8 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
221 221
222 skb->next = sl; 222 skb->next = sl;
223 sl = skb; 223 sl = skb;
224cont:
225 dev_put(ifp);
224 } 226 }
225 read_unlock(&dev_base_lock); 227 read_unlock(&dev_base_lock);
226 228
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index 5b684fddcc03..4941ddb78939 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -145,6 +145,7 @@ static void *m1541_alloc_page(struct agp_bridge_data *bridge)
145 void *addr = agp_generic_alloc_page(agp_bridge); 145 void *addr = agp_generic_alloc_page(agp_bridge);
146 u32 temp; 146 u32 temp;
147 147
148 global_flush_tlb();
148 if (!addr) 149 if (!addr)
149 return NULL; 150 return NULL;
150 151
@@ -160,6 +161,7 @@ static void ali_destroy_page(void * addr)
160 if (addr) { 161 if (addr) {
161 global_cache_flush(); /* is this really needed? --hch */ 162 global_cache_flush(); /* is this really needed? --hch */
162 agp_generic_destroy_page(addr); 163 agp_generic_destroy_page(addr);
164 global_flush_tlb();
163 } 165 }
164} 166}
165 167
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index b0acf41c0db9..aa8f3a39a704 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -173,7 +173,7 @@ alpha_core_agp_setup(void)
173 /* 173 /*
174 * Build a fake pci_dev struct 174 * Build a fake pci_dev struct
175 */ 175 */
176 pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 176 pdev = alloc_pci_dev();
177 if (!pdev) 177 if (!pdev)
178 return -ENOMEM; 178 return -ENOMEM;
179 pdev->vendor = 0xffff; 179 pdev->vendor = 0xffff;
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index f902d71947ba..45aeb917ec63 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -51,28 +51,6 @@ int agp_memory_reserved;
51 */ 51 */
52EXPORT_SYMBOL_GPL(agp_memory_reserved); 52EXPORT_SYMBOL_GPL(agp_memory_reserved);
53 53
54#if defined(CONFIG_X86)
55int map_page_into_agp(struct page *page)
56{
57 int i;
58 i = change_page_attr(page, 1, PAGE_KERNEL_NOCACHE);
59 /* Caller's responsibility to call global_flush_tlb() for
60 * performance reasons */
61 return i;
62}
63EXPORT_SYMBOL_GPL(map_page_into_agp);
64
65int unmap_page_from_agp(struct page *page)
66{
67 int i;
68 i = change_page_attr(page, 1, PAGE_KERNEL);
69 /* Caller's responsibility to call global_flush_tlb() for
70 * performance reasons */
71 return i;
72}
73EXPORT_SYMBOL_GPL(unmap_page_from_agp);
74#endif
75
76/* 54/*
77 * Generic routines for handling agp_memory structures - 55 * Generic routines for handling agp_memory structures -
78 * They use the basic page allocation routines to do the brunt of the work. 56 * They use the basic page allocation routines to do the brunt of the work.
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 55392a45a14b..9c69f2e761f5 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -186,8 +186,9 @@ static void *i8xx_alloc_pages(void)
186 return NULL; 186 return NULL;
187 187
188 if (change_page_attr(page, 4, PAGE_KERNEL_NOCACHE) < 0) { 188 if (change_page_attr(page, 4, PAGE_KERNEL_NOCACHE) < 0) {
189 change_page_attr(page, 4, PAGE_KERNEL);
189 global_flush_tlb(); 190 global_flush_tlb();
190 __free_page(page); 191 __free_pages(page, 2);
191 return NULL; 192 return NULL;
192 } 193 }
193 global_flush_tlb(); 194 global_flush_tlb();
@@ -209,7 +210,7 @@ static void i8xx_destroy_pages(void *addr)
209 global_flush_tlb(); 210 global_flush_tlb();
210 put_page(page); 211 put_page(page);
211 unlock_page(page); 212 unlock_page(page);
212 free_pages((unsigned long)addr, 2); 213 __free_pages(page, 2);
213 atomic_dec(&agp_bridge->current_memory_agp); 214 atomic_dec(&agp_bridge->current_memory_agp);
214} 215}
215 216
@@ -315,9 +316,6 @@ static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
315 struct agp_memory *new; 316 struct agp_memory *new;
316 void *addr; 317 void *addr;
317 318
318 if (pg_count != 1 && pg_count != 4)
319 return NULL;
320
321 switch (pg_count) { 319 switch (pg_count) {
322 case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge); 320 case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge);
323 global_flush_tlb(); 321 global_flush_tlb();
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 0c9dab557c94..6cd7373dcdf4 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -320,11 +320,11 @@ static int __devinit agp_nvidia_probe(struct pci_dev *pdev,
320 u8 cap_ptr; 320 u8 cap_ptr;
321 321
322 nvidia_private.dev_1 = 322 nvidia_private.dev_1 =
323 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1)); 323 pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1));
324 nvidia_private.dev_2 = 324 nvidia_private.dev_2 =
325 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2)); 325 pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
326 nvidia_private.dev_3 = 326 nvidia_private.dev_3 =
327 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0)); 327 pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
328 328
329 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) { 329 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
330 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 " 330 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
@@ -443,6 +443,9 @@ static int __init agp_nvidia_init(void)
443static void __exit agp_nvidia_cleanup(void) 443static void __exit agp_nvidia_cleanup(void)
444{ 444{
445 pci_unregister_driver(&agp_nvidia_pci_driver); 445 pci_unregister_driver(&agp_nvidia_pci_driver);
446 pci_dev_put(nvidia_private.dev_1);
447 pci_dev_put(nvidia_private.dev_2);
448 pci_dev_put(nvidia_private.dev_3);
446} 449}
447 450
448module_init(agp_nvidia_init); 451module_init(agp_nvidia_init);
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 3d83b461ccad..f4562cc22343 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -329,7 +329,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
329 struct agp_bridge_data *bridge; 329 struct agp_bridge_data *bridge;
330 int error = 0; 330 int error = 0;
331 331
332 fake_bridge_dev = kmalloc(sizeof (struct pci_dev), GFP_KERNEL); 332 fake_bridge_dev = alloc_pci_dev();
333 if (!fake_bridge_dev) { 333 if (!fake_bridge_dev) {
334 error = -ENOMEM; 334 error = -ENOMEM;
335 goto fail; 335 goto fail;
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index ee8f50edde1b..cda608c42bea 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -47,9 +47,8 @@ static void *sgi_tioca_alloc_page(struct agp_bridge_data *bridge)
47 47
48 nid = info->ca_closest_node; 48 nid = info->ca_closest_node;
49 page = alloc_pages_node(nid, GFP_KERNEL, 0); 49 page = alloc_pages_node(nid, GFP_KERNEL, 0);
50 if (page == NULL) { 50 if (!page)
51 return 0; 51 return NULL;
52 }
53 52
54 get_page(page); 53 get_page(page);
55 SetPageLocked(page); 54 SetPageLocked(page);
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index 125f4282d955..eb1a1c738190 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -143,96 +143,6 @@ static struct agp_bridge_driver sis_driver = {
143 .agp_type_to_mask_type = agp_generic_type_to_mask_type, 143 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
144}; 144};
145 145
146static struct agp_device_ids sis_agp_device_ids[] __devinitdata =
147{
148 {
149 .device_id = PCI_DEVICE_ID_SI_5591_AGP,
150 .chipset_name = "5591",
151 },
152 {
153 .device_id = PCI_DEVICE_ID_SI_530,
154 .chipset_name = "530",
155 },
156 {
157 .device_id = PCI_DEVICE_ID_SI_540,
158 .chipset_name = "540",
159 },
160 {
161 .device_id = PCI_DEVICE_ID_SI_550,
162 .chipset_name = "550",
163 },
164 {
165 .device_id = PCI_DEVICE_ID_SI_620,
166 .chipset_name = "620",
167 },
168 {
169 .device_id = PCI_DEVICE_ID_SI_630,
170 .chipset_name = "630",
171 },
172 {
173 .device_id = PCI_DEVICE_ID_SI_635,
174 .chipset_name = "635",
175 },
176 {
177 .device_id = PCI_DEVICE_ID_SI_645,
178 .chipset_name = "645",
179 },
180 {
181 .device_id = PCI_DEVICE_ID_SI_646,
182 .chipset_name = "646",
183 },
184 {
185 .device_id = PCI_DEVICE_ID_SI_648,
186 .chipset_name = "648",
187 },
188 {
189 .device_id = PCI_DEVICE_ID_SI_650,
190 .chipset_name = "650",
191 },
192 {
193 .device_id = PCI_DEVICE_ID_SI_651,
194 .chipset_name = "651",
195 },
196 {
197 .device_id = PCI_DEVICE_ID_SI_655,
198 .chipset_name = "655",
199 },
200 {
201 .device_id = PCI_DEVICE_ID_SI_661,
202 .chipset_name = "661",
203 },
204 {
205 .device_id = PCI_DEVICE_ID_SI_730,
206 .chipset_name = "730",
207 },
208 {
209 .device_id = PCI_DEVICE_ID_SI_735,
210 .chipset_name = "735",
211 },
212 {
213 .device_id = PCI_DEVICE_ID_SI_740,
214 .chipset_name = "740",
215 },
216 {
217 .device_id = PCI_DEVICE_ID_SI_741,
218 .chipset_name = "741",
219 },
220 {
221 .device_id = PCI_DEVICE_ID_SI_745,
222 .chipset_name = "745",
223 },
224 {
225 .device_id = PCI_DEVICE_ID_SI_746,
226 .chipset_name = "746",
227 },
228 {
229 .device_id = PCI_DEVICE_ID_SI_760,
230 .chipset_name = "760",
231 },
232 { }, /* dummy final entry, always present */
233};
234
235
236// chipsets that require the 'delay hack' 146// chipsets that require the 'delay hack'
237static int sis_broken_chipsets[] __devinitdata = { 147static int sis_broken_chipsets[] __devinitdata = {
238 PCI_DEVICE_ID_SI_648, 148 PCI_DEVICE_ID_SI_648,
@@ -269,29 +179,15 @@ static void __devinit sis_get_driver(struct agp_bridge_data *bridge)
269static int __devinit agp_sis_probe(struct pci_dev *pdev, 179static int __devinit agp_sis_probe(struct pci_dev *pdev,
270 const struct pci_device_id *ent) 180 const struct pci_device_id *ent)
271{ 181{
272 struct agp_device_ids *devs = sis_agp_device_ids;
273 struct agp_bridge_data *bridge; 182 struct agp_bridge_data *bridge;
274 u8 cap_ptr; 183 u8 cap_ptr;
275 int j;
276 184
277 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 185 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
278 if (!cap_ptr) 186 if (!cap_ptr)
279 return -ENODEV; 187 return -ENODEV;
280 188
281 /* probe for known chipsets */
282 for (j = 0; devs[j].chipset_name; j++) {
283 if (pdev->device == devs[j].device_id) {
284 printk(KERN_INFO PFX "Detected SiS %s chipset\n",
285 devs[j].chipset_name);
286 goto found;
287 }
288 }
289
290 printk(KERN_ERR PFX "Unsupported SiS chipset (device id: %04x)\n",
291 pdev->device);
292 return -ENODEV;
293 189
294found: 190 printk(KERN_INFO PFX "Detected SiS chipset - id:%i\n", pdev->device);
295 bridge = agp_alloc_bridge(); 191 bridge = agp_alloc_bridge();
296 if (!bridge) 192 if (!bridge)
297 return -ENOMEM; 193 return -ENOMEM;
@@ -320,12 +216,172 @@ static void __devexit agp_sis_remove(struct pci_dev *pdev)
320 216
321static struct pci_device_id agp_sis_pci_table[] = { 217static struct pci_device_id agp_sis_pci_table[] = {
322 { 218 {
323 .class = (PCI_CLASS_BRIDGE_HOST << 8), 219 .class = (PCI_CLASS_BRIDGE_HOST << 8),
324 .class_mask = ~0, 220 .class_mask = ~0,
325 .vendor = PCI_VENDOR_ID_SI, 221 .vendor = PCI_VENDOR_ID_SI,
326 .device = PCI_ANY_ID, 222 .device = PCI_DEVICE_ID_SI_5591_AGP,
327 .subvendor = PCI_ANY_ID, 223 .subvendor = PCI_ANY_ID,
328 .subdevice = PCI_ANY_ID, 224 .subdevice = PCI_ANY_ID,
225 },
226 {
227 .class = (PCI_CLASS_BRIDGE_HOST << 8),
228 .class_mask = ~0,
229 .vendor = PCI_VENDOR_ID_SI,
230 .device = PCI_DEVICE_ID_SI_530,
231 .subvendor = PCI_ANY_ID,
232 .subdevice = PCI_ANY_ID,
233 },
234 {
235 .class = (PCI_CLASS_BRIDGE_HOST << 8),
236 .class_mask = ~0,
237 .vendor = PCI_VENDOR_ID_SI,
238 .device = PCI_DEVICE_ID_SI_540,
239 .subvendor = PCI_ANY_ID,
240 .subdevice = PCI_ANY_ID,
241 },
242 {
243 .class = (PCI_CLASS_BRIDGE_HOST << 8),
244 .class_mask = ~0,
245 .vendor = PCI_VENDOR_ID_SI,
246 .device = PCI_DEVICE_ID_SI_550,
247 .subvendor = PCI_ANY_ID,
248 .subdevice = PCI_ANY_ID,
249 },
250 {
251 .class = (PCI_CLASS_BRIDGE_HOST << 8),
252 .class_mask = ~0,
253 .vendor = PCI_VENDOR_ID_SI,
254 .device = PCI_DEVICE_ID_SI_620,
255 .subvendor = PCI_ANY_ID,
256 .subdevice = PCI_ANY_ID,
257 },
258 {
259 .class = (PCI_CLASS_BRIDGE_HOST << 8),
260 .class_mask = ~0,
261 .vendor = PCI_VENDOR_ID_SI,
262 .device = PCI_DEVICE_ID_SI_630,
263 .subvendor = PCI_ANY_ID,
264 .subdevice = PCI_ANY_ID,
265 },
266 {
267 .class = (PCI_CLASS_BRIDGE_HOST << 8),
268 .class_mask = ~0,
269 .vendor = PCI_VENDOR_ID_SI,
270 .device = PCI_DEVICE_ID_SI_635,
271 .subvendor = PCI_ANY_ID,
272 .subdevice = PCI_ANY_ID,
273 },
274 {
275 .class = (PCI_CLASS_BRIDGE_HOST << 8),
276 .class_mask = ~0,
277 .vendor = PCI_VENDOR_ID_SI,
278 .device = PCI_DEVICE_ID_SI_645,
279 .subvendor = PCI_ANY_ID,
280 .subdevice = PCI_ANY_ID,
281 },
282 {
283 .class = (PCI_CLASS_BRIDGE_HOST << 8),
284 .class_mask = ~0,
285 .vendor = PCI_VENDOR_ID_SI,
286 .device = PCI_DEVICE_ID_SI_646,
287 .subvendor = PCI_ANY_ID,
288 .subdevice = PCI_ANY_ID,
289 },
290 {
291 .class = (PCI_CLASS_BRIDGE_HOST << 8),
292 .class_mask = ~0,
293 .vendor = PCI_VENDOR_ID_SI,
294 .device = PCI_DEVICE_ID_SI_648,
295 .subvendor = PCI_ANY_ID,
296 .subdevice = PCI_ANY_ID,
297 },
298 {
299 .class = (PCI_CLASS_BRIDGE_HOST << 8),
300 .class_mask = ~0,
301 .vendor = PCI_VENDOR_ID_SI,
302 .device = PCI_DEVICE_ID_SI_650,
303 .subvendor = PCI_ANY_ID,
304 .subdevice = PCI_ANY_ID,
305 },
306 {
307 .class = (PCI_CLASS_BRIDGE_HOST << 8),
308 .class_mask = ~0,
309 .vendor = PCI_VENDOR_ID_SI,
310 .device = PCI_DEVICE_ID_SI_651,
311 .subvendor = PCI_ANY_ID,
312 .subdevice = PCI_ANY_ID,
313 },
314 {
315 .class = (PCI_CLASS_BRIDGE_HOST << 8),
316 .class_mask = ~0,
317 .vendor = PCI_VENDOR_ID_SI,
318 .device = PCI_DEVICE_ID_SI_655,
319 .subvendor = PCI_ANY_ID,
320 .subdevice = PCI_ANY_ID,
321 },
322 {
323 .class = (PCI_CLASS_BRIDGE_HOST << 8),
324 .class_mask = ~0,
325 .vendor = PCI_VENDOR_ID_SI,
326 .device = PCI_DEVICE_ID_SI_661,
327 .subvendor = PCI_ANY_ID,
328 .subdevice = PCI_ANY_ID,
329 },
330 {
331 .class = (PCI_CLASS_BRIDGE_HOST << 8),
332 .class_mask = ~0,
333 .vendor = PCI_VENDOR_ID_SI,
334 .device = PCI_DEVICE_ID_SI_730,
335 .subvendor = PCI_ANY_ID,
336 .subdevice = PCI_ANY_ID,
337 },
338 {
339 .class = (PCI_CLASS_BRIDGE_HOST << 8),
340 .class_mask = ~0,
341 .vendor = PCI_VENDOR_ID_SI,
342 .device = PCI_DEVICE_ID_SI_735,
343 .subvendor = PCI_ANY_ID,
344 .subdevice = PCI_ANY_ID,
345 },
346 {
347 .class = (PCI_CLASS_BRIDGE_HOST << 8),
348 .class_mask = ~0,
349 .vendor = PCI_VENDOR_ID_SI,
350 .device = PCI_DEVICE_ID_SI_740,
351 .subvendor = PCI_ANY_ID,
352 .subdevice = PCI_ANY_ID,
353 },
354 {
355 .class = (PCI_CLASS_BRIDGE_HOST << 8),
356 .class_mask = ~0,
357 .vendor = PCI_VENDOR_ID_SI,
358 .device = PCI_DEVICE_ID_SI_741,
359 .subvendor = PCI_ANY_ID,
360 .subdevice = PCI_ANY_ID,
361 },
362 {
363 .class = (PCI_CLASS_BRIDGE_HOST << 8),
364 .class_mask = ~0,
365 .vendor = PCI_VENDOR_ID_SI,
366 .device = PCI_DEVICE_ID_SI_745,
367 .subvendor = PCI_ANY_ID,
368 .subdevice = PCI_ANY_ID,
369 },
370 {
371 .class = (PCI_CLASS_BRIDGE_HOST << 8),
372 .class_mask = ~0,
373 .vendor = PCI_VENDOR_ID_SI,
374 .device = PCI_DEVICE_ID_SI_746,
375 .subvendor = PCI_ANY_ID,
376 .subdevice = PCI_ANY_ID,
377 },
378 {
379 .class = (PCI_CLASS_BRIDGE_HOST << 8),
380 .class_mask = ~0,
381 .vendor = PCI_VENDOR_ID_SI,
382 .device = PCI_DEVICE_ID_SI_760,
383 .subvendor = PCI_ANY_ID,
384 .subdevice = PCI_ANY_ID,
329 }, 385 },
330 { } 386 { }
331}; 387};
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 55212a3811fd..551ef25063ef 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -455,15 +455,6 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev,
455 u32 temp, temp2; 455 u32 temp, temp2;
456 u8 cap_ptr = 0; 456 u8 cap_ptr = 0;
457 457
458 /* Everything is on func 1 here so we are hardcoding function one */
459 bridge_dev = pci_find_slot((unsigned int)pdev->bus->number,
460 PCI_DEVFN(0, 1));
461 if (!bridge_dev) {
462 printk(KERN_INFO PFX "Detected a Serverworks chipset "
463 "but could not find the secondary device.\n");
464 return -ENODEV;
465 }
466
467 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 458 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
468 459
469 switch (pdev->device) { 460 switch (pdev->device) {
@@ -483,6 +474,15 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev,
483 return -ENODEV; 474 return -ENODEV;
484 } 475 }
485 476
477 /* Everything is on func 1 here so we are hardcoding function one */
478 bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
479 PCI_DEVFN(0, 1));
480 if (!bridge_dev) {
481 printk(KERN_INFO PFX "Detected a Serverworks chipset "
482 "but could not find the secondary device.\n");
483 return -ENODEV;
484 }
485
486 serverworks_private.svrwrks_dev = bridge_dev; 486 serverworks_private.svrwrks_dev = bridge_dev;
487 serverworks_private.gart_addr_ofs = 0x10; 487 serverworks_private.gart_addr_ofs = 0x10;
488 488
@@ -515,7 +515,7 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev,
515 515
516 bridge->driver = &sworks_driver; 516 bridge->driver = &sworks_driver;
517 bridge->dev_private_data = &serverworks_private, 517 bridge->dev_private_data = &serverworks_private,
518 bridge->dev = pdev; 518 bridge->dev = pci_dev_get(pdev);
519 519
520 pci_set_drvdata(pdev, bridge); 520 pci_set_drvdata(pdev, bridge);
521 return agp_add_bridge(bridge); 521 return agp_add_bridge(bridge);
@@ -525,8 +525,11 @@ static void __devexit agp_serverworks_remove(struct pci_dev *pdev)
525{ 525{
526 struct agp_bridge_data *bridge = pci_get_drvdata(pdev); 526 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
527 527
528 pci_dev_put(bridge->dev);
528 agp_remove_bridge(bridge); 529 agp_remove_bridge(bridge);
529 agp_put_bridge(bridge); 530 agp_put_bridge(bridge);
531 pci_dev_put(serverworks_private.svrwrks_dev);
532 serverworks_private.svrwrks_dev = NULL;
530} 533}
531 534
532static struct pci_device_id agp_serverworks_pci_table[] = { 535static struct pci_device_id agp_serverworks_pci_table[] = {
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index 9ebf84d18655..ec435cb25c4f 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -26,7 +26,6 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/pci.h>
30#include <linux/hw_random.h> 29#include <linux/hw_random.h>
31#include <asm/io.h> 30#include <asm/io.h>
32#include <asm/msr.h> 31#include <asm/msr.h>
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index cb8d691576da..c06e86ad1dab 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -41,7 +41,6 @@
41#include <linux/input.h> 41#include <linux/input.h>
42#include <linux/reboot.h> 42#include <linux/reboot.h>
43 43
44static void kbd_disconnect(struct input_handle *handle);
45extern void ctrl_alt_del(void); 44extern void ctrl_alt_del(void);
46 45
47/* 46/*
@@ -159,65 +158,41 @@ static int sysrq_alt_use;
159static int sysrq_alt; 158static int sysrq_alt;
160 159
161/* 160/*
162 * Translation of scancodes to keycodes. We set them on only the first attached 161 * Translation of scancodes to keycodes. We set them on only the first
163 * keyboard - for per-keyboard setting, /dev/input/event is more useful. 162 * keyboard in the list that accepts the scancode and keycode.
163 * Explanation for not choosing the first attached keyboard anymore:
164 * USB keyboards for example have two event devices: one for all "normal"
165 * keys and one for extra function keys (like "volume up", "make coffee",
166 * etc.). So this means that scancodes for the extra function keys won't
167 * be valid for the first event device, but will be for the second.
164 */ 168 */
165int getkeycode(unsigned int scancode) 169int getkeycode(unsigned int scancode)
166{ 170{
167 struct list_head *node; 171 struct input_handle *handle;
168 struct input_dev *dev = NULL; 172 int keycode;
173 int error = -ENODEV;
169 174
170 list_for_each(node, &kbd_handler.h_list) { 175 list_for_each_entry(handle, &kbd_handler.h_list, h_node) {
171 struct input_handle *handle = to_handle_h(node); 176 error = handle->dev->getkeycode(handle->dev, scancode, &keycode);
172 if (handle->dev->keycodesize) { 177 if (!error)
173 dev = handle->dev; 178 return keycode;
174 break;
175 }
176 } 179 }
177 180
178 if (!dev) 181 return error;
179 return -ENODEV;
180
181 if (scancode >= dev->keycodemax)
182 return -EINVAL;
183
184 return INPUT_KEYCODE(dev, scancode);
185} 182}
186 183
187int setkeycode(unsigned int scancode, unsigned int keycode) 184int setkeycode(unsigned int scancode, unsigned int keycode)
188{ 185{
189 struct list_head *node; 186 struct input_handle *handle;
190 struct input_dev *dev = NULL; 187 int error = -ENODEV;
191 unsigned int i, oldkey;
192 188
193 list_for_each(node, &kbd_handler.h_list) { 189 list_for_each_entry(handle, &kbd_handler.h_list, h_node) {
194 struct input_handle *handle = to_handle_h(node); 190 error = handle->dev->setkeycode(handle->dev, scancode, keycode);
195 if (handle->dev->keycodesize) { 191 if (!error)
196 dev = handle->dev;
197 break; 192 break;
198 }
199 } 193 }
200 194
201 if (!dev) 195 return error;
202 return -ENODEV;
203
204 if (scancode >= dev->keycodemax)
205 return -EINVAL;
206 if (keycode < 0 || keycode > KEY_MAX)
207 return -EINVAL;
208 if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))
209 return -EINVAL;
210
211 oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
212
213 clear_bit(oldkey, dev->keybit);
214 set_bit(keycode, dev->keybit);
215
216 for (i = 0; i < dev->keycodemax; i++)
217 if (INPUT_KEYCODE(dev,i) == oldkey)
218 set_bit(oldkey, dev->keybit);
219
220 return 0;
221} 196}
222 197
223/* 198/*
@@ -225,10 +200,9 @@ int setkeycode(unsigned int scancode, unsigned int keycode)
225 */ 200 */
226static void kd_nosound(unsigned long ignored) 201static void kd_nosound(unsigned long ignored)
227{ 202{
228 struct list_head *node; 203 struct input_handle *handle;
229 204
230 list_for_each(node, &kbd_handler.h_list) { 205 list_for_each_entry(handle, &kbd_handler.h_list, h_node) {
231 struct input_handle *handle = to_handle_h(node);
232 if (test_bit(EV_SND, handle->dev->evbit)) { 206 if (test_bit(EV_SND, handle->dev->evbit)) {
233 if (test_bit(SND_TONE, handle->dev->sndbit)) 207 if (test_bit(SND_TONE, handle->dev->sndbit))
234 input_inject_event(handle, EV_SND, SND_TONE, 0); 208 input_inject_event(handle, EV_SND, SND_TONE, 0);
@@ -1161,7 +1135,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1161 1135
1162 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw) 1136 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw)
1163 if (emulate_raw(vc, keycode, !down << 7)) 1137 if (emulate_raw(vc, keycode, !down << 7))
1164 if (keycode < BTN_MISC) 1138 if (keycode < BTN_MISC && printk_ratelimit())
1165 printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode); 1139 printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
1166 1140
1167#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */ 1141#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
@@ -1285,11 +1259,11 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type,
1285 * likes it, it can open it and get events from it. In this (kbd_connect) 1259 * likes it, it can open it and get events from it. In this (kbd_connect)
1286 * function, we should decide which VT to bind that keyboard to initially. 1260 * function, we should decide which VT to bind that keyboard to initially.
1287 */ 1261 */
1288static struct input_handle *kbd_connect(struct input_handler *handler, 1262static int kbd_connect(struct input_handler *handler, struct input_dev *dev,
1289 struct input_dev *dev, 1263 const struct input_device_id *id)
1290 const struct input_device_id *id)
1291{ 1264{
1292 struct input_handle *handle; 1265 struct input_handle *handle;
1266 int error;
1293 int i; 1267 int i;
1294 1268
1295 for (i = KEY_RESERVED; i < BTN_MISC; i++) 1269 for (i = KEY_RESERVED; i < BTN_MISC; i++)
@@ -1297,24 +1271,37 @@ static struct input_handle *kbd_connect(struct input_handler *handler,
1297 break; 1271 break;
1298 1272
1299 if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) 1273 if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
1300 return NULL; 1274 return -ENODEV;
1301 1275
1302 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); 1276 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
1303 if (!handle) 1277 if (!handle)
1304 return NULL; 1278 return -ENOMEM;
1305 1279
1306 handle->dev = dev; 1280 handle->dev = dev;
1307 handle->handler = handler; 1281 handle->handler = handler;
1308 handle->name = "kbd"; 1282 handle->name = "kbd";
1309 1283
1310 input_open_device(handle); 1284 error = input_register_handle(handle);
1285 if (error)
1286 goto err_free_handle;
1287
1288 error = input_open_device(handle);
1289 if (error)
1290 goto err_unregister_handle;
1291
1292 return 0;
1311 1293
1312 return handle; 1294 err_unregister_handle:
1295 input_unregister_handle(handle);
1296 err_free_handle:
1297 kfree(handle);
1298 return error;
1313} 1299}
1314 1300
1315static void kbd_disconnect(struct input_handle *handle) 1301static void kbd_disconnect(struct input_handle *handle)
1316{ 1302{
1317 input_close_device(handle); 1303 input_close_device(handle);
1304 input_unregister_handle(handle);
1318 kfree(handle); 1305 kfree(handle);
1319} 1306}
1320 1307
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 157b1d09ab55..13808f6083a0 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -42,7 +42,6 @@
42#include <linux/timer.h> 42#include <linux/timer.h>
43#include <linux/time.h> 43#include <linux/time.h>
44#include <linux/interrupt.h> 44#include <linux/interrupt.h>
45#include <linux/pci.h>
46#include <linux/tty.h> 45#include <linux/tty.h>
47#include <linux/tty_flip.h> 46#include <linux/tty_flip.h>
48#include <linux/serial.h> 47#include <linux/serial.h>
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index bb9a43c6cf3d..9f273f032b0f 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -19,7 +19,6 @@
19 * 19 *
20 */ 20 */
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/pci.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
24#include <linux/fs.h> 23#include <linux/fs.h>
25#include <linux/sched.h> 24#include <linux/sched.h>
diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c
index 1e4a8d751a71..2f7ba7a514fe 100644
--- a/drivers/char/watchdog/sc1200wdt.c
+++ b/drivers/char/watchdog/sc1200wdt.c
@@ -38,7 +38,6 @@
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/pnp.h> 39#include <linux/pnp.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/pci.h>
42 41
43#include <asm/semaphore.h> 42#include <asm/semaphore.h>
44#include <asm/io.h> 43#include <asm/io.h>
diff --git a/drivers/char/watchdog/scx200_wdt.c b/drivers/char/watchdog/scx200_wdt.c
index fc0e0347f9d2..d4fd0fa2f176 100644
--- a/drivers/char/watchdog/scx200_wdt.c
+++ b/drivers/char/watchdog/scx200_wdt.c
@@ -25,7 +25,7 @@
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/reboot.h> 26#include <linux/reboot.h>
27#include <linux/fs.h> 27#include <linux/fs.h>
28#include <linux/pci.h> 28#include <linux/ioport.h>
29#include <linux/scx200.h> 29#include <linux/scx200.h>
30 30
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index d155e81b5c97..993fa7b89253 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -9,6 +9,9 @@ config CPU_FREQ
9 clock speed, you need to either enable a dynamic cpufreq governor 9 clock speed, you need to either enable a dynamic cpufreq governor
10 (see below) after boot, or use a userspace tool. 10 (see below) after boot, or use a userspace tool.
11 11
12 To compile this driver as a module, choose M here: the
13 module will be called cpufreq.
14
12 For details, take a look at <file:Documentation/cpu-freq>. 15 For details, take a look at <file:Documentation/cpu-freq>.
13 16
14 If in doubt, say N. 17 If in doubt, say N.
@@ -16,7 +19,7 @@ config CPU_FREQ
16if CPU_FREQ 19if CPU_FREQ
17 20
18config CPU_FREQ_TABLE 21config CPU_FREQ_TABLE
19 tristate 22 tristate
20 23
21config CPU_FREQ_DEBUG 24config CPU_FREQ_DEBUG
22 bool "Enable CPUfreq debugging" 25 bool "Enable CPUfreq debugging"
@@ -32,19 +35,26 @@ config CPU_FREQ_DEBUG
32 4 to activate CPUfreq governor debugging 35 4 to activate CPUfreq governor debugging
33 36
34config CPU_FREQ_STAT 37config CPU_FREQ_STAT
35 tristate "CPU frequency translation statistics" 38 tristate "CPU frequency translation statistics"
36 select CPU_FREQ_TABLE 39 select CPU_FREQ_TABLE
37 default y 40 default y
38 help 41 help
39 This driver exports CPU frequency statistics information through sysfs 42 This driver exports CPU frequency statistics information through sysfs
40 file system 43 file system.
44
45 To compile this driver as a module, choose M here: the
46 module will be called cpufreq_stats.
47
48 If in doubt, say N.
41 49
42config CPU_FREQ_STAT_DETAILS 50config CPU_FREQ_STAT_DETAILS
43 bool "CPU frequency translation statistics details" 51 bool "CPU frequency translation statistics details"
44 depends on CPU_FREQ_STAT 52 depends on CPU_FREQ_STAT
45 help 53 help
46 This will show detail CPU frequency translation table in sysfs file 54 This will show detail CPU frequency translation table in sysfs file
47 system 55 system.
56
57 If in doubt, say N.
48 58
49# Note that it is not currently possible to set the other governors (such as ondemand) 59# Note that it is not currently possible to set the other governors (such as ondemand)
50# as the default, since if they fail to initialise, cpufreq will be 60# as the default, since if they fail to initialise, cpufreq will be
@@ -78,29 +88,38 @@ config CPU_FREQ_DEFAULT_GOV_USERSPACE
78endchoice 88endchoice
79 89
80config CPU_FREQ_GOV_PERFORMANCE 90config CPU_FREQ_GOV_PERFORMANCE
81 tristate "'performance' governor" 91 tristate "'performance' governor"
82 help 92 help
83 This cpufreq governor sets the frequency statically to the 93 This cpufreq governor sets the frequency statically to the
84 highest available CPU frequency. 94 highest available CPU frequency.
85 95
96 To compile this driver as a module, choose M here: the
97 module will be called cpufreq_performance.
98
86 If in doubt, say Y. 99 If in doubt, say Y.
87 100
88config CPU_FREQ_GOV_POWERSAVE 101config CPU_FREQ_GOV_POWERSAVE
89 tristate "'powersave' governor" 102 tristate "'powersave' governor"
90 help 103 help
91 This cpufreq governor sets the frequency statically to the 104 This cpufreq governor sets the frequency statically to the
92 lowest available CPU frequency. 105 lowest available CPU frequency.
93 106
107 To compile this driver as a module, choose M here: the
108 module will be called cpufreq_powersave.
109
94 If in doubt, say Y. 110 If in doubt, say Y.
95 111
96config CPU_FREQ_GOV_USERSPACE 112config CPU_FREQ_GOV_USERSPACE
97 tristate "'userspace' governor for userspace frequency scaling" 113 tristate "'userspace' governor for userspace frequency scaling"
98 help 114 help
99 Enable this cpufreq governor when you either want to set the 115 Enable this cpufreq governor when you either want to set the
100 CPU frequency manually or when an userspace program shall 116 CPU frequency manually or when an userspace program shall
101 be able to set the CPU dynamically, like on LART 117 be able to set the CPU dynamically, like on LART
102 <http://www.lartmaker.nl/>. 118 <http://www.lartmaker.nl/>.
103 119
120 To compile this driver as a module, choose M here: the
121 module will be called cpufreq_userspace.
122
104 For details, take a look at <file:Documentation/cpu-freq/>. 123 For details, take a look at <file:Documentation/cpu-freq/>.
105 124
106 If in doubt, say Y. 125 If in doubt, say Y.
@@ -116,6 +135,9 @@ config CPU_FREQ_GOV_ONDEMAND
116 do fast frequency switching (i.e, very low latency frequency 135 do fast frequency switching (i.e, very low latency frequency
117 transitions). 136 transitions).
118 137
138 To compile this driver as a module, choose M here: the
139 module will be called cpufreq_ondemand.
140
119 For details, take a look at linux/Documentation/cpu-freq. 141 For details, take a look at linux/Documentation/cpu-freq.
120 142
121 If in doubt, say N. 143 If in doubt, say N.
@@ -136,6 +158,9 @@ config CPU_FREQ_GOV_CONSERVATIVE
136 step-by-step latency issues between the minimum and maximum frequency 158 step-by-step latency issues between the minimum and maximum frequency
137 transitions in the CPU) you will probably want to use this governor. 159 transitions in the CPU) you will probably want to use this governor.
138 160
161 To compile this driver as a module, choose M here: the
162 module will be called cpufreq_conservative.
163
139 For details, take a look at linux/Documentation/cpu-freq. 164 For details, take a look at linux/Documentation/cpu-freq.
140 165
141 If in doubt, say N. 166 If in doubt, say N.
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 3162010900c9..893dbaf386fb 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -768,6 +768,9 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
768 unlock_policy_rwsem_write(cpu); 768 unlock_policy_rwsem_write(cpu);
769 goto err_out; 769 goto err_out;
770 } 770 }
771 policy->user_policy.min = policy->cpuinfo.min_freq;
772 policy->user_policy.max = policy->cpuinfo.max_freq;
773 policy->user_policy.governor = policy->governor;
771 774
772#ifdef CONFIG_SMP 775#ifdef CONFIG_SMP
773 for_each_cpu_mask(j, policy->cpus) { 776 for_each_cpu_mask(j, policy->cpus) {
@@ -858,10 +861,13 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
858 861
859 policy->governor = NULL; /* to assure that the starting sequence is 862 policy->governor = NULL; /* to assure that the starting sequence is
860 * run in cpufreq_set_policy */ 863 * run in cpufreq_set_policy */
861 unlock_policy_rwsem_write(cpu);
862 864
863 /* set default policy */ 865 /* set default policy */
864 ret = cpufreq_set_policy(&new_policy); 866 ret = __cpufreq_set_policy(policy, &new_policy);
867 policy->user_policy.policy = policy->policy;
868
869 unlock_policy_rwsem_write(cpu);
870
865 if (ret) { 871 if (ret) {
866 dprintk("setting policy failed\n"); 872 dprintk("setting policy failed\n");
867 goto err_out_unregister; 873 goto err_out_unregister;
@@ -1620,43 +1626,6 @@ error_out:
1620} 1626}
1621 1627
1622/** 1628/**
1623 * cpufreq_set_policy - set a new CPUFreq policy
1624 * @policy: policy to be set.
1625 *
1626 * Sets a new CPU frequency and voltage scaling policy.
1627 */
1628int cpufreq_set_policy(struct cpufreq_policy *policy)
1629{
1630 int ret = 0;
1631 struct cpufreq_policy *data;
1632
1633 if (!policy)
1634 return -EINVAL;
1635
1636 data = cpufreq_cpu_get(policy->cpu);
1637 if (!data)
1638 return -EINVAL;
1639
1640 if (unlikely(lock_policy_rwsem_write(policy->cpu)))
1641 return -EINVAL;
1642
1643
1644 ret = __cpufreq_set_policy(data, policy);
1645 data->user_policy.min = data->min;
1646 data->user_policy.max = data->max;
1647 data->user_policy.policy = data->policy;
1648 data->user_policy.governor = data->governor;
1649
1650 unlock_policy_rwsem_write(policy->cpu);
1651
1652 cpufreq_cpu_put(data);
1653
1654 return ret;
1655}
1656EXPORT_SYMBOL(cpufreq_set_policy);
1657
1658
1659/**
1660 * cpufreq_update_policy - re-evaluate an existing cpufreq policy 1629 * cpufreq_update_policy - re-evaluate an existing cpufreq policy
1661 * @cpu: CPU which shall be re-evaluated 1630 * @cpu: CPU which shall be re-evaluated
1662 * 1631 *
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index ff8c4beaace4..f21fe66c9eef 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -1,10 +1,10 @@
1menu "Hardware crypto devices" 1menu "Hardware crypto devices"
2 2
3config CRYPTO_DEV_PADLOCK 3config CRYPTO_DEV_PADLOCK
4 tristate "Support for VIA PadLock ACE" 4 bool "Support for VIA PadLock ACE"
5 depends on X86_32 5 depends on X86_32
6 select CRYPTO_ALGAPI 6 select CRYPTO_ALGAPI
7 default m 7 default y
8 help 8 help
9 Some VIA processors come with an integrated crypto engine 9 Some VIA processors come with an integrated crypto engine
10 (so called VIA PadLock ACE, Advanced Cryptography Engine) 10 (so called VIA PadLock ACE, Advanced Cryptography Engine)
@@ -14,16 +14,6 @@ config CRYPTO_DEV_PADLOCK
14 The instructions are used only when the CPU supports them. 14 The instructions are used only when the CPU supports them.
15 Otherwise software encryption is used. 15 Otherwise software encryption is used.
16 16
17 Selecting M for this option will compile a helper module
18 padlock.ko that should autoload all below configured
19 algorithms. Don't worry if your hardware does not support
20 some or all of them. In such case padlock.ko will
21 simply write a single line into the kernel log informing
22 about its failure but everything will keep working fine.
23
24 If you are unsure, say M. The compiled module will be
25 called padlock.ko
26
27config CRYPTO_DEV_PADLOCK_AES 17config CRYPTO_DEV_PADLOCK_AES
28 tristate "PadLock driver for AES algorithm" 18 tristate "PadLock driver for AES algorithm"
29 depends on CRYPTO_DEV_PADLOCK 19 depends on CRYPTO_DEV_PADLOCK
@@ -55,7 +45,7 @@ source "arch/s390/crypto/Kconfig"
55 45
56config CRYPTO_DEV_GEODE 46config CRYPTO_DEV_GEODE
57 tristate "Support for the Geode LX AES engine" 47 tristate "Support for the Geode LX AES engine"
58 depends on CRYPTO && X86_32 && PCI 48 depends on X86_32 && PCI
59 select CRYPTO_ALGAPI 49 select CRYPTO_ALGAPI
60 select CRYPTO_BLKCIPHER 50 select CRYPTO_BLKCIPHER
61 default m 51 default m
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index 6059cf869414..d070030f7d7e 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -1,4 +1,3 @@
1obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o
2obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o 1obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o
3obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o 2obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o
4obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o 3obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o
diff --git a/drivers/crypto/padlock.c b/drivers/crypto/padlock.c
deleted file mode 100644
index d6d7dd5bb98c..000000000000
--- a/drivers/crypto/padlock.c
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Support for VIA PadLock hardware crypto engine.
5 *
6 * Copyright (c) 2006 Michal Ludvig <michal@logix.cz>
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 */
14
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/errno.h>
18#include <linux/crypto.h>
19#include <linux/cryptohash.h>
20#include <linux/interrupt.h>
21#include <linux/kernel.h>
22#include <linux/scatterlist.h>
23#include "padlock.h"
24
25static int __init padlock_init(void)
26{
27 int success = 0;
28
29 if (crypto_has_cipher("aes-padlock", 0, 0))
30 success++;
31
32 if (crypto_has_hash("sha1-padlock", 0, 0))
33 success++;
34
35 if (crypto_has_hash("sha256-padlock", 0, 0))
36 success++;
37
38 if (!success) {
39 printk(KERN_WARNING PFX "No VIA PadLock drivers have been loaded.\n");
40 return -ENODEV;
41 }
42
43 printk(KERN_NOTICE PFX "%d drivers are available.\n", success);
44
45 return 0;
46}
47
48static void __exit padlock_fini(void)
49{
50}
51
52module_init(padlock_init);
53module_exit(padlock_fini);
54
55MODULE_DESCRIPTION("Load all configured PadLock algorithms.");
56MODULE_LICENSE("GPL");
57MODULE_AUTHOR("Michal Ludvig");
58
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index c6281ccd4fe7..1324984a4c35 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -409,7 +409,7 @@ static struct kobj_type ktype_efivar = {
409}; 409};
410 410
411static ssize_t 411static ssize_t
412dummy(struct subsystem *sub, char *buf) 412dummy(struct kset *kset, char *buf)
413{ 413{
414 return -ENODEV; 414 return -ENODEV;
415} 415}
@@ -422,7 +422,7 @@ efivar_unregister(struct efivar_entry *var)
422 422
423 423
424static ssize_t 424static ssize_t
425efivar_create(struct subsystem *sub, const char *buf, size_t count) 425efivar_create(struct kset *kset, const char *buf, size_t count)
426{ 426{
427 struct efi_variable *new_var = (struct efi_variable *)buf; 427 struct efi_variable *new_var = (struct efi_variable *)buf;
428 struct efivar_entry *search_efivar, *n; 428 struct efivar_entry *search_efivar, *n;
@@ -480,7 +480,7 @@ efivar_create(struct subsystem *sub, const char *buf, size_t count)
480} 480}
481 481
482static ssize_t 482static ssize_t
483efivar_delete(struct subsystem *sub, const char *buf, size_t count) 483efivar_delete(struct kset *kset, const char *buf, size_t count)
484{ 484{
485 struct efi_variable *del_var = (struct efi_variable *)buf; 485 struct efi_variable *del_var = (struct efi_variable *)buf;
486 struct efivar_entry *search_efivar, *n; 486 struct efivar_entry *search_efivar, *n;
@@ -551,11 +551,11 @@ static struct subsys_attribute *var_subsys_attrs[] = {
551 * the efivars driver 551 * the efivars driver
552 */ 552 */
553static ssize_t 553static ssize_t
554systab_read(struct subsystem *entry, char *buf) 554systab_read(struct kset *kset, char *buf)
555{ 555{
556 char *str = buf; 556 char *str = buf;
557 557
558 if (!entry || !buf) 558 if (!kset || !buf)
559 return -EINVAL; 559 return -EINVAL;
560 560
561 if (efi.mps != EFI_INVALID_TABLE_ADDR) 561 if (efi.mps != EFI_INVALID_TABLE_ADDR)
@@ -687,7 +687,7 @@ efivars_init(void)
687 goto out_free; 687 goto out_free;
688 } 688 }
689 689
690 kset_set_kset_s(&vars_subsys, efi_subsys); 690 kobj_set_kset_s(&vars_subsys, efi_subsys);
691 691
692 error = subsystem_register(&vars_subsys); 692 error = subsystem_register(&vars_subsys);
693 693
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 11935f66fcd8..434a61b415a3 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -2,9 +2,7 @@
2# I2C subsystem configuration 2# I2C subsystem configuration
3# 3#
4 4
5menu "I2C support" 5menuconfig I2C
6
7config I2C
8 tristate "I2C support" 6 tristate "I2C support"
9 ---help--- 7 ---help---
10 I2C (pronounce: I-square-C) is a slow serial bus protocol used in 8 I2C (pronounce: I-square-C) is a slow serial bus protocol used in
@@ -22,9 +20,14 @@ config I2C
22 This I2C support can also be built as a module. If so, the module 20 This I2C support can also be built as a module. If so, the module
23 will be called i2c-core. 21 will be called i2c-core.
24 22
23if I2C
24
25config I2C_BOARDINFO
26 boolean
27 default y
28
25config I2C_CHARDEV 29config I2C_CHARDEV
26 tristate "I2C device interface" 30 tristate "I2C device interface"
27 depends on I2C
28 help 31 help
29 Say Y here to use i2c-* device files, usually found in the /dev 32 Say Y here to use i2c-* device files, usually found in the /dev
30 directory on your system. They make it possible to have user-space 33 directory on your system. They make it possible to have user-space
@@ -40,7 +43,6 @@ source drivers/i2c/chips/Kconfig
40 43
41config I2C_DEBUG_CORE 44config I2C_DEBUG_CORE
42 bool "I2C Core debugging messages" 45 bool "I2C Core debugging messages"
43 depends on I2C
44 help 46 help
45 Say Y here if you want the I2C core to produce a bunch of debug 47 Say Y here if you want the I2C core to produce a bunch of debug
46 messages to the system log. Select this if you are having a 48 messages to the system log. Select this if you are having a
@@ -48,7 +50,6 @@ config I2C_DEBUG_CORE
48 50
49config I2C_DEBUG_ALGO 51config I2C_DEBUG_ALGO
50 bool "I2C Algorithm debugging messages" 52 bool "I2C Algorithm debugging messages"
51 depends on I2C
52 help 53 help
53 Say Y here if you want the I2C algorithm drivers to produce a bunch 54 Say Y here if you want the I2C algorithm drivers to produce a bunch
54 of debug messages to the system log. Select this if you are having 55 of debug messages to the system log. Select this if you are having
@@ -57,7 +58,6 @@ config I2C_DEBUG_ALGO
57 58
58config I2C_DEBUG_BUS 59config I2C_DEBUG_BUS
59 bool "I2C Bus debugging messages" 60 bool "I2C Bus debugging messages"
60 depends on I2C
61 help 61 help
62 Say Y here if you want the I2C bus drivers to produce a bunch of 62 Say Y here if you want the I2C bus drivers to produce a bunch of
63 debug messages to the system log. Select this if you are having 63 debug messages to the system log. Select this if you are having
@@ -66,12 +66,10 @@ config I2C_DEBUG_BUS
66 66
67config I2C_DEBUG_CHIP 67config I2C_DEBUG_CHIP
68 bool "I2C Chip debugging messages" 68 bool "I2C Chip debugging messages"
69 depends on I2C
70 help 69 help
71 Say Y here if you want the I2C chip drivers to produce a bunch of 70 Say Y here if you want the I2C chip drivers to produce a bunch of
72 debug messages to the system log. Select this if you are having 71 debug messages to the system log. Select this if you are having
73 a problem with I2C support and want to see more of what is going 72 a problem with I2C support and want to see more of what is going
74 on. 73 on.
75 74
76endmenu 75endif # I2C
77
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 71c5a854ac5d..ba26e6cbe74e 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -2,6 +2,7 @@
2# Makefile for the i2c core. 2# Makefile for the i2c core.
3# 3#
4 4
5obj-$(CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o
5obj-$(CONFIG_I2C) += i2c-core.o 6obj-$(CONFIG_I2C) += i2c-core.o
6obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o 7obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
7obj-y += busses/ chips/ algos/ 8obj-y += busses/ chips/ algos/
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig
index af0203409dd1..58899078810b 100644
--- a/drivers/i2c/algos/Kconfig
+++ b/drivers/i2c/algos/Kconfig
@@ -3,11 +3,9 @@
3# 3#
4 4
5menu "I2C Algorithms" 5menu "I2C Algorithms"
6 depends on I2C
7 6
8config I2C_ALGOBIT 7config I2C_ALGOBIT
9 tristate "I2C bit-banging interfaces" 8 tristate "I2C bit-banging interfaces"
10 depends on I2C
11 help 9 help
12 This allows you to use a range of I2C adapters called bit-banging 10 This allows you to use a range of I2C adapters called bit-banging
13 adapters. Say Y if you own an I2C adapter belonging to this class 11 adapters. Say Y if you own an I2C adapter belonging to this class
@@ -18,7 +16,6 @@ config I2C_ALGOBIT
18 16
19config I2C_ALGOPCF 17config I2C_ALGOPCF
20 tristate "I2C PCF 8584 interfaces" 18 tristate "I2C PCF 8584 interfaces"
21 depends on I2C
22 help 19 help
23 This allows you to use a range of I2C adapters called PCF adapters. 20 This allows you to use a range of I2C adapters called PCF adapters.
24 Say Y if you own an I2C adapter belonging to this class and then say 21 Say Y if you own an I2C adapter belonging to this class and then say
@@ -29,7 +26,6 @@ config I2C_ALGOPCF
29 26
30config I2C_ALGOPCA 27config I2C_ALGOPCA
31 tristate "I2C PCA 9564 interfaces" 28 tristate "I2C PCA 9564 interfaces"
32 depends on I2C
33 help 29 help
34 This allows you to use a range of I2C adapters called PCA adapters. 30 This allows you to use a range of I2C adapters called PCA adapters.
35 Say Y if you own an I2C adapter belonging to this class and then say 31 Say Y if you own an I2C adapter belonging to this class and then say
@@ -40,11 +36,11 @@ config I2C_ALGOPCA
40 36
41config I2C_ALGO8XX 37config I2C_ALGO8XX
42 tristate "MPC8xx CPM I2C interface" 38 tristate "MPC8xx CPM I2C interface"
43 depends on 8xx && I2C 39 depends on 8xx
44 40
45config I2C_ALGO_SGI 41config I2C_ALGO_SGI
46 tristate "I2C SGI interfaces" 42 tristate "I2C SGI interfaces"
47 depends on I2C && (SGI_IP22 || SGI_IP32 || X86_VISWS) 43 depends on SGI_IP22 || SGI_IP32 || X86_VISWS
48 help 44 help
49 Supports the SGI interfaces like the ones found on SGI Indy VINO 45 Supports the SGI interfaces like the ones found on SGI Indy VINO
50 or SGI O2 MACE. 46 or SGI O2 MACE.
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 95aa5395a5be..8a5f5825bb72 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -33,19 +33,30 @@
33 33
34 34
35/* ----- global defines ----------------------------------------------- */ 35/* ----- global defines ----------------------------------------------- */
36#define DEB(x) if (i2c_debug>=1) x;
37#define DEB2(x) if (i2c_debug>=2) x;
38#define DEBSTAT(x) if (i2c_debug>=3) x; /* print several statistical values*/
39#define DEBPROTO(x) if (i2c_debug>=9) { x; }
40 /* debug the protocol by showing transferred bits */
41 36
37#ifdef DEBUG
38#define bit_dbg(level, dev, format, args...) \
39 do { \
40 if (i2c_debug >= level) \
41 dev_dbg(dev, format, ##args); \
42 } while (0)
43#else
44#define bit_dbg(level, dev, format, args...) \
45 do {} while (0)
46#endif /* DEBUG */
42 47
43/* ----- global variables --------------------------------------------- */ 48/* ----- global variables --------------------------------------------- */
44 49
45/* module parameters:
46 */
47static int i2c_debug;
48static int bit_test; /* see if the line-setting functions work */ 50static int bit_test; /* see if the line-setting functions work */
51module_param(bit_test, bool, 0);
52MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck");
53
54#ifdef DEBUG
55static int i2c_debug = 1;
56module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
57MODULE_PARM_DESC(i2c_debug,
58 "debug level - 0 off; 1 normal; 2 verbose; 3 very verbose");
59#endif
49 60
50/* --- setting states on the bus with the right timing: --------------- */ 61/* --- setting states on the bus with the right timing: --------------- */
51 62
@@ -57,19 +68,19 @@ static int bit_test; /* see if the line-setting functions work */
57static inline void sdalo(struct i2c_algo_bit_data *adap) 68static inline void sdalo(struct i2c_algo_bit_data *adap)
58{ 69{
59 setsda(adap,0); 70 setsda(adap,0);
60 udelay(adap->udelay); 71 udelay((adap->udelay + 1) / 2);
61} 72}
62 73
63static inline void sdahi(struct i2c_algo_bit_data *adap) 74static inline void sdahi(struct i2c_algo_bit_data *adap)
64{ 75{
65 setsda(adap,1); 76 setsda(adap,1);
66 udelay(adap->udelay); 77 udelay((adap->udelay + 1) / 2);
67} 78}
68 79
69static inline void scllo(struct i2c_algo_bit_data *adap) 80static inline void scllo(struct i2c_algo_bit_data *adap)
70{ 81{
71 setscl(adap,0); 82 setscl(adap,0);
72 udelay(adap->udelay); 83 udelay(adap->udelay / 2);
73} 84}
74 85
75/* 86/*
@@ -98,7 +109,11 @@ static int sclhi(struct i2c_algo_bit_data *adap)
98 } 109 }
99 cond_resched(); 110 cond_resched();
100 } 111 }
101 DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); 112#ifdef DEBUG
113 if (jiffies != start && i2c_debug >= 3)
114 pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go "
115 "high\n", jiffies - start);
116#endif
102 117
103done: 118done:
104 udelay(adap->udelay); 119 udelay(adap->udelay);
@@ -110,30 +125,29 @@ done:
110static void i2c_start(struct i2c_algo_bit_data *adap) 125static void i2c_start(struct i2c_algo_bit_data *adap)
111{ 126{
112 /* assert: scl, sda are high */ 127 /* assert: scl, sda are high */
113 DEBPROTO(printk("S ")); 128 setsda(adap, 0);
114 sdalo(adap); 129 udelay(adap->udelay);
115 scllo(adap); 130 scllo(adap);
116} 131}
117 132
118static void i2c_repstart(struct i2c_algo_bit_data *adap) 133static void i2c_repstart(struct i2c_algo_bit_data *adap)
119{ 134{
120 /* scl, sda may not be high */ 135 /* assert: scl is low */
121 DEBPROTO(printk(" Sr ")); 136 sdahi(adap);
122 setsda(adap,1);
123 sclhi(adap); 137 sclhi(adap);
124 138 setsda(adap, 0);
125 sdalo(adap); 139 udelay(adap->udelay);
126 scllo(adap); 140 scllo(adap);
127} 141}
128 142
129 143
130static void i2c_stop(struct i2c_algo_bit_data *adap) 144static void i2c_stop(struct i2c_algo_bit_data *adap)
131{ 145{
132 DEBPROTO(printk("P\n"));
133 /* assert: scl is low */ 146 /* assert: scl is low */
134 sdalo(adap); 147 sdalo(adap);
135 sclhi(adap); 148 sclhi(adap);
136 sdahi(adap); 149 setsda(adap, 1);
150 udelay(adap->udelay);
137} 151}
138 152
139 153
@@ -145,7 +159,7 @@ static void i2c_stop(struct i2c_algo_bit_data *adap)
145 * 0 if the device did not ack 159 * 0 if the device did not ack
146 * -ETIMEDOUT if an error occurred (while raising the scl line) 160 * -ETIMEDOUT if an error occurred (while raising the scl line)
147 */ 161 */
148static int i2c_outb(struct i2c_adapter *i2c_adap, char c) 162static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c)
149{ 163{
150 int i; 164 int i;
151 int sb; 165 int sb;
@@ -154,34 +168,32 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, char c)
154 168
155 /* assert: scl is low */ 169 /* assert: scl is low */
156 for ( i=7 ; i>=0 ; i-- ) { 170 for ( i=7 ; i>=0 ; i-- ) {
157 sb = c & ( 1 << i ); 171 sb = (c >> i) & 1;
158 setsda(adap,sb); 172 setsda(adap,sb);
159 udelay(adap->udelay); 173 udelay((adap->udelay + 1) / 2);
160 DEBPROTO(printk(KERN_DEBUG "%d",sb!=0));
161 if (sclhi(adap)<0) { /* timed out */ 174 if (sclhi(adap)<0) { /* timed out */
162 sdahi(adap); /* we don't want to block the net */ 175 bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
163 DEB2(printk(KERN_DEBUG " i2c_outb: 0x%02x, timeout at bit #%d\n", c&0xff, i)); 176 "timeout at bit #%d\n", (int)c, i);
164 return -ETIMEDOUT; 177 return -ETIMEDOUT;
165 }; 178 };
166 /* do arbitration here: 179 /* do arbitration here:
167 * if ( sb && ! getsda(adap) ) -> ouch! Get out of here. 180 * if ( sb && ! getsda(adap) ) -> ouch! Get out of here.
168 */ 181 */
169 setscl(adap, 0 ); 182 scllo(adap);
170 udelay(adap->udelay);
171 } 183 }
172 sdahi(adap); 184 sdahi(adap);
173 if (sclhi(adap)<0){ /* timeout */ 185 if (sclhi(adap)<0){ /* timeout */
174 DEB2(printk(KERN_DEBUG " i2c_outb: 0x%02x, timeout at ack\n", c&0xff)); 186 bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
175 return -ETIMEDOUT; 187 "timeout at ack\n", (int)c);
188 return -ETIMEDOUT;
176 }; 189 };
177 /* read ack: SDA should be pulled down by slave */ 190 /* read ack: SDA should be pulled down by slave */
178 ack=getsda(adap); /* ack: sda is pulled low ->success. */ 191 ack = !getsda(adap); /* ack: sda is pulled low -> success */
179 DEB2(printk(KERN_DEBUG " i2c_outb: 0x%02x , getsda() = %d\n", c & 0xff, ack)); 192 bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
193 ack ? "A" : "NA");
180 194
181 DEBPROTO( printk(KERN_DEBUG "[%2.2x]",c&0xff) );
182 DEBPROTO(if (0==ack){ printk(KERN_DEBUG " A ");} else printk(KERN_DEBUG " NA ") );
183 scllo(adap); 195 scllo(adap);
184 return 0==ack; /* return 1 if device acked */ 196 return ack;
185 /* assert: scl is low (sda undef) */ 197 /* assert: scl is low (sda undef) */
186} 198}
187 199
@@ -198,19 +210,18 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
198 sdahi(adap); 210 sdahi(adap);
199 for (i=0;i<8;i++) { 211 for (i=0;i<8;i++) {
200 if (sclhi(adap)<0) { /* timeout */ 212 if (sclhi(adap)<0) { /* timeout */
201 DEB2(printk(KERN_DEBUG " i2c_inb: timeout at bit #%d\n", 7-i)); 213 bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit "
214 "#%d\n", 7 - i);
202 return -ETIMEDOUT; 215 return -ETIMEDOUT;
203 }; 216 };
204 indata *= 2; 217 indata *= 2;
205 if ( getsda(adap) ) 218 if ( getsda(adap) )
206 indata |= 0x01; 219 indata |= 0x01;
207 scllo(adap); 220 setscl(adap, 0);
221 udelay(i == 7 ? adap->udelay / 2 : adap->udelay);
208 } 222 }
209 /* assert: scl is low */ 223 /* assert: scl is low */
210 DEB2(printk(KERN_DEBUG "i2c_inb: 0x%02x\n", indata & 0xff)); 224 return indata;
211
212 DEBPROTO(printk(KERN_DEBUG " 0x%02x", indata & 0xff));
213 return (int) (indata & 0xff);
214} 225}
215 226
216/* 227/*
@@ -221,73 +232,67 @@ static int test_bus(struct i2c_algo_bit_data *adap, char* name) {
221 int scl,sda; 232 int scl,sda;
222 233
223 if (adap->getscl==NULL) 234 if (adap->getscl==NULL)
224 printk(KERN_INFO "i2c-algo-bit.o: Testing SDA only, " 235 pr_info("%s: Testing SDA only, SCL is not readable\n", name);
225 "SCL is not readable.\n");
226 236
227 sda=getsda(adap); 237 sda=getsda(adap);
228 scl=(adap->getscl==NULL?1:getscl(adap)); 238 scl=(adap->getscl==NULL?1:getscl(adap));
229 printk(KERN_DEBUG "i2c-algo-bit.o: (0) scl=%d, sda=%d\n",scl,sda);
230 if (!scl || !sda ) { 239 if (!scl || !sda ) {
231 printk(KERN_WARNING "i2c-algo-bit.o: %s seems to be busy.\n", name); 240 printk(KERN_WARNING "%s: bus seems to be busy\n", name);
232 goto bailout; 241 goto bailout;
233 } 242 }
234 243
235 sdalo(adap); 244 sdalo(adap);
236 sda=getsda(adap); 245 sda=getsda(adap);
237 scl=(adap->getscl==NULL?1:getscl(adap)); 246 scl=(adap->getscl==NULL?1:getscl(adap));
238 printk(KERN_DEBUG "i2c-algo-bit.o: (1) scl=%d, sda=%d\n",scl,sda);
239 if ( 0 != sda ) { 247 if ( 0 != sda ) {
240 printk(KERN_WARNING "i2c-algo-bit.o: SDA stuck high!\n"); 248 printk(KERN_WARNING "%s: SDA stuck high!\n", name);
241 goto bailout; 249 goto bailout;
242 } 250 }
243 if ( 0 == scl ) { 251 if ( 0 == scl ) {
244 printk(KERN_WARNING "i2c-algo-bit.o: SCL unexpected low " 252 printk(KERN_WARNING "%s: SCL unexpected low "
245 "while pulling SDA low!\n"); 253 "while pulling SDA low!\n", name);
246 goto bailout; 254 goto bailout;
247 } 255 }
248 256
249 sdahi(adap); 257 sdahi(adap);
250 sda=getsda(adap); 258 sda=getsda(adap);
251 scl=(adap->getscl==NULL?1:getscl(adap)); 259 scl=(adap->getscl==NULL?1:getscl(adap));
252 printk(KERN_DEBUG "i2c-algo-bit.o: (2) scl=%d, sda=%d\n",scl,sda);
253 if ( 0 == sda ) { 260 if ( 0 == sda ) {
254 printk(KERN_WARNING "i2c-algo-bit.o: SDA stuck low!\n"); 261 printk(KERN_WARNING "%s: SDA stuck low!\n", name);
255 goto bailout; 262 goto bailout;
256 } 263 }
257 if ( 0 == scl ) { 264 if ( 0 == scl ) {
258 printk(KERN_WARNING "i2c-algo-bit.o: SCL unexpected low " 265 printk(KERN_WARNING "%s: SCL unexpected low "
259 "while pulling SDA high!\n"); 266 "while pulling SDA high!\n", name);
260 goto bailout; 267 goto bailout;
261 } 268 }
262 269
263 scllo(adap); 270 scllo(adap);
264 sda=getsda(adap); 271 sda=getsda(adap);
265 scl=(adap->getscl==NULL?0:getscl(adap)); 272 scl=(adap->getscl==NULL?0:getscl(adap));
266 printk(KERN_DEBUG "i2c-algo-bit.o: (3) scl=%d, sda=%d\n",scl,sda);
267 if ( 0 != scl ) { 273 if ( 0 != scl ) {
268 printk(KERN_WARNING "i2c-algo-bit.o: SCL stuck high!\n"); 274 printk(KERN_WARNING "%s: SCL stuck high!\n", name);
269 goto bailout; 275 goto bailout;
270 } 276 }
271 if ( 0 == sda ) { 277 if ( 0 == sda ) {
272 printk(KERN_WARNING "i2c-algo-bit.o: SDA unexpected low " 278 printk(KERN_WARNING "%s: SDA unexpected low "
273 "while pulling SCL low!\n"); 279 "while pulling SCL low!\n", name);
274 goto bailout; 280 goto bailout;
275 } 281 }
276 282
277 sclhi(adap); 283 sclhi(adap);
278 sda=getsda(adap); 284 sda=getsda(adap);
279 scl=(adap->getscl==NULL?1:getscl(adap)); 285 scl=(adap->getscl==NULL?1:getscl(adap));
280 printk(KERN_DEBUG "i2c-algo-bit.o: (4) scl=%d, sda=%d\n",scl,sda);
281 if ( 0 == scl ) { 286 if ( 0 == scl ) {
282 printk(KERN_WARNING "i2c-algo-bit.o: SCL stuck low!\n"); 287 printk(KERN_WARNING "%s: SCL stuck low!\n", name);
283 goto bailout; 288 goto bailout;
284 } 289 }
285 if ( 0 == sda ) { 290 if ( 0 == sda ) {
286 printk(KERN_WARNING "i2c-algo-bit.o: SDA unexpected low " 291 printk(KERN_WARNING "%s: SDA unexpected low "
287 "while pulling SCL high!\n"); 292 "while pulling SCL high!\n", name);
288 goto bailout; 293 goto bailout;
289 } 294 }
290 printk(KERN_INFO "i2c-algo-bit.o: %s passed test.\n",name); 295 pr_info("%s: Test OK\n", name);
291 return 0; 296 return 0;
292bailout: 297bailout:
293 sdahi(adap); 298 sdahi(adap);
@@ -312,44 +317,39 @@ static int try_address(struct i2c_adapter *i2c_adap,
312 int i,ret = -1; 317 int i,ret = -1;
313 for (i=0;i<=retries;i++) { 318 for (i=0;i<=retries;i++) {
314 ret = i2c_outb(i2c_adap,addr); 319 ret = i2c_outb(i2c_adap,addr);
315 if (ret==1) 320 if (ret == 1 || i == retries)
316 break; /* success! */
317 i2c_stop(adap);
318 udelay(5/*adap->udelay*/);
319 if (i==retries) /* no success */
320 break; 321 break;
321 i2c_start(adap); 322 bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
323 i2c_stop(adap);
322 udelay(adap->udelay); 324 udelay(adap->udelay);
325 yield();
326 bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
327 i2c_start(adap);
323 } 328 }
324 DEB2(if (i) 329 if (i && ret)
325 printk(KERN_DEBUG "i2c-algo-bit.o: Used %d tries to %s client at 0x%02x : %s\n", 330 bit_dbg(1, &i2c_adap->dev, "Used %d tries to %s client at "
326 i+1, addr & 1 ? "read" : "write", addr>>1, 331 "0x%02x: %s\n", i + 1,
327 ret==1 ? "success" : ret==0 ? "no ack" : "failed, timeout?" ) 332 addr & 1 ? "read from" : "write to", addr >> 1,
328 ); 333 ret == 1 ? "success" : "failed, timeout?");
329 return ret; 334 return ret;
330} 335}
331 336
332static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) 337static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
333{ 338{
334 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; 339 const unsigned char *temp = msg->buf;
335 char c;
336 const char *temp = msg->buf;
337 int count = msg->len; 340 int count = msg->len;
338 unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; 341 unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
339 int retval; 342 int retval;
340 int wrcount=0; 343 int wrcount=0;
341 344
342 while (count > 0) { 345 while (count > 0) {
343 c = *temp; 346 retval = i2c_outb(i2c_adap, *temp);
344 DEB2(dev_dbg(&i2c_adap->dev, "sendbytes: writing %2.2X\n", c&0xff));
345 retval = i2c_outb(i2c_adap,c);
346 if ((retval>0) || (nak_ok && (retval==0))) { /* ok or ignored NAK */ 347 if ((retval>0) || (nak_ok && (retval==0))) { /* ok or ignored NAK */
347 count--; 348 count--;
348 temp++; 349 temp++;
349 wrcount++; 350 wrcount++;
350 } else { /* arbitration or no acknowledge */ 351 } else { /* arbitration or no acknowledge */
351 dev_err(&i2c_adap->dev, "sendbytes: error - bailout.\n"); 352 dev_err(&i2c_adap->dev, "sendbytes: error - bailout.\n");
352 i2c_stop(adap);
353 return (retval<0)? retval : -EFAULT; 353 return (retval<0)? retval : -EFAULT;
354 /* got a better one ?? */ 354 /* got a better one ?? */
355 } 355 }
@@ -362,7 +362,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
362 int inval; 362 int inval;
363 int rdcount=0; /* counts bytes read */ 363 int rdcount=0; /* counts bytes read */
364 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; 364 struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
365 char *temp = msg->buf; 365 unsigned char *temp = msg->buf;
366 int count = msg->len; 366 int count = msg->len;
367 367
368 while (count > 0) { 368 while (count > 0) {
@@ -371,30 +371,44 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
371 *temp = inval; 371 *temp = inval;
372 rdcount++; 372 rdcount++;
373 } else { /* read timed out */ 373 } else { /* read timed out */
374 printk(KERN_ERR "i2c-algo-bit.o: readbytes: i2c_inb timed out.\n");
375 break; 374 break;
376 } 375 }
377 376
378 temp++; 377 temp++;
379 count--; 378 count--;
380 379
381 if (msg->flags & I2C_M_NO_RD_ACK) 380 if (msg->flags & I2C_M_NO_RD_ACK) {
381 bit_dbg(2, &i2c_adap->dev, "i2c_inb: 0x%02x\n",
382 inval);
382 continue; 383 continue;
383
384 if ( count > 0 ) { /* send ack */
385 sdalo(adap);
386 DEBPROTO(printk(" Am "));
387 } else {
388 sdahi(adap); /* neg. ack on last byte */
389 DEBPROTO(printk(" NAm "));
390 } 384 }
385
386 /* assert: sda is high */
387 if (count) /* send ack */
388 setsda(adap, 0);
389 udelay((adap->udelay + 1) / 2);
390 bit_dbg(2, &i2c_adap->dev, "i2c_inb: 0x%02x %s\n", inval,
391 count ? "A" : "NA");
391 if (sclhi(adap)<0) { /* timeout */ 392 if (sclhi(adap)<0) { /* timeout */
392 sdahi(adap); 393 dev_err(&i2c_adap->dev, "readbytes: timeout at ack\n");
393 printk(KERN_ERR "i2c-algo-bit.o: readbytes: Timeout at ack\n");
394 return -ETIMEDOUT; 394 return -ETIMEDOUT;
395 }; 395 };
396 scllo(adap); 396 scllo(adap);
397 sdahi(adap); 397
398 /* Some SMBus transactions require that we receive the
399 transaction length as the first read byte. */
400 if (rdcount == 1 && (msg->flags & I2C_M_RECV_LEN)) {
401 if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) {
402 dev_err(&i2c_adap->dev, "readbytes: invalid "
403 "block length (%d)\n", inval);
404 return -EREMOTEIO;
405 }
406 /* The original count value accounts for the extra
407 bytes, that is, either 1 for a regular transaction,
408 or 2 for a PEC transaction. */
409 count += inval;
410 msg->len += inval;
411 }
398 } 412 }
399 return rdcount; 413 return rdcount;
400} 414}
@@ -421,27 +435,31 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
421 if ( (flags & I2C_M_TEN) ) { 435 if ( (flags & I2C_M_TEN) ) {
422 /* a ten bit address */ 436 /* a ten bit address */
423 addr = 0xf0 | (( msg->addr >> 7) & 0x03); 437 addr = 0xf0 | (( msg->addr >> 7) & 0x03);
424 DEB2(printk(KERN_DEBUG "addr0: %d\n",addr)); 438 bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr);
425 /* try extended address code...*/ 439 /* try extended address code...*/
426 ret = try_address(i2c_adap, addr, retries); 440 ret = try_address(i2c_adap, addr, retries);
427 if ((ret != 1) && !nak_ok) { 441 if ((ret != 1) && !nak_ok) {
428 printk(KERN_ERR "died at extended address code.\n"); 442 dev_err(&i2c_adap->dev,
443 "died at extended address code\n");
429 return -EREMOTEIO; 444 return -EREMOTEIO;
430 } 445 }
431 /* the remaining 8 bit address */ 446 /* the remaining 8 bit address */
432 ret = i2c_outb(i2c_adap,msg->addr & 0x7f); 447 ret = i2c_outb(i2c_adap,msg->addr & 0x7f);
433 if ((ret != 1) && !nak_ok) { 448 if ((ret != 1) && !nak_ok) {
434 /* the chip did not ack / xmission error occurred */ 449 /* the chip did not ack / xmission error occurred */
435 printk(KERN_ERR "died at 2nd address code.\n"); 450 dev_err(&i2c_adap->dev, "died at 2nd address code\n");
436 return -EREMOTEIO; 451 return -EREMOTEIO;
437 } 452 }
438 if ( flags & I2C_M_RD ) { 453 if ( flags & I2C_M_RD ) {
454 bit_dbg(3, &i2c_adap->dev, "emitting repeated "
455 "start condition\n");
439 i2c_repstart(adap); 456 i2c_repstart(adap);
440 /* okay, now switch into reading mode */ 457 /* okay, now switch into reading mode */
441 addr |= 0x01; 458 addr |= 0x01;
442 ret = try_address(i2c_adap, addr, retries); 459 ret = try_address(i2c_adap, addr, retries);
443 if ((ret!=1) && !nak_ok) { 460 if ((ret!=1) && !nak_ok) {
444 printk(KERN_ERR "died at extended address code.\n"); 461 dev_err(&i2c_adap->dev,
462 "died at repeated address code\n");
445 return -EREMOTEIO; 463 return -EREMOTEIO;
446 } 464 }
447 } 465 }
@@ -468,44 +486,62 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
468 int i,ret; 486 int i,ret;
469 unsigned short nak_ok; 487 unsigned short nak_ok;
470 488
489 bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
471 i2c_start(adap); 490 i2c_start(adap);
472 for (i=0;i<num;i++) { 491 for (i=0;i<num;i++) {
473 pmsg = &msgs[i]; 492 pmsg = &msgs[i];
474 nak_ok = pmsg->flags & I2C_M_IGNORE_NAK; 493 nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
475 if (!(pmsg->flags & I2C_M_NOSTART)) { 494 if (!(pmsg->flags & I2C_M_NOSTART)) {
476 if (i) { 495 if (i) {
496 bit_dbg(3, &i2c_adap->dev, "emitting "
497 "repeated start condition\n");
477 i2c_repstart(adap); 498 i2c_repstart(adap);
478 } 499 }
479 ret = bit_doAddress(i2c_adap, pmsg); 500 ret = bit_doAddress(i2c_adap, pmsg);
480 if ((ret != 0) && !nak_ok) { 501 if ((ret != 0) && !nak_ok) {
481 DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: NAK from device addr %2.2x msg #%d\n" 502 bit_dbg(1, &i2c_adap->dev, "NAK from "
482 ,msgs[i].addr,i)); 503 "device addr 0x%02x msg #%d\n",
483 return (ret<0) ? ret : -EREMOTEIO; 504 msgs[i].addr, i);
505 goto bailout;
484 } 506 }
485 } 507 }
486 if (pmsg->flags & I2C_M_RD ) { 508 if (pmsg->flags & I2C_M_RD ) {
487 /* read bytes into buffer*/ 509 /* read bytes into buffer*/
488 ret = readbytes(i2c_adap, pmsg); 510 ret = readbytes(i2c_adap, pmsg);
489 DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: read %d bytes.\n",ret)); 511 if (ret >= 1)
490 if (ret < pmsg->len ) { 512 bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",
491 return (ret<0)? ret : -EREMOTEIO; 513 ret, ret == 1 ? "" : "s");
514 if (ret < pmsg->len) {
515 if (ret >= 0)
516 ret = -EREMOTEIO;
517 goto bailout;
492 } 518 }
493 } else { 519 } else {
494 /* write bytes from buffer */ 520 /* write bytes from buffer */
495 ret = sendbytes(i2c_adap, pmsg); 521 ret = sendbytes(i2c_adap, pmsg);
496 DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: wrote %d bytes.\n",ret)); 522 if (ret >= 1)
497 if (ret < pmsg->len ) { 523 bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",
498 return (ret<0) ? ret : -EREMOTEIO; 524 ret, ret == 1 ? "" : "s");
525 if (ret < pmsg->len) {
526 if (ret >= 0)
527 ret = -EREMOTEIO;
528 goto bailout;
499 } 529 }
500 } 530 }
501 } 531 }
532 ret = i;
533
534bailout:
535 bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
502 i2c_stop(adap); 536 i2c_stop(adap);
503 return num; 537 return ret;
504} 538}
505 539
506static u32 bit_func(struct i2c_adapter *adap) 540static u32 bit_func(struct i2c_adapter *adap)
507{ 541{
508 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | 542 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
543 I2C_FUNC_SMBUS_READ_BLOCK_DATA |
544 I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
509 I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING; 545 I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING;
510} 546}
511 547
@@ -520,7 +556,7 @@ static const struct i2c_algorithm i2c_bit_algo = {
520/* 556/*
521 * registering functions to load algorithms at runtime 557 * registering functions to load algorithms at runtime
522 */ 558 */
523int i2c_bit_add_bus(struct i2c_adapter *adap) 559static int i2c_bit_prepare_bus(struct i2c_adapter *adap)
524{ 560{
525 struct i2c_algo_bit_data *bit_adap = adap->algo_data; 561 struct i2c_algo_bit_data *bit_adap = adap->algo_data;
526 562
@@ -530,25 +566,39 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
530 return -ENODEV; 566 return -ENODEV;
531 } 567 }
532 568
533 DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
534
535 /* register new adapter to i2c module... */ 569 /* register new adapter to i2c module... */
536 adap->algo = &i2c_bit_algo; 570 adap->algo = &i2c_bit_algo;
537 571
538 adap->timeout = 100; /* default values, should */ 572 adap->timeout = 100; /* default values, should */
539 adap->retries = 3; /* be replaced by defines */ 573 adap->retries = 3; /* be replaced by defines */
540 574
575 return 0;
576}
577
578int i2c_bit_add_bus(struct i2c_adapter *adap)
579{
580 int err;
581
582 err = i2c_bit_prepare_bus(adap);
583 if (err)
584 return err;
585
541 return i2c_add_adapter(adap); 586 return i2c_add_adapter(adap);
542} 587}
543EXPORT_SYMBOL(i2c_bit_add_bus); 588EXPORT_SYMBOL(i2c_bit_add_bus);
544 589
590int i2c_bit_add_numbered_bus(struct i2c_adapter *adap)
591{
592 int err;
593
594 err = i2c_bit_prepare_bus(adap);
595 if (err)
596 return err;
597
598 return i2c_add_numbered_adapter(adap);
599}
600EXPORT_SYMBOL(i2c_bit_add_numbered_bus);
601
545MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 602MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
546MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); 603MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm");
547MODULE_LICENSE("GPL"); 604MODULE_LICENSE("GPL");
548
549module_param(bit_test, bool, 0);
550module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
551
552MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck");
553MODULE_PARM_DESC(i2c_debug,
554 "debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol");
diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c
index ac2d5053078a..6eaf145e1ada 100644
--- a/drivers/i2c/algos/i2c-algo-sgi.c
+++ b/drivers/i2c/algos/i2c-algo-sgi.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * i2c-algo-sgi.c: i2c driver algorithms for SGI adapters. 2 * i2c-algo-sgi.c: i2c driver algorithm used by the VINO (SGI Indy) and
3 * 3 * MACE (SGI O2) chips.
4 *
4 * This file is subject to the terms and conditions of the GNU General Public 5 * This file is subject to the terms and conditions of the GNU General Public
5 * License version 2 as published by the Free Software Foundation. 6 * License version 2 as published by the Free Software Foundation.
6 * 7 *
@@ -162,8 +163,8 @@ static const struct i2c_algorithm sgi_algo = {
162 .functionality = sgi_func, 163 .functionality = sgi_func,
163}; 164};
164 165
165/* 166/*
166 * registering functions to load algorithms at runtime 167 * registering functions to load algorithms at runtime
167 */ 168 */
168int i2c_sgi_add_bus(struct i2c_adapter *adap) 169int i2c_sgi_add_bus(struct i2c_adapter *adap)
169{ 170{
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index ece31d2c6c64..838dc1c19d61 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -3,11 +3,10 @@
3# 3#
4 4
5menu "I2C Hardware Bus support" 5menu "I2C Hardware Bus support"
6 depends on I2C
7 6
8config I2C_ALI1535 7config I2C_ALI1535
9 tristate "ALI 1535" 8 tristate "ALI 1535"
10 depends on I2C && PCI 9 depends on PCI
11 help 10 help
12 If you say yes to this option, support will be included for the SMB 11 If you say yes to this option, support will be included for the SMB
13 Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB 12 Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB
@@ -19,7 +18,7 @@ config I2C_ALI1535
19 18
20config I2C_ALI1563 19config I2C_ALI1563
21 tristate "ALI 1563" 20 tristate "ALI 1563"
22 depends on I2C && PCI && EXPERIMENTAL 21 depends on PCI && EXPERIMENTAL
23 help 22 help
24 If you say yes to this option, support will be included for the SMB 23 If you say yes to this option, support will be included for the SMB
25 Host controller on Acer Labs Inc. (ALI) M1563 South Bridges. The SMB 24 Host controller on Acer Labs Inc. (ALI) M1563 South Bridges. The SMB
@@ -31,7 +30,7 @@ config I2C_ALI1563
31 30
32config I2C_ALI15X3 31config I2C_ALI15X3
33 tristate "ALI 15x3" 32 tristate "ALI 15x3"
34 depends on I2C && PCI 33 depends on PCI
35 help 34 help
36 If you say yes to this option, support will be included for the 35 If you say yes to this option, support will be included for the
37 Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. 36 Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces.
@@ -41,7 +40,7 @@ config I2C_ALI15X3
41 40
42config I2C_AMD756 41config I2C_AMD756
43 tristate "AMD 756/766/768/8111 and nVidia nForce" 42 tristate "AMD 756/766/768/8111 and nVidia nForce"
44 depends on I2C && PCI 43 depends on PCI
45 help 44 help
46 If you say yes to this option, support will be included for the AMD 45 If you say yes to this option, support will be included for the AMD
47 756/766/768 mainboard I2C interfaces. The driver also includes 46 756/766/768 mainboard I2C interfaces. The driver also includes
@@ -66,7 +65,7 @@ config I2C_AMD756_S4882
66 65
67config I2C_AMD8111 66config I2C_AMD8111
68 tristate "AMD 8111" 67 tristate "AMD 8111"
69 depends on I2C && PCI 68 depends on PCI
70 help 69 help
71 If you say yes to this option, support will be included for the 70 If you say yes to this option, support will be included for the
72 second (SMBus 2.0) AMD 8111 mainboard I2C interface. 71 second (SMBus 2.0) AMD 8111 mainboard I2C interface.
@@ -76,14 +75,14 @@ config I2C_AMD8111
76 75
77config I2C_AT91 76config I2C_AT91
78 tristate "Atmel AT91 I2C Two-Wire interface (TWI)" 77 tristate "Atmel AT91 I2C Two-Wire interface (TWI)"
79 depends on I2C && ARCH_AT91 && EXPERIMENTAL 78 depends on ARCH_AT91 && EXPERIMENTAL
80 help 79 help
81 This supports the use of the I2C interface on Atmel AT91 80 This supports the use of the I2C interface on Atmel AT91
82 processors. 81 processors.
83 82
84config I2C_AU1550 83config I2C_AU1550
85 tristate "Au1550/Au1200 SMBus interface" 84 tristate "Au1550/Au1200 SMBus interface"
86 depends on I2C && (SOC_AU1550 || SOC_AU1200) 85 depends on SOC_AU1550 || SOC_AU1200
87 help 86 help
88 If you say yes to this option, support will be included for the 87 If you say yes to this option, support will be included for the
89 Au1550 and Au1200 SMBus interface. 88 Au1550 and Au1200 SMBus interface.
@@ -91,9 +90,25 @@ config I2C_AU1550
91 This driver can also be built as a module. If so, the module 90 This driver can also be built as a module. If so, the module
92 will be called i2c-au1550. 91 will be called i2c-au1550.
93 92
93config I2C_BLACKFIN_TWI
94 tristate "Blackfin TWI I2C support"
95 depends on BF534 || BF536 || BF537
96 help
97 This is the TWI I2C device driver for Blackfin 534/536/537.
98 This driver can also be built as a module. If so, the module
99 will be called i2c-bfin-twi.
100
101config I2C_BLACKFIN_TWI_CLK_KHZ
102 int "Blackfin TWI I2C clock (kHz)"
103 depends on I2C_BLACKFIN_TWI
104 range 10 400
105 default 50
106 help
107 The unit of the TWI clock is kHz.
108
94config I2C_ELEKTOR 109config I2C_ELEKTOR
95 tristate "Elektor ISA card" 110 tristate "Elektor ISA card"
96 depends on I2C && ISA && BROKEN_ON_SMP 111 depends on ISA && BROKEN_ON_SMP
97 select I2C_ALGOPCF 112 select I2C_ALGOPCF
98 help 113 help
99 This supports the PCF8584 ISA bus I2C adapter. Say Y if you own 114 This supports the PCF8584 ISA bus I2C adapter. Say Y if you own
@@ -102,9 +117,17 @@ config I2C_ELEKTOR
102 This support is also available as a module. If so, the module 117 This support is also available as a module. If so, the module
103 will be called i2c-elektor. 118 will be called i2c-elektor.
104 119
120config I2C_GPIO
121 tristate "GPIO-based bitbanging I2C"
122 depends on GENERIC_GPIO
123 select I2C_ALGOBIT
124 help
125 This is a very simple bitbanging I2C driver utilizing the
126 arch-neutral GPIO API to control the SCL and SDA lines.
127
105config I2C_HYDRA 128config I2C_HYDRA
106 tristate "CHRP Apple Hydra Mac I/O I2C interface" 129 tristate "CHRP Apple Hydra Mac I/O I2C interface"
107 depends on I2C && PCI && PPC_CHRP && EXPERIMENTAL 130 depends on PCI && PPC_CHRP && EXPERIMENTAL
108 select I2C_ALGOBIT 131 select I2C_ALGOBIT
109 help 132 help
110 This supports the use of the I2C interface in the Apple Hydra Mac 133 This supports the use of the I2C interface in the Apple Hydra Mac
@@ -116,7 +139,7 @@ config I2C_HYDRA
116 139
117config I2C_I801 140config I2C_I801
118 tristate "Intel 82801 (ICH)" 141 tristate "Intel 82801 (ICH)"
119 depends on I2C && PCI 142 depends on PCI
120 help 143 help
121 If you say yes to this option, support will be included for the Intel 144 If you say yes to this option, support will be included for the Intel
122 801 family of mainboard I2C interfaces. Specifically, the following 145 801 family of mainboard I2C interfaces. Specifically, the following
@@ -139,7 +162,7 @@ config I2C_I801
139 162
140config I2C_I810 163config I2C_I810
141 tristate "Intel 810/815" 164 tristate "Intel 810/815"
142 depends on I2C && PCI 165 depends on PCI
143 select I2C_ALGOBIT 166 select I2C_ALGOBIT
144 help 167 help
145 If you say yes to this option, support will be included for the Intel 168 If you say yes to this option, support will be included for the Intel
@@ -156,7 +179,7 @@ config I2C_I810
156 179
157config I2C_PXA 180config I2C_PXA
158 tristate "Intel PXA2XX I2C adapter (EXPERIMENTAL)" 181 tristate "Intel PXA2XX I2C adapter (EXPERIMENTAL)"
159 depends on I2C && EXPERIMENTAL && ARCH_PXA 182 depends on EXPERIMENTAL && ARCH_PXA
160 help 183 help
161 If you have devices in the PXA I2C bus, say yes to this option. 184 If you have devices in the PXA I2C bus, say yes to this option.
162 This driver can also be built as a module. If so, the module 185 This driver can also be built as a module. If so, the module
@@ -172,7 +195,7 @@ config I2C_PXA_SLAVE
172 195
173config I2C_PIIX4 196config I2C_PIIX4
174 tristate "Intel PIIX4 and compatible (ATI/Serverworks/Broadcom/SMSC)" 197 tristate "Intel PIIX4 and compatible (ATI/Serverworks/Broadcom/SMSC)"
175 depends on I2C && PCI 198 depends on PCI
176 help 199 help
177 If you say yes to this option, support will be included for the Intel 200 If you say yes to this option, support will be included for the Intel
178 PIIX4 family of mainboard I2C interfaces. Specifically, the following 201 PIIX4 family of mainboard I2C interfaces. Specifically, the following
@@ -195,7 +218,7 @@ config I2C_PIIX4
195 218
196config I2C_IBM_IIC 219config I2C_IBM_IIC
197 tristate "IBM PPC 4xx on-chip I2C interface" 220 tristate "IBM PPC 4xx on-chip I2C interface"
198 depends on IBM_OCP && I2C 221 depends on IBM_OCP
199 help 222 help
200 Say Y here if you want to use IIC peripheral found on 223 Say Y here if you want to use IIC peripheral found on
201 embedded IBM PPC 4xx based systems. 224 embedded IBM PPC 4xx based systems.
@@ -205,7 +228,7 @@ config I2C_IBM_IIC
205 228
206config I2C_IOP3XX 229config I2C_IOP3XX
207 tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface" 230 tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface"
208 depends on (ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX || ARCH_IOP13XX) && I2C 231 depends on ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX || ARCH_IOP13XX
209 help 232 help
210 Say Y here if you want to use the IIC bus controller on 233 Say Y here if you want to use the IIC bus controller on
211 the Intel IOPx3xx I/O Processors or IXP4xx Network Processors. 234 the Intel IOPx3xx I/O Processors or IXP4xx Network Processors.
@@ -215,11 +238,10 @@ config I2C_IOP3XX
215 238
216config I2C_ISA 239config I2C_ISA
217 tristate 240 tristate
218 depends on I2C
219 241
220config I2C_IXP4XX 242config I2C_IXP4XX
221 tristate "IXP4xx GPIO-Based I2C Interface" 243 tristate "IXP4xx GPIO-Based I2C Interface (DEPRECATED)"
222 depends on I2C && ARCH_IXP4XX 244 depends on ARCH_IXP4XX
223 select I2C_ALGOBIT 245 select I2C_ALGOBIT
224 help 246 help
225 Say Y here if you have an Intel IXP4xx(420,421,422,425) based 247 Say Y here if you have an Intel IXP4xx(420,421,422,425) based
@@ -228,9 +250,12 @@ config I2C_IXP4XX
228 This support is also available as a module. If so, the module 250 This support is also available as a module. If so, the module
229 will be called i2c-ixp4xx. 251 will be called i2c-ixp4xx.
230 252
253 This driver is deprecated and will be dropped soon. Use i2c-gpio
254 instead.
255
231config I2C_IXP2000 256config I2C_IXP2000
232 tristate "IXP2000 GPIO-Based I2C Interface" 257 tristate "IXP2000 GPIO-Based I2C Interface (DEPRECATED)"
233 depends on I2C && ARCH_IXP2000 258 depends on ARCH_IXP2000
234 select I2C_ALGOBIT 259 select I2C_ALGOBIT
235 help 260 help
236 Say Y here if you have an Intel IXP2000(2400, 2800, 2850) based 261 Say Y here if you have an Intel IXP2000(2400, 2800, 2850) based
@@ -239,9 +264,12 @@ config I2C_IXP2000
239 This support is also available as a module. If so, the module 264 This support is also available as a module. If so, the module
240 will be called i2c-ixp2000. 265 will be called i2c-ixp2000.
241 266
267 This driver is deprecated and will be dropped soon. Use i2c-gpio
268 instead.
269
242config I2C_POWERMAC 270config I2C_POWERMAC
243 tristate "Powermac I2C interface" 271 tristate "Powermac I2C interface"
244 depends on I2C && PPC_PMAC 272 depends on PPC_PMAC
245 default y 273 default y
246 help 274 help
247 This exposes the various PowerMac i2c interfaces to the linux i2c 275 This exposes the various PowerMac i2c interfaces to the linux i2c
@@ -253,7 +281,7 @@ config I2C_POWERMAC
253 281
254config I2C_MPC 282config I2C_MPC
255 tristate "MPC107/824x/85xx/52xx/86xx" 283 tristate "MPC107/824x/85xx/52xx/86xx"
256 depends on I2C && PPC32 284 depends on PPC32
257 help 285 help
258 If you say yes to this option, support will be included for the 286 If you say yes to this option, support will be included for the
259 built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and 287 built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
@@ -265,7 +293,7 @@ config I2C_MPC
265 293
266config I2C_NFORCE2 294config I2C_NFORCE2
267 tristate "Nvidia nForce2, nForce3 and nForce4" 295 tristate "Nvidia nForce2, nForce3 and nForce4"
268 depends on I2C && PCI 296 depends on PCI
269 help 297 help
270 If you say yes to this option, support will be included for the Nvidia 298 If you say yes to this option, support will be included for the Nvidia
271 nForce2, nForce3 and nForce4 families of mainboard I2C interfaces. 299 nForce2, nForce3 and nForce4 families of mainboard I2C interfaces.
@@ -275,7 +303,7 @@ config I2C_NFORCE2
275 303
276config I2C_OCORES 304config I2C_OCORES
277 tristate "OpenCores I2C Controller" 305 tristate "OpenCores I2C Controller"
278 depends on I2C && EXPERIMENTAL 306 depends on EXPERIMENTAL
279 help 307 help
280 If you say yes to this option, support will be included for the 308 If you say yes to this option, support will be included for the
281 OpenCores I2C controller. For details see 309 OpenCores I2C controller. For details see
@@ -286,7 +314,7 @@ config I2C_OCORES
286 314
287config I2C_OMAP 315config I2C_OMAP
288 tristate "OMAP I2C adapter" 316 tristate "OMAP I2C adapter"
289 depends on I2C && ARCH_OMAP 317 depends on ARCH_OMAP
290 default y if MACH_OMAP_H3 || MACH_OMAP_OSK 318 default y if MACH_OMAP_H3 || MACH_OMAP_OSK
291 help 319 help
292 If you say yes to this option, support will be included for the 320 If you say yes to this option, support will be included for the
@@ -296,7 +324,7 @@ config I2C_OMAP
296 324
297config I2C_PARPORT 325config I2C_PARPORT
298 tristate "Parallel port adapter" 326 tristate "Parallel port adapter"
299 depends on I2C && PARPORT 327 depends on PARPORT
300 select I2C_ALGOBIT 328 select I2C_ALGOBIT
301 help 329 help
302 This supports parallel port I2C adapters such as the ones made by 330 This supports parallel port I2C adapters such as the ones made by
@@ -320,7 +348,6 @@ config I2C_PARPORT
320 348
321config I2C_PARPORT_LIGHT 349config I2C_PARPORT_LIGHT
322 tristate "Parallel port adapter (light)" 350 tristate "Parallel port adapter (light)"
323 depends on I2C
324 select I2C_ALGOBIT 351 select I2C_ALGOBIT
325 help 352 help
326 This supports parallel port I2C adapters such as the ones made by 353 This supports parallel port I2C adapters such as the ones made by
@@ -344,13 +371,13 @@ config I2C_PARPORT_LIGHT
344 371
345config I2C_PASEMI 372config I2C_PASEMI
346 tristate "PA Semi SMBus interface" 373 tristate "PA Semi SMBus interface"
347 depends on PPC_PASEMI && I2C && PCI 374 depends on PPC_PASEMI && PCI
348 help 375 help
349 Supports the PA Semi PWRficient on-chip SMBus interfaces. 376 Supports the PA Semi PWRficient on-chip SMBus interfaces.
350 377
351config I2C_PROSAVAGE 378config I2C_PROSAVAGE
352 tristate "S3/VIA (Pro)Savage" 379 tristate "S3/VIA (Pro)Savage"
353 depends on I2C && PCI 380 depends on PCI
354 select I2C_ALGOBIT 381 select I2C_ALGOBIT
355 help 382 help
356 If you say yes to this option, support will be included for the 383 If you say yes to this option, support will be included for the
@@ -365,19 +392,19 @@ config I2C_PROSAVAGE
365 392
366config I2C_RPXLITE 393config I2C_RPXLITE
367 tristate "Embedded Planet RPX Lite/Classic support" 394 tristate "Embedded Planet RPX Lite/Classic support"
368 depends on (RPXLITE || RPXCLASSIC) && I2C 395 depends on RPXLITE || RPXCLASSIC
369 select I2C_ALGO8XX 396 select I2C_ALGO8XX
370 397
371config I2C_S3C2410 398config I2C_S3C2410
372 tristate "S3C2410 I2C Driver" 399 tristate "S3C2410 I2C Driver"
373 depends on I2C && ARCH_S3C2410 400 depends on ARCH_S3C2410
374 help 401 help
375 Say Y here to include support for I2C controller in the 402 Say Y here to include support for I2C controller in the
376 Samsung S3C2410 based System-on-Chip devices. 403 Samsung S3C2410 based System-on-Chip devices.
377 404
378config I2C_SAVAGE4 405config I2C_SAVAGE4
379 tristate "S3 Savage 4" 406 tristate "S3 Savage 4"
380 depends on I2C && PCI && EXPERIMENTAL 407 depends on PCI && EXPERIMENTAL
381 select I2C_ALGOBIT 408 select I2C_ALGOBIT
382 help 409 help
383 If you say yes to this option, support will be included for the 410 If you say yes to this option, support will be included for the
@@ -388,13 +415,25 @@ config I2C_SAVAGE4
388 415
389config I2C_SIBYTE 416config I2C_SIBYTE
390 tristate "SiByte SMBus interface" 417 tristate "SiByte SMBus interface"
391 depends on SIBYTE_SB1xxx_SOC && I2C 418 depends on SIBYTE_SB1xxx_SOC
392 help 419 help
393 Supports the SiByte SOC on-chip I2C interfaces (2 channels). 420 Supports the SiByte SOC on-chip I2C interfaces (2 channels).
394 421
422config I2C_SIMTEC
423 tristate "Simtec Generic I2C interface"
424 select I2C_ALGOBIT
425 help
426 If you say yes to this option, support will be inclyded for
427 the Simtec Generic I2C interface. This driver is for the
428 simple I2C bus used on newer Simtec products for general
429 I2C, such as DDC on the Simtec BBD2016A.
430
431 This driver can also be build as a module. If so, the module
432 will be called i2c-simtec.
433
395config SCx200_I2C 434config SCx200_I2C
396 tristate "NatSemi SCx200 I2C using GPIO pins" 435 tristate "NatSemi SCx200 I2C using GPIO pins (DEPRECATED)"
397 depends on SCx200_GPIO && I2C 436 depends on SCx200_GPIO
398 select I2C_ALGOBIT 437 select I2C_ALGOBIT
399 help 438 help
400 Enable the use of two GPIO pins of a SCx200 processor as an I2C bus. 439 Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
@@ -404,6 +443,9 @@ config SCx200_I2C
404 This support is also available as a module. If so, the module 443 This support is also available as a module. If so, the module
405 will be called scx200_i2c. 444 will be called scx200_i2c.
406 445
446 This driver is deprecated and will be dropped soon. Use i2c-gpio
447 (or scx200_acb) instead.
448
407config SCx200_I2C_SCL 449config SCx200_I2C_SCL
408 int "GPIO pin used for SCL" 450 int "GPIO pin used for SCL"
409 depends on SCx200_I2C 451 depends on SCx200_I2C
@@ -422,7 +464,7 @@ config SCx200_I2C_SDA
422 464
423config SCx200_ACB 465config SCx200_ACB
424 tristate "Geode ACCESS.bus support" 466 tristate "Geode ACCESS.bus support"
425 depends on X86_32 && I2C && PCI 467 depends on X86_32 && PCI
426 help 468 help
427 Enable the use of the ACCESS.bus controllers on the Geode SCx200 and 469 Enable the use of the ACCESS.bus controllers on the Geode SCx200 and
428 SC1100 processors and the CS5535 and CS5536 Geode companion devices. 470 SC1100 processors and the CS5535 and CS5536 Geode companion devices.
@@ -434,7 +476,7 @@ config SCx200_ACB
434 476
435config I2C_SIS5595 477config I2C_SIS5595
436 tristate "SiS 5595" 478 tristate "SiS 5595"
437 depends on I2C && PCI 479 depends on PCI
438 help 480 help
439 If you say yes to this option, support will be included for the 481 If you say yes to this option, support will be included for the
440 SiS5595 SMBus (a subset of I2C) interface. 482 SiS5595 SMBus (a subset of I2C) interface.
@@ -444,7 +486,7 @@ config I2C_SIS5595
444 486
445config I2C_SIS630 487config I2C_SIS630
446 tristate "SiS 630/730" 488 tristate "SiS 630/730"
447 depends on I2C && PCI 489 depends on PCI
448 help 490 help
449 If you say yes to this option, support will be included for the 491 If you say yes to this option, support will be included for the
450 SiS630 and SiS730 SMBus (a subset of I2C) interface. 492 SiS630 and SiS730 SMBus (a subset of I2C) interface.
@@ -454,7 +496,7 @@ config I2C_SIS630
454 496
455config I2C_SIS96X 497config I2C_SIS96X
456 tristate "SiS 96x" 498 tristate "SiS 96x"
457 depends on I2C && PCI 499 depends on PCI
458 help 500 help
459 If you say yes to this option, support will be included for the SiS 501 If you say yes to this option, support will be included for the SiS
460 96x SMBus (a subset of I2C) interfaces. Specifically, the following 502 96x SMBus (a subset of I2C) interfaces. Specifically, the following
@@ -472,7 +514,7 @@ config I2C_SIS96X
472 514
473config I2C_STUB 515config I2C_STUB
474 tristate "I2C/SMBus Test Stub" 516 tristate "I2C/SMBus Test Stub"
475 depends on I2C && EXPERIMENTAL && 'm' 517 depends on EXPERIMENTAL && m
476 default 'n' 518 default 'n'
477 help 519 help
478 This module may be useful to developers of SMBus client drivers, 520 This module may be useful to developers of SMBus client drivers,
@@ -483,9 +525,20 @@ config I2C_STUB
483 525
484 If you don't know what to do here, definitely say N. 526 If you don't know what to do here, definitely say N.
485 527
528config I2C_TINY_USB
529 tristate "I2C-Tiny-USB"
530 depends on USB
531 help
532 If you say yes to this option, support will be included for the
533 i2c-tiny-usb, a simple do-it-yourself USB to I2C interface. See
534 http://www.harbaum.org/till/i2c_tiny_usb for hardware details.
535
536 This driver can also be built as a module. If so, the module
537 will be called i2c-tiny-usb.
538
486config I2C_VERSATILE 539config I2C_VERSATILE
487 tristate "ARM Versatile/Realview I2C bus support" 540 tristate "ARM Versatile/Realview I2C bus support"
488 depends on I2C && (ARCH_VERSATILE || ARCH_REALVIEW) 541 depends on ARCH_VERSATILE || ARCH_REALVIEW
489 select I2C_ALGOBIT 542 select I2C_ALGOBIT
490 help 543 help
491 Say yes if you want to support the I2C serial bus on ARMs Versatile 544 Say yes if you want to support the I2C serial bus on ARMs Versatile
@@ -496,7 +549,7 @@ config I2C_VERSATILE
496 549
497config I2C_ACORN 550config I2C_ACORN
498 bool "Acorn IOC/IOMD I2C bus support" 551 bool "Acorn IOC/IOMD I2C bus support"
499 depends on I2C && ARCH_ACORN 552 depends on ARCH_ACORN
500 default y 553 default y
501 select I2C_ALGOBIT 554 select I2C_ALGOBIT
502 help 555 help
@@ -506,7 +559,7 @@ config I2C_ACORN
506 559
507config I2C_VIA 560config I2C_VIA
508 tristate "VIA 82C586B" 561 tristate "VIA 82C586B"
509 depends on I2C && PCI && EXPERIMENTAL 562 depends on PCI && EXPERIMENTAL
510 select I2C_ALGOBIT 563 select I2C_ALGOBIT
511 help 564 help
512 If you say yes to this option, support will be included for the VIA 565 If you say yes to this option, support will be included for the VIA
@@ -517,7 +570,7 @@ config I2C_VIA
517 570
518config I2C_VIAPRO 571config I2C_VIAPRO
519 tristate "VIA VT82C596/82C686/82xx and CX700" 572 tristate "VIA VT82C596/82C686/82xx and CX700"
520 depends on I2C && PCI 573 depends on PCI
521 help 574 help
522 If you say yes to this option, support will be included for the VIA 575 If you say yes to this option, support will be included for the VIA
523 VT82C596 and later SMBus interface. Specifically, the following 576 VT82C596 and later SMBus interface. Specifically, the following
@@ -536,7 +589,7 @@ config I2C_VIAPRO
536 589
537config I2C_VOODOO3 590config I2C_VOODOO3
538 tristate "Voodoo 3" 591 tristate "Voodoo 3"
539 depends on I2C && PCI 592 depends on PCI
540 select I2C_ALGOBIT 593 select I2C_ALGOBIT
541 help 594 help
542 If you say yes to this option, support will be included for the 595 If you say yes to this option, support will be included for the
@@ -547,7 +600,7 @@ config I2C_VOODOO3
547 600
548config I2C_PCA_ISA 601config I2C_PCA_ISA
549 tristate "PCA9564 on an ISA bus" 602 tristate "PCA9564 on an ISA bus"
550 depends on I2C 603 depends on ISA
551 select I2C_ALGOPCA 604 select I2C_ALGOPCA
552 default n 605 default n
553 help 606 help
@@ -564,7 +617,7 @@ config I2C_PCA_ISA
564 617
565config I2C_MV64XXX 618config I2C_MV64XXX
566 tristate "Marvell mv64xxx I2C Controller" 619 tristate "Marvell mv64xxx I2C Controller"
567 depends on I2C && MV64X60 && EXPERIMENTAL 620 depends on MV64X60 && EXPERIMENTAL
568 help 621 help
569 If you say yes to this option, support will be included for the 622 If you say yes to this option, support will be included for the
570 built-in I2C interface on the Marvell 64xxx line of host bridges. 623 built-in I2C interface on the Marvell 64xxx line of host bridges.
@@ -574,7 +627,7 @@ config I2C_MV64XXX
574 627
575config I2C_PNX 628config I2C_PNX
576 tristate "I2C bus support for Philips PNX targets" 629 tristate "I2C bus support for Philips PNX targets"
577 depends on ARCH_PNX4008 && I2C 630 depends on ARCH_PNX4008
578 help 631 help
579 This driver supports the Philips IP3204 I2C IP block master and/or 632 This driver supports the Philips IP3204 I2C IP block master and/or
580 slave controller 633 slave controller
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 290b54018354..14d1432f698b 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -10,7 +10,9 @@ obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o
10obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o 10obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o
11obj-$(CONFIG_I2C_AT91) += i2c-at91.o 11obj-$(CONFIG_I2C_AT91) += i2c-at91.o
12obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o 12obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
13obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
13obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o 14obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
15obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
14obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o 16obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
15obj-$(CONFIG_I2C_I801) += i2c-i801.o 17obj-$(CONFIG_I2C_I801) += i2c-i801.o
16obj-$(CONFIG_I2C_I810) += i2c-i810.o 18obj-$(CONFIG_I2C_I810) += i2c-i810.o
@@ -37,10 +39,12 @@ obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o
37obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o 39obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o
38obj-$(CONFIG_I2C_SAVAGE4) += i2c-savage4.o 40obj-$(CONFIG_I2C_SAVAGE4) += i2c-savage4.o
39obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o 41obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
42obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
40obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o 43obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o
41obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o 44obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o
42obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o 45obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o
43obj-$(CONFIG_I2C_STUB) += i2c-stub.o 46obj-$(CONFIG_I2C_STUB) += i2c-stub.o
47obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o
44obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o 48obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o
45obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o 49obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o
46obj-$(CONFIG_I2C_VIA) += i2c-via.o 50obj-$(CONFIG_I2C_VIA) += i2c-via.o
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index 1e277ba5a9f3..f14372ac2fc5 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -497,7 +497,7 @@ static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_
497 /* set up the sysfs linkage to our parent device */ 497 /* set up the sysfs linkage to our parent device */
498 ali1535_adapter.dev.parent = &dev->dev; 498 ali1535_adapter.dev.parent = &dev->dev;
499 499
500 snprintf(ali1535_adapter.name, I2C_NAME_SIZE, 500 snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name),
501 "SMBus ALI1535 adapter at %04x", ali1535_smba); 501 "SMBus ALI1535 adapter at %04x", ali1535_smba);
502 return i2c_add_adapter(&ali1535_adapter); 502 return i2c_add_adapter(&ali1535_adapter);
503} 503}
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index e47fe01bf42a..93bf87d70961 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -492,7 +492,7 @@ static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_
492 /* set up the sysfs linkage to our parent device */ 492 /* set up the sysfs linkage to our parent device */
493 ali15x3_adapter.dev.parent = &dev->dev; 493 ali15x3_adapter.dev.parent = &dev->dev;
494 494
495 snprintf(ali15x3_adapter.name, I2C_NAME_SIZE, 495 snprintf(ali15x3_adapter.name, sizeof(ali15x3_adapter.name),
496 "SMBus ALI15X3 adapter at %04x", ali15x3_smba); 496 "SMBus ALI15X3 adapter at %04x", ali15x3_smba);
497 return i2c_add_adapter(&ali15x3_adapter); 497 return i2c_add_adapter(&ali15x3_adapter);
498} 498}
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index 0c70f8293341..c9fca7b49267 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -365,7 +365,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev,
365 } 365 }
366 366
367 smbus->adapter.owner = THIS_MODULE; 367 smbus->adapter.owner = THIS_MODULE;
368 snprintf(smbus->adapter.name, I2C_NAME_SIZE, 368 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name),
369 "SMBus2 AMD8111 adapter at %04x", smbus->base); 369 "SMBus2 AMD8111 adapter at %04x", smbus->base);
370 smbus->adapter.id = I2C_HW_SMBUS_AMD8111; 370 smbus->adapter.id = I2C_HW_SMBUS_AMD8111;
371 smbus->adapter.class = I2C_CLASS_HWMON; 371 smbus->adapter.class = I2C_CLASS_HWMON;
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 67f91bdda089..f35156c58922 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -17,7 +17,6 @@
17#include <linux/version.h> 17#include <linux/version.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/pci.h>
21#include <linux/types.h> 20#include <linux/types.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/i2c.h> 22#include <linux/i2c.h>
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
new file mode 100644
index 000000000000..6311039dfe60
--- /dev/null
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -0,0 +1,644 @@
1/*
2 * drivers/i2c/busses/i2c-bfin-twi.c
3 *
4 * Description: Driver for Blackfin Two Wire Interface
5 *
6 * Author: sonicz <sonic.zhang@analog.com>
7 *
8 * Copyright (c) 2005-2007 Analog Devices, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/init.h>
28#include <linux/i2c.h>
29#include <linux/mm.h>
30#include <linux/timer.h>
31#include <linux/spinlock.h>
32#include <linux/completion.h>
33#include <linux/interrupt.h>
34#include <linux/platform_device.h>
35
36#include <asm/blackfin.h>
37#include <asm/irq.h>
38
39#define POLL_TIMEOUT (2 * HZ)
40
41/* SMBus mode*/
42#define TWI_I2C_MODE_STANDARD 0x01
43#define TWI_I2C_MODE_STANDARDSUB 0x02
44#define TWI_I2C_MODE_COMBINED 0x04
45
46struct bfin_twi_iface {
47 struct mutex twi_lock;
48 int irq;
49 spinlock_t lock;
50 char read_write;
51 u8 command;
52 u8 *transPtr;
53 int readNum;
54 int writeNum;
55 int cur_mode;
56 int manual_stop;
57 int result;
58 int timeout_count;
59 struct timer_list timeout_timer;
60 struct i2c_adapter adap;
61 struct completion complete;
62};
63
64static struct bfin_twi_iface twi_iface;
65
66static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface)
67{
68 unsigned short twi_int_status = bfin_read_TWI_INT_STAT();
69 unsigned short mast_stat = bfin_read_TWI_MASTER_STAT();
70
71 if (twi_int_status & XMTSERV) {
72 /* Transmit next data */
73 if (iface->writeNum > 0) {
74 bfin_write_TWI_XMT_DATA8(*(iface->transPtr++));
75 iface->writeNum--;
76 }
77 /* start receive immediately after complete sending in
78 * combine mode.
79 */
80 else if (iface->cur_mode == TWI_I2C_MODE_COMBINED) {
81 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL()
82 | MDIR | RSTART);
83 } else if (iface->manual_stop)
84 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL()
85 | STOP);
86 SSYNC();
87 /* Clear status */
88 bfin_write_TWI_INT_STAT(XMTSERV);
89 SSYNC();
90 }
91 if (twi_int_status & RCVSERV) {
92 if (iface->readNum > 0) {
93 /* Receive next data */
94 *(iface->transPtr) = bfin_read_TWI_RCV_DATA8();
95 if (iface->cur_mode == TWI_I2C_MODE_COMBINED) {
96 /* Change combine mode into sub mode after
97 * read first data.
98 */
99 iface->cur_mode = TWI_I2C_MODE_STANDARDSUB;
100 /* Get read number from first byte in block
101 * combine mode.
102 */
103 if (iface->readNum == 1 && iface->manual_stop)
104 iface->readNum = *iface->transPtr + 1;
105 }
106 iface->transPtr++;
107 iface->readNum--;
108 } else if (iface->manual_stop) {
109 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL()
110 | STOP);
111 SSYNC();
112 }
113 /* Clear interrupt source */
114 bfin_write_TWI_INT_STAT(RCVSERV);
115 SSYNC();
116 }
117 if (twi_int_status & MERR) {
118 bfin_write_TWI_INT_STAT(MERR);
119 bfin_write_TWI_INT_MASK(0);
120 bfin_write_TWI_MASTER_STAT(0x3e);
121 bfin_write_TWI_MASTER_CTL(0);
122 SSYNC();
123 iface->result = -1;
124 /* if both err and complete int stats are set, return proper
125 * results.
126 */
127 if (twi_int_status & MCOMP) {
128 bfin_write_TWI_INT_STAT(MCOMP);
129 bfin_write_TWI_INT_MASK(0);
130 bfin_write_TWI_MASTER_CTL(0);
131 SSYNC();
132 /* If it is a quick transfer, only address bug no data,
133 * not an err, return 1.
134 */
135 if (iface->writeNum == 0 && (mast_stat & BUFRDERR))
136 iface->result = 1;
137 /* If address not acknowledged return -1,
138 * else return 0.
139 */
140 else if (!(mast_stat & ANAK))
141 iface->result = 0;
142 }
143 complete(&iface->complete);
144 return;
145 }
146 if (twi_int_status & MCOMP) {
147 bfin_write_TWI_INT_STAT(MCOMP);
148 SSYNC();
149 if (iface->cur_mode == TWI_I2C_MODE_COMBINED) {
150 if (iface->readNum == 0) {
151 /* set the read number to 1 and ask for manual
152 * stop in block combine mode
153 */
154 iface->readNum = 1;
155 iface->manual_stop = 1;
156 bfin_write_TWI_MASTER_CTL(
157 bfin_read_TWI_MASTER_CTL()
158 | (0xff << 6));
159 } else {
160 /* set the readd number in other
161 * combine mode.
162 */
163 bfin_write_TWI_MASTER_CTL(
164 (bfin_read_TWI_MASTER_CTL() &
165 (~(0xff << 6))) |
166 ( iface->readNum << 6));
167 }
168 /* remove restart bit and enable master receive */
169 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() &
170 ~RSTART);
171 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() |
172 MEN | MDIR);
173 SSYNC();
174 } else {
175 iface->result = 1;
176 bfin_write_TWI_INT_MASK(0);
177 bfin_write_TWI_MASTER_CTL(0);
178 SSYNC();
179 complete(&iface->complete);
180 }
181 }
182}
183
184/* Interrupt handler */
185static irqreturn_t bfin_twi_interrupt_entry(int irq, void *dev_id)
186{
187 struct bfin_twi_iface *iface = dev_id;
188 unsigned long flags;
189
190 spin_lock_irqsave(&iface->lock, flags);
191 del_timer(&iface->timeout_timer);
192 bfin_twi_handle_interrupt(iface);
193 spin_unlock_irqrestore(&iface->lock, flags);
194 return IRQ_HANDLED;
195}
196
197static void bfin_twi_timeout(unsigned long data)
198{
199 struct bfin_twi_iface *iface = (struct bfin_twi_iface *)data;
200 unsigned long flags;
201
202 spin_lock_irqsave(&iface->lock, flags);
203 bfin_twi_handle_interrupt(iface);
204 if (iface->result == 0) {
205 iface->timeout_count--;
206 if (iface->timeout_count > 0) {
207 iface->timeout_timer.expires = jiffies + POLL_TIMEOUT;
208 add_timer(&iface->timeout_timer);
209 } else {
210 iface->result = -1;
211 complete(&iface->complete);
212 }
213 }
214 spin_unlock_irqrestore(&iface->lock, flags);
215}
216
217/*
218 * Generic i2c master transfer entrypoint
219 */
220static int bfin_twi_master_xfer(struct i2c_adapter *adap,
221 struct i2c_msg *msgs, int num)
222{
223 struct bfin_twi_iface *iface = adap->algo_data;
224 struct i2c_msg *pmsg;
225 int i, ret;
226 int rc = 0;
227
228 if (!(bfin_read_TWI_CONTROL() & TWI_ENA))
229 return -ENXIO;
230
231 mutex_lock(&iface->twi_lock);
232
233 while (bfin_read_TWI_MASTER_STAT() & BUSBUSY) {
234 mutex_unlock(&iface->twi_lock);
235 yield();
236 mutex_lock(&iface->twi_lock);
237 }
238
239 ret = 0;
240 for (i = 0; rc >= 0 && i < num; i++) {
241 pmsg = &msgs[i];
242 if (pmsg->flags & I2C_M_TEN) {
243 dev_err(&(adap->dev), "i2c-bfin-twi: 10 bits addr "
244 "not supported !\n");
245 rc = -EINVAL;
246 break;
247 }
248
249 iface->cur_mode = TWI_I2C_MODE_STANDARD;
250 iface->manual_stop = 0;
251 iface->transPtr = pmsg->buf;
252 iface->writeNum = iface->readNum = pmsg->len;
253 iface->result = 0;
254 iface->timeout_count = 10;
255 /* Set Transmit device address */
256 bfin_write_TWI_MASTER_ADDR(pmsg->addr);
257
258 /* FIFO Initiation. Data in FIFO should be
259 * discarded before start a new operation.
260 */
261 bfin_write_TWI_FIFO_CTL(0x3);
262 SSYNC();
263 bfin_write_TWI_FIFO_CTL(0);
264 SSYNC();
265
266 if (pmsg->flags & I2C_M_RD)
267 iface->read_write = I2C_SMBUS_READ;
268 else {
269 iface->read_write = I2C_SMBUS_WRITE;
270 /* Transmit first data */
271 if (iface->writeNum > 0) {
272 bfin_write_TWI_XMT_DATA8(*(iface->transPtr++));
273 iface->writeNum--;
274 SSYNC();
275 }
276 }
277
278 /* clear int stat */
279 bfin_write_TWI_INT_STAT(MERR|MCOMP|XMTSERV|RCVSERV);
280
281 /* Interrupt mask . Enable XMT, RCV interrupt */
282 bfin_write_TWI_INT_MASK(MCOMP | MERR |
283 ((iface->read_write == I2C_SMBUS_READ)?
284 RCVSERV : XMTSERV));
285 SSYNC();
286
287 if (pmsg->len > 0 && pmsg->len <= 255)
288 bfin_write_TWI_MASTER_CTL(pmsg->len << 6);
289 else if (pmsg->len > 255) {
290 bfin_write_TWI_MASTER_CTL(0xff << 6);
291 iface->manual_stop = 1;
292 } else
293 break;
294
295 iface->timeout_timer.expires = jiffies + POLL_TIMEOUT;
296 add_timer(&iface->timeout_timer);
297
298 /* Master enable */
299 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() | MEN |
300 ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) |
301 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ>100) ? FAST : 0));
302 SSYNC();
303
304 wait_for_completion(&iface->complete);
305
306 rc = iface->result;
307 if (rc == 1)
308 ret++;
309 else if (rc == -1)
310 break;
311 }
312
313 /* Release mutex */
314 mutex_unlock(&iface->twi_lock);
315
316 return ret;
317}
318
319/*
320 * SMBus type transfer entrypoint
321 */
322
323int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr,
324 unsigned short flags, char read_write,
325 u8 command, int size, union i2c_smbus_data *data)
326{
327 struct bfin_twi_iface *iface = adap->algo_data;
328 int rc = 0;
329
330 if (!(bfin_read_TWI_CONTROL() & TWI_ENA))
331 return -ENXIO;
332
333 mutex_lock(&iface->twi_lock);
334
335 while (bfin_read_TWI_MASTER_STAT() & BUSBUSY) {
336 mutex_unlock(&iface->twi_lock);
337 yield();
338 mutex_lock(&iface->twi_lock);
339 }
340
341 iface->writeNum = 0;
342 iface->readNum = 0;
343
344 /* Prepare datas & select mode */
345 switch (size) {
346 case I2C_SMBUS_QUICK:
347 iface->transPtr = NULL;
348 iface->cur_mode = TWI_I2C_MODE_STANDARD;
349 break;
350 case I2C_SMBUS_BYTE:
351 if (data == NULL)
352 iface->transPtr = NULL;
353 else {
354 if (read_write == I2C_SMBUS_READ)
355 iface->readNum = 1;
356 else
357 iface->writeNum = 1;
358 iface->transPtr = &data->byte;
359 }
360 iface->cur_mode = TWI_I2C_MODE_STANDARD;
361 break;
362 case I2C_SMBUS_BYTE_DATA:
363 if (read_write == I2C_SMBUS_READ) {
364 iface->readNum = 1;
365 iface->cur_mode = TWI_I2C_MODE_COMBINED;
366 } else {
367 iface->writeNum = 1;
368 iface->cur_mode = TWI_I2C_MODE_STANDARDSUB;
369 }
370 iface->transPtr = &data->byte;
371 break;
372 case I2C_SMBUS_WORD_DATA:
373 if (read_write == I2C_SMBUS_READ) {
374 iface->readNum = 2;
375 iface->cur_mode = TWI_I2C_MODE_COMBINED;
376 } else {
377 iface->writeNum = 2;
378 iface->cur_mode = TWI_I2C_MODE_STANDARDSUB;
379 }
380 iface->transPtr = (u8 *)&data->word;
381 break;
382 case I2C_SMBUS_PROC_CALL:
383 iface->writeNum = 2;
384 iface->readNum = 2;
385 iface->cur_mode = TWI_I2C_MODE_COMBINED;
386 iface->transPtr = (u8 *)&data->word;
387 break;
388 case I2C_SMBUS_BLOCK_DATA:
389 if (read_write == I2C_SMBUS_READ) {
390 iface->readNum = 0;
391 iface->cur_mode = TWI_I2C_MODE_COMBINED;
392 } else {
393 iface->writeNum = data->block[0] + 1;
394 iface->cur_mode = TWI_I2C_MODE_STANDARDSUB;
395 }
396 iface->transPtr = data->block;
397 break;
398 default:
399 return -1;
400 }
401
402 iface->result = 0;
403 iface->manual_stop = 0;
404 iface->read_write = read_write;
405 iface->command = command;
406 iface->timeout_count = 10;
407
408 /* FIFO Initiation. Data in FIFO should be discarded before
409 * start a new operation.
410 */
411 bfin_write_TWI_FIFO_CTL(0x3);
412 SSYNC();
413 bfin_write_TWI_FIFO_CTL(0);
414
415 /* clear int stat */
416 bfin_write_TWI_INT_STAT(MERR|MCOMP|XMTSERV|RCVSERV);
417
418 /* Set Transmit device address */
419 bfin_write_TWI_MASTER_ADDR(addr);
420 SSYNC();
421
422 iface->timeout_timer.expires = jiffies + POLL_TIMEOUT;
423 add_timer(&iface->timeout_timer);
424
425 switch (iface->cur_mode) {
426 case TWI_I2C_MODE_STANDARDSUB:
427 bfin_write_TWI_XMT_DATA8(iface->command);
428 bfin_write_TWI_INT_MASK(MCOMP | MERR |
429 ((iface->read_write == I2C_SMBUS_READ) ?
430 RCVSERV : XMTSERV));
431 SSYNC();
432
433 if (iface->writeNum + 1 <= 255)
434 bfin_write_TWI_MASTER_CTL((iface->writeNum + 1) << 6);
435 else {
436 bfin_write_TWI_MASTER_CTL(0xff << 6);
437 iface->manual_stop = 1;
438 }
439 /* Master enable */
440 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() | MEN |
441 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ>100) ? FAST : 0));
442 break;
443 case TWI_I2C_MODE_COMBINED:
444 bfin_write_TWI_XMT_DATA8(iface->command);
445 bfin_write_TWI_INT_MASK(MCOMP | MERR | RCVSERV | XMTSERV);
446 SSYNC();
447
448 if (iface->writeNum > 0)
449 bfin_write_TWI_MASTER_CTL((iface->writeNum + 1) << 6);
450 else
451 bfin_write_TWI_MASTER_CTL(0x1 << 6);
452 /* Master enable */
453 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() | MEN |
454 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ>100) ? FAST : 0));
455 break;
456 default:
457 bfin_write_TWI_MASTER_CTL(0);
458 if (size != I2C_SMBUS_QUICK) {
459 /* Don't access xmit data register when this is a
460 * read operation.
461 */
462 if (iface->read_write != I2C_SMBUS_READ) {
463 if (iface->writeNum > 0) {
464 bfin_write_TWI_XMT_DATA8(*(iface->transPtr++));
465 if (iface->writeNum <= 255)
466 bfin_write_TWI_MASTER_CTL(iface->writeNum << 6);
467 else {
468 bfin_write_TWI_MASTER_CTL(0xff << 6);
469 iface->manual_stop = 1;
470 }
471 iface->writeNum--;
472 } else {
473 bfin_write_TWI_XMT_DATA8(iface->command);
474 bfin_write_TWI_MASTER_CTL(1 << 6);
475 }
476 } else {
477 if (iface->readNum > 0 && iface->readNum <= 255)
478 bfin_write_TWI_MASTER_CTL(iface->readNum << 6);
479 else if (iface->readNum > 255) {
480 bfin_write_TWI_MASTER_CTL(0xff << 6);
481 iface->manual_stop = 1;
482 } else {
483 del_timer(&iface->timeout_timer);
484 break;
485 }
486 }
487 }
488 bfin_write_TWI_INT_MASK(MCOMP | MERR |
489 ((iface->read_write == I2C_SMBUS_READ) ?
490 RCVSERV : XMTSERV));
491 SSYNC();
492
493 /* Master enable */
494 bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() | MEN |
495 ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) |
496 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0));
497 break;
498 }
499 SSYNC();
500
501 wait_for_completion(&iface->complete);
502
503 rc = (iface->result >= 0) ? 0 : -1;
504
505 /* Release mutex */
506 mutex_unlock(&iface->twi_lock);
507
508 return rc;
509}
510
511/*
512 * Return what the adapter supports
513 */
514static u32 bfin_twi_functionality(struct i2c_adapter *adap)
515{
516 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
517 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
518 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL |
519 I2C_FUNC_I2C;
520}
521
522
523static struct i2c_algorithm bfin_twi_algorithm = {
524 .master_xfer = bfin_twi_master_xfer,
525 .smbus_xfer = bfin_twi_smbus_xfer,
526 .functionality = bfin_twi_functionality,
527};
528
529
530static int i2c_bfin_twi_suspend(struct platform_device *dev, pm_message_t state)
531{
532/* struct bfin_twi_iface *iface = platform_get_drvdata(dev);*/
533
534 /* Disable TWI */
535 bfin_write_TWI_CONTROL(bfin_read_TWI_CONTROL() & ~TWI_ENA);
536 SSYNC();
537
538 return 0;
539}
540
541static int i2c_bfin_twi_resume(struct platform_device *dev)
542{
543/* struct bfin_twi_iface *iface = platform_get_drvdata(dev);*/
544
545 /* Enable TWI */
546 bfin_write_TWI_CONTROL(bfin_read_TWI_CONTROL() | TWI_ENA);
547 SSYNC();
548
549 return 0;
550}
551
552static int i2c_bfin_twi_probe(struct platform_device *dev)
553{
554 struct bfin_twi_iface *iface = &twi_iface;
555 struct i2c_adapter *p_adap;
556 int rc;
557
558 mutex_init(&(iface->twi_lock));
559 spin_lock_init(&(iface->lock));
560 init_completion(&(iface->complete));
561 iface->irq = IRQ_TWI;
562
563 init_timer(&(iface->timeout_timer));
564 iface->timeout_timer.function = bfin_twi_timeout;
565 iface->timeout_timer.data = (unsigned long)iface;
566
567 p_adap = &iface->adap;
568 p_adap->id = I2C_HW_BLACKFIN;
569 strlcpy(p_adap->name, dev->name, sizeof(p_adap->name));
570 p_adap->algo = &bfin_twi_algorithm;
571 p_adap->algo_data = iface;
572 p_adap->class = I2C_CLASS_ALL;
573 p_adap->dev.parent = &dev->dev;
574
575 rc = request_irq(iface->irq, bfin_twi_interrupt_entry,
576 IRQF_DISABLED, dev->name, iface);
577 if (rc) {
578 dev_err(&(p_adap->dev), "i2c-bfin-twi: can't get IRQ %d !\n",
579 iface->irq);
580 return -ENODEV;
581 }
582
583 /* Set TWI internal clock as 10MHz */
584 bfin_write_TWI_CONTROL(((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F);
585
586 /* Set Twi interface clock as specified */
587 bfin_write_TWI_CLKDIV((( 5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ )
588 << 8) | (( 5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ )
589 & 0xFF));
590
591 /* Enable TWI */
592 bfin_write_TWI_CONTROL(bfin_read_TWI_CONTROL() | TWI_ENA);
593 SSYNC();
594
595 rc = i2c_add_adapter(p_adap);
596 if (rc < 0)
597 free_irq(iface->irq, iface);
598 else
599 platform_set_drvdata(dev, iface);
600
601 return rc;
602}
603
604static int i2c_bfin_twi_remove(struct platform_device *pdev)
605{
606 struct bfin_twi_iface *iface = platform_get_drvdata(pdev);
607
608 platform_set_drvdata(pdev, NULL);
609
610 i2c_del_adapter(&(iface->adap));
611 free_irq(iface->irq, iface);
612
613 return 0;
614}
615
616static struct platform_driver i2c_bfin_twi_driver = {
617 .probe = i2c_bfin_twi_probe,
618 .remove = i2c_bfin_twi_remove,
619 .suspend = i2c_bfin_twi_suspend,
620 .resume = i2c_bfin_twi_resume,
621 .driver = {
622 .name = "i2c-bfin-twi",
623 .owner = THIS_MODULE,
624 },
625};
626
627static int __init i2c_bfin_twi_init(void)
628{
629 pr_info("I2C: Blackfin I2C TWI driver\n");
630
631 return platform_driver_register(&i2c_bfin_twi_driver);
632}
633
634static void __exit i2c_bfin_twi_exit(void)
635{
636 platform_driver_unregister(&i2c_bfin_twi_driver);
637}
638
639MODULE_AUTHOR("Sonic Zhang <sonic.zhang@analog.com>");
640MODULE_DESCRIPTION("I2C-Bus adapter routines for Blackfin TWI");
641MODULE_LICENSE("GPL");
642
643module_init(i2c_bfin_twi_init);
644module_exit(i2c_bfin_twi_exit);
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 834967464814..804f0a551c05 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -35,6 +35,7 @@
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/wait.h> 36#include <linux/wait.h>
37 37
38#include <linux/isa.h>
38#include <linux/i2c.h> 39#include <linux/i2c.h>
39#include <linux/i2c-algo-pcf.h> 40#include <linux/i2c-algo-pcf.h>
40 41
@@ -207,7 +208,7 @@ static struct i2c_adapter pcf_isa_ops = {
207 .name = "i2c-elektor", 208 .name = "i2c-elektor",
208}; 209};
209 210
210static int __init i2c_pcfisa_init(void) 211static int __devinit elektor_match(struct device *dev, unsigned int id)
211{ 212{
212#ifdef __alpha__ 213#ifdef __alpha__
213 /* check to see we have memory mapped PCF8584 connected to the 214 /* check to see we have memory mapped PCF8584 connected to the
@@ -222,9 +223,8 @@ static int __init i2c_pcfisa_init(void)
222 /* yeap, we've found cypress, let's check config */ 223 /* yeap, we've found cypress, let's check config */
223 if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { 224 if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
224 225
225 pr_debug("%s: found cy82c693, config " 226 dev_dbg(dev, "found cy82c693, config "
226 "register 0x47 = 0x%02x\n", 227 "register 0x47 = 0x%02x\n", config);
227 pcf_isa_ops.name, config);
228 228
229 /* UP2000 board has this register set to 0xe1, 229 /* UP2000 board has this register set to 0xe1,
230 but the most significant bit as seems can be 230 but the most significant bit as seems can be
@@ -244,9 +244,9 @@ static int __init i2c_pcfisa_init(void)
244 8.25 MHz (PCI/4) clock 244 8.25 MHz (PCI/4) clock
245 (this can be read from cypress) */ 245 (this can be read from cypress) */
246 clock = I2C_PCF_CLK | I2C_PCF_TRNS90; 246 clock = I2C_PCF_CLK | I2C_PCF_TRNS90;
247 pr_info("%s: found API UP2000 like " 247 dev_info(dev, "found API UP2000 like "
248 "board, will probe PCF8584 " 248 "board, will probe PCF8584 "
249 "later\n", pcf_isa_ops.name); 249 "later\n");
250 } 250 }
251 } 251 }
252 pci_dev_put(cy693_dev); 252 pci_dev_put(cy693_dev);
@@ -256,22 +256,27 @@ static int __init i2c_pcfisa_init(void)
256 256
257 /* sanity checks for mmapped I/O */ 257 /* sanity checks for mmapped I/O */
258 if (mmapped && base < 0xc8000) { 258 if (mmapped && base < 0xc8000) {
259 printk(KERN_ERR "%s: incorrect base address (%#x) specified " 259 dev_err(dev, "incorrect base address (%#x) specified "
260 "for mmapped I/O\n", pcf_isa_ops.name, base); 260 "for mmapped I/O\n", base);
261 return -ENODEV; 261 return 0;
262 } 262 }
263 263
264 if (base == 0) { 264 if (base == 0) {
265 base = DEFAULT_BASE; 265 base = DEFAULT_BASE;
266 } 266 }
267 return 1;
268}
267 269
270static int __devinit elektor_probe(struct device *dev, unsigned int id)
271{
268 init_waitqueue_head(&pcf_wait); 272 init_waitqueue_head(&pcf_wait);
269 if (pcf_isa_init()) 273 if (pcf_isa_init())
270 return -ENODEV; 274 return -ENODEV;
275 pcf_isa_ops.dev.parent = dev;
271 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) 276 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
272 goto fail; 277 goto fail;
273 278
274 dev_info(&pcf_isa_ops.dev, "found device at %#x\n", base); 279 dev_info(dev, "found device at %#x\n", base);
275 280
276 return 0; 281 return 0;
277 282
@@ -291,7 +296,7 @@ static int __init i2c_pcfisa_init(void)
291 return -ENODEV; 296 return -ENODEV;
292} 297}
293 298
294static void i2c_pcfisa_exit(void) 299static int __devexit elektor_remove(struct device *dev, unsigned int id)
295{ 300{
296 i2c_del_adapter(&pcf_isa_ops); 301 i2c_del_adapter(&pcf_isa_ops);
297 302
@@ -307,6 +312,28 @@ static void i2c_pcfisa_exit(void)
307 iounmap(base_iomem); 312 iounmap(base_iomem);
308 release_mem_region(base, 2); 313 release_mem_region(base, 2);
309 } 314 }
315
316 return 0;
317}
318
319static struct isa_driver i2c_elektor_driver = {
320 .match = elektor_match,
321 .probe = elektor_probe,
322 .remove = __devexit_p(elektor_remove),
323 .driver = {
324 .owner = THIS_MODULE,
325 .name = "i2c-elektor",
326 },
327};
328
329static int __init i2c_pcfisa_init(void)
330{
331 return isa_register_driver(&i2c_elektor_driver, 1);
332}
333
334static void __exit i2c_pcfisa_exit(void)
335{
336 isa_unregister_driver(&i2c_elektor_driver);
310} 337}
311 338
312MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 339MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
new file mode 100644
index 000000000000..a7dd54654a9a
--- /dev/null
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -0,0 +1,215 @@
1/*
2 * Bitbanging I2C bus driver using the GPIO API
3 *
4 * Copyright (C) 2007 Atmel 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 version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/i2c.h>
11#include <linux/i2c-algo-bit.h>
12#include <linux/i2c-gpio.h>
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/platform_device.h>
16
17#include <asm/gpio.h>
18
19/* Toggle SDA by changing the direction of the pin */
20static void i2c_gpio_setsda_dir(void *data, int state)
21{
22 struct i2c_gpio_platform_data *pdata = data;
23
24 if (state)
25 gpio_direction_input(pdata->sda_pin);
26 else
27 gpio_direction_output(pdata->sda_pin, 0);
28}
29
30/*
31 * Toggle SDA by changing the output value of the pin. This is only
32 * valid for pins configured as open drain (i.e. setting the value
33 * high effectively turns off the output driver.)
34 */
35static void i2c_gpio_setsda_val(void *data, int state)
36{
37 struct i2c_gpio_platform_data *pdata = data;
38
39 gpio_set_value(pdata->sda_pin, state);
40}
41
42/* Toggle SCL by changing the direction of the pin. */
43static void i2c_gpio_setscl_dir(void *data, int state)
44{
45 struct i2c_gpio_platform_data *pdata = data;
46
47 if (state)
48 gpio_direction_input(pdata->scl_pin);
49 else
50 gpio_direction_output(pdata->scl_pin, 0);
51}
52
53/*
54 * Toggle SCL by changing the output value of the pin. This is used
55 * for pins that are configured as open drain and for output-only
56 * pins. The latter case will break the i2c protocol, but it will
57 * often work in practice.
58 */
59static void i2c_gpio_setscl_val(void *data, int state)
60{
61 struct i2c_gpio_platform_data *pdata = data;
62
63 gpio_set_value(pdata->scl_pin, state);
64}
65
66int i2c_gpio_getsda(void *data)
67{
68 struct i2c_gpio_platform_data *pdata = data;
69
70 return gpio_get_value(pdata->sda_pin);
71}
72
73int i2c_gpio_getscl(void *data)
74{
75 struct i2c_gpio_platform_data *pdata = data;
76
77 return gpio_get_value(pdata->scl_pin);
78}
79
80static int __init i2c_gpio_probe(struct platform_device *pdev)
81{
82 struct i2c_gpio_platform_data *pdata;
83 struct i2c_algo_bit_data *bit_data;
84 struct i2c_adapter *adap;
85 int ret;
86
87 pdata = pdev->dev.platform_data;
88 if (!pdata)
89 return -ENXIO;
90
91 ret = -ENOMEM;
92 adap = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
93 if (!adap)
94 goto err_alloc_adap;
95 bit_data = kzalloc(sizeof(struct i2c_algo_bit_data), GFP_KERNEL);
96 if (!bit_data)
97 goto err_alloc_bit_data;
98
99 ret = gpio_request(pdata->sda_pin, "sda");
100 if (ret)
101 goto err_request_sda;
102 ret = gpio_request(pdata->scl_pin, "scl");
103 if (ret)
104 goto err_request_scl;
105
106 if (pdata->sda_is_open_drain) {
107 gpio_direction_output(pdata->sda_pin, 1);
108 bit_data->setsda = i2c_gpio_setsda_val;
109 } else {
110 gpio_direction_input(pdata->sda_pin);
111 bit_data->setsda = i2c_gpio_setsda_dir;
112 }
113
114 if (pdata->scl_is_open_drain || pdata->scl_is_output_only) {
115 gpio_direction_output(pdata->scl_pin, 1);
116 bit_data->setscl = i2c_gpio_setscl_val;
117 } else {
118 gpio_direction_input(pdata->scl_pin);
119 bit_data->setscl = i2c_gpio_setscl_dir;
120 }
121
122 if (!pdata->scl_is_output_only)
123 bit_data->getscl = i2c_gpio_getscl;
124 bit_data->getsda = i2c_gpio_getsda;
125
126 if (pdata->udelay)
127 bit_data->udelay = pdata->udelay;
128 else if (pdata->scl_is_output_only)
129 bit_data->udelay = 50; /* 10 kHz */
130 else
131 bit_data->udelay = 5; /* 100 kHz */
132
133 if (pdata->timeout)
134 bit_data->timeout = pdata->timeout;
135 else
136 bit_data->timeout = HZ / 10; /* 100 ms */
137
138 bit_data->data = pdata;
139
140 adap->owner = THIS_MODULE;
141 snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id);
142 adap->algo_data = bit_data;
143 adap->dev.parent = &pdev->dev;
144
145 ret = i2c_bit_add_bus(adap);
146 if (ret)
147 goto err_add_bus;
148
149 platform_set_drvdata(pdev, adap);
150
151 dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n",
152 pdata->sda_pin, pdata->scl_pin,
153 pdata->scl_is_output_only
154 ? ", no clock stretching" : "");
155
156 return 0;
157
158err_add_bus:
159 gpio_free(pdata->scl_pin);
160err_request_scl:
161 gpio_free(pdata->sda_pin);
162err_request_sda:
163 kfree(bit_data);
164err_alloc_bit_data:
165 kfree(adap);
166err_alloc_adap:
167 return ret;
168}
169
170static int __exit i2c_gpio_remove(struct platform_device *pdev)
171{
172 struct i2c_gpio_platform_data *pdata;
173 struct i2c_adapter *adap;
174
175 adap = platform_get_drvdata(pdev);
176 pdata = pdev->dev.platform_data;
177
178 i2c_del_adapter(adap);
179 gpio_free(pdata->scl_pin);
180 gpio_free(pdata->sda_pin);
181 kfree(adap->algo_data);
182 kfree(adap);
183
184 return 0;
185}
186
187static struct platform_driver i2c_gpio_driver = {
188 .driver = {
189 .name = "i2c-gpio",
190 .owner = THIS_MODULE,
191 },
192 .remove = __exit_p(i2c_gpio_remove),
193};
194
195static int __init i2c_gpio_init(void)
196{
197 int ret;
198
199 ret = platform_driver_probe(&i2c_gpio_driver, i2c_gpio_probe);
200 if (ret)
201 printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret);
202
203 return ret;
204}
205module_init(i2c_gpio_init);
206
207static void __exit i2c_gpio_exit(void)
208{
209 platform_driver_unregister(&i2c_gpio_driver);
210}
211module_exit(i2c_gpio_exit);
212
213MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
214MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver");
215MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index a320e7d82c1f..611b57192c96 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -527,7 +527,7 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
527 /* set up the sysfs linkage to our parent device */ 527 /* set up the sysfs linkage to our parent device */
528 i801_adapter.dev.parent = &dev->dev; 528 i801_adapter.dev.parent = &dev->dev;
529 529
530 snprintf(i801_adapter.name, I2C_NAME_SIZE, 530 snprintf(i801_adapter.name, sizeof(i801_adapter.name),
531 "SMBus I801 adapter at %04lx", i801_smba); 531 "SMBus I801 adapter at %04lx", i801_smba);
532 err = i2c_add_adapter(&i801_adapter); 532 err = i2c_add_adapter(&i801_adapter);
533 if (err) { 533 if (err) {
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 5f33bc9c1e02..b0e1370075de 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -41,6 +41,10 @@
41#include <linux/platform_device.h> 41#include <linux/platform_device.h>
42#include <linux/completion.h> 42#include <linux/completion.h>
43 43
44/* Exported by i2c-core for i2c-isa only */
45extern void i2c_adapter_dev_release(struct device *dev);
46extern struct class i2c_adapter_class;
47
44static u32 isa_func(struct i2c_adapter *adapter); 48static u32 isa_func(struct i2c_adapter *adapter);
45 49
46/* This is the actual algorithm we define */ 50/* This is the actual algorithm we define */
@@ -64,16 +68,6 @@ static u32 isa_func(struct i2c_adapter *adapter)
64} 68}
65 69
66 70
67/* Copied from i2c-core */
68static ssize_t show_adapter_name(struct device *dev,
69 struct device_attribute *attr, char *buf)
70{
71 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
72 return sprintf(buf, "%s\n", adap->name);
73}
74static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
75
76
77/* We implement an interface which resembles i2c_{add,del}_driver, 71/* We implement an interface which resembles i2c_{add,del}_driver,
78 but for i2c-isa drivers. We don't have to remember and handle lists 72 but for i2c-isa drivers. We don't have to remember and handle lists
79 of drivers and adapters so this is much more simple, of course. */ 73 of drivers and adapters so this is much more simple, of course. */
@@ -139,41 +133,18 @@ static int __init i2c_isa_init(void)
139 isa_adapter.nr = ANY_I2C_ISA_BUS; 133 isa_adapter.nr = ANY_I2C_ISA_BUS;
140 isa_adapter.dev.parent = &platform_bus; 134 isa_adapter.dev.parent = &platform_bus;
141 sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); 135 sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr);
142 isa_adapter.dev.driver = &i2c_adapter_driver;
143 isa_adapter.dev.release = &i2c_adapter_dev_release; 136 isa_adapter.dev.release = &i2c_adapter_dev_release;
137 isa_adapter.dev.class = &i2c_adapter_class;
144 err = device_register(&isa_adapter.dev); 138 err = device_register(&isa_adapter.dev);
145 if (err) { 139 if (err) {
146 printk(KERN_ERR "i2c-isa: Failed to register device\n"); 140 printk(KERN_ERR "i2c-isa: Failed to register device\n");
147 goto exit; 141 goto exit;
148 } 142 }
149 err = device_create_file(&isa_adapter.dev, &dev_attr_name);
150 if (err) {
151 printk(KERN_ERR "i2c-isa: Failed to create name file\n");
152 goto exit_unregister;
153 }
154
155 /* Add this adapter to the i2c_adapter class */
156 memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device));
157 isa_adapter.class_dev.dev = &isa_adapter.dev;
158 isa_adapter.class_dev.class = &i2c_adapter_class;
159 strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id,
160 BUS_ID_SIZE);
161 err = class_device_register(&isa_adapter.class_dev);
162 if (err) {
163 printk(KERN_ERR "i2c-isa: Failed to register class device\n");
164 goto exit_remove_name;
165 }
166 143
167 dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); 144 dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name);
168 145
169 return 0; 146 return 0;
170 147
171exit_remove_name:
172 device_remove_file(&isa_adapter.dev, &dev_attr_name);
173exit_unregister:
174 init_completion(&isa_adapter.dev_released); /* Needed? */
175 device_unregister(&isa_adapter.dev);
176 wait_for_completion(&isa_adapter.dev_released);
177exit: 148exit:
178 return err; 149 return err;
179} 150}
@@ -201,15 +172,11 @@ static void __exit i2c_isa_exit(void)
201 /* Clean up the sysfs representation */ 172 /* Clean up the sysfs representation */
202 dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n"); 173 dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n");
203 init_completion(&isa_adapter.dev_released); 174 init_completion(&isa_adapter.dev_released);
204 init_completion(&isa_adapter.class_dev_released);
205 class_device_unregister(&isa_adapter.class_dev);
206 device_remove_file(&isa_adapter.dev, &dev_attr_name);
207 device_unregister(&isa_adapter.dev); 175 device_unregister(&isa_adapter.dev);
208 176
209 /* Wait for sysfs to drop all references */ 177 /* Wait for sysfs to drop all references */
210 dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n"); 178 dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n");
211 wait_for_completion(&isa_adapter.dev_released); 179 wait_for_completion(&isa_adapter.dev_released);
212 wait_for_completion(&isa_adapter.class_dev_released);
213 180
214 dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name); 181 dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name);
215} 182}
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index efa3ecc5522a..6352121a2827 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -118,7 +118,7 @@ static int ixp2000_i2c_probe(struct platform_device *plat_dev)
118 118
119 drv_data->adapter.id = I2C_HW_B_IXP2000, 119 drv_data->adapter.id = I2C_HW_B_IXP2000,
120 strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, 120 strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
121 I2C_NAME_SIZE); 121 sizeof(drv_data->adapter.name));
122 drv_data->adapter.algo_data = &drv_data->algo_data, 122 drv_data->adapter.algo_data = &drv_data->algo_data,
123 123
124 drv_data->adapter.dev.parent = &plat_dev->dev; 124 drv_data->adapter.dev.parent = &plat_dev->dev;
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 08e89b83984a..069ed7f3b395 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -127,7 +127,7 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
127 drv_data->adapter.id = I2C_HW_B_IXP4XX; 127 drv_data->adapter.id = I2C_HW_B_IXP4XX;
128 drv_data->adapter.class = I2C_CLASS_HWMON; 128 drv_data->adapter.class = I2C_CLASS_HWMON;
129 strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, 129 strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
130 I2C_NAME_SIZE); 130 sizeof(drv_data->adapter.name));
131 drv_data->adapter.algo_data = &drv_data->algo_data; 131 drv_data->adapter.algo_data = &drv_data->algo_data;
132 132
133 drv_data->adapter.dev.parent = &plat_dev->dev; 133 drv_data->adapter.dev.parent = &plat_dev->dev;
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index ee65aa1be13a..c6b6898592b1 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,6 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/pci.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22 21
23#include <asm/io.h> 22#include <asm/io.h>
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index a3283b907eb8..a55b3335d1be 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -508,7 +508,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
508 } 508 }
509 509
510 strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", 510 strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter",
511 I2C_NAME_SIZE); 511 sizeof(drv_data->adapter.name));
512 512
513 init_waitqueue_head(&drv_data->waitq); 513 init_waitqueue_head(&drv_data->waitq);
514 spin_lock_init(&drv_data->lock); 514 spin_lock_init(&drv_data->lock);
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 1514ec5b77f8..3cd0d63e7b50 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -33,6 +33,8 @@
33 nForce4 MCP-04 0034 33 nForce4 MCP-04 0034
34 nForce4 MCP51 0264 34 nForce4 MCP51 0264
35 nForce4 MCP55 0368 35 nForce4 MCP55 0368
36 nForce MCP61 03EB
37 nForce MCP65 0446
36 38
37 This driver supports the 2 SMBuses that are included in the MCP of the 39 This driver supports the 2 SMBuses that are included in the MCP of the
38 nForce2/3/4/5xx chipsets. 40 nForce2/3/4/5xx chipsets.
@@ -200,6 +202,8 @@ static struct pci_device_id nforce2_ids[] = {
200 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS) }, 202 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS) },
201 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS) }, 203 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS) },
202 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS) }, 204 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS) },
205 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SMBUS) },
206 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_SMBUS) },
203 { 0 } 207 { 0 }
204}; 208};
205 209
@@ -240,7 +244,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
240 smbus->adapter.algo = &smbus_algorithm; 244 smbus->adapter.algo = &smbus_algorithm;
241 smbus->adapter.algo_data = smbus; 245 smbus->adapter.algo_data = smbus;
242 smbus->adapter.dev.parent = &dev->dev; 246 smbus->adapter.dev.parent = &dev->dev;
243 snprintf(smbus->adapter.name, I2C_NAME_SIZE, 247 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name),
244 "SMBus nForce2 adapter at %04x", smbus->base); 248 "SMBus nForce2 adapter at %04x", smbus->base);
245 249
246 error = i2c_add_adapter(&smbus->adapter); 250 error = i2c_add_adapter(&smbus->adapter);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index bcd8367cede1..e471e3bfdc1e 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -605,7 +605,8 @@ omap_i2c_probe(struct platform_device *pdev)
605 adap->dev.parent = &pdev->dev; 605 adap->dev.parent = &pdev->dev;
606 606
607 /* i2c device drivers may be active on return from add_adapter() */ 607 /* i2c device drivers may be active on return from add_adapter() */
608 r = i2c_add_adapter(adap); 608 adap->nr = pdev->id;
609 r = i2c_add_numbered_adapter(adap);
609 if (r) { 610 if (r) {
610 dev_err(dev->dev, "failure adding adapter\n"); 611 dev_err(dev->dev, "failure adding adapter\n");
611 goto err_free_irq; 612 goto err_free_irq;
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c
index 4bc42810b9aa..49a95e2887bc 100644
--- a/drivers/i2c/busses/i2c-parport-light.c
+++ b/drivers/i2c/busses/i2c-parport-light.c
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------ * 1/* ------------------------------------------------------------------------ *
2 * i2c-parport.c I2C bus over parallel port * 2 * i2c-parport-light.c I2C bus over parallel port *
3 * ------------------------------------------------------------------------ * 3 * ------------------------------------------------------------------------ *
4 Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> 4 Copyright (C) 2003-2007 Jean Delvare <khali@linux-fr.org>
5 5
6 Based on older i2c-velleman.c driver 6 Based on older i2c-velleman.c driver
7 Copyright (C) 1995-2000 Simon G. Vogl 7 Copyright (C) 1995-2000 Simon G. Vogl
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/platform_device.h>
30#include <linux/ioport.h> 31#include <linux/ioport.h>
31#include <linux/i2c.h> 32#include <linux/i2c.h>
32#include <linux/i2c-algo-bit.h> 33#include <linux/i2c-algo-bit.h>
@@ -34,6 +35,9 @@
34#include "i2c-parport.h" 35#include "i2c-parport.h"
35 36
36#define DEFAULT_BASE 0x378 37#define DEFAULT_BASE 0x378
38#define DRVNAME "i2c-parport-light"
39
40static struct platform_device *pdev;
37 41
38static u16 base; 42static u16 base;
39module_param(base, ushort, 0); 43module_param(base, ushort, 0);
@@ -106,7 +110,7 @@ static struct i2c_algo_bit_data parport_algo_data = {
106 .timeout = HZ, 110 .timeout = HZ,
107}; 111};
108 112
109/* ----- I2c structure ---------------------------------------------------- */ 113/* ----- Driver registration ---------------------------------------------- */
110 114
111static struct i2c_adapter parport_adapter = { 115static struct i2c_adapter parport_adapter = {
112 .owner = THIS_MODULE, 116 .owner = THIS_MODULE,
@@ -116,55 +120,141 @@ static struct i2c_adapter parport_adapter = {
116 .name = "Parallel port adapter (light)", 120 .name = "Parallel port adapter (light)",
117}; 121};
118 122
119/* ----- Module loading, unloading and information ------------------------ */ 123static int __devinit i2c_parport_probe(struct platform_device *pdev)
124{
125 int err;
126 struct resource *res;
127
128 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
129 if (!request_region(res->start, res->end - res->start + 1, DRVNAME))
130 return -EBUSY;
131
132 /* Reset hardware to a sane state (SCL and SDA high) */
133 parport_setsda(NULL, 1);
134 parport_setscl(NULL, 1);
135 /* Other init if needed (power on...) */
136 if (adapter_parm[type].init.val)
137 line_set(1, &adapter_parm[type].init);
138
139 parport_adapter.dev.parent = &pdev->dev;
140 err = i2c_bit_add_bus(&parport_adapter);
141 if (err) {
142 dev_err(&pdev->dev, "Unable to register with I2C\n");
143 goto exit_region;
144 }
145 return 0;
146
147exit_region:
148 release_region(res->start, res->end - res->start + 1);
149 return err;
150}
151
152static int __devexit i2c_parport_remove(struct platform_device *pdev)
153{
154 struct resource *res;
155
156 i2c_del_adapter(&parport_adapter);
157
158 /* Un-init if needed (power off...) */
159 if (adapter_parm[type].init.val)
160 line_set(0, &adapter_parm[type].init);
161
162 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
163 release_region(res->start, res->end - res->start + 1);
164 return 0;
165}
166
167static struct platform_driver i2c_parport_driver = {
168 .driver = {
169 .owner = THIS_MODULE,
170 .name = DRVNAME,
171 },
172 .probe = i2c_parport_probe,
173 .remove = __devexit_p(i2c_parport_remove),
174};
175
176static int __init i2c_parport_device_add(u16 address)
177{
178 struct resource res = {
179 .start = address,
180 .end = address + 2,
181 .name = DRVNAME,
182 .flags = IORESOURCE_IO,
183 };
184 int err;
185
186 pdev = platform_device_alloc(DRVNAME, -1);
187 if (!pdev) {
188 err = -ENOMEM;
189 printk(KERN_ERR DRVNAME ": Device allocation failed\n");
190 goto exit;
191 }
192
193 err = platform_device_add_resources(pdev, &res, 1);
194 if (err) {
195 printk(KERN_ERR DRVNAME ": Device resource addition failed "
196 "(%d)\n", err);
197 goto exit_device_put;
198 }
199
200 err = platform_device_add(pdev);
201 if (err) {
202 printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n",
203 err);
204 goto exit_device_put;
205 }
206
207 return 0;
208
209exit_device_put:
210 platform_device_put(pdev);
211exit:
212 return err;
213}
120 214
121static int __init i2c_parport_init(void) 215static int __init i2c_parport_init(void)
122{ 216{
217 int err;
218
123 if (type < 0) { 219 if (type < 0) {
124 printk(KERN_WARNING "i2c-parport: adapter type unspecified\n"); 220 printk(KERN_ERR DRVNAME ": adapter type unspecified\n");
125 return -ENODEV; 221 return -ENODEV;
126 } 222 }
127 223
128 if (type >= ARRAY_SIZE(adapter_parm)) { 224 if (type >= ARRAY_SIZE(adapter_parm)) {
129 printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type); 225 printk(KERN_ERR DRVNAME ": invalid type (%d)\n", type);
130 return -ENODEV; 226 return -ENODEV;
131 } 227 }
132 228
133 if (base == 0) { 229 if (base == 0) {
134 printk(KERN_INFO "i2c-parport: using default base 0x%x\n", DEFAULT_BASE); 230 pr_info(DRVNAME ": using default base 0x%x\n", DEFAULT_BASE);
135 base = DEFAULT_BASE; 231 base = DEFAULT_BASE;
136 } 232 }
137 233
138 if (!request_region(base, 3, "i2c-parport"))
139 return -ENODEV;
140
141 if (!adapter_parm[type].getscl.val) 234 if (!adapter_parm[type].getscl.val)
142 parport_algo_data.getscl = NULL; 235 parport_algo_data.getscl = NULL;
143 236
144 /* Reset hardware to a sane state (SCL and SDA high) */ 237 /* Sets global pdev as a side effect */
145 parport_setsda(NULL, 1); 238 err = i2c_parport_device_add(base);
146 parport_setscl(NULL, 1); 239 if (err)
147 /* Other init if needed (power on...) */ 240 goto exit;
148 if (adapter_parm[type].init.val)
149 line_set(1, &adapter_parm[type].init);
150 241
151 if (i2c_bit_add_bus(&parport_adapter) < 0) { 242 err = platform_driver_register(&i2c_parport_driver);
152 printk(KERN_ERR "i2c-parport: Unable to register with I2C\n"); 243 if (err)
153 release_region(base, 3); 244 goto exit_device;
154 return -ENODEV;
155 }
156 245
157 return 0; 246 return 0;
247
248exit_device:
249 platform_device_unregister(pdev);
250exit:
251 return err;
158} 252}
159 253
160static void __exit i2c_parport_exit(void) 254static void __exit i2c_parport_exit(void)
161{ 255{
162 /* Un-init if needed (power off...) */ 256 platform_driver_unregister(&i2c_parport_driver);
163 if (adapter_parm[type].init.val) 257 platform_device_unregister(pdev);
164 line_set(0, &adapter_parm[type].init);
165
166 i2c_del_adapter(&parport_adapter);
167 release_region(base, 3);
168} 258}
169 259
170MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); 260MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 66696a40c7b5..8c953707253f 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------ * 1/* ------------------------------------------------------------------------ *
2 * i2c-parport.c I2C bus over parallel port * 2 * i2c-parport.c I2C bus over parallel port *
3 * ------------------------------------------------------------------------ * 3 * ------------------------------------------------------------------------ *
4 Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> 4 Copyright (C) 2003-2007 Jean Delvare <khali@linux-fr.org>
5 5
6 Based on older i2c-philips-par.c driver 6 Based on older i2c-philips-par.c driver
7 Copyright (C) 1995-2000 Simon G. Vogl 7 Copyright (C) 1995-2000 Simon G. Vogl
@@ -137,19 +137,12 @@ static struct i2c_algo_bit_data parport_algo_data = {
137 .setscl = parport_setscl, 137 .setscl = parport_setscl,
138 .getsda = parport_getsda, 138 .getsda = parport_getsda,
139 .getscl = parport_getscl, 139 .getscl = parport_getscl,
140 .udelay = 60, 140 .udelay = 10, /* ~50 kbps */
141 .timeout = HZ, 141 .timeout = HZ,
142}; 142};
143 143
144/* ----- I2c and parallel port call-back functions and structures --------- */ 144/* ----- I2c and parallel port call-back functions and structures --------- */
145 145
146static struct i2c_adapter parport_adapter = {
147 .owner = THIS_MODULE,
148 .class = I2C_CLASS_HWMON,
149 .id = I2C_HW_B_LP,
150 .name = "Parallel port adapter",
151};
152
153static void i2c_parport_attach (struct parport *port) 146static void i2c_parport_attach (struct parport *port)
154{ 147{
155 struct i2c_par *adapter; 148 struct i2c_par *adapter;
@@ -169,10 +162,17 @@ static void i2c_parport_attach (struct parport *port)
169 } 162 }
170 163
171 /* Fill the rest of the structure */ 164 /* Fill the rest of the structure */
172 adapter->adapter = parport_adapter; 165 adapter->adapter.owner = THIS_MODULE;
166 adapter->adapter.class = I2C_CLASS_HWMON;
167 adapter->adapter.id = I2C_HW_B_LP;
168 strlcpy(adapter->adapter.name, "Parallel port adapter",
169 sizeof(adapter->adapter.name));
173 adapter->algo_data = parport_algo_data; 170 adapter->algo_data = parport_algo_data;
174 if (!adapter_parm[type].getscl.val) 171 /* Slow down if we can't sense SCL */
172 if (!adapter_parm[type].getscl.val) {
175 adapter->algo_data.getscl = NULL; 173 adapter->algo_data.getscl = NULL;
174 adapter->algo_data.udelay = 50; /* ~10 kbps */
175 }
176 adapter->algo_data.data = port; 176 adapter->algo_data.data = port;
177 adapter->adapter.algo_data = &adapter->algo_data; 177 adapter->adapter.algo_data = &adapter->algo_data;
178 178
@@ -214,11 +214,12 @@ static void i2c_parport_detach (struct parport *port)
214 for (prev = NULL, adapter = adapter_list; adapter; 214 for (prev = NULL, adapter = adapter_list; adapter;
215 prev = adapter, adapter = adapter->next) { 215 prev = adapter, adapter = adapter->next) {
216 if (adapter->pdev->port == port) { 216 if (adapter->pdev->port == port) {
217 i2c_del_adapter(&adapter->adapter);
218
217 /* Un-init if needed (power off...) */ 219 /* Un-init if needed (power off...) */
218 if (adapter_parm[type].init.val) 220 if (adapter_parm[type].init.val)
219 line_set(port, 0, &adapter_parm[type].init); 221 line_set(port, 0, &adapter_parm[type].init);
220 222
221 i2c_del_adapter(&adapter->adapter);
222 parport_unregister_device(adapter->pdev); 223 parport_unregister_device(adapter->pdev);
223 if (prev) 224 if (prev)
224 prev->next = adapter->next; 225 prev->next = adapter->next;
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
index bf89eeef74e9..58e32714afb5 100644
--- a/drivers/i2c/busses/i2c-pasemi.c
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -358,7 +358,7 @@ static int __devinit pasemi_smb_probe(struct pci_dev *dev,
358 } 358 }
359 359
360 smbus->adapter.owner = THIS_MODULE; 360 smbus->adapter.owner = THIS_MODULE;
361 snprintf(smbus->adapter.name, I2C_NAME_SIZE, 361 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name),
362 "PA Semi SMBus adapter at 0x%lx", smbus->base); 362 "PA Semi SMBus adapter at 0x%lx", smbus->base);
363 smbus->adapter.class = I2C_CLASS_HWMON; 363 smbus->adapter.class = I2C_CLASS_HWMON;
364 smbus->adapter.algo = &smbus_algorithm; 364 smbus->adapter.algo = &smbus_algorithm;
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index cc6536a19eca..5161aaf9341b 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -25,9 +25,9 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/pci.h>
29#include <linux/wait.h> 28#include <linux/wait.h>
30 29
30#include <linux/isa.h>
31#include <linux/i2c.h> 31#include <linux/i2c.h>
32#include <linux/i2c-algo-pca.h> 32#include <linux/i2c-algo-pca.h>
33 33
@@ -119,27 +119,26 @@ static struct i2c_adapter pca_isa_ops = {
119 .name = "PCA9564 ISA Adapter", 119 .name = "PCA9564 ISA Adapter",
120}; 120};
121 121
122static int __init pca_isa_init(void) 122static int __devinit pca_isa_probe(struct device *dev, unsigned int id)
123{ 123{
124
125 init_waitqueue_head(&pca_wait); 124 init_waitqueue_head(&pca_wait);
126 125
127 printk(KERN_INFO "i2c-pca-isa: i/o base %#08lx. irq %d\n", base, irq); 126 dev_info(dev, "i/o base %#08lx. irq %d\n", base, irq);
128 127
129 if (!request_region(base, IO_SIZE, "i2c-pca-isa")) { 128 if (!request_region(base, IO_SIZE, "i2c-pca-isa")) {
130 printk(KERN_ERR "i2c-pca-isa: I/O address %#08lx is in use.\n", base); 129 dev_err(dev, "I/O address %#08lx is in use\n", base);
131 goto out; 130 goto out;
132 } 131 }
133 132
134 if (irq > -1) { 133 if (irq > -1) {
135 if (request_irq(irq, pca_handler, 0, "i2c-pca-isa", &pca_isa_ops) < 0) { 134 if (request_irq(irq, pca_handler, 0, "i2c-pca-isa", &pca_isa_ops) < 0) {
136 printk(KERN_ERR "i2c-pca-isa: Request irq%d failed\n", irq); 135 dev_err(dev, "Request irq%d failed\n", irq);
137 goto out_region; 136 goto out_region;
138 } 137 }
139 } 138 }
140 139
141 if (i2c_pca_add_bus(&pca_isa_ops) < 0) { 140 if (i2c_pca_add_bus(&pca_isa_ops) < 0) {
142 printk(KERN_ERR "i2c-pca-isa: Failed to add i2c bus\n"); 141 dev_err(dev, "Failed to add i2c bus\n");
143 goto out_irq; 142 goto out_irq;
144 } 143 }
145 144
@@ -154,7 +153,7 @@ static int __init pca_isa_init(void)
154 return -ENODEV; 153 return -ENODEV;
155} 154}
156 155
157static void pca_isa_exit(void) 156static int __devexit pca_isa_remove(struct device *dev, unsigned int id)
158{ 157{
159 i2c_del_adapter(&pca_isa_ops); 158 i2c_del_adapter(&pca_isa_ops);
160 159
@@ -163,6 +162,27 @@ static void pca_isa_exit(void)
163 free_irq(irq, &pca_isa_ops); 162 free_irq(irq, &pca_isa_ops);
164 } 163 }
165 release_region(base, IO_SIZE); 164 release_region(base, IO_SIZE);
165
166 return 0;
167}
168
169static struct isa_driver pca_isa_driver = {
170 .probe = pca_isa_probe,
171 .remove = __devexit_p(pca_isa_remove),
172 .driver = {
173 .owner = THIS_MODULE,
174 .name = "i2c-pca-isa",
175 }
176};
177
178static int __init pca_isa_init(void)
179{
180 return isa_register_driver(&pca_isa_driver, 1);
181}
182
183static void __exit pca_isa_exit(void)
184{
185 isa_unregister_driver(&pca_isa_driver);
166} 186}
167 187
168MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>"); 188MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>");
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 21b180904085..5a52bf5e3fb0 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -428,7 +428,7 @@ static int __devinit piix4_probe(struct pci_dev *dev,
428 /* set up the sysfs linkage to our parent device */ 428 /* set up the sysfs linkage to our parent device */
429 piix4_adapter.dev.parent = &dev->dev; 429 piix4_adapter.dev.parent = &dev->dev;
430 430
431 snprintf(piix4_adapter.name, I2C_NAME_SIZE, 431 snprintf(piix4_adapter.name, sizeof(piix4_adapter.name),
432 "SMBus PIIX4 adapter at %04x", piix4_smba); 432 "SMBus PIIX4 adapter at %04x", piix4_smba);
433 433
434 if ((retval = i2c_add_adapter(&piix4_adapter))) { 434 if ((retval = i2c_add_adapter(&piix4_adapter))) {
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 14e83d0aac8c..c059b27fa881 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -539,6 +539,18 @@ static inline void i2c_pxa_start_message(struct pxa_i2c *i2c)
539 writel(icr | ICR_START | ICR_TB, _ICR(i2c)); 539 writel(icr | ICR_START | ICR_TB, _ICR(i2c));
540} 540}
541 541
542static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c)
543{
544 u32 icr;
545
546 /*
547 * Clear the STOP and ACK flags
548 */
549 icr = readl(_ICR(i2c));
550 icr &= ~(ICR_STOP | ICR_ACKNAK);
551 writel(icr, _IRC(i2c));
552}
553
542/* 554/*
543 * We are protected by the adapter bus mutex. 555 * We are protected by the adapter bus mutex.
544 */ 556 */
@@ -581,6 +593,7 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
581 * The rest of the processing occurs in the interrupt handler. 593 * The rest of the processing occurs in the interrupt handler.
582 */ 594 */
583 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); 595 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
596 i2c_pxa_stop_message(i2c);
584 597
585 /* 598 /*
586 * We place the return code in i2c->msg_idx. 599 * We place the return code in i2c->msg_idx.
@@ -825,7 +838,7 @@ static const struct i2c_algorithm i2c_pxa_algorithm = {
825}; 838};
826 839
827static struct pxa_i2c i2c_pxa = { 840static struct pxa_i2c i2c_pxa = {
828 .lock = SPIN_LOCK_UNLOCKED, 841 .lock = __SPIN_LOCK_UNLOCKED(i2c_pxa.lock),
829 .adap = { 842 .adap = {
830 .owner = THIS_MODULE, 843 .owner = THIS_MODULE,
831 .algo = &i2c_pxa_algorithm, 844 .algo = &i2c_pxa_algorithm,
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 556f244aae76..e68a96f589fd 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -61,6 +61,8 @@ struct s3c24xx_i2c {
61 unsigned int msg_idx; 61 unsigned int msg_idx;
62 unsigned int msg_ptr; 62 unsigned int msg_ptr;
63 63
64 unsigned int tx_setup;
65
64 enum s3c24xx_i2c_state state; 66 enum s3c24xx_i2c_state state;
65 67
66 void __iomem *regs; 68 void __iomem *regs;
@@ -199,8 +201,11 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
199 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); 201 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
200 writeb(addr, i2c->regs + S3C2410_IICDS); 202 writeb(addr, i2c->regs + S3C2410_IICDS);
201 203
202 // delay a bit and reset iiccon before setting start (per samsung) 204 /* delay here to ensure the data byte has gotten onto the bus
203 udelay(1); 205 * before the transaction is started */
206
207 ndelay(i2c->tx_setup);
208
204 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); 209 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);
205 writel(iiccon, i2c->regs + S3C2410_IICCON); 210 writel(iiccon, i2c->regs + S3C2410_IICCON);
206 211
@@ -322,7 +327,15 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
322 if (!is_msgend(i2c)) { 327 if (!is_msgend(i2c)) {
323 byte = i2c->msg->buf[i2c->msg_ptr++]; 328 byte = i2c->msg->buf[i2c->msg_ptr++];
324 writeb(byte, i2c->regs + S3C2410_IICDS); 329 writeb(byte, i2c->regs + S3C2410_IICDS);
325 330
331 /* delay after writing the byte to allow the
332 * data setup time on the bus, as writing the
333 * data to the register causes the first bit
334 * to appear on SDA, and SCL will change as
335 * soon as the interrupt is acknowledged */
336
337 ndelay(i2c->tx_setup);
338
326 } else if (!is_lastmsg(i2c)) { 339 } else if (!is_lastmsg(i2c)) {
327 /* we need to go to the next i2c message */ 340 /* we need to go to the next i2c message */
328 341
@@ -570,9 +583,10 @@ static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
570}; 583};
571 584
572static struct s3c24xx_i2c s3c24xx_i2c = { 585static struct s3c24xx_i2c s3c24xx_i2c = {
573 .lock = SPIN_LOCK_UNLOCKED, 586 .lock = __SPIN_LOCK_UNLOCKED(s3c24xx_i2c.lock),
574 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait), 587 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
575 .adap = { 588 .tx_setup = 50,
589 .adap = {
576 .name = "s3c2410-i2c", 590 .name = "s3c2410-i2c",
577 .owner = THIS_MODULE, 591 .owner = THIS_MODULE,
578 .algo = &s3c24xx_i2c_algorithm, 592 .algo = &s3c24xx_i2c_algorithm,
@@ -731,26 +745,6 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
731 return 0; 745 return 0;
732} 746}
733 747
734static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c)
735{
736 if (i2c->clk != NULL && !IS_ERR(i2c->clk)) {
737 clk_disable(i2c->clk);
738 clk_put(i2c->clk);
739 i2c->clk = NULL;
740 }
741
742 if (i2c->regs != NULL) {
743 iounmap(i2c->regs);
744 i2c->regs = NULL;
745 }
746
747 if (i2c->ioarea != NULL) {
748 release_resource(i2c->ioarea);
749 kfree(i2c->ioarea);
750 i2c->ioarea = NULL;
751 }
752}
753
754/* s3c24xx_i2c_probe 748/* s3c24xx_i2c_probe
755 * 749 *
756 * called by the bus driver when a suitable device is found 750 * called by the bus driver when a suitable device is found
@@ -769,7 +763,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
769 if (IS_ERR(i2c->clk)) { 763 if (IS_ERR(i2c->clk)) {
770 dev_err(&pdev->dev, "cannot get clock\n"); 764 dev_err(&pdev->dev, "cannot get clock\n");
771 ret = -ENOENT; 765 ret = -ENOENT;
772 goto out; 766 goto err_noclk;
773 } 767 }
774 768
775 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); 769 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
@@ -782,7 +776,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
782 if (res == NULL) { 776 if (res == NULL) {
783 dev_err(&pdev->dev, "cannot find IO resource\n"); 777 dev_err(&pdev->dev, "cannot find IO resource\n");
784 ret = -ENOENT; 778 ret = -ENOENT;
785 goto out; 779 goto err_clk;
786 } 780 }
787 781
788 i2c->ioarea = request_mem_region(res->start, (res->end-res->start)+1, 782 i2c->ioarea = request_mem_region(res->start, (res->end-res->start)+1,
@@ -791,7 +785,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
791 if (i2c->ioarea == NULL) { 785 if (i2c->ioarea == NULL) {
792 dev_err(&pdev->dev, "cannot request IO\n"); 786 dev_err(&pdev->dev, "cannot request IO\n");
793 ret = -ENXIO; 787 ret = -ENXIO;
794 goto out; 788 goto err_clk;
795 } 789 }
796 790
797 i2c->regs = ioremap(res->start, (res->end-res->start)+1); 791 i2c->regs = ioremap(res->start, (res->end-res->start)+1);
@@ -799,7 +793,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
799 if (i2c->regs == NULL) { 793 if (i2c->regs == NULL) {
800 dev_err(&pdev->dev, "cannot map IO\n"); 794 dev_err(&pdev->dev, "cannot map IO\n");
801 ret = -ENXIO; 795 ret = -ENXIO;
802 goto out; 796 goto err_ioarea;
803 } 797 }
804 798
805 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res); 799 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);
@@ -813,7 +807,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
813 807
814 ret = s3c24xx_i2c_init(i2c); 808 ret = s3c24xx_i2c_init(i2c);
815 if (ret != 0) 809 if (ret != 0)
816 goto out; 810 goto err_iomap;
817 811
818 /* find the IRQ for this unit (note, this relies on the init call to 812 /* find the IRQ for this unit (note, this relies on the init call to
819 * ensure no current IRQs pending 813 * ensure no current IRQs pending
@@ -823,7 +817,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
823 if (res == NULL) { 817 if (res == NULL) {
824 dev_err(&pdev->dev, "cannot find IRQ\n"); 818 dev_err(&pdev->dev, "cannot find IRQ\n");
825 ret = -ENOENT; 819 ret = -ENOENT;
826 goto out; 820 goto err_iomap;
827 } 821 }
828 822
829 ret = request_irq(res->start, s3c24xx_i2c_irq, IRQF_DISABLED, 823 ret = request_irq(res->start, s3c24xx_i2c_irq, IRQF_DISABLED,
@@ -831,7 +825,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
831 825
832 if (ret != 0) { 826 if (ret != 0) {
833 dev_err(&pdev->dev, "cannot claim IRQ\n"); 827 dev_err(&pdev->dev, "cannot claim IRQ\n");
834 goto out; 828 goto err_iomap;
835 } 829 }
836 830
837 i2c->irq = res; 831 i2c->irq = res;
@@ -841,17 +835,29 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
841 ret = i2c_add_adapter(&i2c->adap); 835 ret = i2c_add_adapter(&i2c->adap);
842 if (ret < 0) { 836 if (ret < 0) {
843 dev_err(&pdev->dev, "failed to add bus to i2c core\n"); 837 dev_err(&pdev->dev, "failed to add bus to i2c core\n");
844 goto out; 838 goto err_irq;
845 } 839 }
846 840
847 platform_set_drvdata(pdev, i2c); 841 platform_set_drvdata(pdev, i2c);
848 842
849 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); 843 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
844 return 0;
850 845
851 out: 846 err_irq:
852 if (ret < 0) 847 free_irq(i2c->irq->start, i2c);
853 s3c24xx_i2c_free(i2c); 848
849 err_iomap:
850 iounmap(i2c->regs);
854 851
852 err_ioarea:
853 release_resource(i2c->ioarea);
854 kfree(i2c->ioarea);
855
856 err_clk:
857 clk_disable(i2c->clk);
858 clk_put(i2c->clk);
859
860 err_noclk:
855 return ret; 861 return ret;
856} 862}
857 863
@@ -863,11 +869,17 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
863static int s3c24xx_i2c_remove(struct platform_device *pdev) 869static int s3c24xx_i2c_remove(struct platform_device *pdev)
864{ 870{
865 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); 871 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
866 872
867 if (i2c != NULL) { 873 i2c_del_adapter(&i2c->adap);
868 s3c24xx_i2c_free(i2c); 874 free_irq(i2c->irq->start, i2c);
869 platform_set_drvdata(pdev, NULL); 875
870 } 876 clk_disable(i2c->clk);
877 clk_put(i2c->clk);
878
879 iounmap(i2c->regs);
880
881 release_resource(i2c->ioarea);
882 kfree(i2c->ioarea);
871 883
872 return 0; 884 return 0;
873} 885}
diff --git a/drivers/i2c/busses/i2c-simtec.c b/drivers/i2c/busses/i2c-simtec.c
new file mode 100644
index 000000000000..10af8d31e12a
--- /dev/null
+++ b/drivers/i2c/busses/i2c-simtec.c
@@ -0,0 +1,186 @@
1/*
2 * Copyright (C) 2005 Simtec Electronics
3 * Ben Dooks <ben@simtec.co.uk>
4 *
5 * Simtec Generic I2C Controller
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 as published by
9 * the Free Software Foundation; either version 2 of the License
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
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/delay.h>
25#include <linux/platform_device.h>
26
27#include <linux/i2c.h>
28#include <linux/i2c-algo-bit.h>
29
30#include <asm/io.h>
31
32struct simtec_i2c_data {
33 struct resource *ioarea;
34 void __iomem *reg;
35 struct i2c_adapter adap;
36 struct i2c_algo_bit_data bit;
37};
38
39#define CMD_SET_SDA (1<<2)
40#define CMD_SET_SCL (1<<3)
41
42#define STATE_SDA (1<<0)
43#define STATE_SCL (1<<1)
44
45/* i2c bit-bus functions */
46
47static void simtec_i2c_setsda(void *pw, int state)
48{
49 struct simtec_i2c_data *pd = pw;
50 writeb(CMD_SET_SDA | (state ? STATE_SDA : 0), pd->reg);
51}
52
53static void simtec_i2c_setscl(void *pw, int state)
54{
55 struct simtec_i2c_data *pd = pw;
56 writeb(CMD_SET_SCL | (state ? STATE_SCL : 0), pd->reg);
57}
58
59static int simtec_i2c_getsda(void *pw)
60{
61 struct simtec_i2c_data *pd = pw;
62 return readb(pd->reg) & STATE_SDA ? 1 : 0;
63}
64
65static int simtec_i2c_getscl(void *pw)
66{
67 struct simtec_i2c_data *pd = pw;
68 return readb(pd->reg) & STATE_SCL ? 1 : 0;
69}
70
71/* device registration */
72
73static int simtec_i2c_probe(struct platform_device *dev)
74{
75 struct simtec_i2c_data *pd;
76 struct resource *res;
77 int size;
78 int ret;
79
80 pd = kzalloc(sizeof(struct simtec_i2c_data), GFP_KERNEL);
81 if (pd == NULL) {
82 dev_err(&dev->dev, "cannot allocate private data\n");
83 return -ENOMEM;
84 }
85
86 platform_set_drvdata(dev, pd);
87
88 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
89 if (res == NULL) {
90 dev_err(&dev->dev, "cannot find IO resource\n");
91 ret = -ENOENT;
92 goto err;
93 }
94
95 size = (res->end-res->start)+1;
96
97 pd->ioarea = request_mem_region(res->start, size, dev->name);
98 if (pd->ioarea == NULL) {
99 dev_err(&dev->dev, "cannot request IO\n");
100 ret = -ENXIO;
101 goto err;
102 }
103
104 pd->reg = ioremap(res->start, size);
105 if (pd->reg == NULL) {
106 dev_err(&dev->dev, "cannot map IO\n");
107 ret = -ENXIO;
108 goto err_res;
109 }
110
111 /* setup the private data */
112
113 pd->adap.owner = THIS_MODULE;
114 pd->adap.algo_data = &pd->bit;
115 pd->adap.dev.parent = &dev->dev;
116
117 strlcpy(pd->adap.name, "Simtec I2C", sizeof(pd->adap.name));
118
119 pd->bit.data = pd;
120 pd->bit.setsda = simtec_i2c_setsda;
121 pd->bit.setscl = simtec_i2c_setscl;
122 pd->bit.getsda = simtec_i2c_getsda;
123 pd->bit.getscl = simtec_i2c_getscl;
124 pd->bit.timeout = HZ;
125 pd->bit.udelay = 20;
126
127 ret = i2c_bit_add_bus(&pd->adap);
128 if (ret)
129 goto err_all;
130
131 return 0;
132
133 err_all:
134 iounmap(pd->reg);
135
136 err_res:
137 release_resource(pd->ioarea);
138 kfree(pd->ioarea);
139
140 err:
141 kfree(pd);
142 return ret;
143}
144
145static int simtec_i2c_remove(struct platform_device *dev)
146{
147 struct simtec_i2c_data *pd = platform_get_drvdata(dev);
148
149 i2c_del_adapter(&pd->adap);
150
151 iounmap(pd->reg);
152 release_resource(pd->ioarea);
153 kfree(pd->ioarea);
154 kfree(pd);
155
156 return 0;
157}
158
159
160/* device driver */
161
162static struct platform_driver simtec_i2c_driver = {
163 .driver = {
164 .name = "simtec-i2c",
165 .owner = THIS_MODULE,
166 },
167 .probe = simtec_i2c_probe,
168 .remove = simtec_i2c_remove,
169};
170
171static int __init i2c_adap_simtec_init(void)
172{
173 return platform_driver_register(&simtec_i2c_driver);
174}
175
176static void __exit i2c_adap_simtec_exit(void)
177{
178 platform_driver_unregister(&simtec_i2c_driver);
179}
180
181module_init(i2c_adap_simtec_init);
182module_exit(i2c_adap_simtec_exit);
183
184MODULE_DESCRIPTION("Simtec Generic I2C Bus driver");
185MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
186MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 4157b0cd604c..dc235bb8e24d 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -300,7 +300,7 @@ static int __devinit sis96x_probe(struct pci_dev *dev,
300 /* set up the sysfs linkage to our parent device */ 300 /* set up the sysfs linkage to our parent device */
301 sis96x_adapter.dev.parent = &dev->dev; 301 sis96x_adapter.dev.parent = &dev->dev;
302 302
303 snprintf(sis96x_adapter.name, I2C_NAME_SIZE, 303 snprintf(sis96x_adapter.name, sizeof(sis96x_adapter.name),
304 "SiS96x SMBus adapter at 0x%04x", sis96x_smbus_base); 304 "SiS96x SMBus adapter at 0x%04x", sis96x_smbus_base);
305 305
306 if ((retval = i2c_add_adapter(&sis96x_adapter))) { 306 if ((retval = i2c_add_adapter(&sis96x_adapter))) {
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
new file mode 100644
index 000000000000..907999049d50
--- /dev/null
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -0,0 +1,277 @@
1/*
2 * driver for the i2c-tiny-usb adapter - 1.0
3 * http://www.harbaum.org/till/i2c_tiny_usb
4 *
5 * Copyright (C) 2006-2007 Till Harbaum (Till@Harbaum.org)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/errno.h>
15#include <linux/module.h>
16
17/* include interfaces to usb layer */
18#include <linux/usb.h>
19
20/* include interface to i2c layer */
21#include <linux/i2c.h>
22
23/* commands via USB, must match command ids in the firmware */
24#define CMD_ECHO 0
25#define CMD_GET_FUNC 1
26#define CMD_SET_DELAY 2
27#define CMD_GET_STATUS 3
28
29#define CMD_I2C_IO 4
30#define CMD_I2C_IO_BEGIN (1<<0)
31#define CMD_I2C_IO_END (1<<1)
32
33/* i2c bit delay, default is 10us -> 100kHz */
34static int delay = 10;
35module_param(delay, int, 0);
36MODULE_PARM_DESC(delay, "bit delay in microseconds, "
37 "e.g. 10 for 100kHz (default is 100kHz)");
38
39static int usb_read(struct i2c_adapter *adapter, int cmd,
40 int value, int index, void *data, int len);
41
42static int usb_write(struct i2c_adapter *adapter, int cmd,
43 int value, int index, void *data, int len);
44
45/* ----- begin of i2c layer ---------------------------------------------- */
46
47#define STATUS_IDLE 0
48#define STATUS_ADDRESS_ACK 1
49#define STATUS_ADDRESS_NAK 2
50
51static int usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)
52{
53 unsigned char status;
54 struct i2c_msg *pmsg;
55 int i;
56
57 dev_dbg(&adapter->dev, "master xfer %d messages:\n", num);
58
59 for (i = 0 ; i < num ; i++) {
60 int cmd = CMD_I2C_IO;
61
62 if (i == 0)
63 cmd |= CMD_I2C_IO_BEGIN;
64
65 if (i == num-1)
66 cmd |= CMD_I2C_IO_END;
67
68 pmsg = &msgs[i];
69
70 dev_dbg(&adapter->dev,
71 " %d: %s (flags %d) %d bytes to 0x%02x\n",
72 i, pmsg->flags & I2C_M_RD ? "read" : "write",
73 pmsg->flags, pmsg->len, pmsg->addr);
74
75 /* and directly send the message */
76 if (pmsg->flags & I2C_M_RD) {
77 /* read data */
78 if (usb_read(adapter, cmd,
79 pmsg->flags, pmsg->addr,
80 pmsg->buf, pmsg->len) != pmsg->len) {
81 dev_err(&adapter->dev,
82 "failure reading data\n");
83 return -EREMOTEIO;
84 }
85 } else {
86 /* write data */
87 if (usb_write(adapter, cmd,
88 pmsg->flags, pmsg->addr,
89 pmsg->buf, pmsg->len) != pmsg->len) {
90 dev_err(&adapter->dev,
91 "failure writing data\n");
92 return -EREMOTEIO;
93 }
94 }
95
96 /* read status */
97 if (usb_read(adapter, CMD_GET_STATUS, 0, 0, &status, 1) != 1) {
98 dev_err(&adapter->dev, "failure reading status\n");
99 return -EREMOTEIO;
100 }
101
102 dev_dbg(&adapter->dev, " status = %d\n", status);
103 if (status == STATUS_ADDRESS_NAK)
104 return -EREMOTEIO;
105 }
106
107 return i;
108}
109
110static u32 usb_func(struct i2c_adapter *adapter)
111{
112 u32 func;
113
114 /* get functionality from adapter */
115 if (usb_read(adapter, CMD_GET_FUNC, 0, 0, &func, sizeof(func)) !=
116 sizeof(func)) {
117 dev_err(&adapter->dev, "failure reading functionality\n");
118 return 0;
119 }
120
121 return func;
122}
123
124/* This is the actual algorithm we define */
125static const struct i2c_algorithm usb_algorithm = {
126 .master_xfer = usb_xfer,
127 .functionality = usb_func,
128};
129
130/* ----- end of i2c layer ------------------------------------------------ */
131
132/* ----- begin of usb layer ---------------------------------------------- */
133
134/* The usb i2c interface uses a vid/pid pair donated by */
135/* Future Technology Devices International Ltd. */
136static struct usb_device_id i2c_tiny_usb_table [] = {
137 { USB_DEVICE(0x0403, 0xc631) },
138 { } /* Terminating entry */
139};
140
141MODULE_DEVICE_TABLE(usb, i2c_tiny_usb_table);
142
143/* Structure to hold all of our device specific stuff */
144struct i2c_tiny_usb {
145 struct usb_device *usb_dev; /* the usb device for this device */
146 struct usb_interface *interface; /* the interface for this device */
147 struct i2c_adapter adapter; /* i2c related things */
148};
149
150static int usb_read(struct i2c_adapter *adapter, int cmd,
151 int value, int index, void *data, int len)
152{
153 struct i2c_tiny_usb *dev = (struct i2c_tiny_usb *)adapter->algo_data;
154
155 /* do control transfer */
156 return usb_control_msg(dev->usb_dev, usb_rcvctrlpipe(dev->usb_dev, 0),
157 cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE |
158 USB_DIR_IN, value, index, data, len, 2000);
159}
160
161static int usb_write(struct i2c_adapter *adapter, int cmd,
162 int value, int index, void *data, int len)
163{
164 struct i2c_tiny_usb *dev = (struct i2c_tiny_usb *)adapter->algo_data;
165
166 /* do control transfer */
167 return usb_control_msg(dev->usb_dev, usb_sndctrlpipe(dev->usb_dev, 0),
168 cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
169 value, index, data, len, 2000);
170}
171
172static void i2c_tiny_usb_free(struct i2c_tiny_usb *dev)
173{
174 usb_put_dev(dev->usb_dev);
175 kfree(dev);
176}
177
178static int i2c_tiny_usb_probe(struct usb_interface *interface,
179 const struct usb_device_id *id)
180{
181 struct i2c_tiny_usb *dev;
182 int retval = -ENOMEM;
183 u16 version;
184
185 dev_dbg(&interface->dev, "probing usb device\n");
186
187 /* allocate memory for our device state and initialize it */
188 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
189 if (dev == NULL) {
190 dev_err(&interface->dev, "Out of memory\n");
191 goto error;
192 }
193
194 dev->usb_dev = usb_get_dev(interface_to_usbdev(interface));
195 dev->interface = interface;
196
197 /* save our data pointer in this interface device */
198 usb_set_intfdata(interface, dev);
199
200 version = le16_to_cpu(dev->usb_dev->descriptor.bcdDevice);
201 dev_info(&interface->dev,
202 "version %x.%02x found at bus %03d address %03d\n",
203 version >> 8, version & 0xff,
204 dev->usb_dev->bus->busnum, dev->usb_dev->devnum);
205
206 /* setup i2c adapter description */
207 dev->adapter.owner = THIS_MODULE;
208 dev->adapter.class = I2C_CLASS_HWMON;
209 dev->adapter.algo = &usb_algorithm;
210 dev->adapter.algo_data = dev;
211 snprintf(dev->adapter.name, I2C_NAME_SIZE,
212 "i2c-tiny-usb at bus %03d device %03d",
213 dev->usb_dev->bus->busnum, dev->usb_dev->devnum);
214
215 if (usb_write(&dev->adapter, CMD_SET_DELAY,
216 cpu_to_le16(delay), 0, NULL, 0) != 0) {
217 dev_err(&dev->adapter.dev,
218 "failure setting delay to %dus\n", delay);
219 retval = -EIO;
220 goto error;
221 }
222
223 dev->adapter.dev.parent = &dev->interface->dev;
224
225 /* and finally attach to i2c layer */
226 i2c_add_adapter(&dev->adapter);
227
228 /* inform user about successful attachment to i2c layer */
229 dev_info(&dev->adapter.dev, "connected i2c-tiny-usb device\n");
230
231 return 0;
232
233 error:
234 if (dev)
235 i2c_tiny_usb_free(dev);
236
237 return retval;
238}
239
240static void i2c_tiny_usb_disconnect(struct usb_interface *interface)
241{
242 struct i2c_tiny_usb *dev = usb_get_intfdata(interface);
243
244 i2c_del_adapter(&dev->adapter);
245 usb_set_intfdata(interface, NULL);
246 i2c_tiny_usb_free(dev);
247
248 dev_dbg(&interface->dev, "disconnected\n");
249}
250
251static struct usb_driver i2c_tiny_usb_driver = {
252 .name = "i2c-tiny-usb",
253 .probe = i2c_tiny_usb_probe,
254 .disconnect = i2c_tiny_usb_disconnect,
255 .id_table = i2c_tiny_usb_table,
256};
257
258static int __init usb_i2c_tiny_usb_init(void)
259{
260 /* register this driver with the USB subsystem */
261 return usb_register(&i2c_tiny_usb_driver);
262}
263
264static void __exit usb_i2c_tiny_usb_exit(void)
265{
266 /* deregister this driver with the USB subsystem */
267 usb_deregister(&i2c_tiny_usb_driver);
268}
269
270module_init(usb_i2c_tiny_usb_init);
271module_exit(usb_i2c_tiny_usb_exit);
272
273/* ----- end of usb layer ------------------------------------------------ */
274
275MODULE_AUTHOR("Till Harbaum <Till@Harbaum.org>");
276MODULE_DESCRIPTION("i2c-tiny-usb driver v1.0");
277MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 03c5fc868548..7a2bc06304fc 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -404,7 +404,7 @@ found:
404 } 404 }
405 405
406 vt596_adapter.dev.parent = &pdev->dev; 406 vt596_adapter.dev.parent = &pdev->dev;
407 snprintf(vt596_adapter.name, I2C_NAME_SIZE, 407 snprintf(vt596_adapter.name, sizeof(vt596_adapter.name),
408 "SMBus Via Pro adapter at %04x", vt596_smba); 408 "SMBus Via Pro adapter at %04x", vt596_smba);
409 409
410 vt596_pdev = pci_dev_get(pdev); 410 vt596_pdev = pci_dev_get(pdev);
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 0b082c5a0195..0db56e7bc34e 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -441,7 +441,7 @@ static __init struct scx200_acb_iface *scx200_create_iface(const char *text,
441 441
442 adapter = &iface->adapter; 442 adapter = &iface->adapter;
443 i2c_set_adapdata(adapter, iface); 443 i2c_set_adapdata(adapter, iface);
444 snprintf(adapter->name, I2C_NAME_SIZE, "%s ACB%d", text, index); 444 snprintf(adapter->name, sizeof(adapter->name), "%s ACB%d", text, index);
445 adapter->owner = THIS_MODULE; 445 adapter->owner = THIS_MODULE;
446 adapter->id = I2C_HW_SMBUS_SCX200; 446 adapter->id = I2C_HW_SMBUS_SCX200;
447 adapter->algo = &scx200_acb_algorithm; 447 adapter->algo = &scx200_acb_algorithm;
@@ -599,6 +599,7 @@ static __init int scx200_scan_pci(void)
599 else { 599 else {
600 int i; 600 int i;
601 601
602 pci_dev_put(pdev);
602 for (i = 0; i < MAX_DEVICES; ++i) { 603 for (i = 0; i < MAX_DEVICES; ++i) {
603 if (base[i] == 0) 604 if (base[i] == 0)
604 continue; 605 continue;
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 87ee3ce58618..ea085a006ead 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -3,11 +3,10 @@
3# 3#
4 4
5menu "Miscellaneous I2C Chip support" 5menu "Miscellaneous I2C Chip support"
6 depends on I2C
7 6
8config SENSORS_DS1337 7config SENSORS_DS1337
9 tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock" 8 tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock"
10 depends on I2C && EXPERIMENTAL 9 depends on EXPERIMENTAL
11 help 10 help
12 If you say yes here you get support for Dallas Semiconductor 11 If you say yes here you get support for Dallas Semiconductor
13 DS1337 and DS1339 real-time clock chips. 12 DS1337 and DS1339 real-time clock chips.
@@ -17,7 +16,7 @@ config SENSORS_DS1337
17 16
18config SENSORS_DS1374 17config SENSORS_DS1374
19 tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock" 18 tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock"
20 depends on I2C && EXPERIMENTAL 19 depends on EXPERIMENTAL
21 help 20 help
22 If you say yes here you get support for Dallas Semiconductor 21 If you say yes here you get support for Dallas Semiconductor
23 DS1374 real-time clock chips. 22 DS1374 real-time clock chips.
@@ -27,7 +26,7 @@ config SENSORS_DS1374
27 26
28config SENSORS_EEPROM 27config SENSORS_EEPROM
29 tristate "EEPROM reader" 28 tristate "EEPROM reader"
30 depends on I2C && EXPERIMENTAL 29 depends on EXPERIMENTAL
31 help 30 help
32 If you say yes here you get read-only access to the EEPROM data 31 If you say yes here you get read-only access to the EEPROM data
33 available on modern memory DIMMs and Sony Vaio laptops. Such 32 available on modern memory DIMMs and Sony Vaio laptops. Such
@@ -38,7 +37,7 @@ config SENSORS_EEPROM
38 37
39config SENSORS_PCF8574 38config SENSORS_PCF8574
40 tristate "Philips PCF8574 and PCF8574A" 39 tristate "Philips PCF8574 and PCF8574A"
41 depends on I2C && EXPERIMENTAL 40 depends on EXPERIMENTAL
42 default n 41 default n
43 help 42 help
44 If you say yes here you get support for Philips PCF8574 and 43 If you say yes here you get support for Philips PCF8574 and
@@ -52,7 +51,7 @@ config SENSORS_PCF8574
52 51
53config SENSORS_PCA9539 52config SENSORS_PCA9539
54 tristate "Philips PCA9539 16-bit I/O port" 53 tristate "Philips PCA9539 16-bit I/O port"
55 depends on I2C && EXPERIMENTAL 54 depends on EXPERIMENTAL
56 help 55 help
57 If you say yes here you get support for the Philips PCA9539 56 If you say yes here you get support for the Philips PCA9539
58 16-bit I/O port. 57 16-bit I/O port.
@@ -62,7 +61,7 @@ config SENSORS_PCA9539
62 61
63config SENSORS_PCF8591 62config SENSORS_PCF8591
64 tristate "Philips PCF8591" 63 tristate "Philips PCF8591"
65 depends on I2C && EXPERIMENTAL 64 depends on EXPERIMENTAL
66 default n 65 default n
67 help 66 help
68 If you say yes here you get support for Philips PCF8591 chips. 67 If you say yes here you get support for Philips PCF8591 chips.
@@ -75,7 +74,7 @@ config SENSORS_PCF8591
75 74
76config ISP1301_OMAP 75config ISP1301_OMAP
77 tristate "Philips ISP1301 with OMAP OTG" 76 tristate "Philips ISP1301 with OMAP OTG"
78 depends on I2C && ARCH_OMAP_OTG 77 depends on ARCH_OMAP_OTG
79 help 78 help
80 If you say yes here you get support for the Philips ISP1301 79 If you say yes here you get support for the Philips ISP1301
81 USB-On-The-Go transceiver working with the OMAP OTG controller. 80 USB-On-The-Go transceiver working with the OMAP OTG controller.
@@ -90,7 +89,7 @@ config ISP1301_OMAP
90# and having mostly OMAP-specific board support 89# and having mostly OMAP-specific board support
91config TPS65010 90config TPS65010
92 tristate "TPS6501x Power Management chips" 91 tristate "TPS6501x Power Management chips"
93 depends on I2C && ARCH_OMAP 92 depends on ARCH_OMAP
94 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK 93 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK
95 help 94 help
96 If you say yes here you get support for the TPS6501x series of 95 If you say yes here you get support for the TPS6501x series of
@@ -103,7 +102,7 @@ config TPS65010
103 102
104config SENSORS_M41T00 103config SENSORS_M41T00
105 tristate "ST M41T00 RTC chip" 104 tristate "ST M41T00 RTC chip"
106 depends on I2C && PPC32 105 depends on PPC32
107 help 106 help
108 If you say yes here you get support for the ST M41T00 RTC chip. 107 If you say yes here you get support for the ST M41T00 RTC chip.
109 108
@@ -112,7 +111,7 @@ config SENSORS_M41T00
112 111
113config SENSORS_MAX6875 112config SENSORS_MAX6875
114 tristate "Maxim MAX6875 Power supply supervisor" 113 tristate "Maxim MAX6875 Power supply supervisor"
115 depends on I2C && EXPERIMENTAL 114 depends on EXPERIMENTAL
116 help 115 help
117 If you say yes here you get support for the Maxim MAX6875 116 If you say yes here you get support for the Maxim MAX6875
118 EEPROM-programmable, quad power-supply sequencer/supervisor. 117 EEPROM-programmable, quad power-supply sequencer/supervisor.
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c
new file mode 100644
index 000000000000..ffb35f09df03
--- /dev/null
+++ b/drivers/i2c/i2c-boardinfo.c
@@ -0,0 +1,90 @@
1/*
2 * i2c-boardinfo.h - collect pre-declarations of I2C devices
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#include <linux/kernel.h>
20#include <linux/i2c.h>
21
22#include "i2c-core.h"
23
24
25/* These symbols are exported ONLY FOR the i2c core.
26 * No other users will be supported.
27 */
28DEFINE_MUTEX(__i2c_board_lock);
29EXPORT_SYMBOL_GPL(__i2c_board_lock);
30
31LIST_HEAD(__i2c_board_list);
32EXPORT_SYMBOL_GPL(__i2c_board_list);
33
34int __i2c_first_dynamic_bus_num;
35EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num);
36
37
38/**
39 * i2c_register_board_info - statically declare I2C devices
40 * @busnum: identifies the bus to which these devices belong
41 * @info: vector of i2c device descriptors
42 * @len: how many descriptors in the vector; may be zero to reserve
43 * the specified bus number.
44 *
45 * Systems using the Linux I2C driver stack can declare tables of board info
46 * while they initialize. This should be done in board-specific init code
47 * near arch_initcall() time, or equivalent, before any I2C adapter driver is
48 * registered. For example, mainboard init code could define several devices,
49 * as could the init code for each daughtercard in a board stack.
50 *
51 * The I2C devices will be created later, after the adapter for the relevant
52 * bus has been registered. After that moment, standard driver model tools
53 * are used to bind "new style" I2C drivers to the devices. The bus number
54 * for any device declared using this routine is not available for dynamic
55 * allocation.
56 *
57 * The board info passed can safely be __initdata, but be careful of embedded
58 * pointers (for platform_data, functions, etc) since that won't be copied.
59 */
60int __init
61i2c_register_board_info(int busnum,
62 struct i2c_board_info const *info, unsigned len)
63{
64 int status;
65
66 mutex_lock(&__i2c_board_lock);
67
68 /* dynamic bus numbers will be assigned after the last static one */
69 if (busnum >= __i2c_first_dynamic_bus_num)
70 __i2c_first_dynamic_bus_num = busnum + 1;
71
72 for (status = 0; len; len--, info++) {
73 struct i2c_devinfo *devinfo;
74
75 devinfo = kzalloc(sizeof(*devinfo), GFP_KERNEL);
76 if (!devinfo) {
77 pr_debug("i2c-core: can't register boardinfo!\n");
78 status = -ENOMEM;
79 break;
80 }
81
82 devinfo->busnum = busnum;
83 devinfo->board_info = *info;
84 list_add_tail(&devinfo->list, &__i2c_board_list);
85 }
86
87 mutex_unlock(&__i2c_board_lock);
88
89 return status;
90}
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 21fe1406c8b4..64f8e56d300e 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -35,29 +35,92 @@
35#include <linux/completion.h> 35#include <linux/completion.h>
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37 37
38#include "i2c-core.h"
39
38 40
39static LIST_HEAD(adapters); 41static LIST_HEAD(adapters);
40static LIST_HEAD(drivers); 42static LIST_HEAD(drivers);
41static DEFINE_MUTEX(core_lists); 43static DEFINE_MUTEX(core_lists);
42static DEFINE_IDR(i2c_adapter_idr); 44static DEFINE_IDR(i2c_adapter_idr);
43 45
46#define is_newstyle_driver(d) ((d)->probe || (d)->remove)
44 47
45/* ------------------------------------------------------------------------- */ 48/* ------------------------------------------------------------------------- */
46 49
47/* match always succeeds, as we want the probe() to tell if we really accept this match */
48static int i2c_device_match(struct device *dev, struct device_driver *drv) 50static int i2c_device_match(struct device *dev, struct device_driver *drv)
49{ 51{
50 return 1; 52 struct i2c_client *client = to_i2c_client(dev);
53 struct i2c_driver *driver = to_i2c_driver(drv);
54
55 /* make legacy i2c drivers bypass driver model probing entirely;
56 * such drivers scan each i2c adapter/bus themselves.
57 */
58 if (!is_newstyle_driver(driver))
59 return 0;
60
61 /* new style drivers use the same kind of driver matching policy
62 * as platform devices or SPI: compare device and driver IDs.
63 */
64 return strcmp(client->driver_name, drv->name) == 0;
65}
66
67#ifdef CONFIG_HOTPLUG
68
69/* uevent helps with hotplug: modprobe -q $(MODALIAS) */
70static int i2c_device_uevent(struct device *dev, char **envp, int num_envp,
71 char *buffer, int buffer_size)
72{
73 struct i2c_client *client = to_i2c_client(dev);
74 int i = 0, length = 0;
75
76 /* by definition, legacy drivers can't hotplug */
77 if (dev->driver || !client->driver_name)
78 return 0;
79
80 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
81 "MODALIAS=%s", client->driver_name))
82 return -ENOMEM;
83 envp[i] = NULL;
84 dev_dbg(dev, "uevent\n");
85 return 0;
51} 86}
52 87
88#else
89#define i2c_device_uevent NULL
90#endif /* CONFIG_HOTPLUG */
91
53static int i2c_device_probe(struct device *dev) 92static int i2c_device_probe(struct device *dev)
54{ 93{
55 return -ENODEV; 94 struct i2c_client *client = to_i2c_client(dev);
95 struct i2c_driver *driver = to_i2c_driver(dev->driver);
96
97 if (!driver->probe)
98 return -ENODEV;
99 client->driver = driver;
100 dev_dbg(dev, "probe\n");
101 return driver->probe(client);
56} 102}
57 103
58static int i2c_device_remove(struct device *dev) 104static int i2c_device_remove(struct device *dev)
59{ 105{
60 return 0; 106 struct i2c_client *client = to_i2c_client(dev);
107 struct i2c_driver *driver;
108 int status;
109
110 if (!dev->driver)
111 return 0;
112
113 driver = to_i2c_driver(dev->driver);
114 if (driver->remove) {
115 dev_dbg(dev, "remove\n");
116 status = driver->remove(client);
117 } else {
118 dev->driver = NULL;
119 status = 0;
120 }
121 if (status == 0)
122 client->driver = NULL;
123 return status;
61} 124}
62 125
63static void i2c_device_shutdown(struct device *dev) 126static void i2c_device_shutdown(struct device *dev)
@@ -95,122 +158,184 @@ static int i2c_device_resume(struct device * dev)
95 return driver->resume(to_i2c_client(dev)); 158 return driver->resume(to_i2c_client(dev));
96} 159}
97 160
161static void i2c_client_release(struct device *dev)
162{
163 struct i2c_client *client = to_i2c_client(dev);
164 complete(&client->released);
165}
166
167static void i2c_client_dev_release(struct device *dev)
168{
169 kfree(to_i2c_client(dev));
170}
171
172static ssize_t show_client_name(struct device *dev, struct device_attribute *attr, char *buf)
173{
174 struct i2c_client *client = to_i2c_client(dev);
175 return sprintf(buf, "%s\n", client->name);
176}
177
178static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
179{
180 struct i2c_client *client = to_i2c_client(dev);
181 return client->driver_name
182 ? sprintf(buf, "%s\n", client->driver_name)
183 : 0;
184}
185
186static struct device_attribute i2c_dev_attrs[] = {
187 __ATTR(name, S_IRUGO, show_client_name, NULL),
188 /* modalias helps coldplug: modprobe $(cat .../modalias) */
189 __ATTR(modalias, S_IRUGO, show_modalias, NULL),
190 { },
191};
192
98struct bus_type i2c_bus_type = { 193struct bus_type i2c_bus_type = {
99 .name = "i2c", 194 .name = "i2c",
195 .dev_attrs = i2c_dev_attrs,
100 .match = i2c_device_match, 196 .match = i2c_device_match,
197 .uevent = i2c_device_uevent,
101 .probe = i2c_device_probe, 198 .probe = i2c_device_probe,
102 .remove = i2c_device_remove, 199 .remove = i2c_device_remove,
103 .shutdown = i2c_device_shutdown, 200 .shutdown = i2c_device_shutdown,
104 .suspend = i2c_device_suspend, 201 .suspend = i2c_device_suspend,
105 .resume = i2c_device_resume, 202 .resume = i2c_device_resume,
106}; 203};
204EXPORT_SYMBOL_GPL(i2c_bus_type);
107 205
108/* ------------------------------------------------------------------------- */ 206/**
207 * i2c_new_device - instantiate an i2c device for use with a new style driver
208 * @adap: the adapter managing the device
209 * @info: describes one I2C device; bus_num is ignored
210 *
211 * Create a device to work with a new style i2c driver, where binding is
212 * handled through driver model probe()/remove() methods. This call is not
213 * appropriate for use by mainboad initialization logic, which usually runs
214 * during an arch_initcall() long before any i2c_adapter could exist.
215 *
216 * This returns the new i2c client, which may be saved for later use with
217 * i2c_unregister_device(); or NULL to indicate an error.
218 */
219struct i2c_client *
220i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
221{
222 struct i2c_client *client;
223 int status;
109 224
110void i2c_adapter_dev_release(struct device *dev) 225 client = kzalloc(sizeof *client, GFP_KERNEL);
226 if (!client)
227 return NULL;
228
229 client->adapter = adap;
230
231 client->dev.platform_data = info->platform_data;
232 client->flags = info->flags;
233 client->addr = info->addr;
234 client->irq = info->irq;
235
236 strlcpy(client->driver_name, info->driver_name,
237 sizeof(client->driver_name));
238 strlcpy(client->name, info->type, sizeof(client->name));
239
240 /* a new style driver may be bound to this device when we
241 * return from this function, or any later moment (e.g. maybe
242 * hotplugging will load the driver module). and the device
243 * refcount model is the standard driver model one.
244 */
245 status = i2c_attach_client(client);
246 if (status < 0) {
247 kfree(client);
248 client = NULL;
249 }
250 return client;
251}
252EXPORT_SYMBOL_GPL(i2c_new_device);
253
254
255/**
256 * i2c_unregister_device - reverse effect of i2c_new_device()
257 * @client: value returned from i2c_new_device()
258 */
259void i2c_unregister_device(struct i2c_client *client)
111{ 260{
112 struct i2c_adapter *adap = dev_to_i2c_adapter(dev); 261 struct i2c_adapter *adapter = client->adapter;
113 complete(&adap->dev_released); 262 struct i2c_driver *driver = client->driver;
263
264 if (driver && !is_newstyle_driver(driver)) {
265 dev_err(&client->dev, "can't unregister devices "
266 "with legacy drivers\n");
267 WARN_ON(1);
268 return;
269 }
270
271 mutex_lock(&adapter->clist_lock);
272 list_del(&client->list);
273 mutex_unlock(&adapter->clist_lock);
274
275 device_unregister(&client->dev);
114} 276}
277EXPORT_SYMBOL_GPL(i2c_unregister_device);
115 278
116struct device_driver i2c_adapter_driver = {
117 .owner = THIS_MODULE,
118 .name = "i2c_adapter",
119 .bus = &i2c_bus_type,
120};
121 279
122/* ------------------------------------------------------------------------- */ 280/* ------------------------------------------------------------------------- */
123 281
124/* I2C bus adapters -- one roots each I2C or SMBUS segment */ 282/* I2C bus adapters -- one roots each I2C or SMBUS segment */
125 283
126static void i2c_adapter_class_dev_release(struct class_device *dev) 284void i2c_adapter_dev_release(struct device *dev)
127{ 285{
128 struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev); 286 struct i2c_adapter *adap = to_i2c_adapter(dev);
129 complete(&adap->class_dev_released); 287 complete(&adap->dev_released);
130} 288}
289EXPORT_SYMBOL_GPL(i2c_adapter_dev_release); /* exported to i2c-isa */
131 290
132static ssize_t i2c_adapter_show_name(struct class_device *cdev, char *buf) 291static ssize_t
292show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
133{ 293{
134 struct i2c_adapter *adap = class_dev_to_i2c_adapter(cdev); 294 struct i2c_adapter *adap = to_i2c_adapter(dev);
135 return sprintf(buf, "%s\n", adap->name); 295 return sprintf(buf, "%s\n", adap->name);
136} 296}
137 297
138static struct class_device_attribute i2c_adapter_attrs[] = { 298static struct device_attribute i2c_adapter_attrs[] = {
139 __ATTR(name, S_IRUGO, i2c_adapter_show_name, NULL), 299 __ATTR(name, S_IRUGO, show_adapter_name, NULL),
140 { }, 300 { },
141}; 301};
142 302
143struct class i2c_adapter_class = { 303struct class i2c_adapter_class = {
144 .owner = THIS_MODULE, 304 .owner = THIS_MODULE,
145 .name = "i2c-adapter", 305 .name = "i2c-adapter",
146 .class_dev_attrs = i2c_adapter_attrs, 306 .dev_attrs = i2c_adapter_attrs,
147 .release = &i2c_adapter_class_dev_release,
148}; 307};
308EXPORT_SYMBOL_GPL(i2c_adapter_class); /* exported to i2c-isa */
149 309
150static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) 310static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
151{
152 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
153 return sprintf(buf, "%s\n", adap->name);
154}
155static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
156
157
158static void i2c_client_release(struct device *dev)
159{
160 struct i2c_client *client = to_i2c_client(dev);
161 complete(&client->released);
162}
163
164static ssize_t show_client_name(struct device *dev, struct device_attribute *attr, char *buf)
165{ 311{
166 struct i2c_client *client = to_i2c_client(dev); 312 struct i2c_devinfo *devinfo;
167 return sprintf(buf, "%s\n", client->name); 313
314 mutex_lock(&__i2c_board_lock);
315 list_for_each_entry(devinfo, &__i2c_board_list, list) {
316 if (devinfo->busnum == adapter->nr
317 && !i2c_new_device(adapter,
318 &devinfo->board_info))
319 printk(KERN_ERR "i2c-core: can't create i2c%d-%04x\n",
320 i2c_adapter_id(adapter),
321 devinfo->board_info.addr);
322 }
323 mutex_unlock(&__i2c_board_lock);
168} 324}
169 325
170/* 326static int i2c_register_adapter(struct i2c_adapter *adap)
171 * We can't use the DEVICE_ATTR() macro here, as we used the same name for
172 * an i2c adapter attribute (above).
173 */
174static struct device_attribute dev_attr_client_name =
175 __ATTR(name, S_IRUGO, &show_client_name, NULL);
176
177
178/* ---------------------------------------------------
179 * registering functions
180 * ---------------------------------------------------
181 */
182
183/* -----
184 * i2c_add_adapter is called from within the algorithm layer,
185 * when a new hw adapter registers. A new device is register to be
186 * available for clients.
187 */
188int i2c_add_adapter(struct i2c_adapter *adap)
189{ 327{
190 int id, res = 0; 328 int res = 0;
191 struct list_head *item; 329 struct list_head *item;
192 struct i2c_driver *driver; 330 struct i2c_driver *driver;
193 331
194 mutex_lock(&core_lists);
195
196 if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) {
197 res = -ENOMEM;
198 goto out_unlock;
199 }
200
201 res = idr_get_new(&i2c_adapter_idr, adap, &id);
202 if (res < 0) {
203 if (res == -EAGAIN)
204 res = -ENOMEM;
205 goto out_unlock;
206 }
207
208 adap->nr = id & MAX_ID_MASK;
209 mutex_init(&adap->bus_lock); 332 mutex_init(&adap->bus_lock);
210 mutex_init(&adap->clist_lock); 333 mutex_init(&adap->clist_lock);
211 list_add_tail(&adap->list,&adapters);
212 INIT_LIST_HEAD(&adap->clients); 334 INIT_LIST_HEAD(&adap->clients);
213 335
336 mutex_lock(&core_lists);
337 list_add_tail(&adap->list, &adapters);
338
214 /* Add the adapter to the driver core. 339 /* Add the adapter to the driver core.
215 * If the parent pointer is not set up, 340 * If the parent pointer is not set up,
216 * we add this adapter to the host bus. 341 * we add this adapter to the host bus.
@@ -221,27 +346,19 @@ int i2c_add_adapter(struct i2c_adapter *adap)
221 "physical device\n", adap->name); 346 "physical device\n", adap->name);
222 } 347 }
223 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 348 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
224 adap->dev.driver = &i2c_adapter_driver;
225 adap->dev.release = &i2c_adapter_dev_release; 349 adap->dev.release = &i2c_adapter_dev_release;
350 adap->dev.class = &i2c_adapter_class;
226 res = device_register(&adap->dev); 351 res = device_register(&adap->dev);
227 if (res) 352 if (res)
228 goto out_list; 353 goto out_list;
229 res = device_create_file(&adap->dev, &dev_attr_name);
230 if (res)
231 goto out_unregister;
232
233 /* Add this adapter to the i2c_adapter class */
234 memset(&adap->class_dev, 0x00, sizeof(struct class_device));
235 adap->class_dev.dev = &adap->dev;
236 adap->class_dev.class = &i2c_adapter_class;
237 strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE);
238 res = class_device_register(&adap->class_dev);
239 if (res)
240 goto out_remove_name;
241 354
242 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); 355 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
243 356
244 /* inform drivers of new adapters */ 357 /* create pre-declared device nodes for new-style drivers */
358 if (adap->nr < __i2c_first_dynamic_bus_num)
359 i2c_scan_static_board_info(adap);
360
361 /* let legacy drivers scan this bus for matching devices */
245 list_for_each(item,&drivers) { 362 list_for_each(item,&drivers) {
246 driver = list_entry(item, struct i2c_driver, list); 363 driver = list_entry(item, struct i2c_driver, list);
247 if (driver->attach_adapter) 364 if (driver->attach_adapter)
@@ -253,18 +370,98 @@ out_unlock:
253 mutex_unlock(&core_lists); 370 mutex_unlock(&core_lists);
254 return res; 371 return res;
255 372
256out_remove_name:
257 device_remove_file(&adap->dev, &dev_attr_name);
258out_unregister:
259 init_completion(&adap->dev_released); /* Needed? */
260 device_unregister(&adap->dev);
261 wait_for_completion(&adap->dev_released);
262out_list: 373out_list:
263 list_del(&adap->list); 374 list_del(&adap->list);
264 idr_remove(&i2c_adapter_idr, adap->nr); 375 idr_remove(&i2c_adapter_idr, adap->nr);
265 goto out_unlock; 376 goto out_unlock;
266} 377}
267 378
379/**
380 * i2c_add_adapter - declare i2c adapter, use dynamic bus number
381 * @adapter: the adapter to add
382 *
383 * This routine is used to declare an I2C adapter when its bus number
384 * doesn't matter. Examples: for I2C adapters dynamically added by
385 * USB links or PCI plugin cards.
386 *
387 * When this returns zero, a new bus number was allocated and stored
388 * in adap->nr, and the specified adapter became available for clients.
389 * Otherwise, a negative errno value is returned.
390 */
391int i2c_add_adapter(struct i2c_adapter *adapter)
392{
393 int id, res = 0;
394
395retry:
396 if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0)
397 return -ENOMEM;
398
399 mutex_lock(&core_lists);
400 /* "above" here means "above or equal to", sigh */
401 res = idr_get_new_above(&i2c_adapter_idr, adapter,
402 __i2c_first_dynamic_bus_num, &id);
403 mutex_unlock(&core_lists);
404
405 if (res < 0) {
406 if (res == -EAGAIN)
407 goto retry;
408 return res;
409 }
410
411 adapter->nr = id;
412 return i2c_register_adapter(adapter);
413}
414EXPORT_SYMBOL(i2c_add_adapter);
415
416/**
417 * i2c_add_numbered_adapter - declare i2c adapter, use static bus number
418 * @adap: the adapter to register (with adap->nr initialized)
419 *
420 * This routine is used to declare an I2C adapter when its bus number
421 * matters. Example: for I2C adapters from system-on-chip CPUs, or
422 * otherwise built in to the system's mainboard, and where i2c_board_info
423 * is used to properly configure I2C devices.
424 *
425 * If no devices have pre-been declared for this bus, then be sure to
426 * register the adapter before any dynamically allocated ones. Otherwise
427 * the required bus ID may not be available.
428 *
429 * When this returns zero, the specified adapter became available for
430 * clients using the bus number provided in adap->nr. Also, the table
431 * of I2C devices pre-declared using i2c_register_board_info() is scanned,
432 * and the appropriate driver model device nodes are created. Otherwise, a
433 * negative errno value is returned.
434 */
435int i2c_add_numbered_adapter(struct i2c_adapter *adap)
436{
437 int id;
438 int status;
439
440 if (adap->nr & ~MAX_ID_MASK)
441 return -EINVAL;
442
443retry:
444 if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0)
445 return -ENOMEM;
446
447 mutex_lock(&core_lists);
448 /* "above" here means "above or equal to", sigh;
449 * we need the "equal to" result to force the result
450 */
451 status = idr_get_new_above(&i2c_adapter_idr, adap, adap->nr, &id);
452 if (status == 0 && id != adap->nr) {
453 status = -EBUSY;
454 idr_remove(&i2c_adapter_idr, id);
455 }
456 mutex_unlock(&core_lists);
457 if (status == -EAGAIN)
458 goto retry;
459
460 if (status == 0)
461 status = i2c_register_adapter(adap);
462 return status;
463}
464EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter);
268 465
269int i2c_del_adapter(struct i2c_adapter *adap) 466int i2c_del_adapter(struct i2c_adapter *adap)
270{ 467{
@@ -302,9 +499,19 @@ int i2c_del_adapter(struct i2c_adapter *adap)
302 /* detach any active clients. This must be done first, because 499 /* detach any active clients. This must be done first, because
303 * it can fail; in which case we give up. */ 500 * it can fail; in which case we give up. */
304 list_for_each_safe(item, _n, &adap->clients) { 501 list_for_each_safe(item, _n, &adap->clients) {
502 struct i2c_driver *driver;
503
305 client = list_entry(item, struct i2c_client, list); 504 client = list_entry(item, struct i2c_client, list);
505 driver = client->driver;
506
507 /* new style, follow standard driver model */
508 if (!driver || is_newstyle_driver(driver)) {
509 i2c_unregister_device(client);
510 continue;
511 }
306 512
307 if ((res=client->driver->detach_client(client))) { 513 /* legacy drivers create and remove clients themselves */
514 if ((res = driver->detach_client(client))) {
308 dev_err(&adap->dev, "detach_client failed for client " 515 dev_err(&adap->dev, "detach_client failed for client "
309 "[%s] at address 0x%02x\n", client->name, 516 "[%s] at address 0x%02x\n", client->name,
310 client->addr); 517 client->addr);
@@ -314,17 +521,13 @@ int i2c_del_adapter(struct i2c_adapter *adap)
314 521
315 /* clean up the sysfs representation */ 522 /* clean up the sysfs representation */
316 init_completion(&adap->dev_released); 523 init_completion(&adap->dev_released);
317 init_completion(&adap->class_dev_released);
318 class_device_unregister(&adap->class_dev);
319 device_remove_file(&adap->dev, &dev_attr_name);
320 device_unregister(&adap->dev); 524 device_unregister(&adap->dev);
321 list_del(&adap->list); 525 list_del(&adap->list);
322 526
323 /* wait for sysfs to drop all references */ 527 /* wait for sysfs to drop all references */
324 wait_for_completion(&adap->dev_released); 528 wait_for_completion(&adap->dev_released);
325 wait_for_completion(&adap->class_dev_released);
326 529
327 /* free dynamically allocated bus id */ 530 /* free bus id */
328 idr_remove(&i2c_adapter_idr, adap->nr); 531 idr_remove(&i2c_adapter_idr, adap->nr);
329 532
330 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); 533 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name);
@@ -333,24 +536,42 @@ int i2c_del_adapter(struct i2c_adapter *adap)
333 mutex_unlock(&core_lists); 536 mutex_unlock(&core_lists);
334 return res; 537 return res;
335} 538}
539EXPORT_SYMBOL(i2c_del_adapter);
540
336 541
542/* ------------------------------------------------------------------------- */
337 543
338/* ----- 544/*
339 * What follows is the "upwards" interface: commands for talking to clients, 545 * An i2c_driver is used with one or more i2c_client (device) nodes to access
340 * which implement the functions to access the physical information of the 546 * i2c slave chips, on a bus instance associated with some i2c_adapter. There
341 * chips. 547 * are two models for binding the driver to its device: "new style" drivers
548 * follow the standard Linux driver model and just respond to probe() calls
549 * issued if the driver core sees they match(); "legacy" drivers create device
550 * nodes themselves.
342 */ 551 */
343 552
344int i2c_register_driver(struct module *owner, struct i2c_driver *driver) 553int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
345{ 554{
346 struct list_head *item;
347 struct i2c_adapter *adapter;
348 int res; 555 int res;
349 556
557 /* new style driver methods can't mix with legacy ones */
558 if (is_newstyle_driver(driver)) {
559 if (driver->attach_adapter || driver->detach_adapter
560 || driver->detach_client) {
561 printk(KERN_WARNING
562 "i2c-core: driver [%s] is confused\n",
563 driver->driver.name);
564 return -EINVAL;
565 }
566 }
567
350 /* add the driver to the list of i2c drivers in the driver core */ 568 /* add the driver to the list of i2c drivers in the driver core */
351 driver->driver.owner = owner; 569 driver->driver.owner = owner;
352 driver->driver.bus = &i2c_bus_type; 570 driver->driver.bus = &i2c_bus_type;
353 571
572 /* for new style drivers, when registration returns the driver core
573 * will have called probe() for all matching-but-unbound devices.
574 */
354 res = driver_register(&driver->driver); 575 res = driver_register(&driver->driver);
355 if (res) 576 if (res)
356 return res; 577 return res;
@@ -360,10 +581,11 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
360 list_add_tail(&driver->list,&drivers); 581 list_add_tail(&driver->list,&drivers);
361 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); 582 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
362 583
363 /* now look for instances of driver on our adapters */ 584 /* legacy drivers scan i2c busses directly */
364 if (driver->attach_adapter) { 585 if (driver->attach_adapter) {
365 list_for_each(item,&adapters) { 586 struct i2c_adapter *adapter;
366 adapter = list_entry(item, struct i2c_adapter, list); 587
588 list_for_each_entry(adapter, &adapters, list) {
367 driver->attach_adapter(adapter); 589 driver->attach_adapter(adapter);
368 } 590 }
369 } 591 }
@@ -373,16 +595,22 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
373} 595}
374EXPORT_SYMBOL(i2c_register_driver); 596EXPORT_SYMBOL(i2c_register_driver);
375 597
376int i2c_del_driver(struct i2c_driver *driver) 598/**
599 * i2c_del_driver - unregister I2C driver
600 * @driver: the driver being unregistered
601 */
602void i2c_del_driver(struct i2c_driver *driver)
377{ 603{
378 struct list_head *item1, *item2, *_n; 604 struct list_head *item1, *item2, *_n;
379 struct i2c_client *client; 605 struct i2c_client *client;
380 struct i2c_adapter *adap; 606 struct i2c_adapter *adap;
381 607
382 int res = 0;
383
384 mutex_lock(&core_lists); 608 mutex_lock(&core_lists);
385 609
610 /* new-style driver? */
611 if (is_newstyle_driver(driver))
612 goto unregister;
613
386 /* Have a look at each adapter, if clients of this driver are still 614 /* Have a look at each adapter, if clients of this driver are still
387 * attached. If so, detach them to be able to kill the driver 615 * attached. If so, detach them to be able to kill the driver
388 * afterwards. 616 * afterwards.
@@ -390,11 +618,10 @@ int i2c_del_driver(struct i2c_driver *driver)
390 list_for_each(item1,&adapters) { 618 list_for_each(item1,&adapters) {
391 adap = list_entry(item1, struct i2c_adapter, list); 619 adap = list_entry(item1, struct i2c_adapter, list);
392 if (driver->detach_adapter) { 620 if (driver->detach_adapter) {
393 if ((res = driver->detach_adapter(adap))) { 621 if (driver->detach_adapter(adap)) {
394 dev_err(&adap->dev, "detach_adapter failed " 622 dev_err(&adap->dev, "detach_adapter failed "
395 "for driver [%s]\n", 623 "for driver [%s]\n",
396 driver->driver.name); 624 driver->driver.name);
397 goto out_unlock;
398 } 625 }
399 } else { 626 } else {
400 list_for_each_safe(item2, _n, &adap->clients) { 627 list_for_each_safe(item2, _n, &adap->clients) {
@@ -404,25 +631,26 @@ int i2c_del_driver(struct i2c_driver *driver)
404 dev_dbg(&adap->dev, "detaching client [%s] " 631 dev_dbg(&adap->dev, "detaching client [%s] "
405 "at 0x%02x\n", client->name, 632 "at 0x%02x\n", client->name,
406 client->addr); 633 client->addr);
407 if ((res = driver->detach_client(client))) { 634 if (driver->detach_client(client)) {
408 dev_err(&adap->dev, "detach_client " 635 dev_err(&adap->dev, "detach_client "
409 "failed for client [%s] at " 636 "failed for client [%s] at "
410 "0x%02x\n", client->name, 637 "0x%02x\n", client->name,
411 client->addr); 638 client->addr);
412 goto out_unlock;
413 } 639 }
414 } 640 }
415 } 641 }
416 } 642 }
417 643
644 unregister:
418 driver_unregister(&driver->driver); 645 driver_unregister(&driver->driver);
419 list_del(&driver->list); 646 list_del(&driver->list);
420 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); 647 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
421 648
422 out_unlock:
423 mutex_unlock(&core_lists); 649 mutex_unlock(&core_lists);
424 return 0;
425} 650}
651EXPORT_SYMBOL(i2c_del_driver);
652
653/* ------------------------------------------------------------------------- */
426 654
427static int __i2c_check_addr(struct i2c_adapter *adapter, unsigned int addr) 655static int __i2c_check_addr(struct i2c_adapter *adapter, unsigned int addr)
428{ 656{
@@ -447,6 +675,7 @@ int i2c_check_addr(struct i2c_adapter *adapter, int addr)
447 675
448 return rval; 676 return rval;
449} 677}
678EXPORT_SYMBOL(i2c_check_addr);
450 679
451int i2c_attach_client(struct i2c_client *client) 680int i2c_attach_client(struct i2c_client *client)
452{ 681{
@@ -463,9 +692,15 @@ int i2c_attach_client(struct i2c_client *client)
463 client->usage_count = 0; 692 client->usage_count = 0;
464 693
465 client->dev.parent = &client->adapter->dev; 694 client->dev.parent = &client->adapter->dev;
466 client->dev.driver = &client->driver->driver;
467 client->dev.bus = &i2c_bus_type; 695 client->dev.bus = &i2c_bus_type;
468 client->dev.release = &i2c_client_release; 696
697 if (client->driver)
698 client->dev.driver = &client->driver->driver;
699
700 if (client->driver && !is_newstyle_driver(client->driver))
701 client->dev.release = i2c_client_release;
702 else
703 client->dev.release = i2c_client_dev_release;
469 704
470 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), 705 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
471 "%d-%04x", i2c_adapter_id(adapter), client->addr); 706 "%d-%04x", i2c_adapter_id(adapter), client->addr);
@@ -474,9 +709,6 @@ int i2c_attach_client(struct i2c_client *client)
474 res = device_register(&client->dev); 709 res = device_register(&client->dev);
475 if (res) 710 if (res)
476 goto out_list; 711 goto out_list;
477 res = device_create_file(&client->dev, &dev_attr_client_name);
478 if (res)
479 goto out_unregister;
480 mutex_unlock(&adapter->clist_lock); 712 mutex_unlock(&adapter->clist_lock);
481 713
482 if (adapter->client_register) { 714 if (adapter->client_register) {
@@ -489,10 +721,6 @@ int i2c_attach_client(struct i2c_client *client)
489 721
490 return 0; 722 return 0;
491 723
492out_unregister:
493 init_completion(&client->released); /* Needed? */
494 device_unregister(&client->dev);
495 wait_for_completion(&client->released);
496out_list: 724out_list:
497 list_del(&client->list); 725 list_del(&client->list);
498 dev_err(&adapter->dev, "Failed to attach i2c client %s at 0x%02x " 726 dev_err(&adapter->dev, "Failed to attach i2c client %s at 0x%02x "
@@ -501,7 +729,7 @@ out_unlock:
501 mutex_unlock(&adapter->clist_lock); 729 mutex_unlock(&adapter->clist_lock);
502 return res; 730 return res;
503} 731}
504 732EXPORT_SYMBOL(i2c_attach_client);
505 733
506int i2c_detach_client(struct i2c_client *client) 734int i2c_detach_client(struct i2c_client *client)
507{ 735{
@@ -527,7 +755,6 @@ int i2c_detach_client(struct i2c_client *client)
527 mutex_lock(&adapter->clist_lock); 755 mutex_lock(&adapter->clist_lock);
528 list_del(&client->list); 756 list_del(&client->list);
529 init_completion(&client->released); 757 init_completion(&client->released);
530 device_remove_file(&client->dev, &dev_attr_client_name);
531 device_unregister(&client->dev); 758 device_unregister(&client->dev);
532 mutex_unlock(&adapter->clist_lock); 759 mutex_unlock(&adapter->clist_lock);
533 wait_for_completion(&client->released); 760 wait_for_completion(&client->released);
@@ -535,6 +762,7 @@ int i2c_detach_client(struct i2c_client *client)
535 out: 762 out:
536 return res; 763 return res;
537} 764}
765EXPORT_SYMBOL(i2c_detach_client);
538 766
539static int i2c_inc_use_client(struct i2c_client *client) 767static int i2c_inc_use_client(struct i2c_client *client)
540{ 768{
@@ -567,6 +795,7 @@ int i2c_use_client(struct i2c_client *client)
567 795
568 return 0; 796 return 0;
569} 797}
798EXPORT_SYMBOL(i2c_use_client);
570 799
571int i2c_release_client(struct i2c_client *client) 800int i2c_release_client(struct i2c_client *client)
572{ 801{
@@ -581,6 +810,7 @@ int i2c_release_client(struct i2c_client *client)
581 810
582 return 0; 811 return 0;
583} 812}
813EXPORT_SYMBOL(i2c_release_client);
584 814
585void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) 815void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg)
586{ 816{
@@ -601,6 +831,7 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg)
601 } 831 }
602 mutex_unlock(&adap->clist_lock); 832 mutex_unlock(&adap->clist_lock);
603} 833}
834EXPORT_SYMBOL(i2c_clients_command);
604 835
605static int __init i2c_init(void) 836static int __init i2c_init(void)
606{ 837{
@@ -609,16 +840,12 @@ static int __init i2c_init(void)
609 retval = bus_register(&i2c_bus_type); 840 retval = bus_register(&i2c_bus_type);
610 if (retval) 841 if (retval)
611 return retval; 842 return retval;
612 retval = driver_register(&i2c_adapter_driver);
613 if (retval)
614 return retval;
615 return class_register(&i2c_adapter_class); 843 return class_register(&i2c_adapter_class);
616} 844}
617 845
618static void __exit i2c_exit(void) 846static void __exit i2c_exit(void)
619{ 847{
620 class_unregister(&i2c_adapter_class); 848 class_unregister(&i2c_adapter_class);
621 driver_unregister(&i2c_adapter_driver);
622 bus_unregister(&i2c_bus_type); 849 bus_unregister(&i2c_bus_type);
623} 850}
624 851
@@ -638,8 +865,9 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
638#ifdef DEBUG 865#ifdef DEBUG
639 for (ret = 0; ret < num; ret++) { 866 for (ret = 0; ret < num; ret++) {
640 dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, " 867 dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
641 "len=%d\n", ret, msgs[ret].flags & I2C_M_RD ? 868 "len=%d%s\n", ret, (msgs[ret].flags & I2C_M_RD)
642 'R' : 'W', msgs[ret].addr, msgs[ret].len); 869 ? 'R' : 'W', msgs[ret].addr, msgs[ret].len,
870 (msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
643 } 871 }
644#endif 872#endif
645 873
@@ -653,6 +881,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
653 return -ENOSYS; 881 return -ENOSYS;
654 } 882 }
655} 883}
884EXPORT_SYMBOL(i2c_transfer);
656 885
657int i2c_master_send(struct i2c_client *client,const char *buf ,int count) 886int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
658{ 887{
@@ -671,6 +900,7 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
671 transmitted, else error code. */ 900 transmitted, else error code. */
672 return (ret == 1) ? count : ret; 901 return (ret == 1) ? count : ret;
673} 902}
903EXPORT_SYMBOL(i2c_master_send);
674 904
675int i2c_master_recv(struct i2c_client *client, char *buf ,int count) 905int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
676{ 906{
@@ -690,7 +920,7 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
690 transmitted, else error code. */ 920 transmitted, else error code. */
691 return (ret == 1) ? count : ret; 921 return (ret == 1) ? count : ret;
692} 922}
693 923EXPORT_SYMBOL(i2c_master_recv);
694 924
695int i2c_control(struct i2c_client *client, 925int i2c_control(struct i2c_client *client,
696 unsigned int cmd, unsigned long arg) 926 unsigned int cmd, unsigned long arg)
@@ -712,6 +942,7 @@ int i2c_control(struct i2c_client *client,
712 } 942 }
713 return ret; 943 return ret;
714} 944}
945EXPORT_SYMBOL(i2c_control);
715 946
716/* ---------------------------------------------------- 947/* ----------------------------------------------------
717 * the i2c address scanning function 948 * the i2c address scanning function
@@ -853,6 +1084,70 @@ int i2c_probe(struct i2c_adapter *adapter,
853 1084
854 return 0; 1085 return 0;
855} 1086}
1087EXPORT_SYMBOL(i2c_probe);
1088
1089struct i2c_client *
1090i2c_new_probed_device(struct i2c_adapter *adap,
1091 struct i2c_board_info *info,
1092 unsigned short const *addr_list)
1093{
1094 int i;
1095
1096 /* Stop here if the bus doesn't support probing */
1097 if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) {
1098 dev_err(&adap->dev, "Probing not supported\n");
1099 return NULL;
1100 }
1101
1102 mutex_lock(&adap->clist_lock);
1103 for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) {
1104 /* Check address validity */
1105 if (addr_list[i] < 0x03 || addr_list[i] > 0x77) {
1106 dev_warn(&adap->dev, "Invalid 7-bit address "
1107 "0x%02x\n", addr_list[i]);
1108 continue;
1109 }
1110
1111 /* Check address availability */
1112 if (__i2c_check_addr(adap, addr_list[i])) {
1113 dev_dbg(&adap->dev, "Address 0x%02x already in "
1114 "use, not probing\n", addr_list[i]);
1115 continue;
1116 }
1117
1118 /* Test address responsiveness
1119 The default probe method is a quick write, but it is known
1120 to corrupt the 24RF08 EEPROMs due to a state machine bug,
1121 and could also irreversibly write-protect some EEPROMs, so
1122 for address ranges 0x30-0x37 and 0x50-0x5f, we use a byte
1123 read instead. Also, some bus drivers don't implement
1124 quick write, so we fallback to a byte read it that case
1125 too. */
1126 if ((addr_list[i] & ~0x07) == 0x30
1127 || (addr_list[i] & ~0x0f) == 0x50
1128 || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) {
1129 if (i2c_smbus_xfer(adap, addr_list[i], 0,
1130 I2C_SMBUS_READ, 0,
1131 I2C_SMBUS_BYTE, NULL) >= 0)
1132 break;
1133 } else {
1134 if (i2c_smbus_xfer(adap, addr_list[i], 0,
1135 I2C_SMBUS_WRITE, 0,
1136 I2C_SMBUS_QUICK, NULL) >= 0)
1137 break;
1138 }
1139 }
1140 mutex_unlock(&adap->clist_lock);
1141
1142 if (addr_list[i] == I2C_CLIENT_END) {
1143 dev_dbg(&adap->dev, "Probing failed, no device found\n");
1144 return NULL;
1145 }
1146
1147 info->addr = addr_list[i];
1148 return i2c_new_device(adap, info);
1149}
1150EXPORT_SYMBOL_GPL(i2c_new_probed_device);
856 1151
857struct i2c_adapter* i2c_get_adapter(int id) 1152struct i2c_adapter* i2c_get_adapter(int id)
858{ 1153{
@@ -866,11 +1161,13 @@ struct i2c_adapter* i2c_get_adapter(int id)
866 mutex_unlock(&core_lists); 1161 mutex_unlock(&core_lists);
867 return adapter; 1162 return adapter;
868} 1163}
1164EXPORT_SYMBOL(i2c_get_adapter);
869 1165
870void i2c_put_adapter(struct i2c_adapter *adap) 1166void i2c_put_adapter(struct i2c_adapter *adap)
871{ 1167{
872 module_put(adap->owner); 1168 module_put(adap->owner);
873} 1169}
1170EXPORT_SYMBOL(i2c_put_adapter);
874 1171
875/* The SMBus parts */ 1172/* The SMBus parts */
876 1173
@@ -939,6 +1236,7 @@ s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value)
939 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1236 return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
940 value,0,I2C_SMBUS_QUICK,NULL); 1237 value,0,I2C_SMBUS_QUICK,NULL);
941} 1238}
1239EXPORT_SYMBOL(i2c_smbus_write_quick);
942 1240
943s32 i2c_smbus_read_byte(struct i2c_client *client) 1241s32 i2c_smbus_read_byte(struct i2c_client *client)
944{ 1242{
@@ -949,12 +1247,14 @@ s32 i2c_smbus_read_byte(struct i2c_client *client)
949 else 1247 else
950 return data.byte; 1248 return data.byte;
951} 1249}
1250EXPORT_SYMBOL(i2c_smbus_read_byte);
952 1251
953s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) 1252s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value)
954{ 1253{
955 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1254 return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
956 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); 1255 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
957} 1256}
1257EXPORT_SYMBOL(i2c_smbus_write_byte);
958 1258
959s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) 1259s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command)
960{ 1260{
@@ -965,6 +1265,7 @@ s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command)
965 else 1265 else
966 return data.byte; 1266 return data.byte;
967} 1267}
1268EXPORT_SYMBOL(i2c_smbus_read_byte_data);
968 1269
969s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) 1270s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value)
970{ 1271{
@@ -974,6 +1275,7 @@ s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value)
974 I2C_SMBUS_WRITE,command, 1275 I2C_SMBUS_WRITE,command,
975 I2C_SMBUS_BYTE_DATA,&data); 1276 I2C_SMBUS_BYTE_DATA,&data);
976} 1277}
1278EXPORT_SYMBOL(i2c_smbus_write_byte_data);
977 1279
978s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command) 1280s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command)
979{ 1281{
@@ -984,6 +1286,7 @@ s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command)
984 else 1286 else
985 return data.word; 1287 return data.word;
986} 1288}
1289EXPORT_SYMBOL(i2c_smbus_read_word_data);
987 1290
988s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) 1291s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value)
989{ 1292{
@@ -993,6 +1296,23 @@ s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value)
993 I2C_SMBUS_WRITE,command, 1296 I2C_SMBUS_WRITE,command,
994 I2C_SMBUS_WORD_DATA,&data); 1297 I2C_SMBUS_WORD_DATA,&data);
995} 1298}
1299EXPORT_SYMBOL(i2c_smbus_write_word_data);
1300
1301/* Returns the number of read bytes */
1302s32 i2c_smbus_read_block_data(struct i2c_client *client, u8 command,
1303 u8 *values)
1304{
1305 union i2c_smbus_data data;
1306
1307 if (i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1308 I2C_SMBUS_READ, command,
1309 I2C_SMBUS_BLOCK_DATA, &data))
1310 return -1;
1311
1312 memcpy(values, &data.block[1], data.block[0]);
1313 return data.block[0];
1314}
1315EXPORT_SYMBOL(i2c_smbus_read_block_data);
996 1316
997s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, 1317s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
998 u8 length, const u8 *values) 1318 u8 length, const u8 *values)
@@ -1007,6 +1327,7 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
1007 I2C_SMBUS_WRITE,command, 1327 I2C_SMBUS_WRITE,command,
1008 I2C_SMBUS_BLOCK_DATA,&data); 1328 I2C_SMBUS_BLOCK_DATA,&data);
1009} 1329}
1330EXPORT_SYMBOL(i2c_smbus_write_block_data);
1010 1331
1011/* Returns the number of read bytes */ 1332/* Returns the number of read bytes */
1012s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) 1333s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values)
@@ -1021,6 +1342,7 @@ s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *val
1021 memcpy(values, &data.block[1], data.block[0]); 1342 memcpy(values, &data.block[1], data.block[0]);
1022 return data.block[0]; 1343 return data.block[0];
1023} 1344}
1345EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data);
1024 1346
1025s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, 1347s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command,
1026 u8 length, const u8 *values) 1348 u8 length, const u8 *values)
@@ -1035,6 +1357,7 @@ s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command,
1035 I2C_SMBUS_WRITE, command, 1357 I2C_SMBUS_WRITE, command,
1036 I2C_SMBUS_I2C_BLOCK_DATA, &data); 1358 I2C_SMBUS_I2C_BLOCK_DATA, &data);
1037} 1359}
1360EXPORT_SYMBOL(i2c_smbus_write_i2c_block_data);
1038 1361
1039/* Simulate a SMBus command using the i2c protocol 1362/* Simulate a SMBus command using the i2c protocol
1040 No checking of parameters is done! */ 1363 No checking of parameters is done! */
@@ -1098,9 +1421,9 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1098 break; 1421 break;
1099 case I2C_SMBUS_BLOCK_DATA: 1422 case I2C_SMBUS_BLOCK_DATA:
1100 if (read_write == I2C_SMBUS_READ) { 1423 if (read_write == I2C_SMBUS_READ) {
1101 dev_err(&adapter->dev, "Block read not supported " 1424 msg[1].flags |= I2C_M_RECV_LEN;
1102 "under I2C emulation!\n"); 1425 msg[1].len = 1; /* block length will be added by
1103 return -1; 1426 the underlying bus driver */
1104 } else { 1427 } else {
1105 msg[0].len = data->block[0] + 2; 1428 msg[0].len = data->block[0] + 2;
1106 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) { 1429 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) {
@@ -1114,9 +1437,21 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1114 } 1437 }
1115 break; 1438 break;
1116 case I2C_SMBUS_BLOCK_PROC_CALL: 1439 case I2C_SMBUS_BLOCK_PROC_CALL:
1117 dev_dbg(&adapter->dev, "Block process call not supported " 1440 num = 2; /* Another special case */
1118 "under I2C emulation!\n"); 1441 read_write = I2C_SMBUS_READ;
1119 return -1; 1442 if (data->block[0] > I2C_SMBUS_BLOCK_MAX) {
1443 dev_err(&adapter->dev, "%s called with invalid "
1444 "block proc call size (%d)\n", __FUNCTION__,
1445 data->block[0]);
1446 return -1;
1447 }
1448 msg[0].len = data->block[0] + 2;
1449 for (i = 1; i < msg[0].len; i++)
1450 msgbuf0[i] = data->block[i-1];
1451 msg[1].flags |= I2C_M_RECV_LEN;
1452 msg[1].len = 1; /* block length will be added by
1453 the underlying bus driver */
1454 break;
1120 case I2C_SMBUS_I2C_BLOCK_DATA: 1455 case I2C_SMBUS_I2C_BLOCK_DATA:
1121 if (read_write == I2C_SMBUS_READ) { 1456 if (read_write == I2C_SMBUS_READ) {
1122 msg[1].len = I2C_SMBUS_BLOCK_MAX; 1457 msg[1].len = I2C_SMBUS_BLOCK_MAX;
@@ -1180,6 +1515,11 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1180 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) 1515 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
1181 data->block[i+1] = msgbuf1[i]; 1516 data->block[i+1] = msgbuf1[i];
1182 break; 1517 break;
1518 case I2C_SMBUS_BLOCK_DATA:
1519 case I2C_SMBUS_BLOCK_PROC_CALL:
1520 for (i = 0; i < msgbuf1[0] + 1; i++)
1521 data->block[i] = msgbuf1[i];
1522 break;
1183 } 1523 }
1184 return 0; 1524 return 0;
1185} 1525}
@@ -1204,43 +1544,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1204 1544
1205 return res; 1545 return res;
1206} 1546}
1207
1208
1209/* Next four are needed by i2c-isa */
1210EXPORT_SYMBOL_GPL(i2c_adapter_dev_release);
1211EXPORT_SYMBOL_GPL(i2c_adapter_driver);
1212EXPORT_SYMBOL_GPL(i2c_adapter_class);
1213EXPORT_SYMBOL_GPL(i2c_bus_type);
1214
1215EXPORT_SYMBOL(i2c_add_adapter);
1216EXPORT_SYMBOL(i2c_del_adapter);
1217EXPORT_SYMBOL(i2c_del_driver);
1218EXPORT_SYMBOL(i2c_attach_client);
1219EXPORT_SYMBOL(i2c_detach_client);
1220EXPORT_SYMBOL(i2c_use_client);
1221EXPORT_SYMBOL(i2c_release_client);
1222EXPORT_SYMBOL(i2c_clients_command);
1223EXPORT_SYMBOL(i2c_check_addr);
1224
1225EXPORT_SYMBOL(i2c_master_send);
1226EXPORT_SYMBOL(i2c_master_recv);
1227EXPORT_SYMBOL(i2c_control);
1228EXPORT_SYMBOL(i2c_transfer);
1229EXPORT_SYMBOL(i2c_get_adapter);
1230EXPORT_SYMBOL(i2c_put_adapter);
1231EXPORT_SYMBOL(i2c_probe);
1232
1233EXPORT_SYMBOL(i2c_smbus_xfer); 1547EXPORT_SYMBOL(i2c_smbus_xfer);
1234EXPORT_SYMBOL(i2c_smbus_write_quick);
1235EXPORT_SYMBOL(i2c_smbus_read_byte);
1236EXPORT_SYMBOL(i2c_smbus_write_byte);
1237EXPORT_SYMBOL(i2c_smbus_read_byte_data);
1238EXPORT_SYMBOL(i2c_smbus_write_byte_data);
1239EXPORT_SYMBOL(i2c_smbus_read_word_data);
1240EXPORT_SYMBOL(i2c_smbus_write_word_data);
1241EXPORT_SYMBOL(i2c_smbus_write_block_data);
1242EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data);
1243EXPORT_SYMBOL(i2c_smbus_write_i2c_block_data);
1244 1548
1245MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 1549MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
1246MODULE_DESCRIPTION("I2C-Bus main module"); 1550MODULE_DESCRIPTION("I2C-Bus main module");
diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h
new file mode 100644
index 000000000000..cd5bff874855
--- /dev/null
+++ b/drivers/i2c/i2c-core.h
@@ -0,0 +1,31 @@
1/*
2 * i2c-core.h - interfaces internal to the I2C framework
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19struct i2c_devinfo {
20 struct list_head list;
21 int busnum;
22 struct i2c_board_info board_info;
23};
24
25/* board_lock protects board_list and first_dynamic_bus_num.
26 * only i2c core components are allowed to use these symbols.
27 */
28extern struct mutex __i2c_board_lock;
29extern struct list_head __i2c_board_list;
30extern int __i2c_first_dynamic_bus_num;
31
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index 556455fbfa2b..5e8efc89255a 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -730,7 +730,7 @@ static int speed_cris_ide(ide_drive_t *drive, u8 speed)
730 730
731 if (speed >= XFER_PIO_0 && speed <= XFER_PIO_4) { 731 if (speed >= XFER_PIO_0 && speed <= XFER_PIO_4) {
732 tune_cris_ide(drive, speed - XFER_PIO_0); 732 tune_cris_ide(drive, speed - XFER_PIO_0);
733 return 0; 733 return ide_config_drive_speed(drive, speed);
734 } 734 }
735 735
736 switch(speed) 736 switch(speed)
@@ -760,7 +760,8 @@ static int speed_cris_ide(ide_drive_t *drive, u8 speed)
760 hold = ATA_DMA2_HOLD; 760 hold = ATA_DMA2_HOLD;
761 break; 761 break;
762 default: 762 default:
763 return 0; 763 BUG();
764 break;
764 } 765 }
765 766
766 if (speed >= XFER_UDMA_0) 767 if (speed >= XFER_UDMA_0)
@@ -768,7 +769,7 @@ static int speed_cris_ide(ide_drive_t *drive, u8 speed)
768 else 769 else
769 cris_ide_set_speed(TYPE_DMA, 0, strobe, hold); 770 cris_ide_set_speed(TYPE_DMA, 0, strobe, hold);
770 771
771 return 0; 772 return ide_config_drive_speed(drive, speed);
772} 773}
773 774
774void __init 775void __init
@@ -821,7 +822,6 @@ init_e100_ide (void)
821 hwif->udma_four = 0; 822 hwif->udma_four = 0;
822 hwif->ultra_mask = cris_ultra_mask; 823 hwif->ultra_mask = cris_ultra_mask;
823 hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */ 824 hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
824 hwif->swdma_mask = 0x07; /* Singleword DMA 0-2 */
825 hwif->autodma = 1; 825 hwif->autodma = 1;
826 hwif->drives[0].autodma = 1; 826 hwif->drives[0].autodma = 1;
827 hwif->drives[1].autodma = 1; 827 hwif->drives[1].autodma = 1;
@@ -1010,7 +1010,6 @@ static int cris_config_drive_for_dma (ide_drive_t *drive)
1010 return 0; 1010 return 0;
1011 1011
1012 speed_cris_ide(drive, speed); 1012 speed_cris_ide(drive, speed);
1013 ide_config_drive_speed(drive, speed);
1014 1013
1015 return ide_dma_enable(drive); 1014 return ide_dma_enable(drive);
1016} 1015}
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index b08c37c9f956..c6522a64d7ec 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -401,6 +401,7 @@ static struct pcmcia_device_id ide_ids[] = {
401 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 401 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
402 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), 402 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
403 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), 403 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
404 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2),
404 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 405 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
405 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 406 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
406 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), 407 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 990eafe5ea11..73bdf64dbbfc 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * linux/drivers/ide/pci/aec62xx.c Version 0.11 March 27, 2002 2 * linux/drivers/ide/pci/aec62xx.c Version 0.21 Apr 21, 2007
3 * 3 *
4 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
5 * 6 *
6 */ 7 */
7 8
@@ -193,18 +194,8 @@ static int config_chipset_for_dma (ide_drive_t *drive)
193 194
194static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio) 195static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)
195{ 196{
196 u8 speed = 0; 197 pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
197 u8 new_pio = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL); 198 (void) aec62xx_tune_chipset(drive, pio + XFER_PIO_0);
198
199 switch(pio) {
200 case 5: speed = new_pio; break;
201 case 4: speed = XFER_PIO_4; break;
202 case 3: speed = XFER_PIO_3; break;
203 case 2: speed = XFER_PIO_2; break;
204 case 1: speed = XFER_PIO_1; break;
205 default: speed = XFER_PIO_0; break;
206 }
207 (void) aec62xx_tune_chipset(drive, speed);
208} 199}
209 200
210static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive) 201static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
@@ -213,7 +204,7 @@ static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
213 return 0; 204 return 0;
214 205
215 if (ide_use_fast_pio(drive)) 206 if (ide_use_fast_pio(drive))
216 aec62xx_tune_drive(drive, 5); 207 aec62xx_tune_drive(drive, 255);
217 208
218 return -1; 209 return -1;
219} 210}
@@ -288,11 +279,10 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
288 279
289 hwif->ultra_mask = 0x7f; 280 hwif->ultra_mask = 0x7f;
290 hwif->mwdma_mask = 0x07; 281 hwif->mwdma_mask = 0x07;
291 hwif->swdma_mask = 0x07;
292 282
293 hwif->ide_dma_check = &aec62xx_config_drive_xfer_rate; 283 hwif->ide_dma_check = &aec62xx_config_drive_xfer_rate;
294 hwif->ide_dma_lostirq = &aec62xx_irq_timeout; 284 hwif->ide_dma_lostirq = &aec62xx_irq_timeout;
295 hwif->ide_dma_timeout = &aec62xx_irq_timeout; 285
296 if (!noautodma) 286 if (!noautodma)
297 hwif->autodma = 1; 287 hwif->autodma = 1;
298 hwif->drives[0].autodma = hwif->autodma; 288 hwif->drives[0].autodma = hwif->autodma;
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 83e0aa65a431..946a12746cb5 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -534,7 +534,7 @@ static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
534 struct hd_driveid *id = drive->id; 534 struct hd_driveid *id = drive->id;
535 535
536 if ((m5229_revision<=0x20) && (drive->media!=ide_disk)) 536 if ((m5229_revision<=0x20) && (drive->media!=ide_disk))
537 goto no_dma_set; 537 goto ata_pio;
538 538
539 drive->init_speed = 0; 539 drive->init_speed = 0;
540 540
@@ -555,20 +555,19 @@ try_dma_modes:
555 (id->dma_1word & hwif->swdma_mask)) { 555 (id->dma_1word & hwif->swdma_mask)) {
556 /* Force if Capable regular DMA modes */ 556 /* Force if Capable regular DMA modes */
557 if (!config_chipset_for_dma(drive)) 557 if (!config_chipset_for_dma(drive))
558 goto no_dma_set; 558 goto ata_pio;
559 } 559 }
560 } else if (__ide_dma_good_drive(drive) && 560 } else if (__ide_dma_good_drive(drive) &&
561 (id->eide_dma_time < 150)) { 561 (id->eide_dma_time < 150)) {
562 /* Consult the list of known "good" drives */ 562 /* Consult the list of known "good" drives */
563 if (!config_chipset_for_dma(drive)) 563 if (!config_chipset_for_dma(drive))
564 goto no_dma_set; 564 goto ata_pio;
565 } else { 565 } else {
566 goto ata_pio; 566 goto ata_pio;
567 } 567 }
568 } else { 568 } else {
569ata_pio: 569ata_pio:
570 hwif->tuneproc(drive, 255); 570 hwif->tuneproc(drive, 255);
571no_dma_set:
572 return -1; 571 return -1;
573 } 572 }
574 573
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 561197f7b5bb..77f51ab6d439 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -1,10 +1,7 @@
1/* $Id: cmd64x.c,v 1.21 2000/01/30 23:23:16 1/*
2 * 2 * linux/drivers/ide/pci/cmd64x.c Version 1.47 Mar 19, 2007
3 * linux/drivers/ide/pci/cmd64x.c Version 1.42 Feb 8, 2007
4 * 3 *
5 * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines. 4 * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines.
6 * Note, this driver is not used at all on other systems because
7 * there the "BIOS" has done all of the following already.
8 * Due to massive hardware bugs, UltraDMA is only supported 5 * Due to massive hardware bugs, UltraDMA is only supported
9 * on the 646U2 and not on the 646U. 6 * on the 646U2 and not on the 646U.
10 * 7 *
@@ -39,11 +36,12 @@
39 * CMD64x specific registers definition. 36 * CMD64x specific registers definition.
40 */ 37 */
41#define CFR 0x50 38#define CFR 0x50
42#define CFR_INTR_CH0 0x02 39#define CFR_INTR_CH0 0x04
43#define CNTRL 0x51 40#define CNTRL 0x51
44#define CNTRL_DIS_RA0 0x40 41#define CNTRL_ENA_1ST 0x04
45#define CNTRL_DIS_RA1 0x80 42#define CNTRL_ENA_2ND 0x08
46#define CNTRL_ENA_2ND 0x08 43#define CNTRL_DIS_RA0 0x40
44#define CNTRL_DIS_RA1 0x80
47 45
48#define CMDTIM 0x52 46#define CMDTIM 0x52
49#define ARTTIM0 0x53 47#define ARTTIM0 0x53
@@ -90,86 +88,67 @@ static int n_cmd_devs;
90static char * print_cmd64x_get_info (char *buf, struct pci_dev *dev, int index) 88static char * print_cmd64x_get_info (char *buf, struct pci_dev *dev, int index)
91{ 89{
92 char *p = buf; 90 char *p = buf;
93
94 u8 reg53 = 0, reg54 = 0, reg55 = 0, reg56 = 0; /* primary */
95 u8 reg57 = 0, reg58 = 0, reg5b; /* secondary */
96 u8 reg72 = 0, reg73 = 0; /* primary */ 91 u8 reg72 = 0, reg73 = 0; /* primary */
97 u8 reg7a = 0, reg7b = 0; /* secondary */ 92 u8 reg7a = 0, reg7b = 0; /* secondary */
98 u8 reg50 = 0, reg71 = 0; /* extra */ 93 u8 reg50 = 1, reg51 = 1, reg57 = 0, reg71 = 0; /* extra */
94 u8 rev = 0;
99 95
100 p += sprintf(p, "\nController: %d\n", index); 96 p += sprintf(p, "\nController: %d\n", index);
101 p += sprintf(p, "CMD%x Chipset.\n", dev->device); 97 p += sprintf(p, "PCI-%x Chipset.\n", dev->device);
98
102 (void) pci_read_config_byte(dev, CFR, &reg50); 99 (void) pci_read_config_byte(dev, CFR, &reg50);
103 (void) pci_read_config_byte(dev, ARTTIM0, &reg53); 100 (void) pci_read_config_byte(dev, CNTRL, &reg51);
104 (void) pci_read_config_byte(dev, DRWTIM0, &reg54); 101 (void) pci_read_config_byte(dev, ARTTIM23, &reg57);
105 (void) pci_read_config_byte(dev, ARTTIM1, &reg55);
106 (void) pci_read_config_byte(dev, DRWTIM1, &reg56);
107 (void) pci_read_config_byte(dev, ARTTIM2, &reg57);
108 (void) pci_read_config_byte(dev, DRWTIM2, &reg58);
109 (void) pci_read_config_byte(dev, DRWTIM3, &reg5b);
110 (void) pci_read_config_byte(dev, MRDMODE, &reg71); 102 (void) pci_read_config_byte(dev, MRDMODE, &reg71);
111 (void) pci_read_config_byte(dev, BMIDESR0, &reg72); 103 (void) pci_read_config_byte(dev, BMIDESR0, &reg72);
112 (void) pci_read_config_byte(dev, UDIDETCR0, &reg73); 104 (void) pci_read_config_byte(dev, UDIDETCR0, &reg73);
113 (void) pci_read_config_byte(dev, BMIDESR1, &reg7a); 105 (void) pci_read_config_byte(dev, BMIDESR1, &reg7a);
114 (void) pci_read_config_byte(dev, UDIDETCR1, &reg7b); 106 (void) pci_read_config_byte(dev, UDIDETCR1, &reg7b);
115 107
116 p += sprintf(p, "--------------- Primary Channel " 108 /* PCI0643/6 originally didn't have the primary channel enable bit */
117 "---------------- Secondary Channel " 109 (void) pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
118 "-------------\n"); 110 if ((dev->device == PCI_DEVICE_ID_CMD_643) ||
119 p += sprintf(p, " %sabled " 111 (dev->device == PCI_DEVICE_ID_CMD_646 && rev < 3))
120 " %sabled\n", 112 reg51 |= CNTRL_ENA_1ST;
121 (reg72&0x80)?"dis":" en", 113
122 (reg7a&0x80)?"dis":" en"); 114 p += sprintf(p, "---------------- Primary Channel "
123 p += sprintf(p, "--------------- drive0 " 115 "---------------- Secondary Channel ------------\n");
124 "--------- drive1 -------- drive0 " 116 p += sprintf(p, " %s %s\n",
125 "---------- drive1 ------\n"); 117 (reg51 & CNTRL_ENA_1ST) ? "enabled " : "disabled",
126 p += sprintf(p, "DMA enabled: %s %s" 118 (reg51 & CNTRL_ENA_2ND) ? "enabled " : "disabled");
127 " %s %s\n", 119 p += sprintf(p, "---------------- drive0 --------- drive1 "
128 (reg72&0x20)?"yes":"no ", (reg72&0x40)?"yes":"no ", 120 "-------- drive0 --------- drive1 ------\n");
129 (reg7a&0x20)?"yes":"no ", (reg7a&0x40)?"yes":"no "); 121 p += sprintf(p, "DMA enabled: %s %s"
130 122 " %s %s\n",
131 p += sprintf(p, "DMA Mode: %s(%s) %s(%s)", 123 (reg72 & 0x20) ? "yes" : "no ", (reg72 & 0x40) ? "yes" : "no ",
132 (reg72&0x20)?((reg73&0x01)?"UDMA":" DMA"):" PIO", 124 (reg7a & 0x20) ? "yes" : "no ", (reg7a & 0x40) ? "yes" : "no ");
133 (reg72&0x20)?( 125 p += sprintf(p, "UltraDMA mode: %s (%c) %s (%c)",
134 ((reg73&0x30)==0x30)?(((reg73&0x35)==0x35)?"3":"0"): 126 ( reg73 & 0x01) ? " on" : "off",
135 ((reg73&0x20)==0x20)?(((reg73&0x25)==0x25)?"3":"1"): 127 ((reg73 & 0x30) == 0x30) ? ((reg73 & 0x04) ? '3' : '0') :
136 ((reg73&0x10)==0x10)?(((reg73&0x15)==0x15)?"4":"2"): 128 ((reg73 & 0x30) == 0x20) ? ((reg73 & 0x04) ? '3' : '1') :
137 ((reg73&0x00)==0x00)?(((reg73&0x05)==0x05)?"5":"2"): 129 ((reg73 & 0x30) == 0x10) ? ((reg73 & 0x04) ? '4' : '2') :
138 "X"):"?", 130 ((reg73 & 0x30) == 0x00) ? ((reg73 & 0x04) ? '5' : '2') : '?',
139 (reg72&0x40)?((reg73&0x02)?"UDMA":" DMA"):" PIO", 131 ( reg73 & 0x02) ? " on" : "off",
140 (reg72&0x40)?( 132 ((reg73 & 0xC0) == 0xC0) ? ((reg73 & 0x08) ? '3' : '0') :
141 ((reg73&0xC0)==0xC0)?(((reg73&0xC5)==0xC5)?"3":"0"): 133 ((reg73 & 0xC0) == 0x80) ? ((reg73 & 0x08) ? '3' : '1') :
142 ((reg73&0x80)==0x80)?(((reg73&0x85)==0x85)?"3":"1"): 134 ((reg73 & 0xC0) == 0x40) ? ((reg73 & 0x08) ? '4' : '2') :
143 ((reg73&0x40)==0x40)?(((reg73&0x4A)==0x4A)?"4":"2"): 135 ((reg73 & 0xC0) == 0x00) ? ((reg73 & 0x08) ? '5' : '2') : '?');
144 ((reg73&0x00)==0x00)?(((reg73&0x0A)==0x0A)?"5":"2"): 136 p += sprintf(p, " %s (%c) %s (%c)\n",
145 "X"):"?"); 137 ( reg7b & 0x01) ? " on" : "off",
146 p += sprintf(p, " %s(%s) %s(%s)\n", 138 ((reg7b & 0x30) == 0x30) ? ((reg7b & 0x04) ? '3' : '0') :
147 (reg7a&0x20)?((reg7b&0x01)?"UDMA":" DMA"):" PIO", 139 ((reg7b & 0x30) == 0x20) ? ((reg7b & 0x04) ? '3' : '1') :
148 (reg7a&0x20)?( 140 ((reg7b & 0x30) == 0x10) ? ((reg7b & 0x04) ? '4' : '2') :
149 ((reg7b&0x30)==0x30)?(((reg7b&0x35)==0x35)?"3":"0"): 141 ((reg7b & 0x30) == 0x00) ? ((reg7b & 0x04) ? '5' : '2') : '?',
150 ((reg7b&0x20)==0x20)?(((reg7b&0x25)==0x25)?"3":"1"): 142 ( reg7b & 0x02) ? " on" : "off",
151 ((reg7b&0x10)==0x10)?(((reg7b&0x15)==0x15)?"4":"2"): 143 ((reg7b & 0xC0) == 0xC0) ? ((reg7b & 0x08) ? '3' : '0') :
152 ((reg7b&0x00)==0x00)?(((reg7b&0x05)==0x05)?"5":"2"): 144 ((reg7b & 0xC0) == 0x80) ? ((reg7b & 0x08) ? '3' : '1') :
153 "X"):"?", 145 ((reg7b & 0xC0) == 0x40) ? ((reg7b & 0x08) ? '4' : '2') :
154 (reg7a&0x40)?((reg7b&0x02)?"UDMA":" DMA"):" PIO", 146 ((reg7b & 0xC0) == 0x00) ? ((reg7b & 0x08) ? '5' : '2') : '?');
155 (reg7a&0x40)?( 147 p += sprintf(p, "Interrupt: %s, %s %s, %s\n",
156 ((reg7b&0xC0)==0xC0)?(((reg7b&0xC5)==0xC5)?"3":"0"): 148 (reg71 & MRDMODE_BLK_CH0 ) ? "blocked" : "enabled",
157 ((reg7b&0x80)==0x80)?(((reg7b&0x85)==0x85)?"3":"1"): 149 (reg50 & CFR_INTR_CH0 ) ? "pending" : "clear ",
158 ((reg7b&0x40)==0x40)?(((reg7b&0x4A)==0x4A)?"4":"2"): 150 (reg71 & MRDMODE_BLK_CH1 ) ? "blocked" : "enabled",
159 ((reg7b&0x00)==0x00)?(((reg7b&0x0A)==0x0A)?"5":"2"): 151 (reg57 & ARTTIM23_INTR_CH1) ? "pending" : "clear ");
160 "X"):"?" );
161 p += sprintf(p, "PIO Mode: %s %s"
162 " %s %s\n",
163 "?", "?", "?", "?");
164 p += sprintf(p, " %s %s\n",
165 (reg50 & CFR_INTR_CH0) ? "interrupting" : "polling ",
166 (reg57 & ARTTIM23_INTR_CH1) ? "interrupting" : "polling");
167 p += sprintf(p, " %s %s\n",
168 (reg71 & MRDMODE_INTR_CH0) ? "pending" : "clear ",
169 (reg71 & MRDMODE_INTR_CH1) ? "pending" : "clear");
170 p += sprintf(p, " %s %s\n",
171 (reg71 & MRDMODE_BLK_CH0) ? "blocked" : "enabled",
172 (reg71 & MRDMODE_BLK_CH1) ? "blocked" : "enabled");
173 152
174 return (char *)p; 153 return (char *)p;
175} 154}
@@ -179,7 +158,6 @@ static int cmd64x_get_info (char *buffer, char **addr, off_t offset, int count)
179 char *p = buffer; 158 char *p = buffer;
180 int i; 159 int i;
181 160
182 p += sprintf(p, "\n");
183 for (i = 0; i < n_cmd_devs; i++) { 161 for (i = 0; i < n_cmd_devs; i++) {
184 struct pci_dev *dev = cmd_devs[i]; 162 struct pci_dev *dev = cmd_devs[i];
185 p = print_cmd64x_get_info(p, dev, i); 163 p = print_cmd64x_get_info(p, dev, i);
@@ -195,116 +173,103 @@ static u8 quantize_timing(int timing, int quant)
195} 173}
196 174
197/* 175/*
198 * This routine writes the prepared setup/active/recovery counts 176 * This routine calculates active/recovery counts and then writes them into
199 * for a drive into the cmd646 chipset registers to active them. 177 * the chipset registers.
200 */ 178 */
201static void program_drive_counts (ide_drive_t *drive, int setup_count, int active_count, int recovery_count) 179static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time)
202{ 180{
203 unsigned long flags; 181 struct pci_dev *dev = HWIF(drive)->pci_dev;
204 struct pci_dev *dev = HWIF(drive)->pci_dev; 182 int clock_time = 1000 / system_bus_clock();
205 ide_drive_t *drives = HWIF(drive)->drives; 183 u8 cycle_count, active_count, recovery_count, drwtim;
206 u8 temp_b; 184 static const u8 recovery_values[] =
207 static const u8 setup_counts[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0};
208 static const u8 recovery_counts[] =
209 {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; 185 {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0};
210 static const u8 arttim_regs[2][2] = { 186 static const u8 drwtim_regs[4] = {DRWTIM0, DRWTIM1, DRWTIM2, DRWTIM3};
211 { ARTTIM0, ARTTIM1 }, 187
212 { ARTTIM23, ARTTIM23 } 188 cmdprintk("program_cycle_times parameters: total=%d, active=%d\n",
213 }; 189 cycle_time, active_time);
214 static const u8 drwtim_regs[2][2] = { 190
215 { DRWTIM0, DRWTIM1 }, 191 cycle_count = quantize_timing( cycle_time, clock_time);
216 { DRWTIM2, DRWTIM3 } 192 active_count = quantize_timing(active_time, clock_time);
217 }; 193 recovery_count = cycle_count - active_count;
218 int channel = (int) HWIF(drive)->channel; 194
219 int slave = (drives != drive); /* Is this really the best way to determine this?? */
220
221 cmdprintk("program_drive_count parameters = s(%d),a(%d),r(%d),p(%d)\n",
222 setup_count, active_count, recovery_count, drive->present);
223 /* 195 /*
224 * Set up address setup count registers. 196 * In case we've got too long recovery phase, try to lengthen
225 * Primary interface has individual count/timing registers for 197 * the active phase
226 * each drive. Secondary interface has one common set of registers,
227 * for address setup so we merge these timings, using the slowest
228 * value.
229 */ 198 */
230 if (channel) { 199 if (recovery_count > 16) {
231 drive->drive_data = setup_count; 200 active_count += recovery_count - 16;
232 setup_count = max(drives[0].drive_data, 201 recovery_count = 16;
233 drives[1].drive_data);
234 cmdprintk("Secondary interface, setup_count = %d\n",
235 setup_count);
236 } 202 }
203 if (active_count > 16) /* shouldn't actually happen... */
204 active_count = 16;
205
206 cmdprintk("Final counts: total=%d, active=%d, recovery=%d\n",
207 cycle_count, active_count, recovery_count);
237 208
238 /* 209 /*
239 * Convert values to internal chipset representation 210 * Convert values to internal chipset representation
240 */ 211 */
241 setup_count = (setup_count > 5) ? 0xc0 : (int) setup_counts[setup_count]; 212 recovery_count = recovery_values[recovery_count];
242 active_count &= 0xf; /* Remember, max value is 16 */ 213 active_count &= 0x0f;
243 recovery_count = (int) recovery_counts[recovery_count];
244 214
245 cmdprintk("Final values = %d,%d,%d\n", 215 /* Program the active/recovery counts into the DRWTIM register */
246 setup_count, active_count, recovery_count); 216 drwtim = (active_count << 4) | recovery_count;
247 217 (void) pci_write_config_byte(dev, drwtim_regs[drive->dn], drwtim);
248 /* 218 cmdprintk("Write 0x%02x to reg 0x%x\n", drwtim, drwtim_regs[drive->dn]);
249 * Now that everything is ready, program the new timings
250 */
251 local_irq_save(flags);
252 /*
253 * Program the address_setup clocks into ARTTIM reg,
254 * and then the active/recovery counts into the DRWTIM reg
255 */
256 (void) pci_read_config_byte(dev, arttim_regs[channel][slave], &temp_b);
257 (void) pci_write_config_byte(dev, arttim_regs[channel][slave],
258 ((u8) setup_count) | (temp_b & 0x3f));
259 (void) pci_write_config_byte(dev, drwtim_regs[channel][slave],
260 (u8) ((active_count << 4) | recovery_count));
261 cmdprintk ("Write %x to %x\n",
262 ((u8) setup_count) | (temp_b & 0x3f),
263 arttim_regs[channel][slave]);
264 cmdprintk ("Write %x to %x\n",
265 (u8) ((active_count << 4) | recovery_count),
266 drwtim_regs[channel][slave]);
267 local_irq_restore(flags);
268} 219}
269 220
270/* 221/*
271 * This routine selects drive's best PIO mode, calculates setup/active/recovery 222 * This routine selects drive's best PIO mode and writes into the chipset
272 * counts, and then writes them into the chipset registers. 223 * registers setup/active/recovery timings.
273 */ 224 */
274static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted) 225static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted)
275{ 226{
276 int setup_time, active_time, cycle_time; 227 ide_hwif_t *hwif = HWIF(drive);
277 u8 cycle_count, setup_count, active_count, recovery_count; 228 struct pci_dev *dev = hwif->pci_dev;
278 u8 pio_mode;
279 int clock_time = 1000 / system_bus_clock();
280 ide_pio_data_t pio; 229 ide_pio_data_t pio;
281 230 u8 pio_mode, setup_count, arttim = 0;
231 static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0};
232 static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23};
282 pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, &pio); 233 pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, &pio);
283 cycle_time = pio.cycle_time;
284 234
285 setup_time = ide_pio_timings[pio_mode].setup_time; 235 cmdprintk("%s: PIO mode wanted %d, selected %d (%d ns)%s\n",
286 active_time = ide_pio_timings[pio_mode].active_time; 236 drive->name, mode_wanted, pio_mode, pio.cycle_time,
237 pio.overridden ? " (overriding vendor mode)" : "");
287 238
288 setup_count = quantize_timing( setup_time, clock_time); 239 program_cycle_times(drive, pio.cycle_time,
289 cycle_count = quantize_timing( cycle_time, clock_time); 240 ide_pio_timings[pio_mode].active_time);
290 active_count = quantize_timing(active_time, clock_time);
291 241
292 recovery_count = cycle_count - active_count; 242 setup_count = quantize_timing(ide_pio_timings[pio_mode].setup_time,
293 /* program_drive_counts() takes care of zero recovery cycles */ 243 1000 / system_bus_clock());
294 if (recovery_count > 16) { 244
295 active_count += recovery_count - 16; 245 /*
296 recovery_count = 16; 246 * The primary channel has individual address setup timing registers
247 * for each drive and the hardware selects the slowest timing itself.
248 * The secondary channel has one common register and we have to select
249 * the slowest address setup timing ourselves.
250 */
251 if (hwif->channel) {
252 ide_drive_t *drives = hwif->drives;
253
254 drive->drive_data = setup_count;
255 setup_count = max(drives[0].drive_data, drives[1].drive_data);
297 } 256 }
298 if (active_count > 16)
299 active_count = 16; /* maximum allowed by cmd64x */
300 257
301 program_drive_counts (drive, setup_count, active_count, recovery_count); 258 if (setup_count > 5) /* shouldn't actually happen... */
259 setup_count = 5;
260 cmdprintk("Final address setup count: %d\n", setup_count);
302 261
303 cmdprintk("%s: PIO mode wanted %d, selected %d (%dns)%s, " 262 /*
304 "clocks=%d/%d/%d\n", 263 * Program the address setup clocks into the ARTTIM registers.
305 drive->name, mode_wanted, pio_mode, cycle_time, 264 * Avoid clearing the secondary channel's interrupt bit.
306 pio.overridden ? " (overriding vendor mode)" : "", 265 */
307 setup_count, active_count, recovery_count); 266 (void) pci_read_config_byte (dev, arttim_regs[drive->dn], &arttim);
267 if (hwif->channel)
268 arttim &= ~ARTTIM23_INTR_CH1;
269 arttim &= ~0xc0;
270 arttim |= setup_values[setup_count];
271 (void) pci_write_config_byte(dev, arttim_regs[drive->dn], arttim);
272 cmdprintk("Write 0x%02x to reg 0x%x\n", arttim, arttim_regs[drive->dn]);
308 273
309 return pio_mode; 274 return pio_mode;
310} 275}
@@ -376,61 +341,64 @@ static u8 cmd64x_ratemask (ide_drive_t *drive)
376 return mode; 341 return mode;
377} 342}
378 343
379static int cmd64x_tune_chipset (ide_drive_t *drive, u8 xferspeed) 344static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed)
380{ 345{
381 ide_hwif_t *hwif = HWIF(drive); 346 ide_hwif_t *hwif = HWIF(drive);
382 struct pci_dev *dev = hwif->pci_dev; 347 struct pci_dev *dev = hwif->pci_dev;
348 u8 unit = drive->dn & 0x01;
349 u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0;
383 350
384 u8 unit = (drive->select.b.unit & 0x01); 351 speed = ide_rate_filter(cmd64x_ratemask(drive), speed);
385 u8 regU = 0, pciU = (hwif->channel) ? UDIDETCR1 : UDIDETCR0;
386 u8 regD = 0, pciD = (hwif->channel) ? BMIDESR1 : BMIDESR0;
387
388 u8 speed = ide_rate_filter(cmd64x_ratemask(drive), xferspeed);
389 352
390 if (speed >= XFER_SW_DMA_0) { 353 if (speed >= XFER_SW_DMA_0) {
391 (void) pci_read_config_byte(dev, pciD, &regD);
392 (void) pci_read_config_byte(dev, pciU, &regU); 354 (void) pci_read_config_byte(dev, pciU, &regU);
393 regD &= ~(unit ? 0x40 : 0x20);
394 regU &= ~(unit ? 0xCA : 0x35); 355 regU &= ~(unit ? 0xCA : 0x35);
395 (void) pci_write_config_byte(dev, pciD, regD);
396 (void) pci_write_config_byte(dev, pciU, regU);
397 (void) pci_read_config_byte(dev, pciD, &regD);
398 (void) pci_read_config_byte(dev, pciU, &regU);
399 } 356 }
400 357
401 switch(speed) { 358 switch(speed) {
402 case XFER_UDMA_5: regU |= (unit ? 0x0A : 0x05); break; 359 case XFER_UDMA_5:
403 case XFER_UDMA_4: regU |= (unit ? 0x4A : 0x15); break; 360 regU |= unit ? 0x0A : 0x05;
404 case XFER_UDMA_3: regU |= (unit ? 0x8A : 0x25); break; 361 break;
405 case XFER_UDMA_2: regU |= (unit ? 0x42 : 0x11); break; 362 case XFER_UDMA_4:
406 case XFER_UDMA_1: regU |= (unit ? 0x82 : 0x21); break; 363 regU |= unit ? 0x4A : 0x15;
407 case XFER_UDMA_0: regU |= (unit ? 0xC2 : 0x31); break; 364 break;
408 case XFER_MW_DMA_2: regD |= (unit ? 0x40 : 0x10); break; 365 case XFER_UDMA_3:
409 case XFER_MW_DMA_1: regD |= (unit ? 0x80 : 0x20); break; 366 regU |= unit ? 0x8A : 0x25;
410 case XFER_MW_DMA_0: regD |= (unit ? 0xC0 : 0x30); break; 367 break;
411 case XFER_SW_DMA_2: regD |= (unit ? 0x40 : 0x10); break; 368 case XFER_UDMA_2:
412 case XFER_SW_DMA_1: regD |= (unit ? 0x80 : 0x20); break; 369 regU |= unit ? 0x42 : 0x11;
413 case XFER_SW_DMA_0: regD |= (unit ? 0xC0 : 0x30); break; 370 break;
414 case XFER_PIO_5: 371 case XFER_UDMA_1:
415 case XFER_PIO_4: 372 regU |= unit ? 0x82 : 0x21;
416 case XFER_PIO_3: 373 break;
417 case XFER_PIO_2: 374 case XFER_UDMA_0:
418 case XFER_PIO_1: 375 regU |= unit ? 0xC2 : 0x31;
419 case XFER_PIO_0: 376 break;
420 (void) cmd64x_tune_pio(drive, speed - XFER_PIO_0); 377 case XFER_MW_DMA_2:
421 break; 378 program_cycle_times(drive, 120, 70);
422 379 break;
423 default: 380 case XFER_MW_DMA_1:
424 return 1; 381 program_cycle_times(drive, 150, 80);
382 break;
383 case XFER_MW_DMA_0:
384 program_cycle_times(drive, 480, 215);
385 break;
386 case XFER_PIO_5:
387 case XFER_PIO_4:
388 case XFER_PIO_3:
389 case XFER_PIO_2:
390 case XFER_PIO_1:
391 case XFER_PIO_0:
392 (void) cmd64x_tune_pio(drive, speed - XFER_PIO_0);
393 break;
394 default:
395 return 1;
425 } 396 }
426 397
427 if (speed >= XFER_SW_DMA_0) { 398 if (speed >= XFER_SW_DMA_0)
428 (void) pci_write_config_byte(dev, pciU, regU); 399 (void) pci_write_config_byte(dev, pciU, regU);
429 regD |= (unit ? 0x40 : 0x20);
430 (void) pci_write_config_byte(dev, pciD, regD);
431 }
432 400
433 return (ide_config_drive_speed(drive, speed)); 401 return ide_config_drive_speed(drive, speed);
434} 402}
435 403
436static int config_chipset_for_dma (ide_drive_t *drive) 404static int config_chipset_for_dma (ide_drive_t *drive)
@@ -457,67 +425,80 @@ static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
457 return -1; 425 return -1;
458} 426}
459 427
460static int cmd64x_alt_dma_status (struct pci_dev *dev) 428static int cmd648_ide_dma_end (ide_drive_t *drive)
461{ 429{
462 switch(dev->device) { 430 ide_hwif_t *hwif = HWIF(drive);
463 case PCI_DEVICE_ID_CMD_648: 431 int err = __ide_dma_end(drive);
464 case PCI_DEVICE_ID_CMD_649: 432 u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 :
465 return 1; 433 MRDMODE_INTR_CH0;
466 default: 434 u8 mrdmode = inb(hwif->dma_master + 0x01);
467 break; 435
468 } 436 /* clear the interrupt bit */
469 return 0; 437 outb(mrdmode | irq_mask, hwif->dma_master + 0x01);
438
439 return err;
470} 440}
471 441
472static int cmd64x_ide_dma_end (ide_drive_t *drive) 442static int cmd64x_ide_dma_end (ide_drive_t *drive)
473{ 443{
474 u8 dma_stat = 0, dma_cmd = 0;
475 ide_hwif_t *hwif = HWIF(drive); 444 ide_hwif_t *hwif = HWIF(drive);
476 struct pci_dev *dev = hwif->pci_dev; 445 struct pci_dev *dev = hwif->pci_dev;
446 int irq_reg = hwif->channel ? ARTTIM23 : CFR;
447 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 :
448 CFR_INTR_CH0;
449 u8 irq_stat = 0;
450 int err = __ide_dma_end(drive);
477 451
478 drive->waiting_for_dma = 0; 452 (void) pci_read_config_byte(dev, irq_reg, &irq_stat);
479 /* read DMA command state */ 453 /* clear the interrupt bit */
480 dma_cmd = inb(hwif->dma_command); 454 (void) pci_write_config_byte(dev, irq_reg, irq_stat | irq_mask);
481 /* stop DMA */ 455
482 outb(dma_cmd & ~1, hwif->dma_command); 456 return err;
483 /* get DMA status */ 457}
484 dma_stat = inb(hwif->dma_status); 458
485 /* clear the INTR & ERROR bits */ 459static int cmd648_ide_dma_test_irq (ide_drive_t *drive)
486 outb(dma_stat | 6, hwif->dma_status); 460{
487 if (cmd64x_alt_dma_status(dev)) { 461 ide_hwif_t *hwif = HWIF(drive);
488 u8 dma_intr = 0; 462 u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 :
489 u8 dma_mask = (hwif->channel) ? ARTTIM23_INTR_CH1 : 463 MRDMODE_INTR_CH0;
490 CFR_INTR_CH0; 464 u8 dma_stat = inb(hwif->dma_status);
491 u8 dma_reg = (hwif->channel) ? ARTTIM2 : CFR; 465 u8 mrdmode = inb(hwif->dma_master + 0x01);
492 (void) pci_read_config_byte(dev, dma_reg, &dma_intr); 466
493 /* clear the INTR bit */ 467#ifdef DEBUG
494 (void) pci_write_config_byte(dev, dma_reg, dma_intr|dma_mask); 468 printk("%s: dma_stat: 0x%02x mrdmode: 0x%02x irq_mask: 0x%02x\n",
495 } 469 drive->name, dma_stat, mrdmode, irq_mask);
496 /* purge DMA mappings */ 470#endif
497 ide_destroy_dmatable(drive); 471 if (!(mrdmode & irq_mask))
498 /* verify good DMA status */ 472 return 0;
499 return (dma_stat & 7) != 4; 473
474 /* return 1 if INTR asserted */
475 if (dma_stat & 4)
476 return 1;
477
478 return 0;
500} 479}
501 480
502static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) 481static int cmd64x_ide_dma_test_irq (ide_drive_t *drive)
503{ 482{
504 ide_hwif_t *hwif = HWIF(drive); 483 ide_hwif_t *hwif = HWIF(drive);
505 struct pci_dev *dev = hwif->pci_dev; 484 struct pci_dev *dev = hwif->pci_dev;
506 u8 dma_alt_stat = 0, mask = (hwif->channel) ? MRDMODE_INTR_CH1 : 485 int irq_reg = hwif->channel ? ARTTIM23 : CFR;
507 MRDMODE_INTR_CH0; 486 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 :
508 u8 dma_stat = inb(hwif->dma_status); 487 CFR_INTR_CH0;
488 u8 dma_stat = inb(hwif->dma_status);
489 u8 irq_stat = 0;
490
491 (void) pci_read_config_byte(dev, irq_reg, &irq_stat);
509 492
510 (void) pci_read_config_byte(dev, MRDMODE, &dma_alt_stat);
511#ifdef DEBUG 493#ifdef DEBUG
512 printk("%s: dma_stat: 0x%02x dma_alt_stat: " 494 printk("%s: dma_stat: 0x%02x irq_stat: 0x%02x irq_mask: 0x%02x\n",
513 "0x%02x mask: 0x%02x\n", drive->name, 495 drive->name, dma_stat, irq_stat, irq_mask);
514 dma_stat, dma_alt_stat, mask);
515#endif 496#endif
516 if (!(dma_alt_stat & mask)) 497 if (!(irq_stat & irq_mask))
517 return 0; 498 return 0;
518 499
519 /* return 1 if INTR asserted */ 500 /* return 1 if INTR asserted */
520 if ((dma_stat & 4) == 4) 501 if (dma_stat & 4)
521 return 1; 502 return 1;
522 503
523 return 0; 504 return 0;
@@ -665,7 +646,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
665 646
666 hwif->ultra_mask = 0x3f; 647 hwif->ultra_mask = 0x3f;
667 hwif->mwdma_mask = 0x07; 648 hwif->mwdma_mask = 0x07;
668 hwif->swdma_mask = 0x07;
669 649
670 if (dev->device == PCI_DEVICE_ID_CMD_643) 650 if (dev->device == PCI_DEVICE_ID_CMD_643)
671 hwif->ultra_mask = 0x80; 651 hwif->ultra_mask = 0x80;
@@ -678,17 +658,25 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
678 if (!(hwif->udma_four)) 658 if (!(hwif->udma_four))
679 hwif->udma_four = ata66_cmd64x(hwif); 659 hwif->udma_four = ata66_cmd64x(hwif);
680 660
681 if (dev->device == PCI_DEVICE_ID_CMD_646) { 661 switch(dev->device) {
662 case PCI_DEVICE_ID_CMD_648:
663 case PCI_DEVICE_ID_CMD_649:
664 alt_irq_bits:
665 hwif->ide_dma_end = &cmd648_ide_dma_end;
666 hwif->ide_dma_test_irq = &cmd648_ide_dma_test_irq;
667 break;
668 case PCI_DEVICE_ID_CMD_646:
682 hwif->chipset = ide_cmd646; 669 hwif->chipset = ide_cmd646;
683 if (class_rev == 0x01) { 670 if (class_rev == 0x01) {
684 hwif->ide_dma_end = &cmd646_1_ide_dma_end; 671 hwif->ide_dma_end = &cmd646_1_ide_dma_end;
685 } else { 672 break;
686 hwif->ide_dma_end = &cmd64x_ide_dma_end; 673 } else if (class_rev >= 0x03)
687 hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq; 674 goto alt_irq_bits;
688 } 675 /* fall thru */
689 } else { 676 default:
690 hwif->ide_dma_end = &cmd64x_ide_dma_end; 677 hwif->ide_dma_end = &cmd64x_ide_dma_end;
691 hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq; 678 hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq;
679 break;
692 } 680 }
693 681
694 682
@@ -698,42 +686,75 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
698 hwif->drives[1].autodma = hwif->autodma; 686 hwif->drives[1].autodma = hwif->autodma;
699} 687}
700 688
689static int __devinit init_setup_cmd64x(struct pci_dev *dev, ide_pci_device_t *d)
690{
691 return ide_setup_pci_device(dev, d);
692}
693
694static int __devinit init_setup_cmd646(struct pci_dev *dev, ide_pci_device_t *d)
695{
696 u8 rev = 0;
697
698 /*
699 * The original PCI0646 didn't have the primary channel enable bit,
700 * it appeared starting with PCI0646U (i.e. revision ID 3).
701 */
702 pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
703 if (rev < 3)
704 d->enablebits[0].reg = 0;
705
706 return ide_setup_pci_device(dev, d);
707}
708
701static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { 709static ide_pci_device_t cmd64x_chipsets[] __devinitdata = {
702 { /* 0 */ 710 { /* 0 */
703 .name = "CMD643", 711 .name = "CMD643",
712 .init_setup = init_setup_cmd64x,
704 .init_chipset = init_chipset_cmd64x, 713 .init_chipset = init_chipset_cmd64x,
705 .init_hwif = init_hwif_cmd64x, 714 .init_hwif = init_hwif_cmd64x,
706 .channels = 2, 715 .channels = 2,
707 .autodma = AUTODMA, 716 .autodma = AUTODMA,
717 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}},
708 .bootable = ON_BOARD, 718 .bootable = ON_BOARD,
709 },{ /* 1 */ 719 },{ /* 1 */
710 .name = "CMD646", 720 .name = "CMD646",
721 .init_setup = init_setup_cmd646,
711 .init_chipset = init_chipset_cmd64x, 722 .init_chipset = init_chipset_cmd64x,
712 .init_hwif = init_hwif_cmd64x, 723 .init_hwif = init_hwif_cmd64x,
713 .channels = 2, 724 .channels = 2,
714 .autodma = AUTODMA, 725 .autodma = AUTODMA,
715 .enablebits = {{0x00,0x00,0x00}, {0x51,0x80,0x80}}, 726 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
716 .bootable = ON_BOARD, 727 .bootable = ON_BOARD,
717 },{ /* 2 */ 728 },{ /* 2 */
718 .name = "CMD648", 729 .name = "CMD648",
730 .init_setup = init_setup_cmd64x,
719 .init_chipset = init_chipset_cmd64x, 731 .init_chipset = init_chipset_cmd64x,
720 .init_hwif = init_hwif_cmd64x, 732 .init_hwif = init_hwif_cmd64x,
721 .channels = 2, 733 .channels = 2,
722 .autodma = AUTODMA, 734 .autodma = AUTODMA,
735 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
723 .bootable = ON_BOARD, 736 .bootable = ON_BOARD,
724 },{ /* 3 */ 737 },{ /* 3 */
725 .name = "CMD649", 738 .name = "CMD649",
739 .init_setup = init_setup_cmd64x,
726 .init_chipset = init_chipset_cmd64x, 740 .init_chipset = init_chipset_cmd64x,
727 .init_hwif = init_hwif_cmd64x, 741 .init_hwif = init_hwif_cmd64x,
728 .channels = 2, 742 .channels = 2,
729 .autodma = AUTODMA, 743 .autodma = AUTODMA,
744 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
730 .bootable = ON_BOARD, 745 .bootable = ON_BOARD,
731 } 746 }
732}; 747};
733 748
749/*
750 * We may have to modify enablebits for PCI0646, so we'd better pass
751 * a local copy of the ide_pci_device_t structure down the call chain...
752 */
734static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 753static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
735{ 754{
736 return ide_setup_pci_device(dev, &cmd64x_chipsets[id->driver_data]); 755 ide_pci_device_t d = cmd64x_chipsets[id->driver_data];
756
757 return d.init_setup(dev, &d);
737} 758}
738 759
739static struct pci_device_id cmd64x_pci_tbl[] = { 760static struct pci_device_id cmd64x_pci_tbl[] = {
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index ab6fa271aeb3..cf9d344d19f8 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/hpt366.c Version 1.02 Apr 18, 2007 2 * linux/drivers/ide/pci/hpt366.c Version 1.03 May 4, 2007
3 * 3 *
4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
@@ -1527,7 +1527,12 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
1527 if (rev > 2) 1527 if (rev > 2)
1528 goto init_single; 1528 goto init_single;
1529 1529
1530 /*
1531 * HPT36x chips are single channel and
1532 * do not seem to have the channel enable bit...
1533 */
1530 d->channels = 1; 1534 d->channels = 1;
1535 d->enablebits[0].reg = 0;
1531 1536
1532 if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) { 1537 if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) {
1533 u8 pin1 = 0, pin2 = 0; 1538 u8 pin1 = 0, pin2 = 0;
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index a132767f7d90..4e1254813ee0 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -1,8 +1,9 @@
1 1
2/* 2/*
3 * linux/drivers/ide/pci/it821x.c Version 0.09 December 2004 3 * linux/drivers/ide/pci/it821x.c Version 0.10 Mar 10 2007
4 * 4 *
5 * Copyright (C) 2004 Red Hat <alan@redhat.com> 5 * Copyright (C) 2004 Red Hat <alan@redhat.com>
6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
6 * 7 *
7 * May be copied or modified under the terms of the GNU General Public License 8 * May be copied or modified under the terms of the GNU General Public License
8 * Based in part on the ITE vendor provided SCSI driver. 9 * Based in part on the ITE vendor provided SCSI driver.
@@ -104,6 +105,7 @@ static int it8212_noraid;
104/** 105/**
105 * it821x_program - program the PIO/MWDMA registers 106 * it821x_program - program the PIO/MWDMA registers
106 * @drive: drive to tune 107 * @drive: drive to tune
108 * @timing: timing info
107 * 109 *
108 * Program the PIO/MWDMA timing for this channel according to the 110 * Program the PIO/MWDMA timing for this channel according to the
109 * current clock. 111 * current clock.
@@ -127,6 +129,7 @@ static void it821x_program(ide_drive_t *drive, u16 timing)
127/** 129/**
128 * it821x_program_udma - program the UDMA registers 130 * it821x_program_udma - program the UDMA registers
129 * @drive: drive to tune 131 * @drive: drive to tune
132 * @timing: timing info
130 * 133 *
131 * Program the UDMA timing for this drive according to the 134 * Program the UDMA timing for this drive according to the
132 * current clock. 135 * current clock.
@@ -153,10 +156,9 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing)
153 } 156 }
154} 157}
155 158
156
157/** 159/**
158 * it821x_clock_strategy 160 * it821x_clock_strategy
159 * @hwif: hardware interface 161 * @drive: drive to set up
160 * 162 *
161 * Select between the 50 and 66Mhz base clocks to get the best 163 * Select between the 50 and 66Mhz base clocks to get the best
162 * results for this interface. 164 * results for this interface.
@@ -182,8 +184,11 @@ static void it821x_clock_strategy(ide_drive_t *drive)
182 altclock = itdev->want[0][1]; 184 altclock = itdev->want[0][1];
183 } 185 }
184 186
185 /* Master doesn't care does the slave ? */ 187 /*
186 if(clock == ATA_ANY) 188 * if both clocks can be used for the mode with the higher priority
189 * use the clock needed by the mode with the lower priority
190 */
191 if (clock == ATA_ANY)
187 clock = altclock; 192 clock = altclock;
188 193
189 /* Nobody cares - keep the same clock */ 194 /* Nobody cares - keep the same clock */
@@ -240,37 +245,56 @@ static u8 it821x_ratemask (ide_drive_t *drive)
240} 245}
241 246
242/** 247/**
243 * it821x_tuneproc - tune a drive 248 * it821x_tunepio - tune a drive
244 * @drive: drive to tune 249 * @drive: drive to tune
245 * @mode_wanted: the target operating mode 250 * @pio: the desired PIO mode
246 *
247 * Load the timing settings for this device mode into the
248 * controller. By the time we are called the mode has been
249 * modified as neccessary to handle the absence of seperate
250 * master/slave timers for MWDMA/PIO.
251 * 251 *
252 * This code is only used in pass through mode. 252 * Try to tune the drive/host to the desired PIO mode taking into
253 * the consideration the maximum PIO mode supported by the other
254 * device on the cable.
253 */ 255 */
254 256
255static void it821x_tuneproc (ide_drive_t *drive, byte mode_wanted) 257static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
256{ 258{
257 ide_hwif_t *hwif = drive->hwif; 259 ide_hwif_t *hwif = drive->hwif;
258 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 260 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
259 int unit = drive->select.b.unit; 261 int unit = drive->select.b.unit;
262 ide_drive_t *pair = &hwif->drives[1 - unit];
260 263
261 /* Spec says 89 ref driver uses 88 */ 264 /* Spec says 89 ref driver uses 88 */
262 static u16 pio[] = { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; 265 static u16 pio[] = { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
263 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; 266 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
264 267
265 if(itdev->smart) 268 /*
266 return; 269 * Compute the best PIO mode we can for a given device. We must
270 * pick a speed that does not cause problems with the other device
271 * on the cable.
272 */
273 if (pair) {
274 u8 pair_pio = ide_get_best_pio_mode(pair, 255, 4, NULL);
275 /* trim PIO to the slowest of the master/slave */
276 if (pair_pio < set_pio)
277 set_pio = pair_pio;
278 }
279
280 if (itdev->smart)
281 goto set_drive_speed;
267 282
268 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ 283 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */
269 itdev->want[unit][1] = pio_want[mode_wanted]; 284 itdev->want[unit][1] = pio_want[set_pio];
270 itdev->want[unit][0] = 1; /* PIO is lowest priority */ 285 itdev->want[unit][0] = 1; /* PIO is lowest priority */
271 itdev->pio[unit] = pio[mode_wanted]; 286 itdev->pio[unit] = pio[set_pio];
272 it821x_clock_strategy(drive); 287 it821x_clock_strategy(drive);
273 it821x_program(drive, itdev->pio[unit]); 288 it821x_program(drive, itdev->pio[unit]);
289
290set_drive_speed:
291 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio);
292}
293
294static void it821x_tuneproc(ide_drive_t *drive, u8 pio)
295{
296 pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
297 (void)it821x_tunepio(drive, pio);
274} 298}
275 299
276/** 300/**
@@ -354,40 +378,6 @@ static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted)
354} 378}
355 379
356/** 380/**
357 * config_it821x_chipset_for_pio - set drive timings
358 * @drive: drive to tune
359 * @speed we want
360 *
361 * Compute the best pio mode we can for a given device. We must
362 * pick a speed that does not cause problems with the other device
363 * on the cable.
364 */
365
366static void config_it821x_chipset_for_pio (ide_drive_t *drive, byte set_speed)
367{
368 u8 unit = drive->select.b.unit;
369 ide_hwif_t *hwif = drive->hwif;
370 ide_drive_t *pair = &hwif->drives[1-unit];
371 u8 speed = 0, set_pio = ide_get_best_pio_mode(drive, 255, 5, NULL);
372 u8 pair_pio;
373
374 /* We have to deal with this mess in pairs */
375 if(pair != NULL) {
376 pair_pio = ide_get_best_pio_mode(pair, 255, 5, NULL);
377 /* Trim PIO to the slowest of the master/slave */
378 if(pair_pio < set_pio)
379 set_pio = pair_pio;
380 }
381 it821x_tuneproc(drive, set_pio);
382 speed = XFER_PIO_0 + set_pio;
383 /* XXX - We trim to the lowest of the pair so the other drive
384 will always be fine at this point until we do hotplug passthru */
385
386 if (set_speed)
387 (void) ide_config_drive_speed(drive, speed);
388}
389
390/**
391 * it821x_dma_read - DMA hook 381 * it821x_dma_read - DMA hook
392 * @drive: drive for DMA 382 * @drive: drive for DMA
393 * 383 *
@@ -450,15 +440,17 @@ static int it821x_tune_chipset (ide_drive_t *drive, byte xferspeed)
450 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 440 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
451 u8 speed = ide_rate_filter(it821x_ratemask(drive), xferspeed); 441 u8 speed = ide_rate_filter(it821x_ratemask(drive), xferspeed);
452 442
453 if(!itdev->smart) { 443 switch (speed) {
454 switch(speed) { 444 case XFER_PIO_4:
455 case XFER_PIO_4: 445 case XFER_PIO_3:
456 case XFER_PIO_3: 446 case XFER_PIO_2:
457 case XFER_PIO_2: 447 case XFER_PIO_1:
458 case XFER_PIO_1: 448 case XFER_PIO_0:
459 case XFER_PIO_0: 449 return it821x_tunepio(drive, speed - XFER_PIO_0);
460 it821x_tuneproc(drive, (speed - XFER_PIO_0)); 450 }
461 break; 451
452 if (itdev->smart == 0) {
453 switch (speed) {
462 /* MWDMA tuning is really hard because our MWDMA and PIO 454 /* MWDMA tuning is really hard because our MWDMA and PIO
463 timings are kept in the same place. We can switch in the 455 timings are kept in the same place. We can switch in the
464 host dma on/off callbacks */ 456 host dma on/off callbacks */
@@ -498,14 +490,12 @@ static int config_chipset_for_dma (ide_drive_t *drive)
498{ 490{
499 u8 speed = ide_dma_speed(drive, it821x_ratemask(drive)); 491 u8 speed = ide_dma_speed(drive, it821x_ratemask(drive));
500 492
501 if (speed) { 493 if (speed == 0)
502 config_it821x_chipset_for_pio(drive, 0); 494 return 0;
503 it821x_tune_chipset(drive, speed);
504 495
505 return ide_dma_enable(drive); 496 it821x_tune_chipset(drive, speed);
506 }
507 497
508 return 0; 498 return ide_dma_enable(drive);
509} 499}
510 500
511/** 501/**
@@ -523,7 +513,7 @@ static int it821x_config_drive_for_dma (ide_drive_t *drive)
523 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 513 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
524 return 0; 514 return 0;
525 515
526 config_it821x_chipset_for_pio(drive, 1); 516 it821x_tuneproc(drive, 255);
527 517
528 return -1; 518 return -1;
529} 519}
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index ace98929cc3d..2da5cbb53566 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -255,9 +255,6 @@ static int config_chipset_for_dma(ide_drive_t *drive)
255 printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name); 255 printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name);
256 } 256 }
257 257
258 if (drive->media != ide_disk && drive->media != ide_cdrom)
259 return 0;
260
261 if (id->capability & 4) { 258 if (id->capability & 4) {
262 /* 259 /*
263 * Set IORDY_EN & PREFETCH_EN (this seems to have 260 * Set IORDY_EN & PREFETCH_EN (this seems to have
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 71eccdf5f817..c0188de3cc66 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/siimage.c Version 1.11 Jan 27, 2007 2 * linux/drivers/ide/pci/siimage.c Version 1.12 Mar 10 2007
3 * 3 *
4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 5 * Copyright (C) 2003 Red Hat <alan@redhat.com>
@@ -287,11 +287,6 @@ static void config_siimage_chipset_for_pio (ide_drive_t *drive, byte set_speed)
287 (void) ide_config_drive_speed(drive, speed); 287 (void) ide_config_drive_speed(drive, speed);
288} 288}
289 289
290static void config_chipset_for_pio (ide_drive_t *drive, byte set_speed)
291{
292 config_siimage_chipset_for_pio(drive, set_speed);
293}
294
295/** 290/**
296 * siimage_tune_chipset - set controller timings 291 * siimage_tune_chipset - set controller timings
297 * @drive: Drive to set up 292 * @drive: Drive to set up
@@ -396,8 +391,6 @@ static int config_chipset_for_dma (ide_drive_t *drive)
396{ 391{
397 u8 speed = ide_dma_speed(drive, siimage_ratemask(drive)); 392 u8 speed = ide_dma_speed(drive, siimage_ratemask(drive));
398 393
399 config_chipset_for_pio(drive, !speed);
400
401 if (!speed) 394 if (!speed)
402 return 0; 395 return 0;
403 396
@@ -423,7 +416,7 @@ static int siimage_config_drive_for_dma (ide_drive_t *drive)
423 return 0; 416 return 0;
424 417
425 if (ide_use_fast_pio(drive)) 418 if (ide_use_fast_pio(drive))
426 config_chipset_for_pio(drive, 1); 419 config_siimage_chipset_for_pio(drive, 1);
427 420
428 return -1; 421 return -1;
429} 422}
@@ -1015,7 +1008,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
1015 1008
1016 hwif->ultra_mask = 0x7f; 1009 hwif->ultra_mask = 0x7f;
1017 hwif->mwdma_mask = 0x07; 1010 hwif->mwdma_mask = 0x07;
1018 hwif->swdma_mask = 0x07;
1019 1011
1020 if (!is_sata(hwif)) 1012 if (!is_sata(hwif))
1021 hwif->atapi_dma = 1; 1013 hwif->atapi_dma = 1;
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index 3a8a76fc78c7..fe3b4b91f854 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -11,6 +11,8 @@
11 * Merge in Russell's HW workarounds, fix various problems 11 * Merge in Russell's HW workarounds, fix various problems
12 * with the timing registers setup. 12 * with the timing registers setup.
13 * -- Benjamin Herrenschmidt (01/11/03) benh@kernel.crashing.org 13 * -- Benjamin Herrenschmidt (01/11/03) benh@kernel.crashing.org
14 *
15 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com>
14 */ 16 */
15 17
16#include <linux/types.h> 18#include <linux/types.h>
@@ -47,25 +49,19 @@
47#define CTRL_P0EN (1 << 0) 49#define CTRL_P0EN (1 << 0)
48 50
49/* 51/*
50 * Convert a PIO mode and cycle time to the required on/off 52 * Convert a PIO mode and cycle time to the required on/off times
51 * times for the interface. This has protection against run-away 53 * for the interface. This has protection against runaway timings.
52 * timings.
53 */ 54 */
54static unsigned int get_timing_sl82c105(ide_pio_data_t *p) 55static unsigned int get_pio_timings(ide_pio_data_t *p)
55{ 56{
56 unsigned int cmd_on; 57 unsigned int cmd_on, cmd_off;
57 unsigned int cmd_off;
58 58
59 cmd_on = (ide_pio_timings[p->pio_mode].active_time + 29) / 30; 59 cmd_on = (ide_pio_timings[p->pio_mode].active_time + 29) / 30;
60 cmd_off = (p->cycle_time - 30 * cmd_on + 29) / 30; 60 cmd_off = (p->cycle_time - 30 * cmd_on + 29) / 30;
61 61
62 if (cmd_on > 32)
63 cmd_on = 32;
64 if (cmd_on == 0) 62 if (cmd_on == 0)
65 cmd_on = 1; 63 cmd_on = 1;
66 64
67 if (cmd_off > 32)
68 cmd_off = 32;
69 if (cmd_off == 0) 65 if (cmd_off == 0)
70 cmd_off = 1; 66 cmd_off = 1;
71 67
@@ -73,100 +69,59 @@ static unsigned int get_timing_sl82c105(ide_pio_data_t *p)
73} 69}
74 70
75/* 71/*
76 * Configure the drive and chipset for PIO 72 * Configure the chipset for PIO mode.
77 */ 73 */
78static void config_for_pio(ide_drive_t *drive, int pio, int report, int chipset_only) 74static u8 sl82c105_tune_pio(ide_drive_t *drive, u8 pio)
79{ 75{
80 ide_hwif_t *hwif = HWIF(drive); 76 struct pci_dev *dev = HWIF(drive)->pci_dev;
81 struct pci_dev *dev = hwif->pci_dev; 77 int reg = 0x44 + drive->dn * 4;
82 ide_pio_data_t p; 78 ide_pio_data_t p;
83 u16 drv_ctrl = 0x909; 79 u16 drv_ctrl;
84 unsigned int xfer_mode, reg;
85 80
86 DBG(("config_for_pio(drive:%s, pio:%d, report:%d, chipset_only:%d)\n", 81 DBG(("sl82c105_tune_pio(drive:%s, pio:%u)\n", drive->name, pio));
87 drive->name, pio, report, chipset_only));
88
89 reg = (hwif->channel ? 0x4c : 0x44) + (drive->select.b.unit ? 4 : 0);
90 82
91 pio = ide_get_best_pio_mode(drive, pio, 5, &p); 83 pio = ide_get_best_pio_mode(drive, pio, 5, &p);
92 84
93 xfer_mode = XFER_PIO_0 + pio; 85 drive->drive_data = drv_ctrl = get_pio_timings(&p);
94
95 if (chipset_only || ide_config_drive_speed(drive, xfer_mode) == 0) {
96 drv_ctrl = get_timing_sl82c105(&p);
97 drive->pio_speed = xfer_mode;
98 } else
99 drive->pio_speed = XFER_PIO_0;
100 86
101 if (drive->using_dma == 0) { 87 if (!drive->using_dma) {
102 /* 88 /*
103 * If we are actually using MW DMA, then we can not 89 * If we are actually using MW DMA, then we can not
104 * reprogram the interface drive control register. 90 * reprogram the interface drive control register.
105 */ 91 */
106 pci_write_config_word(dev, reg, drv_ctrl); 92 pci_write_config_word(dev, reg, drv_ctrl);
107 pci_read_config_word(dev, reg, &drv_ctrl); 93 pci_read_config_word (dev, reg, &drv_ctrl);
108
109 if (report) {
110 printk("%s: selected %s (%dns) (%04X)\n", drive->name,
111 ide_xfer_verbose(xfer_mode), p.cycle_time, drv_ctrl);
112 }
113 } 94 }
95
96 printk(KERN_DEBUG "%s: selected %s (%dns) (%04X)\n", drive->name,
97 ide_xfer_verbose(pio + XFER_PIO_0), p.cycle_time, drv_ctrl);
98
99 return pio;
114} 100}
115 101
116/* 102/*
117 * Configure the drive and the chipset for DMA 103 * Configure the drive for DMA.
104 * We'll program the chipset only when DMA is actually turned on.
118 */ 105 */
119static int config_for_dma (ide_drive_t *drive) 106static int config_for_dma(ide_drive_t *drive)
120{ 107{
121 ide_hwif_t *hwif = HWIF(drive);
122 struct pci_dev *dev = hwif->pci_dev;
123 unsigned int reg;
124
125 DBG(("config_for_dma(drive:%s)\n", drive->name)); 108 DBG(("config_for_dma(drive:%s)\n", drive->name));
126 109
127 reg = (hwif->channel ? 0x4c : 0x44) + (drive->select.b.unit ? 4 : 0);
128
129 if (ide_config_drive_speed(drive, XFER_MW_DMA_2) != 0) 110 if (ide_config_drive_speed(drive, XFER_MW_DMA_2) != 0)
130 return 1; 111 return 0;
131 112
132 pci_write_config_word(dev, reg, 0x0240); 113 return ide_dma_enable(drive);
133
134 return 0;
135} 114}
136 115
137/* 116/*
138 * Check to see if the drive and 117 * Check to see if the drive and chipset are capable of DMA mode.
139 * chipset is capable of DMA mode
140 */ 118 */
141 119static int sl82c105_ide_dma_check(ide_drive_t *drive)
142static int sl82c105_check_drive (ide_drive_t *drive)
143{ 120{
144 ide_hwif_t *hwif = HWIF(drive); 121 DBG(("sl82c105_ide_dma_check(drive:%s)\n", drive->name));
145
146 DBG(("sl82c105_check_drive(drive:%s)\n", drive->name));
147
148 do {
149 struct hd_driveid *id = drive->id;
150
151 if (!drive->autodma)
152 break;
153
154 if (!id || !(id->capability & 1))
155 break;
156 122
157 /* Consult the list of known "bad" drives */ 123 if (ide_use_dma(drive) && config_for_dma(drive))
158 if (__ide_dma_bad_drive(drive)) 124 return 0;
159 break;
160
161 if (id->field_valid & 2) {
162 if ((id->dma_mword & hwif->mwdma_mask) ||
163 (id->dma_1word & hwif->swdma_mask))
164 return 0;
165 }
166
167 if (__ide_dma_good_drive(drive) && id->eide_dma_time < 150)
168 return 0;
169 } while (0);
170 125
171 return -1; 126 return -1;
172} 127}
@@ -195,14 +150,14 @@ static inline void sl82c105_reset_host(struct pci_dev *dev)
195 * This function is called when the IDE timer expires, the drive 150 * This function is called when the IDE timer expires, the drive
196 * indicates that it is READY, and we were waiting for DMA to complete. 151 * indicates that it is READY, and we were waiting for DMA to complete.
197 */ 152 */
198static int sl82c105_ide_dma_lost_irq(ide_drive_t *drive) 153static int sl82c105_ide_dma_lostirq(ide_drive_t *drive)
199{ 154{
200 ide_hwif_t *hwif = HWIF(drive); 155 ide_hwif_t *hwif = HWIF(drive);
201 struct pci_dev *dev = hwif->pci_dev; 156 struct pci_dev *dev = hwif->pci_dev;
202 u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; 157 u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA;
203 unsigned long dma_base = hwif->dma_base; 158 u8 dma_cmd;
204 159
205 printk("sl82c105: lost IRQ: resetting host\n"); 160 printk("sl82c105: lost IRQ, resetting host\n");
206 161
207 /* 162 /*
208 * Check the raw interrupt from the drive. 163 * Check the raw interrupt from the drive.
@@ -215,15 +170,15 @@ static int sl82c105_ide_dma_lost_irq(ide_drive_t *drive)
215 * Was DMA enabled? If so, disable it - we're resetting the 170 * Was DMA enabled? If so, disable it - we're resetting the
216 * host. The IDE layer will be handling the drive for us. 171 * host. The IDE layer will be handling the drive for us.
217 */ 172 */
218 val = inb(dma_base); 173 dma_cmd = inb(hwif->dma_command);
219 if (val & 1) { 174 if (dma_cmd & 1) {
220 outb(val & ~1, dma_base); 175 outb(dma_cmd & ~1, hwif->dma_command);
221 printk("sl82c105: DMA was enabled\n"); 176 printk("sl82c105: DMA was enabled\n");
222 } 177 }
223 178
224 sl82c105_reset_host(dev); 179 sl82c105_reset_host(dev);
225 180
226 /* ide_dmaproc would return 1, so we do as well */ 181 /* __ide_dma_lostirq would return 1, so we do as well */
227 return 1; 182 return 1;
228} 183}
229 184
@@ -235,10 +190,10 @@ static int sl82c105_ide_dma_lost_irq(ide_drive_t *drive)
235 * The generic IDE core will have disabled the BMEN bit before this 190 * The generic IDE core will have disabled the BMEN bit before this
236 * function is called. 191 * function is called.
237 */ 192 */
238static void sl82c105_ide_dma_start(ide_drive_t *drive) 193static void sl82c105_dma_start(ide_drive_t *drive)
239{ 194{
240 ide_hwif_t *hwif = HWIF(drive); 195 ide_hwif_t *hwif = HWIF(drive);
241 struct pci_dev *dev = hwif->pci_dev; 196 struct pci_dev *dev = hwif->pci_dev;
242 197
243 sl82c105_reset_host(dev); 198 sl82c105_reset_host(dev);
244 ide_dma_start(drive); 199 ide_dma_start(drive);
@@ -246,8 +201,8 @@ static void sl82c105_ide_dma_start(ide_drive_t *drive)
246 201
247static int sl82c105_ide_dma_timeout(ide_drive_t *drive) 202static int sl82c105_ide_dma_timeout(ide_drive_t *drive)
248{ 203{
249 ide_hwif_t *hwif = HWIF(drive); 204 ide_hwif_t *hwif = HWIF(drive);
250 struct pci_dev *dev = hwif->pci_dev; 205 struct pci_dev *dev = hwif->pci_dev;
251 206
252 DBG(("sl82c105_ide_dma_timeout(drive:%s)\n", drive->name)); 207 DBG(("sl82c105_ide_dma_timeout(drive:%s)\n", drive->name));
253 208
@@ -255,26 +210,32 @@ static int sl82c105_ide_dma_timeout(ide_drive_t *drive)
255 return __ide_dma_timeout(drive); 210 return __ide_dma_timeout(drive);
256} 211}
257 212
258static int sl82c105_ide_dma_on (ide_drive_t *drive) 213static int sl82c105_ide_dma_on(ide_drive_t *drive)
259{ 214{
215 struct pci_dev *dev = HWIF(drive)->pci_dev;
216 int rc, reg = 0x44 + drive->dn * 4;
217
260 DBG(("sl82c105_ide_dma_on(drive:%s)\n", drive->name)); 218 DBG(("sl82c105_ide_dma_on(drive:%s)\n", drive->name));
261 219
262 if (config_for_dma(drive)) 220 rc = __ide_dma_on(drive);
263 return 1; 221 if (rc == 0) {
264 printk(KERN_INFO "%s: DMA enabled\n", drive->name); 222 pci_write_config_word(dev, reg, 0x0200);
265 return __ide_dma_on(drive); 223
224 printk(KERN_INFO "%s: DMA enabled\n", drive->name);
225 }
226 return rc;
266} 227}
267 228
268static void sl82c105_dma_off_quietly(ide_drive_t *drive) 229static void sl82c105_dma_off_quietly(ide_drive_t *drive)
269{ 230{
270 u8 speed = XFER_PIO_0; 231 struct pci_dev *dev = HWIF(drive)->pci_dev;
232 int reg = 0x44 + drive->dn * 4;
271 233
272 DBG(("sl82c105_dma_off_quietly(drive:%s)\n", drive->name)); 234 DBG(("sl82c105_dma_off_quietly(drive:%s)\n", drive->name));
273 235
236 pci_write_config_word(dev, reg, drive->drive_data);
237
274 ide_dma_off_quietly(drive); 238 ide_dma_off_quietly(drive);
275 if (drive->pio_speed)
276 speed = drive->pio_speed - XFER_PIO_0;
277 config_for_pio(drive, speed, 0, 1);
278} 239}
279 240
280/* 241/*
@@ -286,8 +247,8 @@ static void sl82c105_dma_off_quietly(ide_drive_t *drive)
286 */ 247 */
287static void sl82c105_selectproc(ide_drive_t *drive) 248static void sl82c105_selectproc(ide_drive_t *drive)
288{ 249{
289 ide_hwif_t *hwif = HWIF(drive); 250 ide_hwif_t *hwif = HWIF(drive);
290 struct pci_dev *dev = hwif->pci_dev; 251 struct pci_dev *dev = hwif->pci_dev;
291 u32 val, old, mask; 252 u32 val, old, mask;
292 253
293 //DBG(("sl82c105_selectproc(drive:%s)\n", drive->name)); 254 //DBG(("sl82c105_selectproc(drive:%s)\n", drive->name));
@@ -323,18 +284,12 @@ static void sl82c105_resetproc(ide_drive_t *drive)
323 * We only deal with PIO mode here - DMA mode 'using_dma' is not 284 * We only deal with PIO mode here - DMA mode 'using_dma' is not
324 * initialised at the point that this function is called. 285 * initialised at the point that this function is called.
325 */ 286 */
326static void tune_sl82c105(ide_drive_t *drive, u8 pio) 287static void sl82c105_tune_drive(ide_drive_t *drive, u8 pio)
327{ 288{
328 DBG(("tune_sl82c105(drive:%s)\n", drive->name)); 289 DBG(("sl82c105_tune_drive(drive:%s, pio:%u)\n", drive->name, pio));
329
330 config_for_pio(drive, pio, 1, 0);
331 290
332 /* 291 pio = sl82c105_tune_pio(drive, pio);
333 * We support 32-bit I/O on this interface, and it 292 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
334 * doesn't have problems with interrupts.
335 */
336 drive->io_32bit = 1;
337 drive->unmask = 1;
338} 293}
339 294
340/* 295/*
@@ -393,7 +348,7 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c
393} 348}
394 349
395/* 350/*
396 * Initialise the chip 351 * Initialise IDE channel
397 */ 352 */
398static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) 353static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
399{ 354{
@@ -401,24 +356,22 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
401 356
402 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); 357 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
403 358
404 hwif->tuneproc = tune_sl82c105; 359 hwif->tuneproc = &sl82c105_tune_drive;
405 hwif->selectproc = sl82c105_selectproc; 360 hwif->selectproc = &sl82c105_selectproc;
406 hwif->resetproc = sl82c105_resetproc; 361 hwif->resetproc = &sl82c105_resetproc;
362
363 /*
364 * We support 32-bit I/O on this interface, and
365 * it doesn't have problems with interrupts.
366 */
367 hwif->drives[0].io_32bit = hwif->drives[1].io_32bit = 1;
368 hwif->drives[0].unmask = hwif->drives[1].unmask = 1;
407 369
408 /* 370 /*
409 * Default to PIO 0 for fallback unless tuned otherwise.
410 * We always autotune PIO, this is done before DMA is checked, 371 * We always autotune PIO, this is done before DMA is checked,
411 * so there's no risk of accidentally disabling DMA 372 * so there's no risk of accidentally disabling DMA
412 */ 373 */
413 hwif->drives[0].pio_speed = XFER_PIO_0; 374 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
414 hwif->drives[0].autotune = 1;
415 hwif->drives[1].pio_speed = XFER_PIO_0;
416 hwif->drives[1].autotune = 1;
417
418 hwif->atapi_dma = 0;
419 hwif->mwdma_mask = 0;
420 hwif->swdma_mask = 0;
421 hwif->autodma = 0;
422 375
423 if (!hwif->dma_base) 376 if (!hwif->dma_base)
424 return; 377 return;
@@ -429,27 +382,27 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
429 * Never ever EVER under any circumstances enable 382 * Never ever EVER under any circumstances enable
430 * DMA when the bridge is this old. 383 * DMA when the bridge is this old.
431 */ 384 */
432 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n", 385 printk(" %s: Winbond W83C553 bridge revision %d, "
433 hwif->name, rev); 386 "BM-DMA disabled\n", hwif->name, rev);
434 } else { 387 return;
435 hwif->atapi_dma = 1;
436 hwif->mwdma_mask = 0x04;
437
438 hwif->ide_dma_check = &sl82c105_check_drive;
439 hwif->ide_dma_on = &sl82c105_ide_dma_on;
440 hwif->dma_off_quietly = &sl82c105_dma_off_quietly;
441 hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq;
442 hwif->dma_start = &sl82c105_ide_dma_start;
443 hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout;
444
445 if (!noautodma)
446 hwif->autodma = 1;
447 hwif->drives[0].autodma = hwif->autodma;
448 hwif->drives[1].autodma = hwif->autodma;
449
450 if (hwif->mate)
451 hwif->serialized = hwif->mate->serialized = 1;
452 } 388 }
389
390 hwif->atapi_dma = 1;
391 hwif->mwdma_mask = 0x04;
392
393 hwif->ide_dma_check = &sl82c105_ide_dma_check;
394 hwif->ide_dma_on = &sl82c105_ide_dma_on;
395 hwif->dma_off_quietly = &sl82c105_dma_off_quietly;
396 hwif->ide_dma_lostirq = &sl82c105_ide_dma_lostirq;
397 hwif->dma_start = &sl82c105_dma_start;
398 hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout;
399
400 if (!noautodma)
401 hwif->autodma = 1;
402 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
403
404 if (hwif->mate)
405 hwif->serialized = hwif->mate->serialized = 1;
453} 406}
454 407
455static ide_pci_device_t sl82c105_chipset __devinitdata = { 408static ide_pci_device_t sl82c105_chipset __devinitdata = {
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index 6164a9a83396..bd0755c789c5 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -15,7 +15,6 @@
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/pci.h>
19#include <linux/timer.h> 18#include <linux/timer.h>
20#include <linux/jiffies.h> 19#include <linux/jiffies.h>
21#include <linux/mutex.h> 20#include <linux/mutex.h>
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 842cd0b53e91..eff591deeb46 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -40,7 +40,6 @@
40#include <linux/err.h> 40#include <linux/err.h>
41#include <linux/idr.h> 41#include <linux/idr.h>
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/pci.h>
44#include <linux/random.h> 43#include <linux/random.h>
45#include <linux/rbtree.h> 44#include <linux/rbtree.h>
46#include <linux/spinlock.h> 45#include <linux/spinlock.h>
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 891d1fa7b2eb..223b1aa7d92b 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -39,7 +39,6 @@
39#include <linux/err.h> 39#include <linux/err.h>
40#include <linux/idr.h> 40#include <linux/idr.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/pci.h>
43#include <linux/rbtree.h> 42#include <linux/rbtree.h>
44#include <linux/spinlock.h> 43#include <linux/spinlock.h>
45#include <linux/workqueue.h> 44#include <linux/workqueue.h>
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index de89717f49fe..9be5cc00a3a9 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -39,7 +39,6 @@
39 39
40#include <linux/completion.h> 40#include <linux/completion.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/pci.h>
43#include <linux/workqueue.h> 42#include <linux/workqueue.h>
44#include <rdma/ib_mad.h> 43#include <rdma/ib_mad.h>
45#include <rdma/ib_smi.h> 44#include <rdma/ib_smi.h>
diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c
index 4a579b3a1c90..1e13ab42b70b 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -34,7 +34,6 @@
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/pci.h>
38#include <linux/bitops.h> 37#include <linux/bitops.h>
39#include <linux/random.h> 38#include <linux/random.h>
40 39
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 9a7eaadb1688..6469406ea9d8 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -40,7 +40,6 @@
40#include <linux/random.h> 40#include <linux/random.h>
41#include <linux/spinlock.h> 41#include <linux/spinlock.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/pci.h>
44#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
45#include <linux/kref.h> 44#include <linux/kref.h>
46#include <linux/idr.h> 45#include <linux/idr.h>
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 8199b83052a9..d97ded25c4ff 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -40,7 +40,6 @@
40#include <linux/err.h> 40#include <linux/err.h>
41#include <linux/fs.h> 41#include <linux/fs.h>
42#include <linux/cdev.h> 42#include <linux/cdev.h>
43#include <linux/pci.h>
44#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
45#include <linux/poll.h> 44#include <linux/poll.h>
46#include <linux/rwsem.h> 45#include <linux/rwsem.h>
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index ed55979bfd34..036ed1ef1796 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -38,7 +38,6 @@
38#include <linux/pagemap.h> 38#include <linux/pagemap.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/namei.h> 40#include <linux/namei.h>
41#include <linux/pci.h>
42 41
43#include "ipath_kernel.h" 42#include "ipath_kernel.h"
44 43
diff --git a/drivers/infiniband/hw/ipath/ipath_layer.c b/drivers/infiniband/hw/ipath/ipath_layer.c
index e46aa4ed2a7e..05a1d2b01d9d 100644
--- a/drivers/infiniband/hw/ipath/ipath_layer.c
+++ b/drivers/infiniband/hw/ipath/ipath_layer.c
@@ -37,7 +37,6 @@
37 */ 37 */
38 38
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/pci.h>
41#include <asm/byteorder.h> 40#include <asm/byteorder.h>
42 41
43#include "ipath_kernel.h" 42#include "ipath_kernel.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_stats.c b/drivers/infiniband/hw/ipath/ipath_stats.c
index 9307f7187ca5..d8b5e4cefe25 100644
--- a/drivers/infiniband/hw/ipath/ipath_stats.c
+++ b/drivers/infiniband/hw/ipath/ipath_stats.c
@@ -31,8 +31,6 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/pci.h>
35
36#include "ipath_kernel.h" 34#include "ipath_kernel.h"
37 35
38struct infinipath_stats ipath_stats; 36struct infinipath_stats ipath_stats;
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c
index ffa6318ad0cc..4dc398d5e011 100644
--- a/drivers/infiniband/hw/ipath/ipath_sysfs.c
+++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c
@@ -32,7 +32,6 @@
32 */ 32 */
33 33
34#include <linux/ctype.h> 34#include <linux/ctype.h>
35#include <linux/pci.h>
36 35
37#include "ipath_kernel.h" 36#include "ipath_kernel.h"
38#include "ipath_common.h" 37#include "ipath_common.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h
index 594144145f45..a1ab06847b75 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.h
@@ -38,7 +38,6 @@
38#define MTHCA_MEMFREE_H 38#define MTHCA_MEMFREE_H
39 39
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/pci.h>
42#include <linux/mutex.h> 41#include <linux/mutex.h>
43 42
44#define MTHCA_ICM_CHUNK_LEN \ 43#define MTHCA_ICM_CHUNK_LEN \
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index fd558267d1cb..d8f6bb4f53fc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -41,7 +41,6 @@
41#include <linux/skbuff.h> 41#include <linux/skbuff.h>
42#include <linux/netdevice.h> 42#include <linux/netdevice.h>
43#include <linux/workqueue.h> 43#include <linux/workqueue.h>
44#include <linux/pci.h>
45#include <linux/kref.h> 44#include <linux/kref.h>
46#include <linux/if_infiniband.h> 45#include <linux/if_infiniband.h>
47#include <linux/mutex.h> 46#include <linux/mutex.h>
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 278fcbccc2d9..3651072f6c1f 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -201,7 +201,7 @@ static int iser_post_receive_control(struct iscsi_conn *conn)
201 * what's common for both schemes is that the connection is not started 201 * what's common for both schemes is that the connection is not started
202 */ 202 */
203 if (conn->c_stage != ISCSI_CONN_STARTED) 203 if (conn->c_stage != ISCSI_CONN_STARTED)
204 rx_data_size = DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH; 204 rx_data_size = ISCSI_DEF_MAX_RECV_SEG_LEN;
205 else /* FIXME till user space sets conn->max_recv_dlength correctly */ 205 else /* FIXME till user space sets conn->max_recv_dlength correctly */
206 rx_data_size = 128; 206 rx_data_size = 128;
207 207
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index da575deb3c7a..b4cd10653c4f 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o
13obj-$(CONFIG_INPUT_JOYDEV) += joydev.o 13obj-$(CONFIG_INPUT_JOYDEV) += joydev.o
14obj-$(CONFIG_INPUT_EVDEV) += evdev.o 14obj-$(CONFIG_INPUT_EVDEV) += evdev.o
15obj-$(CONFIG_INPUT_TSDEV) += tsdev.o 15obj-$(CONFIG_INPUT_TSDEV) += tsdev.o
16obj-$(CONFIG_INPUT_POWER) += power.o
17obj-$(CONFIG_INPUT_EVBUG) += evbug.o 16obj-$(CONFIG_INPUT_EVBUG) += evbug.o
18 17
19obj-$(CONFIG_INPUT_KEYBOARD) += keyboard/ 18obj-$(CONFIG_INPUT_KEYBOARD) += keyboard/
diff --git a/drivers/input/evbug.c b/drivers/input/evbug.c
index 5a9653c3128a..c21f2f127234 100644
--- a/drivers/input/evbug.c
+++ b/drivers/input/evbug.c
@@ -38,31 +38,43 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
38MODULE_DESCRIPTION("Input driver event debug module"); 38MODULE_DESCRIPTION("Input driver event debug module");
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40 40
41static char evbug_name[] = "evbug";
42
43static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) 41static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
44{ 42{
45 printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", 43 printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n",
46 handle->dev->phys, type, code, value); 44 handle->dev->phys, type, code, value);
47} 45}
48 46
49static struct input_handle *evbug_connect(struct input_handler *handler, struct input_dev *dev, 47static int evbug_connect(struct input_handler *handler, struct input_dev *dev,
50 const struct input_device_id *id) 48 const struct input_device_id *id)
51{ 49{
52 struct input_handle *handle; 50 struct input_handle *handle;
51 int error;
53 52
54 if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL))) 53 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
55 return NULL; 54 if (!handle)
55 return -ENOMEM;
56 56
57 handle->dev = dev; 57 handle->dev = dev;
58 handle->handler = handler; 58 handle->handler = handler;
59 handle->name = evbug_name; 59 handle->name = "evbug";
60
61 error = input_register_handle(handle);
62 if (error)
63 goto err_free_handle;
60 64
61 input_open_device(handle); 65 error = input_open_device(handle);
66 if (error)
67 goto err_unregister_handle;
62 68
63 printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys); 69 printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys);
64 70
65 return handle; 71 return 0;
72
73 err_unregister_handle:
74 input_unregister_handle(handle);
75 err_free_handle:
76 kfree(handle);
77 return error;
66} 78}
67 79
68static void evbug_disconnect(struct input_handle *handle) 80static void evbug_disconnect(struct input_handle *handle)
@@ -70,7 +82,7 @@ static void evbug_disconnect(struct input_handle *handle)
70 printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys); 82 printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys);
71 83
72 input_close_device(handle); 84 input_close_device(handle);
73 85 input_unregister_handle(handle);
74 kfree(handle); 86 kfree(handle);
75} 87}
76 88
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 6439f378f6cc..1f6fcec0c6fc 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -29,11 +29,11 @@ struct evdev {
29 char name[16]; 29 char name[16];
30 struct input_handle handle; 30 struct input_handle handle;
31 wait_queue_head_t wait; 31 wait_queue_head_t wait;
32 struct evdev_list *grab; 32 struct evdev_client *grab;
33 struct list_head list; 33 struct list_head client_list;
34}; 34};
35 35
36struct evdev_list { 36struct evdev_client {
37 struct input_event buffer[EVDEV_BUFFER_SIZE]; 37 struct input_event buffer[EVDEV_BUFFER_SIZE];
38 int head; 38 int head;
39 int tail; 39 int tail;
@@ -47,28 +47,28 @@ static struct evdev *evdev_table[EVDEV_MINORS];
47static void evdev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) 47static void evdev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
48{ 48{
49 struct evdev *evdev = handle->private; 49 struct evdev *evdev = handle->private;
50 struct evdev_list *list; 50 struct evdev_client *client;
51 51
52 if (evdev->grab) { 52 if (evdev->grab) {
53 list = evdev->grab; 53 client = evdev->grab;
54 54
55 do_gettimeofday(&list->buffer[list->head].time); 55 do_gettimeofday(&client->buffer[client->head].time);
56 list->buffer[list->head].type = type; 56 client->buffer[client->head].type = type;
57 list->buffer[list->head].code = code; 57 client->buffer[client->head].code = code;
58 list->buffer[list->head].value = value; 58 client->buffer[client->head].value = value;
59 list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1); 59 client->head = (client->head + 1) & (EVDEV_BUFFER_SIZE - 1);
60 60
61 kill_fasync(&list->fasync, SIGIO, POLL_IN); 61 kill_fasync(&client->fasync, SIGIO, POLL_IN);
62 } else 62 } else
63 list_for_each_entry(list, &evdev->list, node) { 63 list_for_each_entry(client, &evdev->client_list, node) {
64 64
65 do_gettimeofday(&list->buffer[list->head].time); 65 do_gettimeofday(&client->buffer[client->head].time);
66 list->buffer[list->head].type = type; 66 client->buffer[client->head].type = type;
67 list->buffer[list->head].code = code; 67 client->buffer[client->head].code = code;
68 list->buffer[list->head].value = value; 68 client->buffer[client->head].value = value;
69 list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1); 69 client->head = (client->head + 1) & (EVDEV_BUFFER_SIZE - 1);
70 70
71 kill_fasync(&list->fasync, SIGIO, POLL_IN); 71 kill_fasync(&client->fasync, SIGIO, POLL_IN);
72 } 72 }
73 73
74 wake_up_interruptible(&evdev->wait); 74 wake_up_interruptible(&evdev->wait);
@@ -76,22 +76,23 @@ static void evdev_event(struct input_handle *handle, unsigned int type, unsigned
76 76
77static int evdev_fasync(int fd, struct file *file, int on) 77static int evdev_fasync(int fd, struct file *file, int on)
78{ 78{
79 struct evdev_client *client = file->private_data;
79 int retval; 80 int retval;
80 struct evdev_list *list = file->private_data;
81 81
82 retval = fasync_helper(fd, file, on, &list->fasync); 82 retval = fasync_helper(fd, file, on, &client->fasync);
83 83
84 return retval < 0 ? retval : 0; 84 return retval < 0 ? retval : 0;
85} 85}
86 86
87static int evdev_flush(struct file *file, fl_owner_t id) 87static int evdev_flush(struct file *file, fl_owner_t id)
88{ 88{
89 struct evdev_list *list = file->private_data; 89 struct evdev_client *client = file->private_data;
90 struct evdev *evdev = client->evdev;
90 91
91 if (!list->evdev->exist) 92 if (!evdev->exist)
92 return -ENODEV; 93 return -ENODEV;
93 94
94 return input_flush_device(&list->evdev->handle, file); 95 return input_flush_device(&evdev->handle, file);
95} 96}
96 97
97static void evdev_free(struct evdev *evdev) 98static void evdev_free(struct evdev *evdev)
@@ -100,48 +101,62 @@ static void evdev_free(struct evdev *evdev)
100 kfree(evdev); 101 kfree(evdev);
101} 102}
102 103
103static int evdev_release(struct inode * inode, struct file * file) 104static int evdev_release(struct inode *inode, struct file *file)
104{ 105{
105 struct evdev_list *list = file->private_data; 106 struct evdev_client *client = file->private_data;
107 struct evdev *evdev = client->evdev;
106 108
107 if (list->evdev->grab == list) { 109 if (evdev->grab == client) {
108 input_release_device(&list->evdev->handle); 110 input_release_device(&evdev->handle);
109 list->evdev->grab = NULL; 111 evdev->grab = NULL;
110 } 112 }
111 113
112 evdev_fasync(-1, file, 0); 114 evdev_fasync(-1, file, 0);
113 list_del(&list->node); 115 list_del(&client->node);
116 kfree(client);
114 117
115 if (!--list->evdev->open) { 118 if (!--evdev->open) {
116 if (list->evdev->exist) 119 if (evdev->exist)
117 input_close_device(&list->evdev->handle); 120 input_close_device(&evdev->handle);
118 else 121 else
119 evdev_free(list->evdev); 122 evdev_free(evdev);
120 } 123 }
121 124
122 kfree(list);
123 return 0; 125 return 0;
124} 126}
125 127
126static int evdev_open(struct inode * inode, struct file * file) 128static int evdev_open(struct inode *inode, struct file *file)
127{ 129{
128 struct evdev_list *list; 130 struct evdev_client *client;
131 struct evdev *evdev;
129 int i = iminor(inode) - EVDEV_MINOR_BASE; 132 int i = iminor(inode) - EVDEV_MINOR_BASE;
133 int error;
130 134
131 if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist) 135 if (i >= EVDEV_MINORS)
132 return -ENODEV; 136 return -ENODEV;
133 137
134 if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL))) 138 evdev = evdev_table[i];
139
140 if (!evdev || !evdev->exist)
141 return -ENODEV;
142
143 client = kzalloc(sizeof(struct evdev_client), GFP_KERNEL);
144 if (!client)
135 return -ENOMEM; 145 return -ENOMEM;
136 146
137 list->evdev = evdev_table[i]; 147 client->evdev = evdev;
138 list_add_tail(&list->node, &evdev_table[i]->list); 148 list_add_tail(&client->node, &evdev->client_list);
139 file->private_data = list;
140 149
141 if (!list->evdev->open++) 150 if (!evdev->open++ && evdev->exist) {
142 if (list->evdev->exist) 151 error = input_open_device(&evdev->handle);
143 input_open_device(&list->evdev->handle); 152 if (error) {
153 list_del(&client->node);
154 kfree(client);
155 return error;
156 }
157 }
144 158
159 file->private_data = client;
145 return 0; 160 return 0;
146} 161}
147 162
@@ -243,54 +258,55 @@ static int evdev_event_to_user(char __user *buffer, const struct input_event *ev
243 258
244#endif /* CONFIG_COMPAT */ 259#endif /* CONFIG_COMPAT */
245 260
246static ssize_t evdev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) 261static ssize_t evdev_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
247{ 262{
248 struct evdev_list *list = file->private_data; 263 struct evdev_client *client = file->private_data;
264 struct evdev *evdev = client->evdev;
249 struct input_event event; 265 struct input_event event;
250 int retval = 0; 266 int retval = 0;
251 267
252 if (!list->evdev->exist) 268 if (!evdev->exist)
253 return -ENODEV; 269 return -ENODEV;
254 270
255 while (retval < count) { 271 while (retval < count) {
256 272
257 if (evdev_event_from_user(buffer + retval, &event)) 273 if (evdev_event_from_user(buffer + retval, &event))
258 return -EFAULT; 274 return -EFAULT;
259 input_inject_event(&list->evdev->handle, event.type, event.code, event.value); 275 input_inject_event(&evdev->handle, event.type, event.code, event.value);
260 retval += evdev_event_size(); 276 retval += evdev_event_size();
261 } 277 }
262 278
263 return retval; 279 return retval;
264} 280}
265 281
266static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) 282static ssize_t evdev_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
267{ 283{
268 struct evdev_list *list = file->private_data; 284 struct evdev_client *client = file->private_data;
285 struct evdev *evdev = client->evdev;
269 int retval; 286 int retval;
270 287
271 if (count < evdev_event_size()) 288 if (count < evdev_event_size())
272 return -EINVAL; 289 return -EINVAL;
273 290
274 if (list->head == list->tail && list->evdev->exist && (file->f_flags & O_NONBLOCK)) 291 if (client->head == client->tail && evdev->exist && (file->f_flags & O_NONBLOCK))
275 return -EAGAIN; 292 return -EAGAIN;
276 293
277 retval = wait_event_interruptible(list->evdev->wait, 294 retval = wait_event_interruptible(evdev->wait,
278 list->head != list->tail || (!list->evdev->exist)); 295 client->head != client->tail || !evdev->exist);
279
280 if (retval) 296 if (retval)
281 return retval; 297 return retval;
282 298
283 if (!list->evdev->exist) 299 if (!evdev->exist)
284 return -ENODEV; 300 return -ENODEV;
285 301
286 while (list->head != list->tail && retval + evdev_event_size() <= count) { 302 while (client->head != client->tail && retval + evdev_event_size() <= count) {
287 303
288 struct input_event *event = (struct input_event *) list->buffer + list->tail; 304 struct input_event *event = (struct input_event *) client->buffer + client->tail;
289 305
290 if (evdev_event_to_user(buffer + retval, event)) 306 if (evdev_event_to_user(buffer + retval, event))
291 return -EFAULT; 307 return -EFAULT;
292 308
293 list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1); 309 client->tail = (client->tail + 1) & (EVDEV_BUFFER_SIZE - 1);
294 retval += evdev_event_size(); 310 retval += evdev_event_size();
295 } 311 }
296 312
@@ -300,11 +316,12 @@ static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count
300/* No kernel lock - fine */ 316/* No kernel lock - fine */
301static unsigned int evdev_poll(struct file *file, poll_table *wait) 317static unsigned int evdev_poll(struct file *file, poll_table *wait)
302{ 318{
303 struct evdev_list *list = file->private_data; 319 struct evdev_client *client = file->private_data;
320 struct evdev *evdev = client->evdev;
304 321
305 poll_wait(file, &list->evdev->wait, wait); 322 poll_wait(file, &evdev->wait, wait);
306 return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | 323 return ((client->head == client->tail) ? 0 : (POLLIN | POLLRDNORM)) |
307 (list->evdev->exist ? 0 : (POLLHUP | POLLERR)); 324 (evdev->exist ? 0 : (POLLHUP | POLLERR));
308} 325}
309 326
310#ifdef CONFIG_COMPAT 327#ifdef CONFIG_COMPAT
@@ -387,8 +404,8 @@ static int str_to_user(const char *str, unsigned int maxlen, void __user *p)
387static long evdev_ioctl_handler(struct file *file, unsigned int cmd, 404static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
388 void __user *p, int compat_mode) 405 void __user *p, int compat_mode)
389{ 406{
390 struct evdev_list *list = file->private_data; 407 struct evdev_client *client = file->private_data;
391 struct evdev *evdev = list->evdev; 408 struct evdev *evdev = client->evdev;
392 struct input_dev *dev = evdev->handle.dev; 409 struct input_dev *dev = evdev->handle.dev;
393 struct input_absinfo abs; 410 struct input_absinfo abs;
394 struct ff_effect effect; 411 struct ff_effect effect;
@@ -434,32 +451,21 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
434 case EVIOCGKEYCODE: 451 case EVIOCGKEYCODE:
435 if (get_user(t, ip)) 452 if (get_user(t, ip))
436 return -EFAULT; 453 return -EFAULT;
437 if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) 454
438 return -EINVAL; 455 error = dev->getkeycode(dev, t, &v);
439 if (put_user(INPUT_KEYCODE(dev, t), ip + 1)) 456 if (error)
457 return error;
458
459 if (put_user(v, ip + 1))
440 return -EFAULT; 460 return -EFAULT;
461
441 return 0; 462 return 0;
442 463
443 case EVIOCSKEYCODE: 464 case EVIOCSKEYCODE:
444 if (get_user(t, ip)) 465 if (get_user(t, ip) || get_user(v, ip + 1))
445 return -EFAULT; 466 return -EFAULT;
446 if (t < 0 || t >= dev->keycodemax || !dev->keycodesize)
447 return -EINVAL;
448 if (get_user(v, ip + 1))
449 return -EFAULT;
450 if (v < 0 || v > KEY_MAX)
451 return -EINVAL;
452 if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8)))
453 return -EINVAL;
454
455 u = SET_INPUT_KEYCODE(dev, t, v);
456 clear_bit(u, dev->keybit);
457 set_bit(v, dev->keybit);
458 for (i = 0; i < dev->keycodemax; i++)
459 if (INPUT_KEYCODE(dev, i) == u)
460 set_bit(u, dev->keybit);
461 467
462 return 0; 468 return dev->setkeycode(dev, t, v);
463 469
464 case EVIOCSFF: 470 case EVIOCSFF:
465 if (copy_from_user(&effect, p, sizeof(effect))) 471 if (copy_from_user(&effect, p, sizeof(effect)))
@@ -487,10 +493,10 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
487 return -EBUSY; 493 return -EBUSY;
488 if (input_grab_device(&evdev->handle)) 494 if (input_grab_device(&evdev->handle))
489 return -EBUSY; 495 return -EBUSY;
490 evdev->grab = list; 496 evdev->grab = client;
491 return 0; 497 return 0;
492 } else { 498 } else {
493 if (evdev->grab != list) 499 if (evdev->grab != client)
494 return -EINVAL; 500 return -EINVAL;
495 input_release_device(&evdev->handle); 501 input_release_device(&evdev->handle);
496 evdev->grab = NULL; 502 evdev->grab = NULL;
@@ -616,23 +622,26 @@ static const struct file_operations evdev_fops = {
616 .flush = evdev_flush 622 .flush = evdev_flush
617}; 623};
618 624
619static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, 625static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
620 const struct input_device_id *id) 626 const struct input_device_id *id)
621{ 627{
622 struct evdev *evdev; 628 struct evdev *evdev;
623 struct class_device *cdev; 629 struct class_device *cdev;
630 dev_t devt;
624 int minor; 631 int minor;
632 int error;
625 633
626 for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++); 634 for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++);
627 if (minor == EVDEV_MINORS) { 635 if (minor == EVDEV_MINORS) {
628 printk(KERN_ERR "evdev: no more free evdev devices\n"); 636 printk(KERN_ERR "evdev: no more free evdev devices\n");
629 return NULL; 637 return -ENFILE;
630 } 638 }
631 639
632 if (!(evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL))) 640 evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL);
633 return NULL; 641 if (!evdev)
642 return -ENOMEM;
634 643
635 INIT_LIST_HEAD(&evdev->list); 644 INIT_LIST_HEAD(&evdev->client_list);
636 init_waitqueue_head(&evdev->wait); 645 init_waitqueue_head(&evdev->wait);
637 646
638 evdev->exist = 1; 647 evdev->exist = 1;
@@ -645,23 +654,45 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
645 654
646 evdev_table[minor] = evdev; 655 evdev_table[minor] = evdev;
647 656
648 cdev = class_device_create(&input_class, &dev->cdev, 657 devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
649 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), 658
650 dev->cdev.dev, evdev->name); 659 cdev = class_device_create(&input_class, &dev->cdev, devt,
660 dev->cdev.dev, evdev->name);
661 if (IS_ERR(cdev)) {
662 error = PTR_ERR(cdev);
663 goto err_free_evdev;
664 }
651 665
652 /* temporary symlink to keep userspace happy */ 666 /* temporary symlink to keep userspace happy */
653 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, 667 error = sysfs_create_link(&input_class.subsys.kobj,
654 evdev->name); 668 &cdev->kobj, evdev->name);
669 if (error)
670 goto err_cdev_destroy;
671
672 error = input_register_handle(&evdev->handle);
673 if (error)
674 goto err_remove_link;
655 675
656 return &evdev->handle; 676 return 0;
677
678 err_remove_link:
679 sysfs_remove_link(&input_class.subsys.kobj, evdev->name);
680 err_cdev_destroy:
681 class_device_destroy(&input_class, devt);
682 err_free_evdev:
683 kfree(evdev);
684 evdev_table[minor] = NULL;
685 return error;
657} 686}
658 687
659static void evdev_disconnect(struct input_handle *handle) 688static void evdev_disconnect(struct input_handle *handle)
660{ 689{
661 struct evdev *evdev = handle->private; 690 struct evdev *evdev = handle->private;
662 struct evdev_list *list; 691 struct evdev_client *client;
692
693 input_unregister_handle(handle);
663 694
664 sysfs_remove_link(&input_class.subsys.kset.kobj, evdev->name); 695 sysfs_remove_link(&input_class.subsys.kobj, evdev->name);
665 class_device_destroy(&input_class, 696 class_device_destroy(&input_class,
666 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor)); 697 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
667 evdev->exist = 0; 698 evdev->exist = 0;
@@ -670,8 +701,8 @@ static void evdev_disconnect(struct input_handle *handle)
670 input_flush_device(handle, NULL); 701 input_flush_device(handle, NULL);
671 input_close_device(handle); 702 input_close_device(handle);
672 wake_up_interruptible(&evdev->wait); 703 wake_up_interruptible(&evdev->wait);
673 list_for_each_entry(list, &evdev->list, node) 704 list_for_each_entry(client, &evdev->client_list, node)
674 kill_fasync(&list->fasync, SIGIO, POLL_HUP); 705 kill_fasync(&client->fasync, SIGIO, POLL_HUP);
675 } else 706 } else
676 evdev_free(evdev); 707 evdev_free(evdev);
677} 708}
diff --git a/drivers/input/input.c b/drivers/input/input.c
index a9a706f8fff9..915e9ab7cab0 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -299,12 +299,87 @@ void input_close_device(struct input_handle *handle)
299} 299}
300EXPORT_SYMBOL(input_close_device); 300EXPORT_SYMBOL(input_close_device);
301 301
302static void input_link_handle(struct input_handle *handle) 302static int input_fetch_keycode(struct input_dev *dev, int scancode)
303{ 303{
304 list_add_tail(&handle->d_node, &handle->dev->h_list); 304 switch (dev->keycodesize) {
305 list_add_tail(&handle->h_node, &handle->handler->h_list); 305 case 1:
306 return ((u8 *)dev->keycode)[scancode];
307
308 case 2:
309 return ((u16 *)dev->keycode)[scancode];
310
311 default:
312 return ((u32 *)dev->keycode)[scancode];
313 }
314}
315
316static int input_default_getkeycode(struct input_dev *dev,
317 int scancode, int *keycode)
318{
319 if (!dev->keycodesize)
320 return -EINVAL;
321
322 if (scancode < 0 || scancode >= dev->keycodemax)
323 return -EINVAL;
324
325 *keycode = input_fetch_keycode(dev, scancode);
326
327 return 0;
328}
329
330static int input_default_setkeycode(struct input_dev *dev,
331 int scancode, int keycode)
332{
333 int old_keycode;
334 int i;
335
336 if (scancode < 0 || scancode >= dev->keycodemax)
337 return -EINVAL;
338
339 if (keycode < 0 || keycode > KEY_MAX)
340 return -EINVAL;
341
342 if (!dev->keycodesize)
343 return -EINVAL;
344
345 if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))
346 return -EINVAL;
347
348 switch (dev->keycodesize) {
349 case 1: {
350 u8 *k = (u8 *)dev->keycode;
351 old_keycode = k[scancode];
352 k[scancode] = keycode;
353 break;
354 }
355 case 2: {
356 u16 *k = (u16 *)dev->keycode;
357 old_keycode = k[scancode];
358 k[scancode] = keycode;
359 break;
360 }
361 default: {
362 u32 *k = (u32 *)dev->keycode;
363 old_keycode = k[scancode];
364 k[scancode] = keycode;
365 break;
366 }
367 }
368
369 clear_bit(old_keycode, dev->keybit);
370 set_bit(keycode, dev->keybit);
371
372 for (i = 0; i < dev->keycodemax; i++) {
373 if (input_fetch_keycode(dev, i) == old_keycode) {
374 set_bit(old_keycode, dev->keybit);
375 break; /* Setting the bit twice is useless, so break */
376 }
377 }
378
379 return 0;
306} 380}
307 381
382
308#define MATCH_BIT(bit, max) \ 383#define MATCH_BIT(bit, max) \
309 for (i = 0; i < NBITS(max); i++) \ 384 for (i = 0; i < NBITS(max); i++) \
310 if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \ 385 if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \
@@ -351,6 +426,29 @@ static const struct input_device_id *input_match_device(const struct input_devic
351 return NULL; 426 return NULL;
352} 427}
353 428
429static int input_attach_handler(struct input_dev *dev, struct input_handler *handler)
430{
431 const struct input_device_id *id;
432 int error;
433
434 if (handler->blacklist && input_match_device(handler->blacklist, dev))
435 return -ENODEV;
436
437 id = input_match_device(handler->id_table, dev);
438 if (!id)
439 return -ENODEV;
440
441 error = handler->connect(handler, dev, id);
442 if (error && error != -ENODEV)
443 printk(KERN_ERR
444 "input: failed to attach handler %s to device %s, "
445 "error: %d\n",
446 handler->name, kobject_name(&dev->cdev.kobj), error);
447
448 return error;
449}
450
451
354#ifdef CONFIG_PROC_FS 452#ifdef CONFIG_PROC_FS
355 453
356static struct proc_dir_entry *proc_bus_input_dir; 454static struct proc_dir_entry *proc_bus_input_dir;
@@ -439,6 +537,7 @@ static int input_devices_seq_show(struct seq_file *seq, void *v)
439 seq_printf(seq, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); 537 seq_printf(seq, "N: Name=\"%s\"\n", dev->name ? dev->name : "");
440 seq_printf(seq, "P: Phys=%s\n", dev->phys ? dev->phys : ""); 538 seq_printf(seq, "P: Phys=%s\n", dev->phys ? dev->phys : "");
441 seq_printf(seq, "S: Sysfs=%s\n", path ? path : ""); 539 seq_printf(seq, "S: Sysfs=%s\n", path ? path : "");
540 seq_printf(seq, "U: Uniq=%s\n", dev->uniq ? dev->uniq : "");
442 seq_printf(seq, "H: Handlers="); 541 seq_printf(seq, "H: Handlers=");
443 542
444 list_for_each_entry(handle, &dev->h_list, d_node) 543 list_for_each_entry(handle, &dev->h_list, d_node)
@@ -753,6 +852,13 @@ static struct attribute_group input_dev_caps_attr_group = {
753 .attrs = input_dev_caps_attrs, 852 .attrs = input_dev_caps_attrs,
754}; 853};
755 854
855static struct attribute_group *input_dev_attr_groups[] = {
856 &input_dev_attr_group,
857 &input_dev_id_attr_group,
858 &input_dev_caps_attr_group,
859 NULL
860};
861
756static void input_dev_release(struct class_device *class_dev) 862static void input_dev_release(struct class_device *class_dev)
757{ 863{
758 struct input_dev *dev = to_input_dev(class_dev); 864 struct input_dev *dev = to_input_dev(class_dev);
@@ -906,6 +1012,7 @@ struct input_dev *input_allocate_device(void)
906 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); 1012 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
907 if (dev) { 1013 if (dev) {
908 dev->cdev.class = &input_class; 1014 dev->cdev.class = &input_class;
1015 dev->cdev.groups = input_dev_attr_groups;
909 class_device_initialize(&dev->cdev); 1016 class_device_initialize(&dev->cdev);
910 mutex_init(&dev->mutex); 1017 mutex_init(&dev->mutex);
911 INIT_LIST_HEAD(&dev->h_list); 1018 INIT_LIST_HEAD(&dev->h_list);
@@ -934,23 +1041,71 @@ EXPORT_SYMBOL(input_allocate_device);
934 */ 1041 */
935void input_free_device(struct input_dev *dev) 1042void input_free_device(struct input_dev *dev)
936{ 1043{
937 if (dev) { 1044 if (dev)
938
939 mutex_lock(&dev->mutex);
940 dev->name = dev->phys = dev->uniq = NULL;
941 mutex_unlock(&dev->mutex);
942
943 input_put_device(dev); 1045 input_put_device(dev);
944 }
945} 1046}
946EXPORT_SYMBOL(input_free_device); 1047EXPORT_SYMBOL(input_free_device);
947 1048
1049/**
1050 * input_set_capability - mark device as capable of a certain event
1051 * @dev: device that is capable of emitting or accepting event
1052 * @type: type of the event (EV_KEY, EV_REL, etc...)
1053 * @code: event code
1054 *
1055 * In addition to setting up corresponding bit in appropriate capability
1056 * bitmap the function also adjusts dev->evbit.
1057 */
1058void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code)
1059{
1060 switch (type) {
1061 case EV_KEY:
1062 __set_bit(code, dev->keybit);
1063 break;
1064
1065 case EV_REL:
1066 __set_bit(code, dev->relbit);
1067 break;
1068
1069 case EV_ABS:
1070 __set_bit(code, dev->absbit);
1071 break;
1072
1073 case EV_MSC:
1074 __set_bit(code, dev->mscbit);
1075 break;
1076
1077 case EV_SW:
1078 __set_bit(code, dev->swbit);
1079 break;
1080
1081 case EV_LED:
1082 __set_bit(code, dev->ledbit);
1083 break;
1084
1085 case EV_SND:
1086 __set_bit(code, dev->sndbit);
1087 break;
1088
1089 case EV_FF:
1090 __set_bit(code, dev->ffbit);
1091 break;
1092
1093 default:
1094 printk(KERN_ERR
1095 "input_set_capability: unknown type %u (code %u)\n",
1096 type, code);
1097 dump_stack();
1098 return;
1099 }
1100
1101 __set_bit(type, dev->evbit);
1102}
1103EXPORT_SYMBOL(input_set_capability);
1104
948int input_register_device(struct input_dev *dev) 1105int input_register_device(struct input_dev *dev)
949{ 1106{
950 static atomic_t input_no = ATOMIC_INIT(0); 1107 static atomic_t input_no = ATOMIC_INIT(0);
951 struct input_handle *handle;
952 struct input_handler *handler; 1108 struct input_handler *handler;
953 const struct input_device_id *id;
954 const char *path; 1109 const char *path;
955 int error; 1110 int error;
956 1111
@@ -969,55 +1124,41 @@ int input_register_device(struct input_dev *dev)
969 dev->rep[REP_PERIOD] = 33; 1124 dev->rep[REP_PERIOD] = 33;
970 } 1125 }
971 1126
1127 if (!dev->getkeycode)
1128 dev->getkeycode = input_default_getkeycode;
1129
1130 if (!dev->setkeycode)
1131 dev->setkeycode = input_default_setkeycode;
1132
972 list_add_tail(&dev->node, &input_dev_list); 1133 list_add_tail(&dev->node, &input_dev_list);
973 1134
974 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id), 1135 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id),
975 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1); 1136 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
976 1137
1138 if (!dev->cdev.dev)
1139 dev->cdev.dev = dev->dev.parent;
1140
977 error = class_device_add(&dev->cdev); 1141 error = class_device_add(&dev->cdev);
978 if (error) 1142 if (error)
979 return error; 1143 return error;
980 1144
981 error = sysfs_create_group(&dev->cdev.kobj, &input_dev_attr_group);
982 if (error)
983 goto fail1;
984
985 error = sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group);
986 if (error)
987 goto fail2;
988
989 error = sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
990 if (error)
991 goto fail3;
992
993 path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); 1145 path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
994 printk(KERN_INFO "input: %s as %s\n", 1146 printk(KERN_INFO "input: %s as %s\n",
995 dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); 1147 dev->name ? dev->name : "Unspecified device", path ? path : "N/A");
996 kfree(path); 1148 kfree(path);
997 1149
998 list_for_each_entry(handler, &input_handler_list, node) 1150 list_for_each_entry(handler, &input_handler_list, node)
999 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 1151 input_attach_handler(dev, handler);
1000 if ((id = input_match_device(handler->id_table, dev)))
1001 if ((handle = handler->connect(handler, dev, id))) {
1002 input_link_handle(handle);
1003 if (handler->start)
1004 handler->start(handle);
1005 }
1006 1152
1007 input_wakeup_procfs_readers(); 1153 input_wakeup_procfs_readers();
1008 1154
1009 return 0; 1155 return 0;
1010
1011 fail3: sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
1012 fail2: sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
1013 fail1: class_device_del(&dev->cdev);
1014 return error;
1015} 1156}
1016EXPORT_SYMBOL(input_register_device); 1157EXPORT_SYMBOL(input_register_device);
1017 1158
1018void input_unregister_device(struct input_dev *dev) 1159void input_unregister_device(struct input_dev *dev)
1019{ 1160{
1020 struct list_head *node, *next; 1161 struct input_handle *handle, *next;
1021 int code; 1162 int code;
1022 1163
1023 for (code = 0; code <= KEY_MAX; code++) 1164 for (code = 0; code <= KEY_MAX; code++)
@@ -1027,19 +1168,12 @@ void input_unregister_device(struct input_dev *dev)
1027 1168
1028 del_timer_sync(&dev->timer); 1169 del_timer_sync(&dev->timer);
1029 1170
1030 list_for_each_safe(node, next, &dev->h_list) { 1171 list_for_each_entry_safe(handle, next, &dev->h_list, d_node)
1031 struct input_handle * handle = to_handle(node);
1032 list_del_init(&handle->d_node);
1033 list_del_init(&handle->h_node);
1034 handle->handler->disconnect(handle); 1172 handle->handler->disconnect(handle);
1035 } 1173 WARN_ON(!list_empty(&dev->h_list));
1036 1174
1037 list_del_init(&dev->node); 1175 list_del_init(&dev->node);
1038 1176
1039 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
1040 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
1041 sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
1042
1043 class_device_unregister(&dev->cdev); 1177 class_device_unregister(&dev->cdev);
1044 1178
1045 input_wakeup_procfs_readers(); 1179 input_wakeup_procfs_readers();
@@ -1049,8 +1183,6 @@ EXPORT_SYMBOL(input_unregister_device);
1049int input_register_handler(struct input_handler *handler) 1183int input_register_handler(struct input_handler *handler)
1050{ 1184{
1051 struct input_dev *dev; 1185 struct input_dev *dev;
1052 struct input_handle *handle;
1053 const struct input_device_id *id;
1054 1186
1055 INIT_LIST_HEAD(&handler->h_list); 1187 INIT_LIST_HEAD(&handler->h_list);
1056 1188
@@ -1064,13 +1196,7 @@ int input_register_handler(struct input_handler *handler)
1064 list_add_tail(&handler->node, &input_handler_list); 1196 list_add_tail(&handler->node, &input_handler_list);
1065 1197
1066 list_for_each_entry(dev, &input_dev_list, node) 1198 list_for_each_entry(dev, &input_dev_list, node)
1067 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 1199 input_attach_handler(dev, handler);
1068 if ((id = input_match_device(handler->id_table, dev)))
1069 if ((handle = handler->connect(handler, dev, id))) {
1070 input_link_handle(handle);
1071 if (handler->start)
1072 handler->start(handle);
1073 }
1074 1200
1075 input_wakeup_procfs_readers(); 1201 input_wakeup_procfs_readers();
1076 return 0; 1202 return 0;
@@ -1079,14 +1205,11 @@ EXPORT_SYMBOL(input_register_handler);
1079 1205
1080void input_unregister_handler(struct input_handler *handler) 1206void input_unregister_handler(struct input_handler *handler)
1081{ 1207{
1082 struct list_head *node, *next; 1208 struct input_handle *handle, *next;
1083 1209
1084 list_for_each_safe(node, next, &handler->h_list) { 1210 list_for_each_entry_safe(handle, next, &handler->h_list, h_node)
1085 struct input_handle * handle = to_handle_h(node);
1086 list_del_init(&handle->h_node);
1087 list_del_init(&handle->d_node);
1088 handler->disconnect(handle); 1211 handler->disconnect(handle);
1089 } 1212 WARN_ON(!list_empty(&handler->h_list));
1090 1213
1091 list_del_init(&handler->node); 1214 list_del_init(&handler->node);
1092 1215
@@ -1097,6 +1220,27 @@ void input_unregister_handler(struct input_handler *handler)
1097} 1220}
1098EXPORT_SYMBOL(input_unregister_handler); 1221EXPORT_SYMBOL(input_unregister_handler);
1099 1222
1223int input_register_handle(struct input_handle *handle)
1224{
1225 struct input_handler *handler = handle->handler;
1226
1227 list_add_tail(&handle->d_node, &handle->dev->h_list);
1228 list_add_tail(&handle->h_node, &handler->h_list);
1229
1230 if (handler->start)
1231 handler->start(handle);
1232
1233 return 0;
1234}
1235EXPORT_SYMBOL(input_register_handle);
1236
1237void input_unregister_handle(struct input_handle *handle)
1238{
1239 list_del_init(&handle->h_node);
1240 list_del_init(&handle->d_node);
1241}
1242EXPORT_SYMBOL(input_unregister_handle);
1243
1100static int input_open_file(struct inode *inode, struct file *file) 1244static int input_open_file(struct inode *inode, struct file *file)
1101{ 1245{
1102 struct input_handler *handler = input_table[iminor(inode) >> 5]; 1246 struct input_handler *handler = input_table[iminor(inode) >> 5];
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 9f3529ad3fda..9bcc5425049b 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -43,7 +43,7 @@ struct joydev {
43 char name[16]; 43 char name[16];
44 struct input_handle handle; 44 struct input_handle handle;
45 wait_queue_head_t wait; 45 wait_queue_head_t wait;
46 struct list_head list; 46 struct list_head client_list;
47 struct js_corr corr[ABS_MAX + 1]; 47 struct js_corr corr[ABS_MAX + 1];
48 struct JS_DATA_SAVE_TYPE glue; 48 struct JS_DATA_SAVE_TYPE glue;
49 int nabs; 49 int nabs;
@@ -55,7 +55,7 @@ struct joydev {
55 __s16 abs[ABS_MAX + 1]; 55 __s16 abs[ABS_MAX + 1];
56}; 56};
57 57
58struct joydev_list { 58struct joydev_client {
59 struct js_event buffer[JOYDEV_BUFFER_SIZE]; 59 struct js_event buffer[JOYDEV_BUFFER_SIZE];
60 int head; 60 int head;
61 int tail; 61 int tail;
@@ -87,7 +87,7 @@ static int joydev_correct(int value, struct js_corr *corr)
87static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) 87static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
88{ 88{
89 struct joydev *joydev = handle->private; 89 struct joydev *joydev = handle->private;
90 struct joydev_list *list; 90 struct joydev_client *client;
91 struct js_event event; 91 struct js_event event;
92 92
93 switch (type) { 93 switch (type) {
@@ -115,15 +115,15 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne
115 115
116 event.time = jiffies_to_msecs(jiffies); 116 event.time = jiffies_to_msecs(jiffies);
117 117
118 list_for_each_entry(list, &joydev->list, node) { 118 list_for_each_entry(client, &joydev->client_list, node) {
119 119
120 memcpy(list->buffer + list->head, &event, sizeof(struct js_event)); 120 memcpy(client->buffer + client->head, &event, sizeof(struct js_event));
121 121
122 if (list->startup == joydev->nabs + joydev->nkey) 122 if (client->startup == joydev->nabs + joydev->nkey)
123 if (list->tail == (list->head = (list->head + 1) & (JOYDEV_BUFFER_SIZE - 1))) 123 if (client->tail == (client->head = (client->head + 1) & (JOYDEV_BUFFER_SIZE - 1)))
124 list->startup = 0; 124 client->startup = 0;
125 125
126 kill_fasync(&list->fasync, SIGIO, POLL_IN); 126 kill_fasync(&client->fasync, SIGIO, POLL_IN);
127 } 127 }
128 128
129 wake_up_interruptible(&joydev->wait); 129 wake_up_interruptible(&joydev->wait);
@@ -132,9 +132,9 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne
132static int joydev_fasync(int fd, struct file *file, int on) 132static int joydev_fasync(int fd, struct file *file, int on)
133{ 133{
134 int retval; 134 int retval;
135 struct joydev_list *list = file->private_data; 135 struct joydev_client *client = file->private_data;
136 136
137 retval = fasync_helper(fd, file, on, &list->fasync); 137 retval = fasync_helper(fd, file, on, &client->fasync);
138 138
139 return retval < 0 ? retval : 0; 139 return retval < 0 ? retval : 0;
140} 140}
@@ -145,60 +145,73 @@ static void joydev_free(struct joydev *joydev)
145 kfree(joydev); 145 kfree(joydev);
146} 146}
147 147
148static int joydev_release(struct inode * inode, struct file * file) 148static int joydev_release(struct inode *inode, struct file *file)
149{ 149{
150 struct joydev_list *list = file->private_data; 150 struct joydev_client *client = file->private_data;
151 struct joydev *joydev = client->joydev;
151 152
152 joydev_fasync(-1, file, 0); 153 joydev_fasync(-1, file, 0);
153 154
154 list_del(&list->node); 155 list_del(&client->node);
156 kfree(client);
155 157
156 if (!--list->joydev->open) { 158 if (!--joydev->open) {
157 if (list->joydev->exist) 159 if (joydev->exist)
158 input_close_device(&list->joydev->handle); 160 input_close_device(&joydev->handle);
159 else 161 else
160 joydev_free(list->joydev); 162 joydev_free(joydev);
161 } 163 }
162 164
163 kfree(list);
164 return 0; 165 return 0;
165} 166}
166 167
167static int joydev_open(struct inode *inode, struct file *file) 168static int joydev_open(struct inode *inode, struct file *file)
168{ 169{
169 struct joydev_list *list; 170 struct joydev_client *client;
171 struct joydev *joydev;
170 int i = iminor(inode) - JOYDEV_MINOR_BASE; 172 int i = iminor(inode) - JOYDEV_MINOR_BASE;
173 int error;
174
175 if (i >= JOYDEV_MINORS)
176 return -ENODEV;
171 177
172 if (i >= JOYDEV_MINORS || !joydev_table[i]) 178 joydev = joydev_table[i];
179 if (!joydev || !joydev->exist)
173 return -ENODEV; 180 return -ENODEV;
174 181
175 if (!(list = kzalloc(sizeof(struct joydev_list), GFP_KERNEL))) 182 client = kzalloc(sizeof(struct joydev_client), GFP_KERNEL);
183 if (!client)
176 return -ENOMEM; 184 return -ENOMEM;
177 185
178 list->joydev = joydev_table[i]; 186 client->joydev = joydev;
179 list_add_tail(&list->node, &joydev_table[i]->list); 187 list_add_tail(&client->node, &joydev->client_list);
180 file->private_data = list;
181 188
182 if (!list->joydev->open++) 189 if (!joydev->open++ && joydev->exist) {
183 if (list->joydev->exist) 190 error = input_open_device(&joydev->handle);
184 input_open_device(&list->joydev->handle); 191 if (error) {
192 list_del(&client->node);
193 kfree(client);
194 return error;
195 }
196 }
185 197
198 file->private_data = client;
186 return 0; 199 return 0;
187} 200}
188 201
189static ssize_t joydev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) 202static ssize_t joydev_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
190{ 203{
191 return -EINVAL; 204 return -EINVAL;
192} 205}
193 206
194static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 207static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
195{ 208{
196 struct joydev_list *list = file->private_data; 209 struct joydev_client *client = file->private_data;
197 struct joydev *joydev = list->joydev; 210 struct joydev *joydev = client->joydev;
198 struct input_dev *input = joydev->handle.dev; 211 struct input_dev *input = joydev->handle.dev;
199 int retval = 0; 212 int retval = 0;
200 213
201 if (!list->joydev->exist) 214 if (!joydev->exist)
202 return -ENODEV; 215 return -ENODEV;
203 216
204 if (count < sizeof(struct js_event)) 217 if (count < sizeof(struct js_event))
@@ -217,56 +230,55 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo
217 if (copy_to_user(buf, &data, sizeof(struct JS_DATA_TYPE))) 230 if (copy_to_user(buf, &data, sizeof(struct JS_DATA_TYPE)))
218 return -EFAULT; 231 return -EFAULT;
219 232
220 list->startup = 0; 233 client->startup = 0;
221 list->tail = list->head; 234 client->tail = client->head;
222 235
223 return sizeof(struct JS_DATA_TYPE); 236 return sizeof(struct JS_DATA_TYPE);
224 } 237 }
225 238
226 if (list->startup == joydev->nabs + joydev->nkey && 239 if (client->startup == joydev->nabs + joydev->nkey &&
227 list->head == list->tail && (file->f_flags & O_NONBLOCK)) 240 client->head == client->tail && (file->f_flags & O_NONBLOCK))
228 return -EAGAIN; 241 return -EAGAIN;
229 242
230 retval = wait_event_interruptible(list->joydev->wait, 243 retval = wait_event_interruptible(joydev->wait,
231 !list->joydev->exist || 244 !joydev->exist ||
232 list->startup < joydev->nabs + joydev->nkey || 245 client->startup < joydev->nabs + joydev->nkey ||
233 list->head != list->tail); 246 client->head != client->tail);
234
235 if (retval) 247 if (retval)
236 return retval; 248 return retval;
237 249
238 if (!list->joydev->exist) 250 if (!joydev->exist)
239 return -ENODEV; 251 return -ENODEV;
240 252
241 while (list->startup < joydev->nabs + joydev->nkey && retval + sizeof(struct js_event) <= count) { 253 while (client->startup < joydev->nabs + joydev->nkey && retval + sizeof(struct js_event) <= count) {
242 254
243 struct js_event event; 255 struct js_event event;
244 256
245 event.time = jiffies_to_msecs(jiffies); 257 event.time = jiffies_to_msecs(jiffies);
246 258
247 if (list->startup < joydev->nkey) { 259 if (client->startup < joydev->nkey) {
248 event.type = JS_EVENT_BUTTON | JS_EVENT_INIT; 260 event.type = JS_EVENT_BUTTON | JS_EVENT_INIT;
249 event.number = list->startup; 261 event.number = client->startup;
250 event.value = !!test_bit(joydev->keypam[event.number], input->key); 262 event.value = !!test_bit(joydev->keypam[event.number], input->key);
251 } else { 263 } else {
252 event.type = JS_EVENT_AXIS | JS_EVENT_INIT; 264 event.type = JS_EVENT_AXIS | JS_EVENT_INIT;
253 event.number = list->startup - joydev->nkey; 265 event.number = client->startup - joydev->nkey;
254 event.value = joydev->abs[event.number]; 266 event.value = joydev->abs[event.number];
255 } 267 }
256 268
257 if (copy_to_user(buf + retval, &event, sizeof(struct js_event))) 269 if (copy_to_user(buf + retval, &event, sizeof(struct js_event)))
258 return -EFAULT; 270 return -EFAULT;
259 271
260 list->startup++; 272 client->startup++;
261 retval += sizeof(struct js_event); 273 retval += sizeof(struct js_event);
262 } 274 }
263 275
264 while (list->head != list->tail && retval + sizeof(struct js_event) <= count) { 276 while (client->head != client->tail && retval + sizeof(struct js_event) <= count) {
265 277
266 if (copy_to_user(buf + retval, list->buffer + list->tail, sizeof(struct js_event))) 278 if (copy_to_user(buf + retval, client->buffer + client->tail, sizeof(struct js_event)))
267 return -EFAULT; 279 return -EFAULT;
268 280
269 list->tail = (list->tail + 1) & (JOYDEV_BUFFER_SIZE - 1); 281 client->tail = (client->tail + 1) & (JOYDEV_BUFFER_SIZE - 1);
270 retval += sizeof(struct js_event); 282 retval += sizeof(struct js_event);
271 } 283 }
272 284
@@ -276,11 +288,12 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo
276/* No kernel lock - fine */ 288/* No kernel lock - fine */
277static unsigned int joydev_poll(struct file *file, poll_table *wait) 289static unsigned int joydev_poll(struct file *file, poll_table *wait)
278{ 290{
279 struct joydev_list *list = file->private_data; 291 struct joydev_client *client = file->private_data;
292 struct joydev *joydev = client->joydev;
280 293
281 poll_wait(file, &list->joydev->wait, wait); 294 poll_wait(file, &joydev->wait, wait);
282 return ((list->head != list->tail || list->startup < list->joydev->nabs + list->joydev->nkey) ? 295 return ((client->head != client->tail || client->startup < joydev->nabs + joydev->nkey) ?
283 (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); 296 (POLLIN | POLLRDNORM) : 0) | (joydev->exist ? 0 : (POLLHUP | POLLERR));
284} 297}
285 298
286static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp) 299static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp)
@@ -374,8 +387,8 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u
374#ifdef CONFIG_COMPAT 387#ifdef CONFIG_COMPAT
375static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 388static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
376{ 389{
377 struct joydev_list *list = file->private_data; 390 struct joydev_client *client = file->private_data;
378 struct joydev *joydev = list->joydev; 391 struct joydev *joydev = client->joydev;
379 void __user *argp = (void __user *)arg; 392 void __user *argp = (void __user *)arg;
380 s32 tmp32; 393 s32 tmp32;
381 struct JS_DATA_SAVE_TYPE_32 ds32; 394 struct JS_DATA_SAVE_TYPE_32 ds32;
@@ -428,8 +441,8 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo
428 441
429static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 442static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
430{ 443{
431 struct joydev_list *list = file->private_data; 444 struct joydev_client *client = file->private_data;
432 struct joydev *joydev = list->joydev; 445 struct joydev *joydev = client->joydev;
433 void __user *argp = (void __user *)arg; 446 void __user *argp = (void __user *)arg;
434 447
435 if (!joydev->exist) 448 if (!joydev->exist)
@@ -465,23 +478,26 @@ static const struct file_operations joydev_fops = {
465 .fasync = joydev_fasync, 478 .fasync = joydev_fasync,
466}; 479};
467 480
468static struct input_handle *joydev_connect(struct input_handler *handler, struct input_dev *dev, 481static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
469 const struct input_device_id *id) 482 const struct input_device_id *id)
470{ 483{
471 struct joydev *joydev; 484 struct joydev *joydev;
472 struct class_device *cdev; 485 struct class_device *cdev;
486 dev_t devt;
473 int i, j, t, minor; 487 int i, j, t, minor;
488 int error;
474 489
475 for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++); 490 for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
476 if (minor == JOYDEV_MINORS) { 491 if (minor == JOYDEV_MINORS) {
477 printk(KERN_ERR "joydev: no more free joydev devices\n"); 492 printk(KERN_ERR "joydev: no more free joydev devices\n");
478 return NULL; 493 return -ENFILE;
479 } 494 }
480 495
481 if (!(joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL))) 496 joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL);
482 return NULL; 497 if (!joydev)
498 return -ENOMEM;
483 499
484 INIT_LIST_HEAD(&joydev->list); 500 INIT_LIST_HEAD(&joydev->client_list);
485 init_waitqueue_head(&joydev->wait); 501 init_waitqueue_head(&joydev->wait);
486 502
487 joydev->minor = minor; 503 joydev->minor = minor;
@@ -534,31 +550,54 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
534 550
535 joydev_table[minor] = joydev; 551 joydev_table[minor] = joydev;
536 552
537 cdev = class_device_create(&input_class, &dev->cdev, 553 devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
538 MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), 554
539 dev->cdev.dev, joydev->name); 555 cdev = class_device_create(&input_class, &dev->cdev, devt,
556 dev->cdev.dev, joydev->name);
557 if (IS_ERR(cdev)) {
558 error = PTR_ERR(cdev);
559 goto err_free_joydev;
560 }
540 561
541 /* temporary symlink to keep userspace happy */ 562 /* temporary symlink to keep userspace happy */
542 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, 563 error = sysfs_create_link(&input_class.subsys.kobj,
543 joydev->name); 564 &cdev->kobj, joydev->name);
565 if (error)
566 goto err_cdev_destroy;
567
568 error = input_register_handle(&joydev->handle);
569 if (error)
570 goto err_remove_link;
571
572 return 0;
544 573
545 return &joydev->handle; 574 err_remove_link:
575 sysfs_remove_link(&input_class.subsys.kobj, joydev->name);
576 err_cdev_destroy:
577 class_device_destroy(&input_class, devt);
578 err_free_joydev:
579 joydev_table[minor] = NULL;
580 kfree(joydev);
581 return error;
546} 582}
547 583
584
548static void joydev_disconnect(struct input_handle *handle) 585static void joydev_disconnect(struct input_handle *handle)
549{ 586{
550 struct joydev *joydev = handle->private; 587 struct joydev *joydev = handle->private;
551 struct joydev_list *list; 588 struct joydev_client *client;
589
590 input_unregister_handle(handle);
552 591
553 sysfs_remove_link(&input_class.subsys.kset.kobj, joydev->name); 592 sysfs_remove_link(&input_class.subsys.kobj, joydev->name);
554 class_device_destroy(&input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor)); 593 class_device_destroy(&input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
555 joydev->exist = 0; 594 joydev->exist = 0;
556 595
557 if (joydev->open) { 596 if (joydev->open) {
558 input_close_device(handle); 597 input_close_device(handle);
559 wake_up_interruptible(&joydev->wait); 598 wake_up_interruptible(&joydev->wait);
560 list_for_each_entry(list, &joydev->list, node) 599 list_for_each_entry(client, &joydev->client_list, node)
561 kill_fasync(&list->fasync, SIGIO, POLL_HUP); 600 kill_fasync(&client->fasync, SIGIO, POLL_HUP);
562 } else 601 } else
563 joydev_free(joydev); 602 joydev_free(joydev);
564} 603}
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index b11a4bbc84c4..ff701ab10d74 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -241,7 +241,7 @@ static void a3d_adc_close(struct gameport *gameport)
241 241
242static int a3d_open(struct input_dev *dev) 242static int a3d_open(struct input_dev *dev)
243{ 243{
244 struct a3d *a3d = dev->private; 244 struct a3d *a3d = input_get_drvdata(dev);
245 245
246 gameport_start_polling(a3d->gameport); 246 gameport_start_polling(a3d->gameport);
247 return 0; 247 return 0;
@@ -253,7 +253,7 @@ static int a3d_open(struct input_dev *dev)
253 253
254static void a3d_close(struct input_dev *dev) 254static void a3d_close(struct input_dev *dev)
255{ 255{
256 struct a3d *a3d = dev->private; 256 struct a3d *a3d = input_get_drvdata(dev);
257 257
258 gameport_stop_polling(a3d->gameport); 258 gameport_stop_polling(a3d->gameport);
259} 259}
@@ -314,11 +314,12 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
314 input_dev->id.vendor = GAMEPORT_ID_VENDOR_MADCATZ; 314 input_dev->id.vendor = GAMEPORT_ID_VENDOR_MADCATZ;
315 input_dev->id.product = a3d->mode; 315 input_dev->id.product = a3d->mode;
316 input_dev->id.version = 0x0100; 316 input_dev->id.version = 0x0100;
317 input_dev->cdev.dev = &gameport->dev; 317 input_dev->dev.parent = &gameport->dev;
318 input_dev->private = a3d;
319 input_dev->open = a3d_open; 318 input_dev->open = a3d_open;
320 input_dev->close = a3d_close; 319 input_dev->close = a3d_close;
321 320
321 input_set_drvdata(input_dev, a3d);
322
322 if (a3d->mode == A3D_MODE_PXL) { 323 if (a3d->mode == A3D_MODE_PXL) {
323 324
324 int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER }; 325 int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER };
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index 6279ced8a35b..28140c4a110d 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -290,7 +290,7 @@ static void adi_poll(struct gameport *gameport)
290 290
291static int adi_open(struct input_dev *dev) 291static int adi_open(struct input_dev *dev)
292{ 292{
293 struct adi_port *port = dev->private; 293 struct adi_port *port = input_get_drvdata(dev);
294 294
295 gameport_start_polling(port->gameport); 295 gameport_start_polling(port->gameport);
296 return 0; 296 return 0;
@@ -302,7 +302,7 @@ static int adi_open(struct input_dev *dev)
302 302
303static void adi_close(struct input_dev *dev) 303static void adi_close(struct input_dev *dev)
304{ 304{
305 struct adi_port *port = dev->private; 305 struct adi_port *port = input_get_drvdata(dev);
306 306
307 gameport_stop_polling(port->gameport); 307 gameport_stop_polling(port->gameport);
308} 308}
@@ -424,8 +424,9 @@ static int adi_init_input(struct adi *adi, struct adi_port *port, int half)
424 input_dev->id.vendor = GAMEPORT_ID_VENDOR_LOGITECH; 424 input_dev->id.vendor = GAMEPORT_ID_VENDOR_LOGITECH;
425 input_dev->id.product = adi->id; 425 input_dev->id.product = adi->id;
426 input_dev->id.version = 0x0100; 426 input_dev->id.version = 0x0100;
427 input_dev->cdev.dev = &port->gameport->dev; 427 input_dev->dev.parent = &port->gameport->dev;
428 input_dev->private = port; 428
429 input_set_drvdata(input_dev, port);
429 430
430 input_dev->open = adi_open; 431 input_dev->open = adi_open;
431 input_dev->close = adi_close; 432 input_dev->close = adi_close;
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index 51f1e4bfff3e..1c1afb5d4684 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -343,7 +343,7 @@ static void analog_poll(struct gameport *gameport)
343 343
344static int analog_open(struct input_dev *dev) 344static int analog_open(struct input_dev *dev)
345{ 345{
346 struct analog_port *port = dev->private; 346 struct analog_port *port = input_get_drvdata(dev);
347 347
348 gameport_start_polling(port->gameport); 348 gameport_start_polling(port->gameport);
349 return 0; 349 return 0;
@@ -355,7 +355,7 @@ static int analog_open(struct input_dev *dev)
355 355
356static void analog_close(struct input_dev *dev) 356static void analog_close(struct input_dev *dev)
357{ 357{
358 struct analog_port *port = dev->private; 358 struct analog_port *port = input_get_drvdata(dev);
359 359
360 gameport_stop_polling(port->gameport); 360 gameport_stop_polling(port->gameport);
361} 361}
@@ -449,10 +449,13 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
449 input_dev->id.vendor = GAMEPORT_ID_VENDOR_ANALOG; 449 input_dev->id.vendor = GAMEPORT_ID_VENDOR_ANALOG;
450 input_dev->id.product = analog->mask >> 4; 450 input_dev->id.product = analog->mask >> 4;
451 input_dev->id.version = 0x0100; 451 input_dev->id.version = 0x0100;
452 input_dev->dev.parent = &port->gameport->dev;
453
454 input_set_drvdata(input_dev, port);
452 455
453 input_dev->open = analog_open; 456 input_dev->open = analog_open;
454 input_dev->close = analog_close; 457 input_dev->close = analog_close;
455 input_dev->private = port; 458
456 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 459 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
457 460
458 for (i = j = 0; i < 4; i++) 461 for (i = j = 0; i < 4; i++)
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index 034ec39c251d..d3352a849b85 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -142,7 +142,7 @@ static void cobra_poll(struct gameport *gameport)
142 142
143static int cobra_open(struct input_dev *dev) 143static int cobra_open(struct input_dev *dev)
144{ 144{
145 struct cobra *cobra = dev->private; 145 struct cobra *cobra = input_get_drvdata(dev);
146 146
147 gameport_start_polling(cobra->gameport); 147 gameport_start_polling(cobra->gameport);
148 return 0; 148 return 0;
@@ -150,7 +150,7 @@ static int cobra_open(struct input_dev *dev)
150 150
151static void cobra_close(struct input_dev *dev) 151static void cobra_close(struct input_dev *dev)
152{ 152{
153 struct cobra *cobra = dev->private; 153 struct cobra *cobra = input_get_drvdata(dev);
154 154
155 gameport_stop_polling(cobra->gameport); 155 gameport_stop_polling(cobra->gameport);
156} 156}
@@ -211,8 +211,9 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
211 input_dev->id.vendor = GAMEPORT_ID_VENDOR_CREATIVE; 211 input_dev->id.vendor = GAMEPORT_ID_VENDOR_CREATIVE;
212 input_dev->id.product = 0x0008; 212 input_dev->id.product = 0x0008;
213 input_dev->id.version = 0x0100; 213 input_dev->id.version = 0x0100;
214 input_dev->cdev.dev = &gameport->dev; 214 input_dev->dev.parent = &gameport->dev;
215 input_dev->private = cobra; 215
216 input_set_drvdata(input_dev, cobra);
216 217
217 input_dev->open = cobra_open; 218 input_dev->open = cobra_open;
218 input_dev->close = cobra_close; 219 input_dev->close = cobra_close;
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index b41bd2eb37dd..c27593bf9978 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -518,7 +518,7 @@ static void db9_timer(unsigned long private)
518 518
519static int db9_open(struct input_dev *dev) 519static int db9_open(struct input_dev *dev)
520{ 520{
521 struct db9 *db9 = dev->private; 521 struct db9 *db9 = input_get_drvdata(dev);
522 struct parport *port = db9->pd->port; 522 struct parport *port = db9->pd->port;
523 int err; 523 int err;
524 524
@@ -542,7 +542,7 @@ static int db9_open(struct input_dev *dev)
542 542
543static void db9_close(struct input_dev *dev) 543static void db9_close(struct input_dev *dev)
544{ 544{
545 struct db9 *db9 = dev->private; 545 struct db9 *db9 = input_get_drvdata(dev);
546 struct parport *port = db9->pd->port; 546 struct parport *port = db9->pd->port;
547 547
548 mutex_lock(&db9->mutex); 548 mutex_lock(&db9->mutex);
@@ -625,7 +625,8 @@ static struct db9 __init *db9_probe(int parport, int mode)
625 input_dev->id.vendor = 0x0002; 625 input_dev->id.vendor = 0x0002;
626 input_dev->id.product = mode; 626 input_dev->id.product = mode;
627 input_dev->id.version = 0x0100; 627 input_dev->id.version = 0x0100;
628 input_dev->private = db9; 628
629 input_set_drvdata(input_dev, db9);
629 630
630 input_dev->open = db9_open; 631 input_dev->open = db9_open;
631 input_dev->close = db9_close; 632 input_dev->close = db9_close;
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 711e4b3e9e61..c71b58fe225d 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -591,7 +591,7 @@ static void gc_timer(unsigned long private)
591 591
592static int gc_open(struct input_dev *dev) 592static int gc_open(struct input_dev *dev)
593{ 593{
594 struct gc *gc = dev->private; 594 struct gc *gc = input_get_drvdata(dev);
595 int err; 595 int err;
596 596
597 err = mutex_lock_interruptible(&gc->mutex); 597 err = mutex_lock_interruptible(&gc->mutex);
@@ -610,7 +610,7 @@ static int gc_open(struct input_dev *dev)
610 610
611static void gc_close(struct input_dev *dev) 611static void gc_close(struct input_dev *dev)
612{ 612{
613 struct gc *gc = dev->private; 613 struct gc *gc = input_get_drvdata(dev);
614 614
615 mutex_lock(&gc->mutex); 615 mutex_lock(&gc->mutex);
616 if (!--gc->used) { 616 if (!--gc->used) {
@@ -646,7 +646,8 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
646 input_dev->id.vendor = 0x0001; 646 input_dev->id.vendor = 0x0001;
647 input_dev->id.product = pad_type; 647 input_dev->id.product = pad_type;
648 input_dev->id.version = 0x0100; 648 input_dev->id.version = 0x0100;
649 input_dev->private = gc; 649
650 input_set_drvdata(input_dev, gc);
650 651
651 input_dev->open = gc_open; 652 input_dev->open = gc_open;
652 input_dev->close = gc_close; 653 input_dev->close = gc_close;
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index bacbab5d1b6f..d514aebf7554 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -220,7 +220,7 @@ static void gf2k_poll(struct gameport *gameport)
220 220
221static int gf2k_open(struct input_dev *dev) 221static int gf2k_open(struct input_dev *dev)
222{ 222{
223 struct gf2k *gf2k = dev->private; 223 struct gf2k *gf2k = input_get_drvdata(dev);
224 224
225 gameport_start_polling(gf2k->gameport); 225 gameport_start_polling(gf2k->gameport);
226 return 0; 226 return 0;
@@ -228,7 +228,7 @@ static int gf2k_open(struct input_dev *dev)
228 228
229static void gf2k_close(struct input_dev *dev) 229static void gf2k_close(struct input_dev *dev)
230{ 230{
231 struct gf2k *gf2k = dev->private; 231 struct gf2k *gf2k = input_get_drvdata(dev);
232 232
233 gameport_stop_polling(gf2k->gameport); 233 gameport_stop_polling(gf2k->gameport);
234} 234}
@@ -308,11 +308,13 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
308 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GENIUS; 308 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GENIUS;
309 input_dev->id.product = gf2k->id; 309 input_dev->id.product = gf2k->id;
310 input_dev->id.version = 0x0100; 310 input_dev->id.version = 0x0100;
311 input_dev->cdev.dev = &gameport->dev; 311 input_dev->dev.parent = &gameport->dev;
312 input_dev->private = gf2k; 312
313 input_set_drvdata(input_dev, gf2k);
313 314
314 input_dev->open = gf2k_open; 315 input_dev->open = gf2k_open;
315 input_dev->close = gf2k_close; 316 input_dev->close = gf2k_close;
317
316 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 318 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
317 319
318 for (i = 0; i < gf2k_axes[gf2k->id]; i++) 320 for (i = 0; i < gf2k_axes[gf2k->id]; i++)
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index 17a90c436de8..73eb5ab6f140 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -285,7 +285,7 @@ static void grip_poll(struct gameport *gameport)
285 285
286static int grip_open(struct input_dev *dev) 286static int grip_open(struct input_dev *dev)
287{ 287{
288 struct grip *grip = dev->private; 288 struct grip *grip = input_get_drvdata(dev);
289 289
290 gameport_start_polling(grip->gameport); 290 gameport_start_polling(grip->gameport);
291 return 0; 291 return 0;
@@ -293,7 +293,7 @@ static int grip_open(struct input_dev *dev)
293 293
294static void grip_close(struct input_dev *dev) 294static void grip_close(struct input_dev *dev)
295{ 295{
296 struct grip *grip = dev->private; 296 struct grip *grip = input_get_drvdata(dev);
297 297
298 gameport_stop_polling(grip->gameport); 298 gameport_stop_polling(grip->gameport);
299} 299}
@@ -363,8 +363,9 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
363 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; 363 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
364 input_dev->id.product = grip->mode[i]; 364 input_dev->id.product = grip->mode[i];
365 input_dev->id.version = 0x0100; 365 input_dev->id.version = 0x0100;
366 input_dev->cdev.dev = &gameport->dev; 366 input_dev->dev.parent = &gameport->dev;
367 input_dev->private = grip; 367
368 input_set_drvdata(input_dev, grip);
368 369
369 input_dev->open = grip_open; 370 input_dev->open = grip_open;
370 input_dev->close = grip_close; 371 input_dev->close = grip_close;
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index 8120a9c40773..555319e6378c 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -562,7 +562,7 @@ static void grip_poll(struct gameport *gameport)
562 562
563static int grip_open(struct input_dev *dev) 563static int grip_open(struct input_dev *dev)
564{ 564{
565 struct grip_mp *grip = dev->private; 565 struct grip_mp *grip = input_get_drvdata(dev);
566 566
567 gameport_start_polling(grip->gameport); 567 gameport_start_polling(grip->gameport);
568 return 0; 568 return 0;
@@ -574,9 +574,9 @@ static int grip_open(struct input_dev *dev)
574 574
575static void grip_close(struct input_dev *dev) 575static void grip_close(struct input_dev *dev)
576{ 576{
577 struct grip_mp *grip = dev->private; 577 struct grip_mp *grip = input_get_drvdata(dev);
578 578
579 gameport_start_polling(grip->gameport); 579 gameport_stop_polling(grip->gameport);
580} 580}
581 581
582/* 582/*
@@ -599,8 +599,9 @@ static int register_slot(int slot, struct grip_mp *grip)
599 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; 599 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
600 input_dev->id.product = 0x0100 + port->mode; 600 input_dev->id.product = 0x0100 + port->mode;
601 input_dev->id.version = 0x0100; 601 input_dev->id.version = 0x0100;
602 input_dev->cdev.dev = &grip->gameport->dev; 602 input_dev->dev.parent = &grip->gameport->dev;
603 input_dev->private = grip; 603
604 input_set_drvdata(input_dev, grip);
604 605
605 input_dev->open = grip_open; 606 input_dev->open = grip_open;
606 input_dev->close = grip_close; 607 input_dev->close = grip_close;
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index dbc5d92858b8..d4e8073caf27 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -156,7 +156,7 @@ static void guillemot_poll(struct gameport *gameport)
156 156
157static int guillemot_open(struct input_dev *dev) 157static int guillemot_open(struct input_dev *dev)
158{ 158{
159 struct guillemot *guillemot = dev->private; 159 struct guillemot *guillemot = input_get_drvdata(dev);
160 160
161 gameport_start_polling(guillemot->gameport); 161 gameport_start_polling(guillemot->gameport);
162 return 0; 162 return 0;
@@ -168,7 +168,7 @@ static int guillemot_open(struct input_dev *dev)
168 168
169static void guillemot_close(struct input_dev *dev) 169static void guillemot_close(struct input_dev *dev)
170{ 170{
171 struct guillemot *guillemot = dev->private; 171 struct guillemot *guillemot = input_get_drvdata(dev);
172 172
173 gameport_stop_polling(guillemot->gameport); 173 gameport_stop_polling(guillemot->gameport);
174} 174}
@@ -231,8 +231,9 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
231 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GUILLEMOT; 231 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GUILLEMOT;
232 input_dev->id.product = guillemot_type[i].id; 232 input_dev->id.product = guillemot_type[i].id;
233 input_dev->id.version = (int)data[14] << 8 | data[15]; 233 input_dev->id.version = (int)data[14] << 8 | data[15];
234 input_dev->cdev.dev = &gameport->dev; 234 input_dev->dev.parent = &gameport->dev;
235 input_dev->private = guillemot; 235
236 input_set_drvdata(input_dev, guillemot);
236 237
237 input_dev->open = guillemot_open; 238 input_dev->open = guillemot_open;
238 input_dev->close = guillemot_close; 239 input_dev->close = guillemot_close;
diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c
index 8fb0c19cc60e..f2a4381d0ab8 100644
--- a/drivers/input/joystick/iforce/iforce-ff.c
+++ b/drivers/input/joystick/iforce/iforce-ff.c
@@ -2,7 +2,7 @@
2 * $Id: iforce-ff.c,v 1.9 2002/02/02 19:28:35 jdeneux Exp $ 2 * $Id: iforce-ff.c,v 1.9 2002/02/02 19:28:35 jdeneux Exp $
3 * 3 *
4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> 4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
5 * Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> 5 * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
6 * 6 *
7 * USB/RS232 I-Force joysticks and wheels. 7 * USB/RS232 I-Force joysticks and wheels.
8 */ 8 */
@@ -205,7 +205,7 @@ static int need_condition_modifier(struct ff_effect *old, struct ff_effect *new)
205 int i; 205 int i;
206 206
207 if (new->type != FF_SPRING && new->type != FF_FRICTION) { 207 if (new->type != FF_SPRING && new->type != FF_FRICTION) {
208 printk(KERN_WARNING "iforce.c: bad effect type in need_condition_modifier\n"); 208 warn("bad effect type in need_condition_modifier");
209 return 0; 209 return 0;
210 } 210 }
211 211
@@ -227,7 +227,7 @@ static int need_condition_modifier(struct ff_effect *old, struct ff_effect *new)
227static int need_magnitude_modifier(struct ff_effect *old, struct ff_effect *effect) 227static int need_magnitude_modifier(struct ff_effect *old, struct ff_effect *effect)
228{ 228{
229 if (effect->type != FF_CONSTANT) { 229 if (effect->type != FF_CONSTANT) {
230 printk(KERN_WARNING "iforce.c: bad effect type in need_envelope_modifier\n"); 230 warn("bad effect type in need_envelope_modifier");
231 return 0; 231 return 0;
232 } 232 }
233 233
@@ -258,7 +258,7 @@ static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effec
258 break; 258 break;
259 259
260 default: 260 default:
261 printk(KERN_WARNING "iforce.c: bad effect type in need_envelope_modifier\n"); 261 warn("bad effect type in need_envelope_modifier");
262 } 262 }
263 263
264 return 0; 264 return 0;
@@ -271,7 +271,7 @@ static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effec
271static int need_period_modifier(struct ff_effect *old, struct ff_effect *new) 271static int need_period_modifier(struct ff_effect *old, struct ff_effect *new)
272{ 272{
273 if (new->type != FF_PERIODIC) { 273 if (new->type != FF_PERIODIC) {
274 printk(KERN_WARNING "iforce.c: bad effect type in need_period_modifier\n"); 274 warn("bad effect type in need_period_modifier");
275 return 0; 275 return 0;
276 } 276 }
277 return (old->u.periodic.period != new->u.periodic.period 277 return (old->u.periodic.period != new->u.periodic.period
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index 3393a37fec39..fb129c479a66 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -2,7 +2,7 @@
2 * $Id: iforce-main.c,v 1.19 2002/07/07 10:22:50 jdeneux Exp $ 2 * $Id: iforce-main.c,v 1.19 2002/07/07 10:22:50 jdeneux Exp $
3 * 3 *
4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> 4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
5 * Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> 5 * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
6 * 6 *
7 * USB/RS232 I-Force joysticks and wheels. 7 * USB/RS232 I-Force joysticks and wheels.
8 */ 8 */
@@ -29,7 +29,7 @@
29 29
30#include "iforce.h" 30#include "iforce.h"
31 31
32MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <deneux@ifrance.com>"); 32MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <johann.deneux@gmail.com>");
33MODULE_DESCRIPTION("USB/RS232 I-Force joysticks and wheels driver"); 33MODULE_DESCRIPTION("USB/RS232 I-Force joysticks and wheels driver");
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35 35
@@ -220,7 +220,7 @@ static void iforce_release(struct input_dev *dev)
220 /* Check: no effects should be present in memory */ 220 /* Check: no effects should be present in memory */
221 for (i = 0; i < dev->ff->max_effects; i++) { 221 for (i = 0; i < dev->ff->max_effects; i++) {
222 if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags)) { 222 if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags)) {
223 printk(KERN_WARNING "iforce_release: Device still owns effects\n"); 223 warn("iforce_release: Device still owns effects");
224 break; 224 break;
225 } 225 }
226 } 226 }
@@ -232,7 +232,7 @@ static void iforce_release(struct input_dev *dev)
232 switch (iforce->bus) { 232 switch (iforce->bus) {
233#ifdef CONFIG_JOYSTICK_IFORCE_USB 233#ifdef CONFIG_JOYSTICK_IFORCE_USB
234 case IFORCE_USB: 234 case IFORCE_USB:
235 usb_unlink_urb(iforce->irq); 235 usb_kill_urb(iforce->irq);
236 236
237 /* The device was unplugged before the file 237 /* The device was unplugged before the file
238 * was released */ 238 * was released */
@@ -287,13 +287,13 @@ int iforce_init_device(struct iforce *iforce)
287#ifdef CONFIG_JOYSTICK_IFORCE_USB 287#ifdef CONFIG_JOYSTICK_IFORCE_USB
288 case IFORCE_USB: 288 case IFORCE_USB:
289 input_dev->id.bustype = BUS_USB; 289 input_dev->id.bustype = BUS_USB;
290 input_dev->cdev.dev = &iforce->usbdev->dev; 290 input_dev->dev.parent = &iforce->usbdev->dev;
291 break; 291 break;
292#endif 292#endif
293#ifdef CONFIG_JOYSTICK_IFORCE_232 293#ifdef CONFIG_JOYSTICK_IFORCE_232
294 case IFORCE_232: 294 case IFORCE_232:
295 input_dev->id.bustype = BUS_RS232; 295 input_dev->id.bustype = BUS_RS232;
296 input_dev->cdev.dev = &iforce->serio->dev; 296 input_dev->dev.parent = &iforce->serio->dev;
297 break; 297 break;
298#endif 298#endif
299 } 299 }
@@ -324,7 +324,7 @@ int iforce_init_device(struct iforce *iforce)
324 break; 324 break;
325 325
326 if (i == 20) { /* 5 seconds */ 326 if (i == 20) { /* 5 seconds */
327 printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n"); 327 err("Timeout waiting for response from device.");
328 error = -ENODEV; 328 error = -ENODEV;
329 goto fail; 329 goto fail;
330 } 330 }
@@ -336,26 +336,26 @@ int iforce_init_device(struct iforce *iforce)
336 if (!iforce_get_id_packet(iforce, "M")) 336 if (!iforce_get_id_packet(iforce, "M"))
337 input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; 337 input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1];
338 else 338 else
339 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet M\n"); 339 warn("Device does not respond to id packet M");
340 340
341 if (!iforce_get_id_packet(iforce, "P")) 341 if (!iforce_get_id_packet(iforce, "P"))
342 input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; 342 input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1];
343 else 343 else
344 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet P\n"); 344 warn("Device does not respond to id packet P");
345 345
346 if (!iforce_get_id_packet(iforce, "B")) 346 if (!iforce_get_id_packet(iforce, "B"))
347 iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1]; 347 iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1];
348 else 348 else
349 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet B\n"); 349 warn("Device does not respond to id packet B");
350 350
351 if (!iforce_get_id_packet(iforce, "N")) 351 if (!iforce_get_id_packet(iforce, "N"))
352 ff_effects = iforce->edata[1]; 352 ff_effects = iforce->edata[1];
353 else 353 else
354 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet N\n"); 354 warn("Device does not respond to id packet N");
355 355
356 /* Check if the device can store more effects than the driver can really handle */ 356 /* Check if the device can store more effects than the driver can really handle */
357 if (ff_effects > IFORCE_EFFECTS_MAX) { 357 if (ff_effects > IFORCE_EFFECTS_MAX) {
358 printk(KERN_WARNING "iforce: Limiting number of effects to %d (device reports %d)\n", 358 warn("Limiting number of effects to %d (device reports %d)",
359 IFORCE_EFFECTS_MAX, ff_effects); 359 IFORCE_EFFECTS_MAX, ff_effects);
360 ff_effects = IFORCE_EFFECTS_MAX; 360 ff_effects = IFORCE_EFFECTS_MAX;
361 } 361 }
@@ -457,8 +457,6 @@ int iforce_init_device(struct iforce *iforce)
457 if (error) 457 if (error)
458 goto fail; 458 goto fail;
459 459
460 printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open);
461
462 return 0; 460 return 0;
463 461
464 fail: input_free_device(input_dev); 462 fail: input_free_device(input_dev);
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
index 808f05932a6f..21c4e13d3a50 100644
--- a/drivers/input/joystick/iforce/iforce-packets.c
+++ b/drivers/input/joystick/iforce/iforce-packets.c
@@ -2,7 +2,7 @@
2 * $Id: iforce-packets.c,v 1.16 2002/07/07 10:22:50 jdeneux Exp $ 2 * $Id: iforce-packets.c,v 1.16 2002/07/07 10:22:50 jdeneux Exp $
3 * 3 *
4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> 4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
5 * Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> 5 * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
6 * 6 *
7 * USB/RS232 I-Force joysticks and wheels. 7 * USB/RS232 I-Force joysticks and wheels.
8 */ 8 */
@@ -39,10 +39,10 @@ void iforce_dump_packet(char *msg, u16 cmd, unsigned char *data)
39{ 39{
40 int i; 40 int i;
41 41
42 printk(KERN_DEBUG "iforce.c: %s ( cmd = %04x, data = ", msg, cmd); 42 printk(KERN_DEBUG __FILE__ ": %s cmd = %04x, data = ", msg, cmd);
43 for (i = 0; i < LO(cmd); i++) 43 for (i = 0; i < LO(cmd); i++)
44 printk("%02x ", data[i]); 44 printk("%02x ", data[i]);
45 printk(")\n"); 45 printk("\n");
46} 46}
47 47
48/* 48/*
@@ -65,8 +65,9 @@ int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data)
65 head = iforce->xmit.head; 65 head = iforce->xmit.head;
66 tail = iforce->xmit.tail; 66 tail = iforce->xmit.tail;
67 67
68
68 if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) { 69 if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) {
69 printk(KERN_WARNING "iforce.c: not enough space in xmit buffer to send new packet\n"); 70 warn("not enough space in xmit buffer to send new packet");
70 spin_unlock_irqrestore(&iforce->xmit_lock, flags); 71 spin_unlock_irqrestore(&iforce->xmit_lock, flags);
71 return -1; 72 return -1;
72 } 73 }
@@ -126,8 +127,6 @@ int iforce_control_playback(struct iforce* iforce, u16 id, unsigned int value)
126{ 127{
127 unsigned char data[3]; 128 unsigned char data[3];
128 129
129printk(KERN_DEBUG "iforce-packets.c: control_playback %d %d\n", id, value);
130
131 data[0] = LO(id); 130 data[0] = LO(id);
132 data[1] = (value > 0) ? ((value > 1) ? 0x41 : 0x01) : 0; 131 data[1] = (value > 0) ? ((value > 1) ? 0x41 : 0x01) : 0;
133 data[2] = LO(value); 132 data[2] = LO(value);
@@ -151,7 +150,7 @@ static int mark_core_as_ready(struct iforce *iforce, unsigned short addr)
151 return 0; 150 return 0;
152 } 151 }
153 } 152 }
154 printk(KERN_WARNING "iforce-packets.c: unused effect %04x updated !!!\n", addr); 153 warn("unused effect %04x updated !!!", addr);
155 return -1; 154 return -1;
156} 155}
157 156
@@ -162,7 +161,7 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data)
162 static int being_used = 0; 161 static int being_used = 0;
163 162
164 if (being_used) 163 if (being_used)
165 printk(KERN_WARNING "iforce-packets.c: re-entrant call to iforce_process %d\n", being_used); 164 warn("re-entrant call to iforce_process %d", being_used);
166 being_used++; 165 being_used++;
167 166
168#ifdef CONFIG_JOYSTICK_IFORCE_232 167#ifdef CONFIG_JOYSTICK_IFORCE_232
@@ -266,7 +265,7 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
266 return -1; 265 return -1;
267 } 266 }
268#else 267#else
269 printk(KERN_ERR "iforce_get_id_packet: iforce->bus = USB!\n"); 268 err("iforce_get_id_packet: iforce->bus = USB!");
270#endif 269#endif
271 break; 270 break;
272 271
@@ -284,13 +283,12 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
284 return -1; 283 return -1;
285 } 284 }
286#else 285#else
287 printk(KERN_ERR "iforce_get_id_packet: iforce->bus = SERIO!\n"); 286 err("iforce_get_id_packet: iforce->bus = SERIO!");
288#endif 287#endif
289 break; 288 break;
290 289
291 default: 290 default:
292 printk(KERN_ERR "iforce_get_id_packet: iforce->bus = %d\n", 291 err("iforce_get_id_packet: iforce->bus = %d", iforce->bus);
293 iforce->bus);
294 break; 292 break;
295 } 293 }
296 294
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
index ec4be535f483..7b4bc19cef27 100644
--- a/drivers/input/joystick/iforce/iforce-serio.c
+++ b/drivers/input/joystick/iforce/iforce-serio.c
@@ -2,7 +2,7 @@
2 * $Id: iforce-serio.c,v 1.4 2002/01/28 22:45:00 jdeneux Exp $ 2 * $Id: iforce-serio.c,v 1.4 2002/01/28 22:45:00 jdeneux Exp $
3 * 3 *
4 * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@ucw.cz> 4 * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@ucw.cz>
5 * Copyright (c) 2001 Johann Deneux <deneux@ifrance.com> 5 * Copyright (c) 2001, 2007 Johann Deneux <johann.deneux@gmail.com>
6 * 6 *
7 * USB/RS232 I-Force joysticks and wheels. 7 * USB/RS232 I-Force joysticks and wheels.
8 */ 8 */
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 80cdebcbcb99..750099d8e3c6 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -2,7 +2,7 @@
2 * $Id: iforce-usb.c,v 1.16 2002/06/09 11:08:04 jdeneux Exp $ 2 * $Id: iforce-usb.c,v 1.16 2002/06/09 11:08:04 jdeneux Exp $
3 * 3 *
4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> 4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
5 * Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> 5 * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
6 * 6 *
7 * USB/RS232 I-Force joysticks and wheels. 7 * USB/RS232 I-Force joysticks and wheels.
8 */ 8 */
@@ -65,7 +65,7 @@ void iforce_usb_xmit(struct iforce *iforce)
65 XMIT_INC(iforce->xmit.tail, n); 65 XMIT_INC(iforce->xmit.tail, n);
66 66
67 if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) { 67 if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) {
68 printk(KERN_WARNING "iforce-usb.c: iforce_usb_xmit: usb_submit_urb failed %d\n", n); 68 warn("usb_submit_urb failed %d\n", n);
69 } 69 }
70 70
71 /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended. 71 /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended.
@@ -110,7 +110,7 @@ static void iforce_usb_out(struct urb *urb)
110 struct iforce *iforce = urb->context; 110 struct iforce *iforce = urb->context;
111 111
112 if (urb->status) { 112 if (urb->status) {
113 printk(KERN_DEBUG "iforce_usb_out: urb->status %d, exiting", urb->status); 113 dbg("urb->status %d, exiting", urb->status);
114 return; 114 return;
115 } 115 }
116 116
@@ -190,10 +190,9 @@ fail:
190/* Called by iforce_delete() */ 190/* Called by iforce_delete() */
191void iforce_usb_delete(struct iforce* iforce) 191void iforce_usb_delete(struct iforce* iforce)
192{ 192{
193 usb_unlink_urb(iforce->irq); 193 usb_kill_urb(iforce->irq);
194/* Is it ok to unlink those ? */ 194 usb_kill_urb(iforce->out);
195 usb_unlink_urb(iforce->out); 195 usb_kill_urb(iforce->ctrl);
196 usb_unlink_urb(iforce->ctrl);
197 196
198 usb_free_urb(iforce->irq); 197 usb_free_urb(iforce->irq);
199 usb_free_urb(iforce->out); 198 usb_free_urb(iforce->out);
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h
index ffaeaefa1a42..dadcf4fb92ae 100644
--- a/drivers/input/joystick/iforce/iforce.h
+++ b/drivers/input/joystick/iforce/iforce.h
@@ -2,7 +2,7 @@
2 * $Id: iforce.h,v 1.13 2002/07/07 10:22:50 jdeneux Exp $ 2 * $Id: iforce.h,v 1.13 2002/07/07 10:22:50 jdeneux Exp $
3 * 3 *
4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> 4 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
5 * Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> 5 * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
6 * 6 *
7 * USB/RS232 I-Force joysticks and wheels. 7 * USB/RS232 I-Force joysticks and wheels.
8 */ 8 */
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index fec8b3d0967d..1aec1e9d7c59 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -185,7 +185,7 @@ static void interact_poll(struct gameport *gameport)
185 185
186static int interact_open(struct input_dev *dev) 186static int interact_open(struct input_dev *dev)
187{ 187{
188 struct interact *interact = dev->private; 188 struct interact *interact = input_get_drvdata(dev);
189 189
190 gameport_start_polling(interact->gameport); 190 gameport_start_polling(interact->gameport);
191 return 0; 191 return 0;
@@ -197,7 +197,7 @@ static int interact_open(struct input_dev *dev)
197 197
198static void interact_close(struct input_dev *dev) 198static void interact_close(struct input_dev *dev)
199{ 199{
200 struct interact *interact = dev->private; 200 struct interact *interact = input_get_drvdata(dev);
201 201
202 gameport_stop_polling(interact->gameport); 202 gameport_stop_polling(interact->gameport);
203} 203}
@@ -262,7 +262,9 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
262 input_dev->id.vendor = GAMEPORT_ID_VENDOR_INTERACT; 262 input_dev->id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
263 input_dev->id.product = interact_type[i].id; 263 input_dev->id.product = interact_type[i].id;
264 input_dev->id.version = 0x0100; 264 input_dev->id.version = 0x0100;
265 input_dev->private = interact; 265 input_dev->dev.parent = &gameport->dev;
266
267 input_set_drvdata(input_dev, interact);
266 268
267 input_dev->open = interact_open; 269 input_dev->open = interact_open;
268 input_dev->close = interact_close; 270 input_dev->close = interact_close;
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index 4112789f1196..b35604ee43ae 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -168,8 +168,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
168 input_dev->id.vendor = SERIO_MAGELLAN; 168 input_dev->id.vendor = SERIO_MAGELLAN;
169 input_dev->id.product = 0x0001; 169 input_dev->id.product = 0x0001;
170 input_dev->id.version = 0x0100; 170 input_dev->id.version = 0x0100;
171 input_dev->cdev.dev = &serio->dev; 171 input_dev->dev.parent = &serio->dev;
172 input_dev->private = magellan;
173 172
174 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 173 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
175 174
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index e58b22c018e4..2adf73f63c94 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -509,7 +509,7 @@ static void sw_poll(struct gameport *gameport)
509 509
510static int sw_open(struct input_dev *dev) 510static int sw_open(struct input_dev *dev)
511{ 511{
512 struct sw *sw = dev->private; 512 struct sw *sw = input_get_drvdata(dev);
513 513
514 gameport_start_polling(sw->gameport); 514 gameport_start_polling(sw->gameport);
515 return 0; 515 return 0;
@@ -517,7 +517,7 @@ static int sw_open(struct input_dev *dev)
517 517
518static void sw_close(struct input_dev *dev) 518static void sw_close(struct input_dev *dev)
519{ 519{
520 struct sw *sw = dev->private; 520 struct sw *sw = input_get_drvdata(dev);
521 521
522 gameport_stop_polling(sw->gameport); 522 gameport_stop_polling(sw->gameport);
523} 523}
@@ -751,8 +751,9 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
751 input_dev->id.vendor = GAMEPORT_ID_VENDOR_MICROSOFT; 751 input_dev->id.vendor = GAMEPORT_ID_VENDOR_MICROSOFT;
752 input_dev->id.product = sw->type; 752 input_dev->id.product = sw->type;
753 input_dev->id.version = 0x0100; 753 input_dev->id.version = 0x0100;
754 input_dev->cdev.dev = &gameport->dev; 754 input_dev->dev.parent = &gameport->dev;
755 input_dev->private = sw; 755
756 input_set_drvdata(input_dev, sw);
756 757
757 input_dev->open = sw_open; 758 input_dev->open = sw_open;
758 input_dev->close = sw_close; 759 input_dev->close = sw_close;
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index 08bf113e62eb..abb7c4cf54ad 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -226,8 +226,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
226 input_dev->id.vendor = SERIO_SPACEBALL; 226 input_dev->id.vendor = SERIO_SPACEBALL;
227 input_dev->id.product = id; 227 input_dev->id.product = id;
228 input_dev->id.version = 0x0100; 228 input_dev->id.version = 0x0100;
229 input_dev->cdev.dev = &serio->dev; 229 input_dev->dev.parent = &serio->dev;
230 input_dev->private = spaceball;
231 230
232 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 231 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
233 232
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index c9c79211af71..c4937f1e837c 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -183,8 +183,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
183 input_dev->id.vendor = SERIO_SPACEORB; 183 input_dev->id.vendor = SERIO_SPACEORB;
184 input_dev->id.product = 0x0001; 184 input_dev->id.product = 0x0001;
185 input_dev->id.version = 0x0100; 185 input_dev->id.version = 0x0100;
186 input_dev->cdev.dev = &serio->dev; 186 input_dev->dev.parent = &serio->dev;
187 input_dev->private = spaceorb;
188 187
189 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 188 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
190 189
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index ecb0916215fa..8581ee991d4e 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -154,8 +154,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
154 input_dev->id.vendor = SERIO_STINGER; 154 input_dev->id.vendor = SERIO_STINGER;
155 input_dev->id.product = 0x0001; 155 input_dev->id.product = 0x0001;
156 input_dev->id.version = 0x0100; 156 input_dev->id.version = 0x0100;
157 input_dev->cdev.dev = &serio->dev; 157 input_dev->dev.parent = &serio->dev;
158 input_dev->private = stinger;
159 158
160 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 159 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
161 input_dev->keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) | 160 input_dev->keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) |
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index bb23ed2a04a6..3b36ee04f726 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -265,7 +265,7 @@ static void tmdc_poll(struct gameport *gameport)
265 265
266static int tmdc_open(struct input_dev *dev) 266static int tmdc_open(struct input_dev *dev)
267{ 267{
268 struct tmdc *tmdc = dev->private; 268 struct tmdc *tmdc = input_get_drvdata(dev);
269 269
270 gameport_start_polling(tmdc->gameport); 270 gameport_start_polling(tmdc->gameport);
271 return 0; 271 return 0;
@@ -273,7 +273,7 @@ static int tmdc_open(struct input_dev *dev)
273 273
274static void tmdc_close(struct input_dev *dev) 274static void tmdc_close(struct input_dev *dev)
275{ 275{
276 struct tmdc *tmdc = dev->private; 276 struct tmdc *tmdc = input_get_drvdata(dev);
277 277
278 gameport_stop_polling(tmdc->gameport); 278 gameport_stop_polling(tmdc->gameport);
279} 279}
@@ -326,8 +326,9 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
326 input_dev->id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER; 326 input_dev->id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER;
327 input_dev->id.product = model->id; 327 input_dev->id.product = model->id;
328 input_dev->id.version = 0x0100; 328 input_dev->id.version = 0x0100;
329 input_dev->cdev.dev = &tmdc->gameport->dev; 329 input_dev->dev.parent = &tmdc->gameport->dev;
330 input_dev->private = tmdc; 330
331 input_set_drvdata(input_dev, tmdc);
331 332
332 input_dev->open = tmdc_open; 333 input_dev->open = tmdc_open;
333 input_dev->close = tmdc_close; 334 input_dev->close = tmdc_close;
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index 037d3487fcc7..0f2c60823b0b 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -122,7 +122,7 @@ static void tgfx_timer(unsigned long private)
122 122
123static int tgfx_open(struct input_dev *dev) 123static int tgfx_open(struct input_dev *dev)
124{ 124{
125 struct tgfx *tgfx = dev->private; 125 struct tgfx *tgfx = input_get_drvdata(dev);
126 int err; 126 int err;
127 127
128 err = mutex_lock_interruptible(&tgfx->sem); 128 err = mutex_lock_interruptible(&tgfx->sem);
@@ -141,7 +141,7 @@ static int tgfx_open(struct input_dev *dev)
141 141
142static void tgfx_close(struct input_dev *dev) 142static void tgfx_close(struct input_dev *dev)
143{ 143{
144 struct tgfx *tgfx = dev->private; 144 struct tgfx *tgfx = input_get_drvdata(dev);
145 145
146 mutex_lock(&tgfx->sem); 146 mutex_lock(&tgfx->sem);
147 if (!--tgfx->used) { 147 if (!--tgfx->used) {
@@ -224,7 +224,8 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
224 input_dev->id.product = n_buttons[i]; 224 input_dev->id.product = n_buttons[i];
225 input_dev->id.version = 0x0100; 225 input_dev->id.version = 0x0100;
226 226
227 input_dev->private = tgfx; 227 input_set_drvdata(input_dev, tgfx);
228
228 input_dev->open = tgfx_open; 229 input_dev->open = tgfx_open;
229 input_dev->close = tgfx_close; 230 input_dev->close = tgfx_close;
230 231
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index 9cf17d6ced82..c91504ec38eb 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -205,11 +205,9 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
205 input_dev->id.vendor = SERIO_TWIDJOY; 205 input_dev->id.vendor = SERIO_TWIDJOY;
206 input_dev->id.product = 0x0001; 206 input_dev->id.product = 0x0001;
207 input_dev->id.version = 0x0100; 207 input_dev->id.version = 0x0100;
208 input_dev->cdev.dev = &serio->dev; 208 input_dev->dev.parent = &serio->dev;
209 input_dev->private = twidjoy;
210 209
211 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 210 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
212 input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
213 input_set_abs_params(input_dev, ABS_X, -50, 50, 4, 4); 211 input_set_abs_params(input_dev, ABS_X, -50, 50, 4, 4);
214 input_set_abs_params(input_dev, ABS_Y, -50, 50, 4, 4); 212 input_set_abs_params(input_dev, ABS_Y, -50, 50, 4, 4);
215 213
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index 29d339acf430..4e85f72eefd7 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -160,8 +160,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
160 input_dev->id.vendor = SERIO_WARRIOR; 160 input_dev->id.vendor = SERIO_WARRIOR;
161 input_dev->id.product = 0x0001; 161 input_dev->id.product = 0x0001;
162 input_dev->id.version = 0x0100; 162 input_dev->id.version = 0x0100;
163 input_dev->cdev.dev = &serio->dev; 163 input_dev->dev.parent = &serio->dev;
164 input_dev->private = warrior;
165 164
166 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS); 165 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
167 input_dev->keybit[LONG(BTN_TRIGGER)] = BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_TOP2); 166 input_dev->keybit[LONG(BTN_TRIGGER)] = BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_TOP2);
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index f17e9c7d4b36..9f42e4d3649e 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -164,6 +164,17 @@ config KEYBOARD_AMIGA
164 To compile this driver as a module, choose M here: the 164 To compile this driver as a module, choose M here: the
165 module will be called amikbd. 165 module will be called amikbd.
166 166
167config KEYBOARD_ATARI
168 tristate "Atari keyboard"
169 depends on ATARI
170 select ATARI_KBD_CORE
171 help
172 Say Y here if you are running Linux on any Atari and have a keyboard
173 attached.
174
175 To compile this driver as a module, choose M here: the
176 module will be called atakbd.
177
167config KEYBOARD_HIL_OLD 178config KEYBOARD_HIL_OLD
168 tristate "HP HIL keyboard support (simple driver)" 179 tristate "HP HIL keyboard support (simple driver)"
169 depends on GSC || HP300 180 depends on GSC || HP300
@@ -203,6 +214,15 @@ config KEYBOARD_OMAP
203 To compile this driver as a module, choose M here: the 214 To compile this driver as a module, choose M here: the
204 module will be called omap-keypad. 215 module will be called omap-keypad.
205 216
217config KEYBOARD_PXA27x
218 tristate "PXA27x keyboard support"
219 depends on PXA27x
220 help
221 Enable support for PXA27x matrix keyboard controller
222
223 To compile this driver as a module, choose M here: the
224 module will be called pxa27x_keyboard.
225
206config KEYBOARD_AAED2000 226config KEYBOARD_AAED2000
207 tristate "AAED-2000 keyboard" 227 tristate "AAED-2000 keyboard"
208 depends on MACH_AAED2000 228 depends on MACH_AAED2000
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 586a0fe53be6..28d211b87b14 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
9obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o 9obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
10obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o 10obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
11obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o 11obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o
12obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o
12obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o 13obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o
13obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 14obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
14obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o 15obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
@@ -17,6 +18,7 @@ obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
17obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
18obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
19obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o 20obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
21obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keyboard.o
20obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o 22obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o
21obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 23obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
22 24
diff --git a/drivers/input/keyboard/aaed2000_kbd.c b/drivers/input/keyboard/aaed2000_kbd.c
index 65fcb6af63a8..3a37505f067c 100644
--- a/drivers/input/keyboard/aaed2000_kbd.c
+++ b/drivers/input/keyboard/aaed2000_kbd.c
@@ -97,7 +97,7 @@ static void aaedkbd_work(void *data)
97 97
98static int aaedkbd_open(struct input_dev *indev) 98static int aaedkbd_open(struct input_dev *indev)
99{ 99{
100 struct aaedkbd *aaedkbd = indev->private; 100 struct aaedkbd *aaedkbd = input_get_drvdata(indev);
101 101
102 schedule_delayed_work(&aaedkbd->workq, msecs_to_jiffies(SCAN_INTERVAL)); 102 schedule_delayed_work(&aaedkbd->workq, msecs_to_jiffies(SCAN_INTERVAL));
103 103
@@ -106,7 +106,7 @@ static int aaedkbd_open(struct input_dev *indev)
106 106
107static void aaedkbd_close(struct input_dev *indev) 107static void aaedkbd_close(struct input_dev *indev)
108{ 108{
109 struct aaedkbd *aaedkbd = indev->private; 109 struct aaedkbd *aaedkbd = input_get_drvdata(indev);
110 110
111 cancel_delayed_work(&aaedkbd->workq); 111 cancel_delayed_work(&aaedkbd->workq);
112 flush_scheduled_work(); 112 flush_scheduled_work();
@@ -141,8 +141,9 @@ static int __devinit aaedkbd_probe(struct platform_device *pdev)
141 input_dev->id.vendor = 0x0001; 141 input_dev->id.vendor = 0x0001;
142 input_dev->id.product = 0x0001; 142 input_dev->id.product = 0x0001;
143 input_dev->id.version = 0x0100; 143 input_dev->id.version = 0x0100;
144 input_dev->cdev.dev = &pdev->dev; 144 input_dev->dev.parent = &pdev->dev;
145 input_dev->private = aaedkbd; 145
146 input_set_drvdata(input_dev, aaedkbd);
146 147
147 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 148 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
148 input_dev->keycode = aaedkbd->keycode; 149 input_dev->keycode = aaedkbd->keycode;
diff --git a/drivers/input/keyboard/atakbd.c b/drivers/input/keyboard/atakbd.c
new file mode 100644
index 000000000000..ded1d6ac6ff3
--- /dev/null
+++ b/drivers/input/keyboard/atakbd.c
@@ -0,0 +1,134 @@
1/*
2 * atakbd.c
3 *
4 * Copyright (c) 2005 Michael Schmitz
5 *
6 * Based on amikbd.c, which is
7 *
8 * Copyright (c) 2000-2001 Vojtech Pavlik
9 *
10 * Based on the work of:
11 * Hamish Macdonald
12 */
13
14/*
15 * Atari keyboard driver for Linux/m68k
16 *
17 * The low level init and interrupt stuff is handled in arch/mm68k/atari/atakeyb.c
18 * (the keyboard ACIA also handles the mouse and joystick data, and the keyboard
19 * interrupt is shared with the MIDI ACIA so MIDI data also get handled there).
20 * This driver only deals with handing key events off to the input layer.
21 */
22
23/*
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
28 *
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 *
38 * Should you need to contact me, the author, you can do so either by
39 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
40 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
41 */
42
43#include <linux/module.h>
44#include <linux/init.h>
45#include <linux/input.h>
46#include <linux/delay.h>
47#include <linux/interrupt.h>
48
49#include <asm/atariints.h>
50#include <asm/atarihw.h>
51#include <asm/atarikb.h>
52#include <asm/irq.h>
53
54MODULE_AUTHOR("Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>");
55MODULE_DESCRIPTION("Atari keyboard driver");
56MODULE_LICENSE("GPL");
57
58static unsigned char atakbd_keycode[0x72];
59
60static struct input_dev *atakbd_dev;
61
62static void atakbd_interrupt(unsigned char scancode, char down)
63{
64
65 if (scancode < 0x72) { /* scancodes < 0xf2 are keys */
66
67 // report raw events here?
68
69 scancode = atakbd_keycode[scancode];
70
71 if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */
72 input_report_key(atakbd_dev, scancode, 1);
73 input_report_key(atakbd_dev, scancode, 0);
74 input_sync(atakbd_dev);
75 } else {
76 input_report_key(atakbd_dev, scancode, down);
77 input_sync(atakbd_dev);
78 }
79 } else /* scancodes >= 0xf2 are mouse data, most likely */
80 printk(KERN_INFO "atakbd: unhandled scancode %x\n", scancode);
81
82 return;
83}
84
85static int __init atakbd_init(void)
86{
87 int i;
88
89 if (!ATARIHW_PRESENT(ST_MFP))
90 return -EIO;
91
92 // TODO: request_mem_region if not done in arch code
93
94 if (!(atakbd_dev = input_allocate_device()))
95 return -ENOMEM;
96
97 // need to init core driver if not already done so
98 if (atari_keyb_init())
99 return -ENODEV;
100
101 atakbd_dev->name = "Atari Keyboard";
102 atakbd_dev->phys = "atakbd/input0";
103 atakbd_dev->id.bustype = BUS_ATARI;
104 atakbd_dev->id.vendor = 0x0001;
105 atakbd_dev->id.product = 0x0001;
106 atakbd_dev->id.version = 0x0100;
107
108 atakbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
109 atakbd_dev->keycode = atakbd_keycode;
110 atakbd_dev->keycodesize = sizeof(unsigned char);
111 atakbd_dev->keycodemax = ARRAY_SIZE(atakbd_keycode);
112
113 for (i = 1; i < 0x72; i++) {
114 atakbd_keycode[i] = i;
115 set_bit(atakbd_keycode[i], atakbd_dev->keybit);
116 }
117
118 input_register_device(atakbd_dev);
119
120 atari_input_keyboard_interrupt_hook = atakbd_interrupt;
121
122 printk(KERN_INFO "input: %s at IKBD ACIA\n", atakbd_dev->name);
123
124 return 0;
125}
126
127static void __exit atakbd_exit(void)
128{
129 atari_input_keyboard_interrupt_hook = NULL;
130 input_unregister_device(atakbd_dev);
131}
132
133module_init(atakbd_init);
134module_exit(atakbd_exit);
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 663877076bc7..be1fe46cd308 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -586,7 +586,7 @@ static void atkbd_event_work(struct work_struct *work)
586 586
587static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 587static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
588{ 588{
589 struct atkbd *atkbd = dev->private; 589 struct atkbd *atkbd = input_get_drvdata(dev);
590 590
591 if (!atkbd->write) 591 if (!atkbd->write)
592 return -1; 592 return -1;
@@ -883,8 +883,9 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd)
883 input_dev->id.product = atkbd->translated ? 1 : atkbd->set; 883 input_dev->id.product = atkbd->translated ? 1 : atkbd->set;
884 input_dev->id.version = atkbd->id; 884 input_dev->id.version = atkbd->id;
885 input_dev->event = atkbd_event; 885 input_dev->event = atkbd_event;
886 input_dev->private = atkbd; 886 input_dev->dev.parent = &atkbd->ps2dev.serio->dev;
887 input_dev->cdev.dev = &atkbd->ps2dev.serio->dev; 887
888 input_set_drvdata(input_dev, atkbd);
888 889
889 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC); 890 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC);
890 891
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index 1016c94e65db..6578bfff644b 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -323,8 +323,7 @@ static int __init corgikbd_probe(struct platform_device *pdev)
323 input_dev->id.vendor = 0x0001; 323 input_dev->id.vendor = 0x0001;
324 input_dev->id.product = 0x0001; 324 input_dev->id.product = 0x0001;
325 input_dev->id.version = 0x0100; 325 input_dev->id.version = 0x0100;
326 input_dev->cdev.dev = &pdev->dev; 326 input_dev->dev.parent = &pdev->dev;
327 input_dev->private = corgikbd;
328 327
329 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); 328 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
330 input_dev->keycode = corgikbd->keycode; 329 input_dev->keycode = corgikbd->keycode;
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ccf6df387b62..739212252b09 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -35,11 +35,14 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
35 struct input_dev *input = platform_get_drvdata(pdev); 35 struct input_dev *input = platform_get_drvdata(pdev);
36 36
37 for (i = 0; i < pdata->nbuttons; i++) { 37 for (i = 0; i < pdata->nbuttons; i++) {
38 int gpio = pdata->buttons[i].gpio; 38 struct gpio_keys_button *button = &pdata->buttons[i];
39 int gpio = button->gpio;
40
39 if (irq == gpio_to_irq(gpio)) { 41 if (irq == gpio_to_irq(gpio)) {
40 int state = (gpio_get_value(gpio) ? 1 : 0) ^ (pdata->buttons[i].active_low); 42 unsigned int type = button->type ?: EV_KEY;
43 int state = (gpio_get_value(gpio) ? 1 : 0) ^ button->active_low;
41 44
42 input_report_key(input, pdata->buttons[i].keycode, state); 45 input_event(input, type, button->code, !!state);
43 input_sync(input); 46 input_sync(input);
44 } 47 }
45 } 48 }
@@ -63,8 +66,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
63 66
64 input->name = pdev->name; 67 input->name = pdev->name;
65 input->phys = "gpio-keys/input0"; 68 input->phys = "gpio-keys/input0";
66 input->cdev.dev = &pdev->dev; 69 input->dev.parent = &pdev->dev;
67 input->private = pdata;
68 70
69 input->id.bustype = BUS_HOST; 71 input->id.bustype = BUS_HOST;
70 input->id.vendor = 0x0001; 72 input->id.vendor = 0x0001;
@@ -72,19 +74,21 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
72 input->id.version = 0x0100; 74 input->id.version = 0x0100;
73 75
74 for (i = 0; i < pdata->nbuttons; i++) { 76 for (i = 0; i < pdata->nbuttons; i++) {
75 int code = pdata->buttons[i].keycode; 77 struct gpio_keys_button *button = &pdata->buttons[i];
76 int irq = gpio_to_irq(pdata->buttons[i].gpio); 78 int irq = gpio_to_irq(button->gpio);
79 unsigned int type = button->type ?: EV_KEY;
77 80
78 set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); 81 set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
79 error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM, 82 error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM,
80 pdata->buttons[i].desc ? pdata->buttons[i].desc : "gpio_keys", 83 button->desc ? button->desc : "gpio_keys",
81 pdev); 84 pdev);
82 if (error) { 85 if (error) {
83 printk(KERN_ERR "gpio-keys: unable to claim irq %d; error %d\n", 86 printk(KERN_ERR "gpio-keys: unable to claim irq %d; error %d\n",
84 irq, error); 87 irq, error);
85 goto fail; 88 goto fail;
86 } 89 }
87 set_bit(code, input->keybit); 90
91 input_set_capability(input, type, button->code);
88 } 92 }
89 93
90 error = input_register_device(input); 94 error = input_register_device(input);
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
index 7cc9728b04df..cdd254f2e6c7 100644
--- a/drivers/input/keyboard/hil_kbd.c
+++ b/drivers/input/keyboard/hil_kbd.c
@@ -51,7 +51,7 @@ MODULE_LICENSE("Dual BSD/GPL");
51 51
52#define HIL_KBD_SET1_UPBIT 0x01 52#define HIL_KBD_SET1_UPBIT 0x01
53#define HIL_KBD_SET1_SHIFT 1 53#define HIL_KBD_SET1_SHIFT 1
54static unsigned int hil_kbd_set1[HIL_KEYCODES_SET1_TBLSIZE] = 54static unsigned int hil_kbd_set1[HIL_KEYCODES_SET1_TBLSIZE] __read_mostly =
55 { HIL_KEYCODES_SET1 }; 55 { HIL_KEYCODES_SET1 };
56 56
57#define HIL_KBD_SET2_UPBIT 0x01 57#define HIL_KBD_SET2_UPBIT 0x01
@@ -60,10 +60,10 @@ static unsigned int hil_kbd_set1[HIL_KEYCODES_SET1_TBLSIZE] =
60 60
61#define HIL_KBD_SET3_UPBIT 0x80 61#define HIL_KBD_SET3_UPBIT 0x80
62#define HIL_KBD_SET3_SHIFT 0 62#define HIL_KBD_SET3_SHIFT 0
63static unsigned int hil_kbd_set3[HIL_KEYCODES_SET3_TBLSIZE] = 63static unsigned int hil_kbd_set3[HIL_KEYCODES_SET3_TBLSIZE] __read_mostly =
64 { HIL_KEYCODES_SET3 }; 64 { HIL_KEYCODES_SET3 };
65 65
66static char hil_language[][16] = { HIL_LOCALE_MAP }; 66static const char hil_language[][16] = { HIL_LOCALE_MAP };
67 67
68struct hil_kbd { 68struct hil_kbd {
69 struct input_dev *dev; 69 struct input_dev *dev;
@@ -94,10 +94,12 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
94 idx = kbd->idx4/4; 94 idx = kbd->idx4/4;
95 p = data[idx - 1]; 95 p = data[idx - 1];
96 96
97 if ((p & ~HIL_CMDCT_POL) == 97 if ((p & ~HIL_CMDCT_POL) ==
98 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) goto report; 98 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
99 if ((p & ~HIL_CMDCT_RPL) == 99 goto report;
100 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL)) goto report; 100 if ((p & ~HIL_CMDCT_RPL) ==
101 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL))
102 goto report;
101 103
102 /* Not a poll response. See if we are loading config records. */ 104 /* Not a poll response. See if we are loading config records. */
103 switch (p & HIL_PKT_DATA_MASK) { 105 switch (p & HIL_PKT_DATA_MASK) {
@@ -107,27 +109,32 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
107 for (; i < HIL_KBD_MAX_LENGTH; i++) 109 for (; i < HIL_KBD_MAX_LENGTH; i++)
108 kbd->idd[i] = 0; 110 kbd->idd[i] = 0;
109 break; 111 break;
112
110 case HIL_CMD_RSC: 113 case HIL_CMD_RSC:
111 for (i = 0; i < idx; i++) 114 for (i = 0; i < idx; i++)
112 kbd->rsc[i] = kbd->data[i] & HIL_PKT_DATA_MASK; 115 kbd->rsc[i] = kbd->data[i] & HIL_PKT_DATA_MASK;
113 for (; i < HIL_KBD_MAX_LENGTH; i++) 116 for (; i < HIL_KBD_MAX_LENGTH; i++)
114 kbd->rsc[i] = 0; 117 kbd->rsc[i] = 0;
115 break; 118 break;
119
116 case HIL_CMD_EXD: 120 case HIL_CMD_EXD:
117 for (i = 0; i < idx; i++) 121 for (i = 0; i < idx; i++)
118 kbd->exd[i] = kbd->data[i] & HIL_PKT_DATA_MASK; 122 kbd->exd[i] = kbd->data[i] & HIL_PKT_DATA_MASK;
119 for (; i < HIL_KBD_MAX_LENGTH; i++) 123 for (; i < HIL_KBD_MAX_LENGTH; i++)
120 kbd->exd[i] = 0; 124 kbd->exd[i] = 0;
121 break; 125 break;
126
122 case HIL_CMD_RNM: 127 case HIL_CMD_RNM:
123 for (i = 0; i < idx; i++) 128 for (i = 0; i < idx; i++)
124 kbd->rnm[i] = kbd->data[i] & HIL_PKT_DATA_MASK; 129 kbd->rnm[i] = kbd->data[i] & HIL_PKT_DATA_MASK;
125 for (; i < HIL_KBD_MAX_LENGTH + 1; i++) 130 for (; i < HIL_KBD_MAX_LENGTH + 1; i++)
126 kbd->rnm[i] = '\0'; 131 kbd->rnm[i] = '\0';
127 break; 132 break;
133
128 default: 134 default:
129 /* These occur when device isn't present */ 135 /* These occur when device isn't present */
130 if (p == (HIL_ERR_INT | HIL_PKT_CMD)) break; 136 if (p == (HIL_ERR_INT | HIL_PKT_CMD))
137 break;
131 /* Anything else we'd like to know about. */ 138 /* Anything else we'd like to know about. */
132 printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p); 139 printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p);
133 break; 140 break;
@@ -139,16 +146,19 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
139 switch (kbd->data[0] & HIL_POL_CHARTYPE_MASK) { 146 switch (kbd->data[0] & HIL_POL_CHARTYPE_MASK) {
140 case HIL_POL_CHARTYPE_NONE: 147 case HIL_POL_CHARTYPE_NONE:
141 break; 148 break;
149
142 case HIL_POL_CHARTYPE_ASCII: 150 case HIL_POL_CHARTYPE_ASCII:
143 while (cnt < idx - 1) 151 while (cnt < idx - 1)
144 input_report_key(dev, kbd->data[cnt++] & 0x7f, 1); 152 input_report_key(dev, kbd->data[cnt++] & 0x7f, 1);
145 break; 153 break;
154
146 case HIL_POL_CHARTYPE_RSVD1: 155 case HIL_POL_CHARTYPE_RSVD1:
147 case HIL_POL_CHARTYPE_RSVD2: 156 case HIL_POL_CHARTYPE_RSVD2:
148 case HIL_POL_CHARTYPE_BINARY: 157 case HIL_POL_CHARTYPE_BINARY:
149 while (cnt < idx - 1) 158 while (cnt < idx - 1)
150 input_report_key(dev, kbd->data[cnt++], 1); 159 input_report_key(dev, kbd->data[cnt++], 1);
151 break; 160 break;
161
152 case HIL_POL_CHARTYPE_SET1: 162 case HIL_POL_CHARTYPE_SET1:
153 while (cnt < idx - 1) { 163 while (cnt < idx - 1) {
154 unsigned int key; 164 unsigned int key;
@@ -161,6 +171,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
161 input_report_key(dev, key, !up); 171 input_report_key(dev, key, !up);
162 } 172 }
163 break; 173 break;
174
164 case HIL_POL_CHARTYPE_SET2: 175 case HIL_POL_CHARTYPE_SET2:
165 while (cnt < idx - 1) { 176 while (cnt < idx - 1) {
166 unsigned int key; 177 unsigned int key;
@@ -173,6 +184,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
173 input_report_key(dev, key, !up); 184 input_report_key(dev, key, !up);
174 } 185 }
175 break; 186 break;
187
176 case HIL_POL_CHARTYPE_SET3: 188 case HIL_POL_CHARTYPE_SET3:
177 while (cnt < idx - 1) { 189 while (cnt < idx - 1) {
178 unsigned int key; 190 unsigned int key;
@@ -191,42 +203,43 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
191 up(&kbd->sem); 203 up(&kbd->sem);
192} 204}
193 205
194static void hil_kbd_process_err(struct hil_kbd *kbd) { 206static void hil_kbd_process_err(struct hil_kbd *kbd)
207{
195 printk(KERN_WARNING PREFIX "errored HIL packet\n"); 208 printk(KERN_WARNING PREFIX "errored HIL packet\n");
196 kbd->idx4 = 0; 209 kbd->idx4 = 0;
197 up(&kbd->sem); 210 up(&kbd->sem);
198} 211}
199 212
200static irqreturn_t hil_kbd_interrupt(struct serio *serio, 213static irqreturn_t hil_kbd_interrupt(struct serio *serio,
201 unsigned char data, unsigned int flags) 214 unsigned char data, unsigned int flags)
202{ 215{
203 struct hil_kbd *kbd; 216 struct hil_kbd *kbd;
204 hil_packet packet; 217 hil_packet packet;
205 int idx; 218 int idx;
206 219
207 kbd = serio_get_drvdata(serio); 220 kbd = serio_get_drvdata(serio);
208 if (kbd == NULL) { 221 BUG_ON(kbd == NULL);
209 BUG();
210 return IRQ_HANDLED;
211 }
212 222
213 if (kbd->idx4 >= (HIL_KBD_MAX_LENGTH * sizeof(hil_packet))) { 223 if (kbd->idx4 >= (HIL_KBD_MAX_LENGTH * sizeof(hil_packet))) {
214 hil_kbd_process_err(kbd); 224 hil_kbd_process_err(kbd);
215 return IRQ_HANDLED; 225 return IRQ_HANDLED;
216 } 226 }
217 idx = kbd->idx4/4; 227 idx = kbd->idx4/4;
218 if (!(kbd->idx4 % 4)) kbd->data[idx] = 0; 228 if (!(kbd->idx4 % 4))
229 kbd->data[idx] = 0;
219 packet = kbd->data[idx]; 230 packet = kbd->data[idx];
220 packet |= ((hil_packet)data) << ((3 - (kbd->idx4 % 4)) * 8); 231 packet |= ((hil_packet)data) << ((3 - (kbd->idx4 % 4)) * 8);
221 kbd->data[idx] = packet; 232 kbd->data[idx] = packet;
222 233
223 /* Records of N 4-byte hil_packets must terminate with a command. */ 234 /* Records of N 4-byte hil_packets must terminate with a command. */
224 if ((++(kbd->idx4)) % 4) return IRQ_HANDLED; 235 if ((++(kbd->idx4)) % 4)
236 return IRQ_HANDLED;
225 if ((packet & 0xffff0000) != HIL_ERR_INT) { 237 if ((packet & 0xffff0000) != HIL_ERR_INT) {
226 hil_kbd_process_err(kbd); 238 hil_kbd_process_err(kbd);
227 return IRQ_HANDLED; 239 return IRQ_HANDLED;
228 } 240 }
229 if (packet & HIL_PKT_CMD) hil_kbd_process_record(kbd); 241 if (packet & HIL_PKT_CMD)
242 hil_kbd_process_record(kbd);
230 return IRQ_HANDLED; 243 return IRQ_HANDLED;
231} 244}
232 245
@@ -235,10 +248,7 @@ static void hil_kbd_disconnect(struct serio *serio)
235 struct hil_kbd *kbd; 248 struct hil_kbd *kbd;
236 249
237 kbd = serio_get_drvdata(serio); 250 kbd = serio_get_drvdata(serio);
238 if (kbd == NULL) { 251 BUG_ON(kbd == NULL);
239 BUG();
240 return;
241 }
242 252
243 serio_close(serio); 253 serio_close(serio);
244 input_unregister_device(kbd->dev); 254 input_unregister_device(kbd->dev);
@@ -259,42 +269,40 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
259 if (!kbd->dev) 269 if (!kbd->dev)
260 goto bail0; 270 goto bail0;
261 271
262 kbd->dev->private = kbd;
263
264 if (serio_open(serio, drv)) 272 if (serio_open(serio, drv))
265 goto bail1; 273 goto bail1;
266 274
267 serio_set_drvdata(serio, kbd); 275 serio_set_drvdata(serio, kbd);
268 kbd->serio = serio; 276 kbd->serio = serio;
269 277
270 init_MUTEX_LOCKED(&(kbd->sem)); 278 init_MUTEX_LOCKED(&kbd->sem);
271 279
272 /* Get device info. MLC driver supplies devid/status/etc. */ 280 /* Get device info. MLC driver supplies devid/status/etc. */
273 serio->write(serio, 0); 281 serio->write(serio, 0);
274 serio->write(serio, 0); 282 serio->write(serio, 0);
275 serio->write(serio, HIL_PKT_CMD >> 8); 283 serio->write(serio, HIL_PKT_CMD >> 8);
276 serio->write(serio, HIL_CMD_IDD); 284 serio->write(serio, HIL_CMD_IDD);
277 down(&(kbd->sem)); 285 down(&kbd->sem);
278 286
279 serio->write(serio, 0); 287 serio->write(serio, 0);
280 serio->write(serio, 0); 288 serio->write(serio, 0);
281 serio->write(serio, HIL_PKT_CMD >> 8); 289 serio->write(serio, HIL_PKT_CMD >> 8);
282 serio->write(serio, HIL_CMD_RSC); 290 serio->write(serio, HIL_CMD_RSC);
283 down(&(kbd->sem)); 291 down(&kbd->sem);
284 292
285 serio->write(serio, 0); 293 serio->write(serio, 0);
286 serio->write(serio, 0); 294 serio->write(serio, 0);
287 serio->write(serio, HIL_PKT_CMD >> 8); 295 serio->write(serio, HIL_PKT_CMD >> 8);
288 serio->write(serio, HIL_CMD_RNM); 296 serio->write(serio, HIL_CMD_RNM);
289 down(&(kbd->sem)); 297 down(&kbd->sem);
290 298
291 serio->write(serio, 0); 299 serio->write(serio, 0);
292 serio->write(serio, 0); 300 serio->write(serio, 0);
293 serio->write(serio, HIL_PKT_CMD >> 8); 301 serio->write(serio, HIL_PKT_CMD >> 8);
294 serio->write(serio, HIL_CMD_EXD); 302 serio->write(serio, HIL_CMD_EXD);
295 down(&(kbd->sem)); 303 down(&kbd->sem);
296 304
297 up(&(kbd->sem)); 305 up(&kbd->sem);
298 306
299 did = kbd->idd[0]; 307 did = kbd->idd[0];
300 idd = kbd->idd + 1; 308 idd = kbd->idd + 1;
@@ -310,12 +318,11 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
310 goto bail2; 318 goto bail2;
311 } 319 }
312 320
313 if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { 321 if (HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) {
314 printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); 322 printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n");
315 goto bail2; 323 goto bail2;
316 } 324 }
317 325
318
319 kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 326 kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
320 kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); 327 kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
321 kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; 328 kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
@@ -328,7 +335,7 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
328 kbd->dev->id.vendor = PCI_VENDOR_ID_HP; 335 kbd->dev->id.vendor = PCI_VENDOR_ID_HP;
329 kbd->dev->id.product = 0x0001; /* TODO: get from kbd->rsc */ 336 kbd->dev->id.product = 0x0001; /* TODO: get from kbd->rsc */
330 kbd->dev->id.version = 0x0100; /* TODO: get from kbd->rsc */ 337 kbd->dev->id.version = 0x0100; /* TODO: get from kbd->rsc */
331 kbd->dev->cdev.dev = &serio->dev; 338 kbd->dev->dev.parent = &serio->dev;
332 339
333 for (i = 0; i < 128; i++) { 340 for (i = 0; i < 128; i++) {
334 set_bit(hil_kbd_set1[i], kbd->dev->keybit); 341 set_bit(hil_kbd_set1[i], kbd->dev->keybit);
@@ -344,8 +351,8 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
344 serio->write(serio, 0); 351 serio->write(serio, 0);
345 serio->write(serio, HIL_PKT_CMD >> 8); 352 serio->write(serio, HIL_PKT_CMD >> 8);
346 serio->write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */ 353 serio->write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */
347 down(&(kbd->sem)); 354 down(&kbd->sem);
348 up(&(kbd->sem)); 355 up(&kbd->sem);
349 356
350 return 0; 357 return 0;
351 bail2: 358 bail2:
@@ -368,26 +375,26 @@ static struct serio_device_id hil_kbd_ids[] = {
368 { 0 } 375 { 0 }
369}; 376};
370 377
371struct serio_driver hil_kbd_serio_drv = { 378static struct serio_driver hil_kbd_serio_drv = {
372 .driver = { 379 .driver = {
373 .name = "hil_kbd", 380 .name = "hil_kbd",
374 }, 381 },
375 .description = "HP HIL keyboard driver", 382 .description = "HP HIL keyboard driver",
376 .id_table = hil_kbd_ids, 383 .id_table = hil_kbd_ids,
377 .connect = hil_kbd_connect, 384 .connect = hil_kbd_connect,
378 .disconnect = hil_kbd_disconnect, 385 .disconnect = hil_kbd_disconnect,
379 .interrupt = hil_kbd_interrupt 386 .interrupt = hil_kbd_interrupt
380}; 387};
381 388
382static int __init hil_kbd_init(void) 389static int __init hil_kbd_init(void)
383{ 390{
384 return serio_register_driver(&hil_kbd_serio_drv); 391 return serio_register_driver(&hil_kbd_serio_drv);
385} 392}
386 393
387static void __exit hil_kbd_exit(void) 394static void __exit hil_kbd_exit(void)
388{ 395{
389 serio_unregister_driver(&hil_kbd_serio_drv); 396 serio_unregister_driver(&hil_kbd_serio_drv);
390} 397}
391 398
392module_init(hil_kbd_init); 399module_init(hil_kbd_init);
393module_exit(hil_kbd_exit); 400module_exit(hil_kbd_exit);
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
index 4de4dc297d50..499b6974457f 100644
--- a/drivers/input/keyboard/hilkbd.c
+++ b/drivers/input/keyboard/hilkbd.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 1998 Philip Blundell <philb@gnu.org> 4 * Copyright (C) 1998 Philip Blundell <philb@gnu.org>
5 * Copyright (C) 1999 Matthew Wilcox <willy@bofh.ai> 5 * Copyright (C) 1999 Matthew Wilcox <willy@bofh.ai>
6 * Copyright (C) 1999-2006 Helge Deller <deller@gmx.de> 6 * Copyright (C) 1999-2007 Helge Deller <deller@gmx.de>
7 * 7 *
8 * Very basic HP Human Interface Loop (HIL) driver. 8 * Very basic HP Human Interface Loop (HIL) driver.
9 * This driver handles the keyboard on HP300 (m68k) and on some 9 * This driver handles the keyboard on HP300 (m68k) and on some
@@ -52,7 +52,7 @@ MODULE_LICENSE("GPL v2");
52 52
53#elif defined(CONFIG_HP300) 53#elif defined(CONFIG_HP300)
54 54
55 #define HILBASE 0xf0428000 /* HP300 (m86k) port address */ 55 #define HILBASE 0xf0428000UL /* HP300 (m68k) port address */
56 #define HIL_DATA 0x1 56 #define HIL_DATA 0x1
57 #define HIL_CMD 0x3 57 #define HIL_CMD 0x3
58 #define HIL_IRQ 2 58 #define HIL_IRQ 2
@@ -89,7 +89,7 @@ MODULE_LICENSE("GPL v2");
89#define HIL_READKBDSADR 0xF9 89#define HIL_READKBDSADR 0xF9
90#define HIL_WRITEKBDSADR 0xE9 90#define HIL_WRITEKBDSADR 0xE9
91 91
92static unsigned int hphilkeyb_keycode[HIL_KEYCODES_SET1_TBLSIZE] = 92static unsigned int hphilkeyb_keycode[HIL_KEYCODES_SET1_TBLSIZE] __read_mostly =
93 { HIL_KEYCODES_SET1 }; 93 { HIL_KEYCODES_SET1 };
94 94
95/* HIL structure */ 95/* HIL structure */
@@ -211,10 +211,10 @@ hil_keyb_init(void)
211 return -ENODEV; /* already initialized */ 211 return -ENODEV; /* already initialized */
212 } 212 }
213 213
214 spin_lock_init(&hil_dev.lock);
214 hil_dev.dev = input_allocate_device(); 215 hil_dev.dev = input_allocate_device();
215 if (!hil_dev.dev) 216 if (!hil_dev.dev)
216 return -ENOMEM; 217 return -ENOMEM;
217 hil_dev.dev->private = &hil_dev;
218 218
219#if defined(CONFIG_HP300) 219#if defined(CONFIG_HP300)
220 if (!hwreg_present((void *)(HILBASE + HIL_DATA))) { 220 if (!hwreg_present((void *)(HILBASE + HIL_DATA))) {
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 3d4d0a0ede28..1b08f4e79dd2 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -515,7 +515,7 @@ static int
515lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code, 515lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code,
516 int value) 516 int value)
517{ 517{
518 struct lkkbd *lk = dev->private; 518 struct lkkbd *lk = input_get_drvdata (dev);
519 unsigned char leds_on = 0; 519 unsigned char leds_on = 0;
520 unsigned char leds_off = 0; 520 unsigned char leds_off = 0;
521 521
@@ -666,9 +666,10 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv)
666 input_dev->id.vendor = SERIO_LKKBD; 666 input_dev->id.vendor = SERIO_LKKBD;
667 input_dev->id.product = 0; 667 input_dev->id.product = 0;
668 input_dev->id.version = 0x0100; 668 input_dev->id.version = 0x0100;
669 input_dev->cdev.dev = &serio->dev; 669 input_dev->dev.parent = &serio->dev;
670 input_dev->event = lkkbd_event; 670 input_dev->event = lkkbd_event;
671 input_dev->private = lk; 671
672 input_set_drvdata (input_dev, lk);
672 673
673 set_bit (EV_KEY, input_dev->evbit); 674 set_bit (EV_KEY, input_dev->evbit);
674 set_bit (EV_LED, input_dev->evbit); 675 set_bit (EV_LED, input_dev->evbit);
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index 2ade5186cc41..7a41b271f222 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -231,7 +231,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
231 input_dev->id.vendor = 0x0001; 231 input_dev->id.vendor = 0x0001;
232 input_dev->id.product = 0x0001; 232 input_dev->id.product = 0x0001;
233 input_dev->id.version = 0x0100; 233 input_dev->id.version = 0x0100;
234 input_dev->private = locomokbd; 234 input_dev->dev.parent = &dev->dev;
235 235
236 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 236 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
237 input_dev->keycode = locomokbd->keycode; 237 input_dev->keycode = locomokbd->keycode;
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
index aa29b50765c9..b97a41e3ee56 100644
--- a/drivers/input/keyboard/newtonkbd.c
+++ b/drivers/input/keyboard/newtonkbd.c
@@ -104,8 +104,7 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv)
104 input_dev->id.vendor = SERIO_NEWTON; 104 input_dev->id.vendor = SERIO_NEWTON;
105 input_dev->id.product = 0x0001; 105 input_dev->id.product = 0x0001;
106 input_dev->id.version = 0x0100; 106 input_dev->id.version = 0x0100;
107 input_dev->cdev.dev = &serio->dev; 107 input_dev->dev.parent = &serio->dev;
108 input_dev->private = nkbd;
109 108
110 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 109 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
111 input_dev->keycode = nkbd->keycode; 110 input_dev->keycode = nkbd->keycode;
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index 5680a6d95b2b..3a228634f101 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -370,8 +370,7 @@ static int __init omap_kp_probe(struct platform_device *pdev)
370 set_bit(keymap[i] & KEY_MAX, input_dev->keybit); 370 set_bit(keymap[i] & KEY_MAX, input_dev->keybit);
371 input_dev->name = "omap-keypad"; 371 input_dev->name = "omap-keypad";
372 input_dev->phys = "omap-keypad/input0"; 372 input_dev->phys = "omap-keypad/input0";
373 input_dev->cdev.dev = &pdev->dev; 373 input_dev->dev.parent = &pdev->dev;
374 input_dev->private = omap_kp;
375 374
376 input_dev->id.bustype = BUS_HOST; 375 input_dev->id.bustype = BUS_HOST;
377 input_dev->id.vendor = 0x0001; 376 input_dev->id.vendor = 0x0001;
diff --git a/drivers/input/keyboard/pxa27x_keyboard.c b/drivers/input/keyboard/pxa27x_keyboard.c
new file mode 100644
index 000000000000..06eaf766d9d2
--- /dev/null
+++ b/drivers/input/keyboard/pxa27x_keyboard.c
@@ -0,0 +1,258 @@
1/*
2 * linux/drivers/input/keyboard/pxa27x_keyboard.c
3 *
4 * Driver for the pxa27x matrix keyboard controller.
5 *
6 * Created: Feb 22, 2007
7 * Author: Rodolfo Giometti <giometti@linux.it>
8 *
9 * Based on a previous implementations by Kevin O'Connor
10 * <kevin_at_koconnor.net> and Alex Osborne <bobofdoom@gmail.com> and
11 * on some suggestions by Nicolas Pitre <nico@cam.org>.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/input.h>
24#include <linux/device.h>
25#include <linux/platform_device.h>
26
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30
31#include <asm/arch/hardware.h>
32#include <asm/arch/pxa-regs.h>
33#include <asm/arch/irqs.h>
34#include <asm/arch/pxa27x_keyboard.h>
35
36#define DRIVER_NAME "pxa27x-keyboard"
37
38#define KPASMKP(col) (col/2 == 0 ? KPASMKP0 : \
39 col/2 == 1 ? KPASMKP1 : \
40 col/2 == 2 ? KPASMKP2 : KPASMKP3)
41#define KPASMKPx_MKC(row, col) (1 << (row + 16 * (col % 2)))
42
43static irqreturn_t pxakbd_irq_handler(int irq, void *dev_id)
44{
45 struct platform_device *pdev = dev_id;
46 struct pxa27x_keyboard_platform_data *pdata = pdev->dev.platform_data;
47 struct input_dev *input_dev = platform_get_drvdata(pdev);
48 unsigned long kpc = KPC;
49 int p, row, col, rel;
50
51 if (kpc & KPC_DI) {
52 unsigned long kpdk = KPDK;
53
54 if (!(kpdk & KPDK_DKP)) {
55 /* better luck next time */
56 } else if (kpc & KPC_REE0) {
57 unsigned long kprec = KPREC;
58 KPREC = 0x7f;
59
60 if (kprec & KPREC_OF0)
61 rel = (kprec & 0xff) + 0x7f;
62 else if (kprec & KPREC_UF0)
63 rel = (kprec & 0xff) - 0x7f - 0xff;
64 else
65 rel = (kprec & 0xff) - 0x7f;
66
67 if (rel) {
68 input_report_rel(input_dev, REL_WHEEL, rel);
69 input_sync(input_dev);
70 }
71 }
72 }
73
74 if (kpc & KPC_MI) {
75 /* report the status of every button */
76 for (row = 0; row < pdata->nr_rows; row++) {
77 for (col = 0; col < pdata->nr_cols; col++) {
78 p = KPASMKP(col) & KPASMKPx_MKC(row, col) ?
79 1 : 0;
80 pr_debug("keycode %x - pressed %x\n",
81 pdata->keycodes[row][col], p);
82 input_report_key(input_dev,
83 pdata->keycodes[row][col], p);
84 }
85 }
86 input_sync(input_dev);
87 }
88
89 return IRQ_HANDLED;
90}
91
92static int pxakbd_open(struct input_dev *dev)
93{
94 /* Set keypad control register */
95 KPC |= (KPC_ASACT |
96 KPC_MS_ALL |
97 (2 << 6) | KPC_REE0 | KPC_DK_DEB_SEL |
98 KPC_ME | KPC_MIE | KPC_DE | KPC_DIE);
99
100 KPC &= ~KPC_AS; /* disable automatic scan */
101 KPC &= ~KPC_IMKP; /* do not ignore multiple keypresses */
102
103 /* Set rotary count to mid-point value */
104 KPREC = 0x7F;
105
106 /* Enable unit clock */
107 pxa_set_cken(CKEN19_KEYPAD, 1);
108
109 return 0;
110}
111
112static void pxakbd_close(struct input_dev *dev)
113{
114 /* Disable clock unit */
115 pxa_set_cken(CKEN19_KEYPAD, 0);
116}
117
118#ifdef CONFIG_PM
119static int pxakbd_suspend(struct platform_device *pdev, pm_message_t state)
120{
121 struct pxa27x_keyboard_platform_data *pdata = pdev->dev.platform_data;
122
123 /* Save controller status */
124 pdata->reg_kpc = KPC;
125 pdata->reg_kprec = KPREC;
126
127 return 0;
128}
129
130static int pxakbd_resume(struct platform_device *pdev)
131{
132 struct pxa27x_keyboard_platform_data *pdata = pdev->dev.platform_data;
133 struct input_dev *input_dev = platform_get_drvdata(pdev);
134
135 mutex_lock(&input_dev->mutex);
136
137 if (input_dev->users) {
138 /* Restore controller status */
139 KPC = pdata->reg_kpc;
140 KPREC = pdata->reg_kprec;
141
142 /* Enable unit clock */
143 pxa_set_cken(CKEN19_KEYPAD, 1);
144 }
145
146 mutex_unlock(&input_dev->mutex);
147
148 return 0;
149}
150#else
151#define pxakbd_suspend NULL
152#define pxakbd_resume NULL
153#endif
154
155static int __devinit pxakbd_probe(struct platform_device *pdev)
156{
157 struct pxa27x_keyboard_platform_data *pdata = pdev->dev.platform_data;
158 struct input_dev *input_dev;
159 int i, row, col, error;
160
161 /* Create and register the input driver. */
162 input_dev = input_allocate_device();
163 if (!input_dev) {
164 printk(KERN_ERR "Cannot request keypad device\n");
165 return -ENOMEM;
166 }
167
168 input_dev->name = DRIVER_NAME;
169 input_dev->id.bustype = BUS_HOST;
170 input_dev->open = pxakbd_open;
171 input_dev->close = pxakbd_close;
172 input_dev->dev.parent = &pdev->dev;
173
174 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL);
175 input_dev->relbit[LONG(REL_WHEEL)] = BIT(REL_WHEEL);
176 for (row = 0; row < pdata->nr_rows; row++) {
177 for (col = 0; col < pdata->nr_cols; col++) {
178 int code = pdata->keycodes[row][col];
179 if (code > 0)
180 set_bit(code, input_dev->keybit);
181 }
182 }
183
184 error = request_irq(IRQ_KEYPAD, pxakbd_irq_handler, IRQF_DISABLED,
185 DRIVER_NAME, pdev);
186 if (error) {
187 printk(KERN_ERR "Cannot request keypad IRQ\n");
188 pxa_set_cken(CKEN19_KEYPAD, 0);
189 goto err_free_dev;
190 }
191
192 platform_set_drvdata(pdev, input_dev);
193
194 /* Register the input device */
195 error = input_register_device(input_dev);
196 if (error)
197 goto err_free_irq;
198
199 /* Setup GPIOs. */
200 for (i = 0; i < pdata->nr_rows + pdata->nr_cols; i++)
201 pxa_gpio_mode(pdata->gpio_modes[i]);
202
203 /*
204 * Store rows/cols info into keyboard registers.
205 */
206
207 KPC |= (pdata->nr_rows - 1) << 26;
208 KPC |= (pdata->nr_cols - 1) << 23;
209
210 for (col = 0; col < pdata->nr_cols; col++)
211 KPC |= KPC_MS0 << col;
212
213 return 0;
214
215 err_free_irq:
216 platform_set_drvdata(pdev, NULL);
217 free_irq(IRQ_KEYPAD, pdev);
218 err_free_dev:
219 input_free_device(input_dev);
220 return error;
221}
222
223static int __devexit pxakbd_remove(struct platform_device *pdev)
224{
225 struct input_dev *input_dev = platform_get_drvdata(pdev);
226
227 input_unregister_device(input_dev);
228 free_irq(IRQ_KEYPAD, pdev);
229 platform_set_drvdata(pdev, NULL);
230
231 return 0;
232}
233
234static struct platform_driver pxakbd_driver = {
235 .probe = pxakbd_probe,
236 .remove = __devexit_p(pxakbd_remove),
237 .suspend = pxakbd_suspend,
238 .resume = pxakbd_resume,
239 .driver = {
240 .name = DRIVER_NAME,
241 },
242};
243
244static int __init pxakbd_init(void)
245{
246 return platform_driver_register(&pxakbd_driver);
247}
248
249static void __exit pxakbd_exit(void)
250{
251 platform_driver_unregister(&pxakbd_driver);
252}
253
254module_init(pxakbd_init);
255module_exit(pxakbd_exit);
256
257MODULE_DESCRIPTION("PXA27x Matrix Keyboard Driver");
258MODULE_LICENSE("GPL");
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 8a2166c77ff4..41b80385476c 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -372,10 +372,9 @@ static int __init spitzkbd_probe(struct platform_device *dev)
372 372
373 spitzkbd->input = input_dev; 373 spitzkbd->input = input_dev;
374 374
375 input_dev->private = spitzkbd;
376 input_dev->name = "Spitz Keyboard"; 375 input_dev->name = "Spitz Keyboard";
377 input_dev->phys = spitzkbd->phys; 376 input_dev->phys = spitzkbd->phys;
378 input_dev->cdev.dev = &dev->dev; 377 input_dev->dev.parent = &dev->dev;
379 378
380 input_dev->id.bustype = BUS_HOST; 379 input_dev->id.bustype = BUS_HOST;
381 input_dev->id.vendor = 0x0001; 380 input_dev->id.vendor = 0x0001;
diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c
index f7b5c5b81451..b44b0684d543 100644
--- a/drivers/input/keyboard/stowaway.c
+++ b/drivers/input/keyboard/stowaway.c
@@ -108,8 +108,7 @@ static int skbd_connect(struct serio *serio, struct serio_driver *drv)
108 input_dev->id.vendor = SERIO_STOWAWAY; 108 input_dev->id.vendor = SERIO_STOWAWAY;
109 input_dev->id.product = 0x0001; 109 input_dev->id.product = 0x0001;
110 input_dev->id.version = 0x0100; 110 input_dev->id.version = 0x0100;
111 input_dev->cdev.dev = &serio->dev; 111 input_dev->dev.parent = &serio->dev;
112 input_dev->private = skbd;
113 112
114 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 113 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
115 input_dev->keycode = skbd->keycode; 114 input_dev->keycode = skbd->keycode;
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index cc0238366414..1d4e39624cfe 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -146,7 +146,7 @@ out:
146 146
147static int sunkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 147static int sunkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
148{ 148{
149 struct sunkbd *sunkbd = dev->private; 149 struct sunkbd *sunkbd = input_get_drvdata(dev);
150 150
151 switch (type) { 151 switch (type) {
152 152
@@ -271,8 +271,10 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
271 input_dev->id.vendor = SERIO_SUNKBD; 271 input_dev->id.vendor = SERIO_SUNKBD;
272 input_dev->id.product = sunkbd->type; 272 input_dev->id.product = sunkbd->type;
273 input_dev->id.version = 0x0100; 273 input_dev->id.version = 0x0100;
274 input_dev->cdev.dev = &serio->dev; 274 input_dev->dev.parent = &serio->dev;
275 input_dev->private = sunkbd; 275
276 input_set_drvdata(input_dev, sunkbd);
277
276 input_dev->event = sunkbd_event; 278 input_dev->event = sunkbd_event;
277 279
278 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP); 280 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP);
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
index a82093432138..f3a56eb58ed1 100644
--- a/drivers/input/keyboard/xtkbd.c
+++ b/drivers/input/keyboard/xtkbd.c
@@ -108,8 +108,7 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv)
108 input_dev->id.vendor = 0x0001; 108 input_dev->id.vendor = 0x0001;
109 input_dev->id.product = 0x0001; 109 input_dev->id.product = 0x0001;
110 input_dev->id.version = 0x0100; 110 input_dev->id.version = 0x0100;
111 input_dev->cdev.dev = &serio->dev; 111 input_dev->dev.parent = &serio->dev;
112 input_dev->private = xtkbd;
113 112
114 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 113 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
115 input_dev->keycode = xtkbd->keycode; 114 input_dev->keycode = xtkbd->keycode;
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 41b42587f5e9..1d0d3e765db6 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -40,6 +40,16 @@ config INPUT_M68K_BEEP
40 tristate "M68k Beeper support" 40 tristate "M68k Beeper support"
41 depends on M68K 41 depends on M68K
42 42
43config INPUT_COBALT_BTNS
44 tristate "Cobalt button interface"
45 depends on MIPS_COBALT
46 select INPUT_POLLDEV
47 help
48 Say Y here if you want to support MIPS Cobalt button interface.
49
50 To compile this driver as a module, choose M here: the
51 module will be called cobalt_btns.
52
43config INPUT_WISTRON_BTNS 53config INPUT_WISTRON_BTNS
44 tristate "x86 Wistron laptop button interface" 54 tristate "x86 Wistron laptop button interface"
45 depends on X86 && !X86_64 55 depends on X86 && !X86_64
@@ -81,8 +91,19 @@ config INPUT_UINPUT
81 To compile this driver as a module, choose M here: the 91 To compile this driver as a module, choose M here: the
82 module will be called uinput. 92 module will be called uinput.
83 93
94config INPUT_POLLDEV
95 tristate "Polled input device skeleton"
96 help
97 Say Y here if you are using a driver for an input
98 device that periodically polls hardware state. This
99 option is only useful for out-of-tree drivers since
100 in-tree drivers select it automatically.
101
102 To compile this driver as a module, choose M here: the
103 module will be called input-polldev.
104
84config HP_SDC_RTC 105config HP_SDC_RTC
85 tristate "HP SDC Real Time Clock" 106 tristate "HP SDC Real Time Clock"
86 depends on GSC || HP300 107 depends on GSC || HP300
87 select HP_SDC 108 select HP_SDC
88 help 109 help
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index e0a8d58c9e9b..21e3cca0d33e 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -4,10 +4,12 @@
4 4
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
7obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o 8obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o
8obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o 9obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
9obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o 10obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o
10obj-$(CONFIG_INPUT_UINPUT) += uinput.o 11obj-$(CONFIG_INPUT_UINPUT) += uinput.o
12obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o
11obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o 13obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
12obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o 14obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
13obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 15obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c
new file mode 100644
index 000000000000..064b07936019
--- /dev/null
+++ b/drivers/input/misc/cobalt_btns.c
@@ -0,0 +1,172 @@
1/*
2 * Cobalt button interface driver.
3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/init.h>
21#include <linux/input-polldev.h>
22#include <linux/ioport.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
25
26#define BUTTONS_POLL_INTERVAL 30 /* msec */
27#define BUTTONS_COUNT_THRESHOLD 3
28#define BUTTONS_STATUS_MASK 0xfe000000
29
30struct buttons_dev {
31 struct input_polled_dev *poll_dev;
32 void __iomem *reg;
33};
34
35struct buttons_map {
36 uint32_t mask;
37 int keycode;
38 int count;
39};
40
41static struct buttons_map buttons_map[] = {
42 { 0x02000000, KEY_RESTART, },
43 { 0x04000000, KEY_LEFT, },
44 { 0x08000000, KEY_UP, },
45 { 0x10000000, KEY_DOWN, },
46 { 0x20000000, KEY_RIGHT, },
47 { 0x40000000, KEY_ENTER, },
48 { 0x80000000, KEY_SELECT, },
49};
50
51static void handle_buttons(struct input_polled_dev *dev)
52{
53 struct buttons_map *button = buttons_map;
54 struct buttons_dev *bdev = dev->private;
55 struct input_dev *input = dev->input;
56 uint32_t status;
57 int i;
58
59 status = readl(bdev->reg);
60 status = ~status & BUTTONS_STATUS_MASK;
61
62 for (i = 0; i < ARRAY_SIZE(buttons_map); i++) {
63 if (status & button->mask) {
64 button->count++;
65 } else {
66 if (button->count >= BUTTONS_COUNT_THRESHOLD) {
67 input_report_key(input, button->keycode, 0);
68 input_sync(input);
69 }
70 button->count = 0;
71 }
72
73 if (button->count == BUTTONS_COUNT_THRESHOLD) {
74 input_report_key(input, button->keycode, 1);
75 input_sync(input);
76 }
77
78 button++;
79 }
80}
81
82static int __devinit cobalt_buttons_probe(struct platform_device *pdev)
83{
84 struct buttons_dev *bdev;
85 struct input_polled_dev *poll_dev;
86 struct input_dev *input;
87 struct resource *res;
88 int error, i;
89
90 bdev = kzalloc(sizeof(struct buttons_dev), GFP_KERNEL);
91 poll_dev = input_allocate_polled_device();
92 if (!bdev || !poll_dev) {
93 error = -ENOMEM;
94 goto err_free_mem;
95 }
96
97 poll_dev->private = bdev;
98 poll_dev->poll = handle_buttons;
99 poll_dev->poll_interval = BUTTONS_POLL_INTERVAL;
100
101 input = poll_dev->input;
102 input->name = "Cobalt buttons";
103 input->phys = "cobalt/input0";
104 input->id.bustype = BUS_HOST;
105 input->cdev.dev = &pdev->dev;
106
107 input->evbit[0] = BIT(EV_KEY);
108 for (i = 0; i < ARRAY_SIZE(buttons_map); i++) {
109 set_bit(buttons_map[i].keycode, input->keybit);
110 buttons_map[i].count = 0;
111 }
112
113 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
114 if (!res) {
115 error = -EBUSY;
116 goto err_free_mem;
117 }
118
119 bdev->poll_dev = poll_dev;
120 bdev->reg = ioremap(res->start, res->end - res->start + 1);
121 dev_set_drvdata(&pdev->dev, bdev);
122
123 error = input_register_polled_device(poll_dev);
124 if (error)
125 goto err_iounmap;
126
127 return 0;
128
129 err_iounmap:
130 iounmap(bdev->reg);
131 err_free_mem:
132 input_free_polled_device(poll_dev);
133 kfree(bdev);
134 dev_set_drvdata(&pdev->dev, NULL);
135 return error;
136}
137
138static int __devexit cobalt_buttons_remove(struct platform_device *pdev)
139{
140 struct device *dev = &pdev->dev;
141 struct buttons_dev *bdev = dev_get_drvdata(dev);
142
143 input_unregister_polled_device(bdev->poll_dev);
144 input_free_polled_device(bdev->poll_dev);
145 iounmap(bdev->reg);
146 kfree(bdev);
147 dev_set_drvdata(dev, NULL);
148
149 return 0;
150}
151
152static struct platform_driver cobalt_buttons_driver = {
153 .probe = cobalt_buttons_probe,
154 .remove = __devexit_p(cobalt_buttons_remove),
155 .driver = {
156 .name = "Cobalt buttons",
157 .owner = THIS_MODULE,
158 },
159};
160
161static int __init cobalt_buttons_init(void)
162{
163 return platform_driver_register(&cobalt_buttons_driver);
164}
165
166static void __exit cobalt_buttons_exit(void)
167{
168 platform_driver_unregister(&cobalt_buttons_driver);
169}
170
171module_init(cobalt_buttons_init);
172module_exit(cobalt_buttons_exit);
diff --git a/drivers/input/misc/input-polldev.c b/drivers/input/misc/input-polldev.c
new file mode 100644
index 000000000000..1b2b9c9c5d88
--- /dev/null
+++ b/drivers/input/misc/input-polldev.c
@@ -0,0 +1,171 @@
1/*
2 * Generic implementation of a polled input device
3
4 * Copyright (c) 2007 Dmitry Torokhov
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 version 2 as published by
8 * the Free Software Foundation.
9 */
10
11#include <linux/jiffies.h>
12#include <linux/mutex.h>
13#include <linux/input-polldev.h>
14
15static DEFINE_MUTEX(polldev_mutex);
16static int polldev_users;
17static struct workqueue_struct *polldev_wq;
18
19static int input_polldev_start_workqueue(void)
20{
21 int retval;
22
23 retval = mutex_lock_interruptible(&polldev_mutex);
24 if (retval)
25 return retval;
26
27 if (!polldev_users) {
28 polldev_wq = create_singlethread_workqueue("ipolldevd");
29 if (!polldev_wq) {
30 printk(KERN_ERR "input-polldev: failed to create "
31 "ipolldevd workqueue\n");
32 retval = -ENOMEM;
33 goto out;
34 }
35 }
36
37 polldev_users++;
38
39 out:
40 mutex_unlock(&polldev_mutex);
41 return retval;
42}
43
44static void input_polldev_stop_workqueue(void)
45{
46 mutex_lock(&polldev_mutex);
47
48 if (!--polldev_users)
49 destroy_workqueue(polldev_wq);
50
51 mutex_unlock(&polldev_mutex);
52}
53
54static void input_polled_device_work(struct work_struct *work)
55{
56 struct input_polled_dev *dev =
57 container_of(work, struct input_polled_dev, work.work);
58
59 dev->poll(dev);
60 queue_delayed_work(polldev_wq, &dev->work,
61 msecs_to_jiffies(dev->poll_interval));
62}
63
64static int input_open_polled_device(struct input_dev *input)
65{
66 struct input_polled_dev *dev = input->private;
67 int error;
68
69 error = input_polldev_start_workqueue();
70 if (error)
71 return error;
72
73 if (dev->flush)
74 dev->flush(dev);
75
76 queue_delayed_work(polldev_wq, &dev->work,
77 msecs_to_jiffies(dev->poll_interval));
78
79 return 0;
80}
81
82static void input_close_polled_device(struct input_dev *input)
83{
84 struct input_polled_dev *dev = input->private;
85
86 cancel_rearming_delayed_workqueue(polldev_wq, &dev->work);
87 input_polldev_stop_workqueue();
88}
89
90/**
91 * input_allocate_polled_device - allocated memory polled device
92 *
93 * The function allocates memory for a polled device and also
94 * for an input device associated with this polled device.
95 */
96struct input_polled_dev *input_allocate_polled_device(void)
97{
98 struct input_polled_dev *dev;
99
100 dev = kzalloc(sizeof(struct input_polled_dev), GFP_KERNEL);
101 if (!dev)
102 return NULL;
103
104 dev->input = input_allocate_device();
105 if (!dev->input) {
106 kfree(dev);
107 return NULL;
108 }
109
110 return dev;
111}
112EXPORT_SYMBOL(input_allocate_polled_device);
113
114/**
115 * input_free_polled_device - free memory allocated for polled device
116 * @dev: device to free
117 *
118 * The function frees memory allocated for polling device and drops
119 * reference to the associated input device (if present).
120 */
121void input_free_polled_device(struct input_polled_dev *dev)
122{
123 if (dev) {
124 input_free_device(dev->input);
125 kfree(dev);
126 }
127}
128EXPORT_SYMBOL(input_free_polled_device);
129
130/**
131 * input_register_polled_device - register polled device
132 * @dev: device to register
133 *
134 * The function registers previously initialized polled input device
135 * with input layer. The device should be allocated with call to
136 * input_allocate_polled_device(). Callers should also set up poll()
137 * method and set up capabilities (id, name, phys, bits) of the
138 * corresponing input_dev structure.
139 */
140int input_register_polled_device(struct input_polled_dev *dev)
141{
142 struct input_dev *input = dev->input;
143
144 INIT_DELAYED_WORK(&dev->work, input_polled_device_work);
145 if (!dev->poll_interval)
146 dev->poll_interval = 500;
147 input->private = dev;
148 input->open = input_open_polled_device;
149 input->close = input_close_polled_device;
150
151 return input_register_device(input);
152}
153EXPORT_SYMBOL(input_register_polled_device);
154
155/**
156 * input_unregister_polled_device - unregister polled device
157 * @dev: device to unregister
158 *
159 * The function unregisters previously registered polled input
160 * device from input layer. Polling is stopped and device is
161 * ready to be freed with call to input_free_polled_device().
162 * Callers should not attempt to access dev->input pointer
163 * after calling this function.
164 */
165void input_unregister_polled_device(struct input_polled_dev *dev)
166{
167 input_unregister_device(dev->input);
168 dev->input = NULL;
169}
170EXPORT_SYMBOL(input_unregister_polled_device);
171
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c
index 105c6fc27823..3d4b619dadab 100644
--- a/drivers/input/misc/ixp4xx-beeper.c
+++ b/drivers/input/misc/ixp4xx-beeper.c
@@ -51,7 +51,7 @@ static void ixp4xx_spkr_control(unsigned int pin, unsigned int count)
51 51
52static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 52static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
53{ 53{
54 unsigned int pin = (unsigned int) dev->private; 54 unsigned int pin = (unsigned int) input_get_drvdata(input_dev);
55 unsigned int count = 0; 55 unsigned int count = 0;
56 56
57 if (type != EV_SND) 57 if (type != EV_SND)
@@ -99,14 +99,15 @@ static int __devinit ixp4xx_spkr_probe(struct platform_device *dev)
99 if (!input_dev) 99 if (!input_dev)
100 return -ENOMEM; 100 return -ENOMEM;
101 101
102 input_dev->private = (void *) dev->id; 102 input_set_drvdata(input_dev, (void *) dev->id);
103
103 input_dev->name = "ixp4xx beeper", 104 input_dev->name = "ixp4xx beeper",
104 input_dev->phys = "ixp4xx/gpio"; 105 input_dev->phys = "ixp4xx/gpio";
105 input_dev->id.bustype = BUS_HOST; 106 input_dev->id.bustype = BUS_HOST;
106 input_dev->id.vendor = 0x001f; 107 input_dev->id.vendor = 0x001f;
107 input_dev->id.product = 0x0001; 108 input_dev->id.product = 0x0001;
108 input_dev->id.version = 0x0100; 109 input_dev->id.version = 0x0100;
109 input_dev->cdev.dev = &dev->dev; 110 input_dev->dev.parent = &dev->dev;
110 111
111 input_dev->evbit[0] = BIT(EV_SND); 112 input_dev->evbit[0] = BIT(EV_SND);
112 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 113 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
@@ -136,7 +137,7 @@ static int __devinit ixp4xx_spkr_probe(struct platform_device *dev)
136static int __devexit ixp4xx_spkr_remove(struct platform_device *dev) 137static int __devexit ixp4xx_spkr_remove(struct platform_device *dev)
137{ 138{
138 struct input_dev *input_dev = platform_get_drvdata(dev); 139 struct input_dev *input_dev = platform_get_drvdata(dev);
139 unsigned int pin = (unsigned int) input_dev->private; 140 unsigned int pin = (unsigned int) input_get_drvdata(input_dev);
140 141
141 input_unregister_device(input_dev); 142 input_unregister_device(input_dev);
142 platform_set_drvdata(dev, NULL); 143 platform_set_drvdata(dev, NULL);
@@ -153,7 +154,7 @@ static int __devexit ixp4xx_spkr_remove(struct platform_device *dev)
153static void ixp4xx_spkr_shutdown(struct platform_device *dev) 154static void ixp4xx_spkr_shutdown(struct platform_device *dev)
154{ 155{
155 struct input_dev *input_dev = platform_get_drvdata(dev); 156 struct input_dev *input_dev = platform_get_drvdata(dev);
156 unsigned int pin = (unsigned int) input_dev->private; 157 unsigned int pin = (unsigned int) input_get_drvdata(input_dev);
157 158
158 /* turn off the speaker */ 159 /* turn off the speaker */
159 disable_irq(IRQ_IXP4XX_TIMER2); 160 disable_irq(IRQ_IXP4XX_TIMER2);
diff --git a/drivers/input/misc/m68kspkr.c b/drivers/input/misc/m68kspkr.c
index 8d6c3837badb..e9f26e766b4d 100644
--- a/drivers/input/misc/m68kspkr.c
+++ b/drivers/input/misc/m68kspkr.c
@@ -63,7 +63,7 @@ static int __devinit m68kspkr_probe(struct platform_device *dev)
63 input_dev->id.vendor = 0x001f; 63 input_dev->id.vendor = 0x001f;
64 input_dev->id.product = 0x0001; 64 input_dev->id.product = 0x0001;
65 input_dev->id.version = 0x0100; 65 input_dev->id.version = 0x0100;
66 input_dev->cdev.dev = &dev->dev; 66 input_dev->dev.parent = &dev->dev;
67 67
68 input_dev->evbit[0] = BIT(EV_SND); 68 input_dev->evbit[0] = BIT(EV_SND);
69 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 69 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c
index afd322185bbf..31989dcd922c 100644
--- a/drivers/input/misc/pcspkr.c
+++ b/drivers/input/misc/pcspkr.c
@@ -78,7 +78,7 @@ static int __devinit pcspkr_probe(struct platform_device *dev)
78 pcspkr_dev->id.vendor = 0x001f; 78 pcspkr_dev->id.vendor = 0x001f;
79 pcspkr_dev->id.product = 0x0001; 79 pcspkr_dev->id.product = 0x0001;
80 pcspkr_dev->id.version = 0x0100; 80 pcspkr_dev->id.version = 0x0100;
81 pcspkr_dev->cdev.dev = &dev->dev; 81 pcspkr_dev->dev.parent = &dev->dev;
82 82
83 pcspkr_dev->evbit[0] = BIT(EV_SND); 83 pcspkr_dev->evbit[0] = BIT(EV_SND);
84 pcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 84 pcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index 106c94f33b93..e36ec1d92be8 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -28,7 +28,7 @@ struct sparcspkr_state {
28 28
29static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 29static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
30{ 30{
31 struct sparcspkr_state *state = dev_get_drvdata(dev->cdev.dev); 31 struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent);
32 unsigned int count = 0; 32 unsigned int count = 0;
33 unsigned long flags; 33 unsigned long flags;
34 34
@@ -61,7 +61,7 @@ static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned in
61 61
62static int isa_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 62static int isa_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
63{ 63{
64 struct sparcspkr_state *state = dev_get_drvdata(dev->cdev.dev); 64 struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent);
65 unsigned int count = 0; 65 unsigned int count = 0;
66 unsigned long flags; 66 unsigned long flags;
67 67
@@ -113,7 +113,7 @@ static int __devinit sparcspkr_probe(struct device *dev)
113 input_dev->id.vendor = 0x001f; 113 input_dev->id.vendor = 0x001f;
114 input_dev->id.product = 0x0001; 114 input_dev->id.product = 0x0001;
115 input_dev->id.version = 0x0100; 115 input_dev->id.version = 0x0100;
116 input_dev->cdev.dev = dev; 116 input_dev->dev.parent = dev;
117 117
118 input_dev->evbit[0] = BIT(EV_SND); 118 input_dev->evbit[0] = BIT(EV_SND);
119 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 119 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 42556232c523..031467eadd31 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -41,9 +41,7 @@
41 41
42static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 42static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
43{ 43{
44 struct uinput_device *udev; 44 struct uinput_device *udev = input_get_drvdata(dev);
45
46 udev = dev->private;
47 45
48 udev->buff[udev->head].type = type; 46 udev->buff[udev->head].type = type;
49 udev->buff[udev->head].code = code; 47 udev->buff[udev->head].code = code;
@@ -136,7 +134,7 @@ static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *eff
136 request.u.upload.effect = effect; 134 request.u.upload.effect = effect;
137 request.u.upload.old = old; 135 request.u.upload.old = old;
138 136
139 retval = uinput_request_reserve_slot(dev->private, &request); 137 retval = uinput_request_reserve_slot(input_get_drvdata(dev), &request);
140 if (!retval) 138 if (!retval)
141 retval = uinput_request_submit(dev, &request); 139 retval = uinput_request_submit(dev, &request);
142 140
@@ -156,7 +154,7 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id)
156 request.code = UI_FF_ERASE; 154 request.code = UI_FF_ERASE;
157 request.u.effect_id = effect_id; 155 request.u.effect_id = effect_id;
158 156
159 retval = uinput_request_reserve_slot(dev->private, &request); 157 retval = uinput_request_reserve_slot(input_get_drvdata(dev), &request);
160 if (!retval) 158 if (!retval)
161 retval = uinput_request_submit(dev, &request); 159 retval = uinput_request_submit(dev, &request);
162 160
@@ -274,7 +272,7 @@ static int uinput_allocate_device(struct uinput_device *udev)
274 return -ENOMEM; 272 return -ENOMEM;
275 273
276 udev->dev->event = uinput_dev_event; 274 udev->dev->event = uinput_dev_event;
277 udev->dev->private = udev; 275 input_set_drvdata(udev->dev, udev);
278 276
279 return 0; 277 return 0;
280} 278}
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index e1183aeb8ed5..961aad7a0476 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -50,7 +50,7 @@
50MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>"); 50MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>");
51MODULE_DESCRIPTION("Wistron laptop button driver"); 51MODULE_DESCRIPTION("Wistron laptop button driver");
52MODULE_LICENSE("GPL v2"); 52MODULE_LICENSE("GPL v2");
53MODULE_VERSION("0.1"); 53MODULE_VERSION("0.2");
54 54
55static int force; /* = 0; */ 55static int force; /* = 0; */
56module_param(force, bool, 0); 56module_param(force, bool, 0);
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(force, "Load even if computer is not in database");
58 58
59static char *keymap_name; /* = NULL; */ 59static char *keymap_name; /* = NULL; */
60module_param_named(keymap, keymap_name, charp, 0); 60module_param_named(keymap, keymap_name, charp, 0);
61MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected"); 61MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected [generic, 1557/MS2141]");
62 62
63static struct platform_device *wistron_device; 63static struct platform_device *wistron_device;
64 64
@@ -233,10 +233,20 @@ static void bios_set_state(u8 subsys, int enable)
233struct key_entry { 233struct key_entry {
234 char type; /* See KE_* below */ 234 char type; /* See KE_* below */
235 u8 code; 235 u8 code;
236 unsigned keycode; /* For KE_KEY */ 236 union {
237 u16 keycode; /* For KE_KEY */
238 struct { /* For KE_SW */
239 u8 code;
240 u8 value;
241 } sw;
242 };
237}; 243};
238 244
239enum { KE_END, KE_KEY, KE_WIFI, KE_BLUETOOTH }; 245enum { KE_END, KE_KEY, KE_SW, KE_WIFI, KE_BLUETOOTH };
246
247#define FE_MAIL_LED 0x01
248#define FE_WIFI_LED 0x02
249#define FE_UNTESTED 0x80
240 250
241static const struct key_entry *keymap; /* = NULL; Current key map */ 251static const struct key_entry *keymap; /* = NULL; Current key map */
242static int have_wifi; 252static int have_wifi;
@@ -256,93 +266,341 @@ static int __init dmi_matched(struct dmi_system_id *dmi)
256 return 1; 266 return 1;
257} 267}
258 268
259static struct key_entry keymap_empty[] = { 269static struct key_entry keymap_empty[] __initdata = {
260 { KE_END, 0 } 270 { KE_END, 0 }
261}; 271};
262 272
263static struct key_entry keymap_fs_amilo_pro_v2000[] = { 273static struct key_entry keymap_fs_amilo_pro_v2000[] __initdata = {
264 { KE_KEY, 0x01, KEY_HELP }, 274 { KE_KEY, 0x01, {KEY_HELP} },
265 { KE_KEY, 0x11, KEY_PROG1 }, 275 { KE_KEY, 0x11, {KEY_PROG1} },
266 { KE_KEY, 0x12, KEY_PROG2 }, 276 { KE_KEY, 0x12, {KEY_PROG2} },
267 { KE_WIFI, 0x30, 0 }, 277 { KE_WIFI, 0x30 },
268 { KE_KEY, 0x31, KEY_MAIL }, 278 { KE_KEY, 0x31, {KEY_MAIL} },
269 { KE_KEY, 0x36, KEY_WWW }, 279 { KE_KEY, 0x36, {KEY_WWW} },
270 { KE_END, 0 } 280 { KE_END, 0 }
271}; 281};
272 282
273static struct key_entry keymap_fujitsu_n3510[] = { 283static struct key_entry keymap_fujitsu_n3510[] __initdata = {
274 { KE_KEY, 0x11, KEY_PROG1 }, 284 { KE_KEY, 0x11, {KEY_PROG1} },
275 { KE_KEY, 0x12, KEY_PROG2 }, 285 { KE_KEY, 0x12, {KEY_PROG2} },
276 { KE_KEY, 0x36, KEY_WWW }, 286 { KE_KEY, 0x36, {KEY_WWW} },
277 { KE_KEY, 0x31, KEY_MAIL }, 287 { KE_KEY, 0x31, {KEY_MAIL} },
278 { KE_KEY, 0x71, KEY_STOPCD }, 288 { KE_KEY, 0x71, {KEY_STOPCD} },
279 { KE_KEY, 0x72, KEY_PLAYPAUSE }, 289 { KE_KEY, 0x72, {KEY_PLAYPAUSE} },
280 { KE_KEY, 0x74, KEY_REWIND }, 290 { KE_KEY, 0x74, {KEY_REWIND} },
281 { KE_KEY, 0x78, KEY_FORWARD }, 291 { KE_KEY, 0x78, {KEY_FORWARD} },
282 { KE_END, 0 } 292 { KE_END, 0 }
283}; 293};
284 294
285static struct key_entry keymap_wistron_ms2111[] = { 295static struct key_entry keymap_wistron_ms2111[] __initdata = {
286 { KE_KEY, 0x11, KEY_PROG1 }, 296 { KE_KEY, 0x11, {KEY_PROG1} },
287 { KE_KEY, 0x12, KEY_PROG2 }, 297 { KE_KEY, 0x12, {KEY_PROG2} },
288 { KE_KEY, 0x13, KEY_PROG3 }, 298 { KE_KEY, 0x13, {KEY_PROG3} },
289 { KE_KEY, 0x31, KEY_MAIL }, 299 { KE_KEY, 0x31, {KEY_MAIL} },
290 { KE_KEY, 0x36, KEY_WWW }, 300 { KE_KEY, 0x36, {KEY_WWW} },
291 { KE_END, 0 } 301 { KE_END, FE_MAIL_LED }
302};
303
304static struct key_entry keymap_wistron_md40100[] __initdata = {
305 { KE_KEY, 0x01, {KEY_HELP} },
306 { KE_KEY, 0x02, {KEY_CONFIG} },
307 { KE_KEY, 0x31, {KEY_MAIL} },
308 { KE_KEY, 0x36, {KEY_WWW} },
309 { KE_KEY, 0x37, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
310 { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
292}; 311};
293 312
294static struct key_entry keymap_wistron_ms2141[] = { 313static struct key_entry keymap_wistron_ms2141[] __initdata = {
295 { KE_KEY, 0x11, KEY_PROG1 }, 314 { KE_KEY, 0x11, {KEY_PROG1} },
296 { KE_KEY, 0x12, KEY_PROG2 }, 315 { KE_KEY, 0x12, {KEY_PROG2} },
297 { KE_WIFI, 0x30, 0 }, 316 { KE_WIFI, 0x30 },
298 { KE_KEY, 0x22, KEY_REWIND }, 317 { KE_KEY, 0x22, {KEY_REWIND} },
299 { KE_KEY, 0x23, KEY_FORWARD }, 318 { KE_KEY, 0x23, {KEY_FORWARD} },
300 { KE_KEY, 0x24, KEY_PLAYPAUSE }, 319 { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
301 { KE_KEY, 0x25, KEY_STOPCD }, 320 { KE_KEY, 0x25, {KEY_STOPCD} },
302 { KE_KEY, 0x31, KEY_MAIL }, 321 { KE_KEY, 0x31, {KEY_MAIL} },
303 { KE_KEY, 0x36, KEY_WWW }, 322 { KE_KEY, 0x36, {KEY_WWW} },
304 { KE_END, 0 } 323 { KE_END, 0 }
305}; 324};
306 325
307static struct key_entry keymap_acer_aspire_1500[] = { 326static struct key_entry keymap_acer_aspire_1500[] __initdata = {
308 { KE_KEY, 0x11, KEY_PROG1 }, 327 { KE_KEY, 0x01, {KEY_HELP} },
309 { KE_KEY, 0x12, KEY_PROG2 }, 328 { KE_KEY, 0x03, {KEY_POWER} },
310 { KE_WIFI, 0x30, 0 }, 329 { KE_KEY, 0x11, {KEY_PROG1} },
311 { KE_KEY, 0x31, KEY_MAIL }, 330 { KE_KEY, 0x12, {KEY_PROG2} },
312 { KE_KEY, 0x36, KEY_WWW }, 331 { KE_WIFI, 0x30 },
313 { KE_BLUETOOTH, 0x44, 0 }, 332 { KE_KEY, 0x31, {KEY_MAIL} },
314 { KE_END, 0 } 333 { KE_KEY, 0x36, {KEY_WWW} },
334 { KE_KEY, 0x49, {KEY_CONFIG} },
335 { KE_BLUETOOTH, 0x44 },
336 { KE_END, FE_UNTESTED }
315}; 337};
316 338
317static struct key_entry keymap_acer_travelmate_240[] = { 339static struct key_entry keymap_acer_aspire_1600[] __initdata = {
318 { KE_KEY, 0x31, KEY_MAIL }, 340 { KE_KEY, 0x01, {KEY_HELP} },
319 { KE_KEY, 0x36, KEY_WWW }, 341 { KE_KEY, 0x03, {KEY_POWER} },
320 { KE_KEY, 0x11, KEY_PROG1 }, 342 { KE_KEY, 0x08, {KEY_MUTE} },
321 { KE_KEY, 0x12, KEY_PROG2 }, 343 { KE_KEY, 0x11, {KEY_PROG1} },
322 { KE_BLUETOOTH, 0x44, 0 }, 344 { KE_KEY, 0x12, {KEY_PROG2} },
323 { KE_WIFI, 0x30, 0 }, 345 { KE_KEY, 0x13, {KEY_PROG3} },
324 { KE_END, 0 } 346 { KE_KEY, 0x31, {KEY_MAIL} },
347 { KE_KEY, 0x36, {KEY_WWW} },
348 { KE_KEY, 0x49, {KEY_CONFIG} },
349 { KE_WIFI, 0x30 },
350 { KE_BLUETOOTH, 0x44 },
351 { KE_END, FE_MAIL_LED | FE_UNTESTED }
352};
353
354/* 3020 has been tested */
355static struct key_entry keymap_acer_aspire_5020[] __initdata = {
356 { KE_KEY, 0x01, {KEY_HELP} },
357 { KE_KEY, 0x03, {KEY_POWER} },
358 { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
359 { KE_KEY, 0x11, {KEY_PROG1} },
360 { KE_KEY, 0x12, {KEY_PROG2} },
361 { KE_KEY, 0x31, {KEY_MAIL} },
362 { KE_KEY, 0x36, {KEY_WWW} },
363 { KE_KEY, 0x6a, {KEY_CONFIG} },
364 { KE_WIFI, 0x30 },
365 { KE_BLUETOOTH, 0x44 },
366 { KE_END, FE_MAIL_LED | FE_UNTESTED }
367};
368
369static struct key_entry keymap_acer_travelmate_2410[] __initdata = {
370 { KE_KEY, 0x01, {KEY_HELP} },
371 { KE_KEY, 0x6d, {KEY_POWER} },
372 { KE_KEY, 0x11, {KEY_PROG1} },
373 { KE_KEY, 0x12, {KEY_PROG2} },
374 { KE_KEY, 0x31, {KEY_MAIL} },
375 { KE_KEY, 0x36, {KEY_WWW} },
376 { KE_KEY, 0x6a, {KEY_CONFIG} },
377 { KE_WIFI, 0x30 },
378 { KE_BLUETOOTH, 0x44 },
379 { KE_END, FE_MAIL_LED | FE_UNTESTED }
380};
381
382static struct key_entry keymap_acer_travelmate_110[] __initdata = {
383 { KE_KEY, 0x01, {KEY_HELP} },
384 { KE_KEY, 0x02, {KEY_CONFIG} },
385 { KE_KEY, 0x03, {KEY_POWER} },
386 { KE_KEY, 0x08, {KEY_MUTE} },
387 { KE_KEY, 0x11, {KEY_PROG1} },
388 { KE_KEY, 0x12, {KEY_PROG2} },
389 { KE_KEY, 0x20, {KEY_VOLUMEUP} },
390 { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
391 { KE_KEY, 0x31, {KEY_MAIL} },
392 { KE_KEY, 0x36, {KEY_WWW} },
393 { KE_SW, 0x4a, {.sw = {SW_LID, 1}} }, /* lid close */
394 { KE_SW, 0x4b, {.sw = {SW_LID, 0}} }, /* lid open */
395 { KE_WIFI, 0x30 },
396 { KE_END, FE_MAIL_LED | FE_UNTESTED }
397};
398
399static struct key_entry keymap_acer_travelmate_300[] __initdata = {
400 { KE_KEY, 0x01, {KEY_HELP} },
401 { KE_KEY, 0x02, {KEY_CONFIG} },
402 { KE_KEY, 0x03, {KEY_POWER} },
403 { KE_KEY, 0x08, {KEY_MUTE} },
404 { KE_KEY, 0x11, {KEY_PROG1} },
405 { KE_KEY, 0x12, {KEY_PROG2} },
406 { KE_KEY, 0x20, {KEY_VOLUMEUP} },
407 { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
408 { KE_KEY, 0x31, {KEY_MAIL} },
409 { KE_KEY, 0x36, {KEY_WWW} },
410 { KE_WIFI, 0x30 },
411 { KE_BLUETOOTH, 0x44 },
412 { KE_END, FE_MAIL_LED | FE_UNTESTED }
325}; 413};
326 414
327static struct key_entry keymap_aopen_1559as[] = { 415static struct key_entry keymap_acer_travelmate_380[] __initdata = {
328 { KE_KEY, 0x01, KEY_HELP }, 416 { KE_KEY, 0x01, {KEY_HELP} },
329 { KE_KEY, 0x06, KEY_PROG3 }, 417 { KE_KEY, 0x02, {KEY_CONFIG} },
330 { KE_KEY, 0x11, KEY_PROG1 }, 418 { KE_KEY, 0x03, {KEY_POWER} }, /* not 370 */
331 { KE_KEY, 0x12, KEY_PROG2 }, 419 { KE_KEY, 0x11, {KEY_PROG1} },
332 { KE_WIFI, 0x30, 0 }, 420 { KE_KEY, 0x12, {KEY_PROG2} },
333 { KE_KEY, 0x31, KEY_MAIL }, 421 { KE_KEY, 0x13, {KEY_PROG3} },
334 { KE_KEY, 0x36, KEY_WWW }, 422 { KE_KEY, 0x31, {KEY_MAIL} },
423 { KE_KEY, 0x36, {KEY_WWW} },
424 { KE_WIFI, 0x30 },
425 { KE_END, FE_MAIL_LED | FE_UNTESTED }
426};
427
428/* unusual map */
429static struct key_entry keymap_acer_travelmate_220[] __initdata = {
430 { KE_KEY, 0x01, {KEY_HELP} },
431 { KE_KEY, 0x02, {KEY_CONFIG} },
432 { KE_KEY, 0x11, {KEY_MAIL} },
433 { KE_KEY, 0x12, {KEY_WWW} },
434 { KE_KEY, 0x13, {KEY_PROG2} },
435 { KE_KEY, 0x31, {KEY_PROG1} },
436 { KE_END, FE_WIFI_LED | FE_UNTESTED }
437};
438
439static struct key_entry keymap_acer_travelmate_230[] __initdata = {
440 { KE_KEY, 0x01, {KEY_HELP} },
441 { KE_KEY, 0x02, {KEY_CONFIG} },
442 { KE_KEY, 0x11, {KEY_PROG1} },
443 { KE_KEY, 0x12, {KEY_PROG2} },
444 { KE_KEY, 0x31, {KEY_MAIL} },
445 { KE_KEY, 0x36, {KEY_WWW} },
446 { KE_END, FE_WIFI_LED | FE_UNTESTED }
447};
448
449static struct key_entry keymap_acer_travelmate_240[] __initdata = {
450 { KE_KEY, 0x01, {KEY_HELP} },
451 { KE_KEY, 0x02, {KEY_CONFIG} },
452 { KE_KEY, 0x03, {KEY_POWER} },
453 { KE_KEY, 0x08, {KEY_MUTE} },
454 { KE_KEY, 0x31, {KEY_MAIL} },
455 { KE_KEY, 0x36, {KEY_WWW} },
456 { KE_KEY, 0x11, {KEY_PROG1} },
457 { KE_KEY, 0x12, {KEY_PROG2} },
458 { KE_BLUETOOTH, 0x44 },
459 { KE_WIFI, 0x30 },
460 { KE_END, FE_UNTESTED }
461};
462
463static struct key_entry keymap_acer_travelmate_350[] __initdata = {
464 { KE_KEY, 0x01, {KEY_HELP} },
465 { KE_KEY, 0x02, {KEY_CONFIG} },
466 { KE_KEY, 0x11, {KEY_PROG1} },
467 { KE_KEY, 0x12, {KEY_PROG2} },
468 { KE_KEY, 0x13, {KEY_MAIL} },
469 { KE_KEY, 0x14, {KEY_PROG3} },
470 { KE_KEY, 0x15, {KEY_WWW} },
471 { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
472};
473
474static struct key_entry keymap_acer_travelmate_360[] __initdata = {
475 { KE_KEY, 0x01, {KEY_HELP} },
476 { KE_KEY, 0x02, {KEY_CONFIG} },
477 { KE_KEY, 0x11, {KEY_PROG1} },
478 { KE_KEY, 0x12, {KEY_PROG2} },
479 { KE_KEY, 0x13, {KEY_MAIL} },
480 { KE_KEY, 0x14, {KEY_PROG3} },
481 { KE_KEY, 0x15, {KEY_WWW} },
482 { KE_KEY, 0x40, {KEY_WLAN} },
483 { KE_END, FE_WIFI_LED | FE_UNTESTED } /* no mail led */
484};
485
486/* Wifi subsystem only activates the led. Therefore we need to pass
487 * wifi event as a normal key, then userspace can really change the wifi state.
488 * TODO we need to export led state to userspace (wifi and mail) */
489static struct key_entry keymap_acer_travelmate_610[] __initdata = {
490 { KE_KEY, 0x01, {KEY_HELP} },
491 { KE_KEY, 0x02, {KEY_CONFIG} },
492 { KE_KEY, 0x11, {KEY_PROG1} },
493 { KE_KEY, 0x12, {KEY_PROG2} },
494 { KE_KEY, 0x13, {KEY_PROG3} },
495 { KE_KEY, 0x14, {KEY_MAIL} },
496 { KE_KEY, 0x15, {KEY_WWW} },
497 { KE_KEY, 0x40, {KEY_WLAN} },
498 { KE_END, FE_MAIL_LED | FE_WIFI_LED }
499};
500
501static struct key_entry keymap_acer_travelmate_630[] __initdata = {
502 { KE_KEY, 0x01, {KEY_HELP} },
503 { KE_KEY, 0x02, {KEY_CONFIG} },
504 { KE_KEY, 0x03, {KEY_POWER} },
505 { KE_KEY, 0x08, {KEY_MUTE} }, /* not 620 */
506 { KE_KEY, 0x11, {KEY_PROG1} },
507 { KE_KEY, 0x12, {KEY_PROG2} },
508 { KE_KEY, 0x13, {KEY_PROG3} },
509 { KE_KEY, 0x20, {KEY_VOLUMEUP} },
510 { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
511 { KE_KEY, 0x31, {KEY_MAIL} },
512 { KE_KEY, 0x36, {KEY_WWW} },
513 { KE_WIFI, 0x30 },
514 { KE_END, FE_MAIL_LED | FE_UNTESTED }
515};
516
517static struct key_entry keymap_aopen_1559as[] __initdata = {
518 { KE_KEY, 0x01, {KEY_HELP} },
519 { KE_KEY, 0x06, {KEY_PROG3} },
520 { KE_KEY, 0x11, {KEY_PROG1} },
521 { KE_KEY, 0x12, {KEY_PROG2} },
522 { KE_WIFI, 0x30 },
523 { KE_KEY, 0x31, {KEY_MAIL} },
524 { KE_KEY, 0x36, {KEY_WWW} },
335 { KE_END, 0 }, 525 { KE_END, 0 },
336}; 526};
337 527
338static struct key_entry keymap_fs_amilo_d88x0[] = { 528static struct key_entry keymap_fs_amilo_d88x0[] __initdata = {
339 { KE_KEY, 0x01, KEY_HELP }, 529 { KE_KEY, 0x01, {KEY_HELP} },
340 { KE_KEY, 0x08, KEY_MUTE }, 530 { KE_KEY, 0x08, {KEY_MUTE} },
341 { KE_KEY, 0x31, KEY_MAIL }, 531 { KE_KEY, 0x31, {KEY_MAIL} },
342 { KE_KEY, 0x36, KEY_WWW }, 532 { KE_KEY, 0x36, {KEY_WWW} },
343 { KE_KEY, 0x11, KEY_PROG1 }, 533 { KE_KEY, 0x11, {KEY_PROG1} },
344 { KE_KEY, 0x12, KEY_PROG2 }, 534 { KE_KEY, 0x12, {KEY_PROG2} },
345 { KE_KEY, 0x13, KEY_PROG3 }, 535 { KE_KEY, 0x13, {KEY_PROG3} },
536 { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
537};
538
539static struct key_entry keymap_wistron_md2900[] __initdata = {
540 { KE_KEY, 0x01, {KEY_HELP} },
541 { KE_KEY, 0x02, {KEY_CONFIG} },
542 { KE_KEY, 0x11, {KEY_PROG1} },
543 { KE_KEY, 0x12, {KEY_PROG2} },
544 { KE_KEY, 0x31, {KEY_MAIL} },
545 { KE_KEY, 0x36, {KEY_WWW} },
546 { KE_WIFI, 0x30 },
547 { KE_END, FE_MAIL_LED | FE_UNTESTED }
548};
549
550static struct key_entry keymap_wistron_md96500[] __initdata = {
551 { KE_KEY, 0x01, {KEY_HELP} },
552 { KE_KEY, 0x02, {KEY_CONFIG} },
553 { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
554 { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
555 { KE_KEY, 0x08, {KEY_MUTE} },
556 { KE_KEY, 0x11, {KEY_PROG1} },
557 { KE_KEY, 0x12, {KEY_PROG2} },
558 { KE_KEY, 0x20, {KEY_VOLUMEUP} },
559 { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
560 { KE_KEY, 0x22, {KEY_REWIND} },
561 { KE_KEY, 0x23, {KEY_FORWARD} },
562 { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
563 { KE_KEY, 0x25, {KEY_STOPCD} },
564 { KE_KEY, 0x31, {KEY_MAIL} },
565 { KE_KEY, 0x36, {KEY_WWW} },
566 { KE_WIFI, 0x30 },
567 { KE_BLUETOOTH, 0x44 },
568 { KE_END, FE_UNTESTED }
569};
570
571static struct key_entry keymap_wistron_generic[] __initdata = {
572 { KE_KEY, 0x01, {KEY_HELP} },
573 { KE_KEY, 0x02, {KEY_CONFIG} },
574 { KE_KEY, 0x03, {KEY_POWER} },
575 { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
576 { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
577 { KE_KEY, 0x08, {KEY_MUTE} },
578 { KE_KEY, 0x11, {KEY_PROG1} },
579 { KE_KEY, 0x12, {KEY_PROG2} },
580 { KE_KEY, 0x13, {KEY_PROG3} },
581 { KE_KEY, 0x14, {KEY_MAIL} },
582 { KE_KEY, 0x15, {KEY_WWW} },
583 { KE_KEY, 0x20, {KEY_VOLUMEUP} },
584 { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
585 { KE_KEY, 0x22, {KEY_REWIND} },
586 { KE_KEY, 0x23, {KEY_FORWARD} },
587 { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
588 { KE_KEY, 0x25, {KEY_STOPCD} },
589 { KE_KEY, 0x31, {KEY_MAIL} },
590 { KE_KEY, 0x36, {KEY_WWW} },
591 { KE_KEY, 0x37, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
592 { KE_KEY, 0x40, {KEY_WLAN} },
593 { KE_KEY, 0x49, {KEY_CONFIG} },
594 { KE_SW, 0x4a, {.sw = {SW_LID, 1}} }, /* lid close */
595 { KE_SW, 0x4b, {.sw = {SW_LID, 0}} }, /* lid open */
596 { KE_KEY, 0x6a, {KEY_CONFIG} },
597 { KE_KEY, 0x6d, {KEY_POWER} },
598 { KE_KEY, 0x71, {KEY_STOPCD} },
599 { KE_KEY, 0x72, {KEY_PLAYPAUSE} },
600 { KE_KEY, 0x74, {KEY_REWIND} },
601 { KE_KEY, 0x78, {KEY_FORWARD} },
602 { KE_WIFI, 0x30 },
603 { KE_BLUETOOTH, 0x44 },
346 { KE_END, 0 } 604 { KE_END, 0 }
347}; 605};
348 606
@@ -390,6 +648,133 @@ static struct dmi_system_id dmi_ids[] __initdata = {
390 }, 648 },
391 { 649 {
392 .callback = dmi_matched, 650 .callback = dmi_matched,
651 .ident = "Acer Aspire 1600",
652 .matches = {
653 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
654 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1600"),
655 },
656 .driver_data = keymap_acer_aspire_1600
657 },
658 {
659 .callback = dmi_matched,
660 .ident = "Acer Aspire 3020",
661 .matches = {
662 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
663 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3020"),
664 },
665 .driver_data = keymap_acer_aspire_5020
666 },
667 {
668 .callback = dmi_matched,
669 .ident = "Acer Aspire 5020",
670 .matches = {
671 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
672 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5020"),
673 },
674 .driver_data = keymap_acer_aspire_5020
675 },
676 {
677 .callback = dmi_matched,
678 .ident = "Acer TravelMate 2100",
679 .matches = {
680 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
681 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2100"),
682 },
683 .driver_data = keymap_acer_aspire_5020
684 },
685 {
686 .callback = dmi_matched,
687 .ident = "Acer TravelMate 2410",
688 .matches = {
689 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
690 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2410"),
691 },
692 .driver_data = keymap_acer_travelmate_2410
693 },
694 {
695 .callback = dmi_matched,
696 .ident = "Acer TravelMate C300",
697 .matches = {
698 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
699 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C300"),
700 },
701 .driver_data = keymap_acer_travelmate_300
702 },
703 {
704 .callback = dmi_matched,
705 .ident = "Acer TravelMate C100",
706 .matches = {
707 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
708 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C100"),
709 },
710 .driver_data = keymap_acer_travelmate_300
711 },
712 {
713 .callback = dmi_matched,
714 .ident = "Acer TravelMate C110",
715 .matches = {
716 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
717 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C110"),
718 },
719 .driver_data = keymap_acer_travelmate_110
720 },
721 {
722 .callback = dmi_matched,
723 .ident = "Acer TravelMate 380",
724 .matches = {
725 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
726 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 380"),
727 },
728 .driver_data = keymap_acer_travelmate_380
729 },
730 {
731 .callback = dmi_matched,
732 .ident = "Acer TravelMate 370",
733 .matches = {
734 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
735 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 370"),
736 },
737 .driver_data = keymap_acer_travelmate_380 /* keyboard minus 1 key */
738 },
739 {
740 .callback = dmi_matched,
741 .ident = "Acer TravelMate 220",
742 .matches = {
743 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
744 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 220"),
745 },
746 .driver_data = keymap_acer_travelmate_220
747 },
748 {
749 .callback = dmi_matched,
750 .ident = "Acer TravelMate 260",
751 .matches = {
752 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
753 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 260"),
754 },
755 .driver_data = keymap_acer_travelmate_220
756 },
757 {
758 .callback = dmi_matched,
759 .ident = "Acer TravelMate 230",
760 .matches = {
761 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
762 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 230"),
763 /* acerhk looks for "TravelMate F4..." ?! */
764 },
765 .driver_data = keymap_acer_travelmate_230
766 },
767 {
768 .callback = dmi_matched,
769 .ident = "Acer TravelMate 280",
770 .matches = {
771 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
772 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 280"),
773 },
774 .driver_data = keymap_acer_travelmate_230
775 },
776 {
777 .callback = dmi_matched,
393 .ident = "Acer TravelMate 240", 778 .ident = "Acer TravelMate 240",
394 .matches = { 779 .matches = {
395 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 780 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
@@ -399,6 +784,15 @@ static struct dmi_system_id dmi_ids[] __initdata = {
399 }, 784 },
400 { 785 {
401 .callback = dmi_matched, 786 .callback = dmi_matched,
787 .ident = "Acer TravelMate 250",
788 .matches = {
789 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
790 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 250"),
791 },
792 .driver_data = keymap_acer_travelmate_240
793 },
794 {
795 .callback = dmi_matched,
402 .ident = "Acer TravelMate 2424NWXCi", 796 .ident = "Acer TravelMate 2424NWXCi",
403 .matches = { 797 .matches = {
404 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 798 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
@@ -408,6 +802,51 @@ static struct dmi_system_id dmi_ids[] __initdata = {
408 }, 802 },
409 { 803 {
410 .callback = dmi_matched, 804 .callback = dmi_matched,
805 .ident = "Acer TravelMate 350",
806 .matches = {
807 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
808 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 350"),
809 },
810 .driver_data = keymap_acer_travelmate_350
811 },
812 {
813 .callback = dmi_matched,
814 .ident = "Acer TravelMate 360",
815 .matches = {
816 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
817 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
818 },
819 .driver_data = keymap_acer_travelmate_360
820 },
821 {
822 .callback = dmi_matched,
823 .ident = "Acer TravelMate 610",
824 .matches = {
825 DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
826 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 610"),
827 },
828 .driver_data = keymap_acer_travelmate_610
829 },
830 {
831 .callback = dmi_matched,
832 .ident = "Acer TravelMate 620",
833 .matches = {
834 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
835 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 620"),
836 },
837 .driver_data = keymap_acer_travelmate_630
838 },
839 {
840 .callback = dmi_matched,
841 .ident = "Acer TravelMate 630",
842 .matches = {
843 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
844 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 630"),
845 },
846 .driver_data = keymap_acer_travelmate_630
847 },
848 {
849 .callback = dmi_matched,
411 .ident = "AOpen 1559AS", 850 .ident = "AOpen 1559AS",
412 .matches = { 851 .matches = {
413 DMI_MATCH(DMI_PRODUCT_NAME, "E2U"), 852 DMI_MATCH(DMI_PRODUCT_NAME, "E2U"),
@@ -426,6 +865,51 @@ static struct dmi_system_id dmi_ids[] __initdata = {
426 }, 865 },
427 { 866 {
428 .callback = dmi_matched, 867 .callback = dmi_matched,
868 .ident = "Medion MD 40100",
869 .matches = {
870 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
871 DMI_MATCH(DMI_PRODUCT_NAME, "WID2000"),
872 },
873 .driver_data = keymap_wistron_md40100
874 },
875 {
876 .callback = dmi_matched,
877 .ident = "Medion MD 2900",
878 .matches = {
879 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
880 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2000"),
881 },
882 .driver_data = keymap_wistron_md2900
883 },
884 {
885 .callback = dmi_matched,
886 .ident = "Medion MD 96500",
887 .matches = {
888 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
889 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2040"),
890 },
891 .driver_data = keymap_wistron_md96500
892 },
893 {
894 .callback = dmi_matched,
895 .ident = "Medion MD 95400",
896 .matches = {
897 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
898 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2050"),
899 },
900 .driver_data = keymap_wistron_md96500
901 },
902 {
903 .callback = dmi_matched,
904 .ident = "Fujitsu Siemens Amilo D7820",
905 .matches = {
906 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), /* not sure */
907 DMI_MATCH(DMI_PRODUCT_NAME, "Amilo D"),
908 },
909 .driver_data = keymap_fs_amilo_d88x0
910 },
911 {
912 .callback = dmi_matched,
429 .ident = "Fujitsu Siemens Amilo D88x0", 913 .ident = "Fujitsu Siemens Amilo D88x0",
430 .matches = { 914 .matches = {
431 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 915 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
@@ -436,17 +920,39 @@ static struct dmi_system_id dmi_ids[] __initdata = {
436 { NULL, } 920 { NULL, }
437}; 921};
438 922
923/* Copy the good keymap, as the original ones are free'd */
924static int __init copy_keymap(void)
925{
926 const struct key_entry *key;
927 struct key_entry *new_keymap;
928 unsigned int length = 1;
929
930 for (key = keymap; key->type != KE_END; key++)
931 length++;
932
933 new_keymap = kmalloc(length * sizeof(struct key_entry), GFP_KERNEL);
934 if (!new_keymap)
935 return -ENOMEM;
936
937 memcpy(new_keymap, keymap, length * sizeof(struct key_entry));
938 keymap = new_keymap;
939
940 return 0;
941}
942
439static int __init select_keymap(void) 943static int __init select_keymap(void)
440{ 944{
945 dmi_check_system(dmi_ids);
441 if (keymap_name != NULL) { 946 if (keymap_name != NULL) {
442 if (strcmp (keymap_name, "1557/MS2141") == 0) 947 if (strcmp (keymap_name, "1557/MS2141") == 0)
443 keymap = keymap_wistron_ms2141; 948 keymap = keymap_wistron_ms2141;
949 else if (strcmp (keymap_name, "generic") == 0)
950 keymap = keymap_wistron_generic;
444 else { 951 else {
445 printk(KERN_ERR "wistron_btns: Keymap unknown\n"); 952 printk(KERN_ERR "wistron_btns: Keymap unknown\n");
446 return -EINVAL; 953 return -EINVAL;
447 } 954 }
448 } 955 }
449 dmi_check_system(dmi_ids);
450 if (keymap == NULL) { 956 if (keymap == NULL) {
451 if (!force) { 957 if (!force) {
452 printk(KERN_ERR "wistron_btns: System unknown\n"); 958 printk(KERN_ERR "wistron_btns: System unknown\n");
@@ -454,7 +960,8 @@ static int __init select_keymap(void)
454 } 960 }
455 keymap = keymap_empty; 961 keymap = keymap_empty;
456 } 962 }
457 return 0; 963
964 return copy_keymap();
458} 965}
459 966
460 /* Input layer interface */ 967 /* Input layer interface */
@@ -476,12 +983,28 @@ static int __devinit setup_input_dev(void)
476 input_dev->cdev.dev = &wistron_device->dev; 983 input_dev->cdev.dev = &wistron_device->dev;
477 984
478 for (key = keymap; key->type != KE_END; key++) { 985 for (key = keymap; key->type != KE_END; key++) {
479 if (key->type == KE_KEY) { 986 switch (key->type) {
480 input_dev->evbit[LONG(EV_KEY)] = BIT(EV_KEY); 987 case KE_KEY:
481 set_bit(key->keycode, input_dev->keybit); 988 set_bit(EV_KEY, input_dev->evbit);
989 set_bit(key->keycode, input_dev->keybit);
990 break;
991
992 case KE_SW:
993 set_bit(EV_SW, input_dev->evbit);
994 set_bit(key->sw.code, input_dev->swbit);
995 break;
996
997 default:
998 ;
482 } 999 }
483 } 1000 }
484 1001
1002 /* reads information flags on KE_END */
1003 if (key->code & FE_UNTESTED)
1004 printk(KERN_WARNING "Untested laptop multimedia keys, "
1005 "please report success or failure to eric.piel"
1006 "@tremplin-utc.net\n");
1007
485 error = input_register_device(input_dev); 1008 error = input_register_device(input_dev);
486 if (error) { 1009 if (error) {
487 input_free_device(input_dev); 1010 input_free_device(input_dev);
@@ -499,6 +1022,12 @@ static void report_key(unsigned keycode)
499 input_sync(input_dev); 1022 input_sync(input_dev);
500} 1023}
501 1024
1025static void report_switch(unsigned code, int value)
1026{
1027 input_report_switch(input_dev, code, value);
1028 input_sync(input_dev);
1029}
1030
502 /* Driver core */ 1031 /* Driver core */
503 1032
504static int wifi_enabled; 1033static int wifi_enabled;
@@ -519,6 +1048,10 @@ static void handle_key(u8 code)
519 report_key(key->keycode); 1048 report_key(key->keycode);
520 break; 1049 break;
521 1050
1051 case KE_SW:
1052 report_switch(key->sw.code, key->sw.value);
1053 break;
1054
522 case KE_WIFI: 1055 case KE_WIFI:
523 if (have_wifi) { 1056 if (have_wifi) {
524 wifi_enabled = !wifi_enabled; 1057 wifi_enabled = !wifi_enabled;
@@ -534,6 +1067,7 @@ static void handle_key(u8 code)
534 break; 1067 break;
535 1068
536 case KE_END: 1069 case KE_END:
1070 break;
537 default: 1071 default:
538 BUG(); 1072 BUG();
539 } 1073 }
@@ -690,6 +1224,7 @@ static void __exit wb_module_exit(void)
690 platform_device_unregister(wistron_device); 1224 platform_device_unregister(wistron_device);
691 platform_driver_unregister(&wistron_driver); 1225 platform_driver_unregister(&wistron_driver);
692 unmap_bios(); 1226 unmap_bios();
1227 kfree(keymap);
693} 1228}
694 1229
695module_init(wb_module_init); 1230module_init(wb_module_init);
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 35d998c3e578..81dd8c7211a7 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -37,6 +37,65 @@ config MOUSE_PS2
37 To compile this driver as a module, choose M here: the 37 To compile this driver as a module, choose M here: the
38 module will be called psmouse. 38 module will be called psmouse.
39 39
40config MOUSE_PS2_ALPS
41 bool "ALPS PS/2 mouse protocol extension" if EMBEDDED
42 default y
43 depends on MOUSE_PS2
44 ---help---
45 Say Y here if you have an ALPS PS/2 touchpad connected to
46 your system.
47
48 If unsure, say Y.
49
50config MOUSE_PS2_LOGIPS2PP
51 bool "Logictech PS/2++ mouse protocol extension" if EMBEDDED
52 default y
53 depends on MOUSE_PS2
54 ---help---
55 Say Y here if you have a Logictech PS/2++ mouse connected to
56 your system.
57
58 If unsure, say Y.
59
60config MOUSE_PS2_SYNAPTICS
61 bool "Synaptics PS/2 mouse protocol extension" if EMBEDDED
62 default y
63 depends on MOUSE_PS2
64 ---help---
65 Say Y here if you have a Synaptics PS/2 TouchPad connected to
66 your system.
67
68 If unsure, say Y.
69
70config MOUSE_PS2_LIFEBOOK
71 bool "Fujitsu Lifebook PS/2 mouse protocol extension" if EMBEDDED
72 default y
73 depends on MOUSE_PS2
74 ---help---
75 Say Y here if you have a Fujitsu B-series Lifebook PS/2
76 TouchScreen connected to your system.
77
78 If unsure, say Y.
79
80config MOUSE_PS2_TRACKPOINT
81 bool "IBM Trackpoint PS/2 mouse protocol extension" if EMBEDDED
82 default y
83 depends on MOUSE_PS2
84 ---help---
85 Say Y here if you have an IBM Trackpoint PS/2 mouse connected
86 to your system.
87
88 If unsure, say Y.
89
90config MOUSE_PS2_TOUCHKIT
91 bool "eGalax TouchKit PS/2 protocol extension"
92 depends on MOUSE_PS2
93 ---help---
94 Say Y here if you have an eGalax TouchKit PS/2 touchscreen
95 connected to your system.
96
97 If unsure, say N.
98
40config MOUSE_SERIAL 99config MOUSE_SERIAL
41 tristate "Serial mouse" 100 tristate "Serial mouse"
42 select SERIO 101 select SERIO
@@ -96,6 +155,17 @@ config MOUSE_AMIGA
96 To compile this driver as a module, choose M here: the 155 To compile this driver as a module, choose M here: the
97 module will be called amimouse. 156 module will be called amimouse.
98 157
158config MOUSE_ATARI
159 tristate "Atari mouse"
160 depends on ATARI
161 select ATARI_KBD_CORE
162 help
163 Say Y here if you have an Atari and want its native mouse
164 supported by the kernel.
165
166 To compile this driver as a module, choose M here: the
167 module will be called atarimouse.
168
99config MOUSE_RISCPC 169config MOUSE_RISCPC
100 tristate "Acorn RiscPC mouse" 170 tristate "Acorn RiscPC mouse"
101 depends on ARCH_ACORN 171 depends on ARCH_ACORN
@@ -118,7 +188,7 @@ config MOUSE_VSXXXAA
118 digitizer (VSXXX-AB) DEC produced. 188 digitizer (VSXXX-AB) DEC produced.
119 189
120config MOUSE_HIL 190config MOUSE_HIL
121 tristate "HIL pointers (mice etc)." 191 tristate "HIL pointers (mice etc)."
122 depends on GSC || HP300 192 depends on GSC || HP300
123 select HP_SDC 193 select HP_SDC
124 select HIL_MLC 194 select HIL_MLC
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 21a1de61a79b..6a8f622927f2 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -5,6 +5,7 @@
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o 7obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o
8obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o
8obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o 9obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o
9obj-$(CONFIG_MOUSE_INPORT) += inport.o 10obj-$(CONFIG_MOUSE_INPORT) += inport.o
10obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o 11obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
@@ -14,4 +15,10 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o
14obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o 15obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
15obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o 16obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o
16 17
17psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o 18psmouse-objs := psmouse-base.o synaptics.o
19
20psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o
21psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o
22psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o
23psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
24psmouse-$(CONFIG_MOUSE_PS2_TOUCHKIT) += touchkit_ps2.o
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 4e71a66fc7fc..cf3e4664e72b 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -424,14 +424,15 @@ int alps_init(struct psmouse *psmouse)
424 struct input_dev *dev1 = psmouse->dev, *dev2; 424 struct input_dev *dev1 = psmouse->dev, *dev2;
425 int version; 425 int version;
426 426
427 psmouse->private = priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); 427 priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL);
428 dev2 = input_allocate_device(); 428 dev2 = input_allocate_device();
429 if (!priv || !dev2) 429 if (!priv || !dev2)
430 goto init_fail; 430 goto init_fail;
431 431
432 priv->dev2 = dev2; 432 priv->dev2 = dev2;
433 433
434 if (!(priv->i = alps_get_model(psmouse, &version))) 434 priv->i = alps_get_model(psmouse, &version);
435 if (!priv->i)
435 goto init_fail; 436 goto init_fail;
436 437
437 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1)) 438 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1))
@@ -480,7 +481,8 @@ int alps_init(struct psmouse *psmouse)
480 dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); 481 dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y);
481 dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 482 dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
482 483
483 input_register_device(priv->dev2); 484 if (input_register_device(priv->dev2))
485 goto init_fail;
484 486
485 psmouse->protocol_handler = alps_process_byte; 487 psmouse->protocol_handler = alps_process_byte;
486 psmouse->poll = alps_poll; 488 psmouse->poll = alps_poll;
@@ -491,9 +493,11 @@ int alps_init(struct psmouse *psmouse)
491 /* We are having trouble resyncing ALPS touchpads so disable it for now */ 493 /* We are having trouble resyncing ALPS touchpads so disable it for now */
492 psmouse->resync_time = 0; 494 psmouse->resync_time = 0;
493 495
496 psmouse->private = priv;
494 return 0; 497 return 0;
495 498
496init_fail: 499init_fail:
500 psmouse_reset(psmouse);
497 input_free_device(dev2); 501 input_free_device(dev2);
498 kfree(priv); 502 kfree(priv);
499 return -1; 503 return -1;
@@ -504,7 +508,8 @@ int alps_detect(struct psmouse *psmouse, int set_properties)
504 int version; 508 int version;
505 const struct alps_model_info *model; 509 const struct alps_model_info *model;
506 510
507 if (!(model = alps_get_model(psmouse, &version))) 511 model = alps_get_model(psmouse, &version);
512 if (!model)
508 return -1; 513 return -1;
509 514
510 if (set_properties) { 515 if (set_properties) {
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index 69db7325a494..4bbddc99962b 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -12,9 +12,6 @@
12#ifndef _ALPS_H 12#ifndef _ALPS_H
13#define _ALPS_H 13#define _ALPS_H
14 14
15int alps_detect(struct psmouse *psmouse, int set_properties);
16int alps_init(struct psmouse *psmouse);
17
18struct alps_model_info { 15struct alps_model_info {
19 unsigned char signature[3]; 16 unsigned char signature[3];
20 unsigned char byte0, mask0; 17 unsigned char byte0, mask0;
@@ -23,10 +20,23 @@ struct alps_model_info {
23 20
24struct alps_data { 21struct alps_data {
25 struct input_dev *dev2; /* Relative device */ 22 struct input_dev *dev2; /* Relative device */
26 char name[32]; /* Name */
27 char phys[32]; /* Phys */ 23 char phys[32]; /* Phys */
28 const struct alps_model_info *i;/* Info */ 24 const struct alps_model_info *i;/* Info */
29 int prev_fin; /* Finger bit from previous packet */ 25 int prev_fin; /* Finger bit from previous packet */
30}; 26};
31 27
28#ifdef CONFIG_MOUSE_PS2_ALPS
29int alps_detect(struct psmouse *psmouse, int set_properties);
30int alps_init(struct psmouse *psmouse);
31#else
32inline int alps_detect(struct psmouse *psmouse, int set_properties)
33{
34 return -ENOSYS;
35}
36inline int alps_init(struct psmouse *psmouse)
37{
38 return -ENOSYS;
39}
40#endif /* CONFIG_MOUSE_PS2_ALPS */
41
32#endif 42#endif
diff --git a/drivers/input/mouse/atarimouse.c b/drivers/input/mouse/atarimouse.c
new file mode 100644
index 000000000000..43ab6566fb65
--- /dev/null
+++ b/drivers/input/mouse/atarimouse.c
@@ -0,0 +1,160 @@
1/*
2 * Atari mouse driver for Linux/m68k
3 *
4 * Copyright (c) 2005 Michael Schmitz
5 *
6 * Based on:
7 * Amiga mouse driver for Linux/m68k
8 *
9 * Copyright (c) 2000-2002 Vojtech Pavlik
10 *
11 */
12/*
13 * The low level init and interrupt stuff is handled in arch/mm68k/atari/atakeyb.c
14 * (the keyboard ACIA also handles the mouse and joystick data, and the keyboard
15 * interrupt is shared with the MIDI ACIA so MIDI data also get handled there).
16 * This driver only deals with handing key events off to the input layer.
17 *
18 * Largely based on the old:
19 *
20 * Atari Mouse Driver for Linux
21 * by Robert de Vries (robert@and.nl) 19Jul93
22 *
23 * 16 Nov 1994 Andreas Schwab
24 * Compatibility with busmouse
25 * Support for three button mouse (shamelessly stolen from MiNT)
26 * third button wired to one of the joystick directions on joystick 1
27 *
28 * 1996/02/11 Andreas Schwab
29 * Module support
30 * Allow multiple open's
31 *
32 * Converted to use new generic busmouse code. 5 Apr 1998
33 * Russell King <rmk@arm.uk.linux.org>
34 */
35
36
37/*
38 * This program is free software; you can redistribute it and/or modify it
39 * under the terms of the GNU General Public License version 2 as published by
40 * the Free Software Foundation
41 */
42
43#include <linux/module.h>
44#include <linux/init.h>
45#include <linux/input.h>
46#include <linux/interrupt.h>
47
48#include <asm/irq.h>
49#include <asm/setup.h>
50#include <asm/system.h>
51#include <asm/uaccess.h>
52#include <asm/atarihw.h>
53#include <asm/atarikb.h>
54#include <asm/atariints.h>
55
56MODULE_AUTHOR("Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>");
57MODULE_DESCRIPTION("Atari mouse driver");
58MODULE_LICENSE("GPL");
59
60static int mouse_threshold[2] = {2,2};
61
62#ifdef __MODULE__
63MODULE_PARM(mouse_threshold, "2i");
64#endif
65#ifdef FIXED_ATARI_JOYSTICK
66extern int atari_mouse_buttons;
67#endif
68static int atamouse_used = 0;
69
70static struct input_dev *atamouse_dev;
71
72static void atamouse_interrupt(char *buf)
73{
74 int buttons, dx, dy;
75
76/* ikbd_mouse_disable(); */
77
78 buttons = (buf[0] & 1) | ((buf[0] & 2) << 1);
79#ifdef FIXED_ATARI_JOYSTICK
80 buttons |= atari_mouse_buttons & 2;
81 atari_mouse_buttons = buttons;
82#endif
83/* ikbd_mouse_rel_pos(); */
84
85 /* only relative events get here */
86 dx = buf[1];
87 dy = -buf[2];
88
89 input_report_rel(atamouse_dev, REL_X, dx);
90 input_report_rel(atamouse_dev, REL_Y, dy);
91
92 input_report_key(atamouse_dev, BTN_LEFT, buttons & 0x1);
93 input_report_key(atamouse_dev, BTN_MIDDLE, buttons & 0x2);
94 input_report_key(atamouse_dev, BTN_RIGHT, buttons & 0x4);
95
96 input_sync(atamouse_dev);
97
98 return;
99}
100
101static int atamouse_open(struct input_dev *dev)
102{
103 if (atamouse_used++)
104 return 0;
105
106#ifdef FIXED_ATARI_JOYSTICK
107 atari_mouse_buttons = 0;
108#endif
109 ikbd_mouse_y0_top();
110 ikbd_mouse_thresh(mouse_threshold[0], mouse_threshold[1]);
111 ikbd_mouse_rel_pos();
112 atari_input_mouse_interrupt_hook = atamouse_interrupt;
113 return 0;
114}
115
116static void atamouse_close(struct input_dev *dev)
117{
118 if (!--atamouse_used) {
119 ikbd_mouse_disable();
120 atari_mouse_interrupt_hook = NULL;
121 }
122}
123
124static int __init atamouse_init(void)
125{
126 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))
127 return -ENODEV;
128
129 if (!(atamouse_dev = input_allocate_device()))
130 return -ENOMEM;
131
132 if (!(atari_keyb_init()))
133 return -ENODEV;
134
135 atamouse_dev->name = "Atari mouse";
136 atamouse_dev->phys = "atamouse/input0";
137 atamouse_dev->id.bustype = BUS_ATARI;
138 atamouse_dev->id.vendor = 0x0001;
139 atamouse_dev->id.product = 0x0002;
140 atamouse_dev->id.version = 0x0100;
141
142 atamouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
143 atamouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
144 atamouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
145 atamouse_dev->open = atamouse_open;
146 atamouse_dev->close = atamouse_close;
147
148 input_register_device(atamouse_dev);
149
150 printk(KERN_INFO "input: %s at keyboard ACIA\n", atamouse_dev->name);
151 return 0;
152}
153
154static void __exit atamouse_exit(void)
155{
156 input_unregister_device(atamouse_dev);
157}
158
159module_init(atamouse_init);
160module_exit(atamouse_exit);
diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c
index bfb174fe3230..449bf4dcbbcc 100644
--- a/drivers/input/mouse/hil_ptr.c
+++ b/drivers/input/mouse/hil_ptr.c
@@ -88,10 +88,12 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
88 idx = ptr->idx4/4; 88 idx = ptr->idx4/4;
89 p = data[idx - 1]; 89 p = data[idx - 1];
90 90
91 if ((p & ~HIL_CMDCT_POL) == 91 if ((p & ~HIL_CMDCT_POL) ==
92 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) goto report; 92 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
93 if ((p & ~HIL_CMDCT_RPL) == 93 goto report;
94 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL)) goto report; 94 if ((p & ~HIL_CMDCT_RPL) ==
95 (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL))
96 goto report;
95 97
96 /* Not a poll response. See if we are loading config records. */ 98 /* Not a poll response. See if we are loading config records. */
97 switch (p & HIL_PKT_DATA_MASK) { 99 switch (p & HIL_PKT_DATA_MASK) {
@@ -101,27 +103,32 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
101 for (; i < HIL_PTR_MAX_LENGTH; i++) 103 for (; i < HIL_PTR_MAX_LENGTH; i++)
102 ptr->idd[i] = 0; 104 ptr->idd[i] = 0;
103 break; 105 break;
106
104 case HIL_CMD_RSC: 107 case HIL_CMD_RSC:
105 for (i = 0; i < idx; i++) 108 for (i = 0; i < idx; i++)
106 ptr->rsc[i] = ptr->data[i] & HIL_PKT_DATA_MASK; 109 ptr->rsc[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
107 for (; i < HIL_PTR_MAX_LENGTH; i++) 110 for (; i < HIL_PTR_MAX_LENGTH; i++)
108 ptr->rsc[i] = 0; 111 ptr->rsc[i] = 0;
109 break; 112 break;
113
110 case HIL_CMD_EXD: 114 case HIL_CMD_EXD:
111 for (i = 0; i < idx; i++) 115 for (i = 0; i < idx; i++)
112 ptr->exd[i] = ptr->data[i] & HIL_PKT_DATA_MASK; 116 ptr->exd[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
113 for (; i < HIL_PTR_MAX_LENGTH; i++) 117 for (; i < HIL_PTR_MAX_LENGTH; i++)
114 ptr->exd[i] = 0; 118 ptr->exd[i] = 0;
115 break; 119 break;
120
116 case HIL_CMD_RNM: 121 case HIL_CMD_RNM:
117 for (i = 0; i < idx; i++) 122 for (i = 0; i < idx; i++)
118 ptr->rnm[i] = ptr->data[i] & HIL_PKT_DATA_MASK; 123 ptr->rnm[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
119 for (; i < HIL_PTR_MAX_LENGTH + 1; i++) 124 for (; i < HIL_PTR_MAX_LENGTH + 1; i++)
120 ptr->rnm[i] = '\0'; 125 ptr->rnm[i] = 0;
121 break; 126 break;
127
122 default: 128 default:
123 /* These occur when device isn't present */ 129 /* These occur when device isn't present */
124 if (p == (HIL_ERR_INT | HIL_PKT_CMD)) break; 130 if (p == (HIL_ERR_INT | HIL_PKT_CMD))
131 break;
125 /* Anything else we'd like to know about. */ 132 /* Anything else we'd like to know about. */
126 printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p); 133 printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p);
127 break; 134 break;
@@ -130,7 +137,8 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
130 137
131 report: 138 report:
132 if ((p & HIL_CMDCT_POL) != idx - 1) { 139 if ((p & HIL_CMDCT_POL) != idx - 1) {
133 printk(KERN_WARNING PREFIX "Malformed poll packet %x (idx = %i)\n", p, idx); 140 printk(KERN_WARNING PREFIX
141 "Malformed poll packet %x (idx = %i)\n", p, idx);
134 goto out; 142 goto out;
135 } 143 }
136 144
@@ -139,7 +147,7 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
139 laxis += i; 147 laxis += i;
140 148
141 ax16 = ptr->idd[1] & HIL_IDD_HEADER_16BIT; /* 8 or 16bit resolution */ 149 ax16 = ptr->idd[1] & HIL_IDD_HEADER_16BIT; /* 8 or 16bit resolution */
142 absdev = ptr->idd[1] & HIL_IDD_HEADER_ABS; 150 absdev = ptr->idd[1] & HIL_IDD_HEADER_ABS;
143 151
144 for (cnt = 1; i < laxis; i++) { 152 for (cnt = 1; i < laxis; i++) {
145 unsigned int lo,hi,val; 153 unsigned int lo,hi,val;
@@ -157,7 +165,8 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
157 input_report_abs(dev, ABS_X + i, val); 165 input_report_abs(dev, ABS_X + i, val);
158 } else { 166 } else {
159 val = (int) (((int8_t)lo) | ((int8_t)hi<<8)); 167 val = (int) (((int8_t)lo) | ((int8_t)hi<<8));
160 if (i%3) val *= -1; 168 if (i%3)
169 val *= -1;
161 input_report_rel(dev, REL_X + i, val); 170 input_report_rel(dev, REL_X + i, val);
162 } 171 }
163 } 172 }
@@ -168,10 +177,11 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
168 btn = ptr->data[cnt++]; 177 btn = ptr->data[cnt++];
169 up = btn & 1; 178 up = btn & 1;
170 btn &= 0xfe; 179 btn &= 0xfe;
171 if (btn == 0x8e) { 180 if (btn == 0x8e)
172 continue; /* TODO: proximity == touch? */ 181 continue; /* TODO: proximity == touch? */
173 } 182 else
174 else if ((btn > 0x8c) || (btn < 0x80)) continue; 183 if ((btn > 0x8c) || (btn < 0x80))
184 continue;
175 btn = (btn - 0x80) >> 1; 185 btn = (btn - 0x80) >> 1;
176 btn = ptr->btnmap[btn]; 186 btn = ptr->btnmap[btn];
177 input_report_key(dev, btn, !up); 187 input_report_key(dev, btn, !up);
@@ -182,14 +192,14 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
182 up(&ptr->sem); 192 up(&ptr->sem);
183} 193}
184 194
185static void hil_ptr_process_err(struct hil_ptr *ptr) { 195static void hil_ptr_process_err(struct hil_ptr *ptr)
196{
186 printk(KERN_WARNING PREFIX "errored HIL packet\n"); 197 printk(KERN_WARNING PREFIX "errored HIL packet\n");
187 ptr->idx4 = 0; 198 ptr->idx4 = 0;
188 up(&ptr->sem); 199 up(&ptr->sem);
189 return;
190} 200}
191 201
192static irqreturn_t hil_ptr_interrupt(struct serio *serio, 202static irqreturn_t hil_ptr_interrupt(struct serio *serio,
193 unsigned char data, unsigned int flags) 203 unsigned char data, unsigned int flags)
194{ 204{
195 struct hil_ptr *ptr; 205 struct hil_ptr *ptr;
@@ -197,29 +207,29 @@ static irqreturn_t hil_ptr_interrupt(struct serio *serio,
197 int idx; 207 int idx;
198 208
199 ptr = serio_get_drvdata(serio); 209 ptr = serio_get_drvdata(serio);
200 if (ptr == NULL) { 210 BUG_ON(ptr == NULL);
201 BUG();
202 return IRQ_HANDLED;
203 }
204 211
205 if (ptr->idx4 >= (HIL_PTR_MAX_LENGTH * sizeof(hil_packet))) { 212 if (ptr->idx4 >= (HIL_PTR_MAX_LENGTH * sizeof(hil_packet))) {
206 hil_ptr_process_err(ptr); 213 hil_ptr_process_err(ptr);
207 return IRQ_HANDLED; 214 return IRQ_HANDLED;
208 } 215 }
209 idx = ptr->idx4/4; 216 idx = ptr->idx4/4;
210 if (!(ptr->idx4 % 4)) ptr->data[idx] = 0; 217 if (!(ptr->idx4 % 4))
218 ptr->data[idx] = 0;
211 packet = ptr->data[idx]; 219 packet = ptr->data[idx];
212 packet |= ((hil_packet)data) << ((3 - (ptr->idx4 % 4)) * 8); 220 packet |= ((hil_packet)data) << ((3 - (ptr->idx4 % 4)) * 8);
213 ptr->data[idx] = packet; 221 ptr->data[idx] = packet;
214 222
215 /* Records of N 4-byte hil_packets must terminate with a command. */ 223 /* Records of N 4-byte hil_packets must terminate with a command. */
216 if ((++(ptr->idx4)) % 4) return IRQ_HANDLED; 224 if ((++(ptr->idx4)) % 4)
225 return IRQ_HANDLED;
217 if ((packet & 0xffff0000) != HIL_ERR_INT) { 226 if ((packet & 0xffff0000) != HIL_ERR_INT) {
218 hil_ptr_process_err(ptr); 227 hil_ptr_process_err(ptr);
219 return IRQ_HANDLED; 228 return IRQ_HANDLED;
220 } 229 }
221 if (packet & HIL_PKT_CMD) 230 if (packet & HIL_PKT_CMD)
222 hil_ptr_process_record(ptr); 231 hil_ptr_process_record(ptr);
232
223 return IRQ_HANDLED; 233 return IRQ_HANDLED;
224} 234}
225 235
@@ -228,10 +238,7 @@ static void hil_ptr_disconnect(struct serio *serio)
228 struct hil_ptr *ptr; 238 struct hil_ptr *ptr;
229 239
230 ptr = serio_get_drvdata(serio); 240 ptr = serio_get_drvdata(serio);
231 if (ptr == NULL) { 241 BUG_ON(ptr == NULL);
232 BUG();
233 return;
234 }
235 242
236 serio_close(serio); 243 serio_close(serio);
237 input_unregister_device(ptr->dev); 244 input_unregister_device(ptr->dev);
@@ -241,7 +248,7 @@ static void hil_ptr_disconnect(struct serio *serio)
241static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) 248static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
242{ 249{
243 struct hil_ptr *ptr; 250 struct hil_ptr *ptr;
244 char *txt; 251 const char *txt;
245 unsigned int i, naxsets, btntype; 252 unsigned int i, naxsets, btntype;
246 uint8_t did, *idd; 253 uint8_t did, *idd;
247 254
@@ -252,42 +259,40 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
252 if (!ptr->dev) 259 if (!ptr->dev)
253 goto bail0; 260 goto bail0;
254 261
255 ptr->dev->private = ptr;
256
257 if (serio_open(serio, driver)) 262 if (serio_open(serio, driver))
258 goto bail1; 263 goto bail1;
259 264
260 serio_set_drvdata(serio, ptr); 265 serio_set_drvdata(serio, ptr);
261 ptr->serio = serio; 266 ptr->serio = serio;
262 267
263 init_MUTEX_LOCKED(&(ptr->sem)); 268 init_MUTEX_LOCKED(&ptr->sem);
264 269
265 /* Get device info. MLC driver supplies devid/status/etc. */ 270 /* Get device info. MLC driver supplies devid/status/etc. */
266 serio->write(serio, 0); 271 serio->write(serio, 0);
267 serio->write(serio, 0); 272 serio->write(serio, 0);
268 serio->write(serio, HIL_PKT_CMD >> 8); 273 serio->write(serio, HIL_PKT_CMD >> 8);
269 serio->write(serio, HIL_CMD_IDD); 274 serio->write(serio, HIL_CMD_IDD);
270 down(&(ptr->sem)); 275 down(&ptr->sem);
271 276
272 serio->write(serio, 0); 277 serio->write(serio, 0);
273 serio->write(serio, 0); 278 serio->write(serio, 0);
274 serio->write(serio, HIL_PKT_CMD >> 8); 279 serio->write(serio, HIL_PKT_CMD >> 8);
275 serio->write(serio, HIL_CMD_RSC); 280 serio->write(serio, HIL_CMD_RSC);
276 down(&(ptr->sem)); 281 down(&ptr->sem);
277 282
278 serio->write(serio, 0); 283 serio->write(serio, 0);
279 serio->write(serio, 0); 284 serio->write(serio, 0);
280 serio->write(serio, HIL_PKT_CMD >> 8); 285 serio->write(serio, HIL_PKT_CMD >> 8);
281 serio->write(serio, HIL_CMD_RNM); 286 serio->write(serio, HIL_CMD_RNM);
282 down(&(ptr->sem)); 287 down(&ptr->sem);
283 288
284 serio->write(serio, 0); 289 serio->write(serio, 0);
285 serio->write(serio, 0); 290 serio->write(serio, 0);
286 serio->write(serio, HIL_PKT_CMD >> 8); 291 serio->write(serio, HIL_PKT_CMD >> 8);
287 serio->write(serio, HIL_CMD_EXD); 292 serio->write(serio, HIL_CMD_EXD);
288 down(&(ptr->sem)); 293 down(&ptr->sem);
289 294
290 up(&(ptr->sem)); 295 up(&ptr->sem);
291 296
292 did = ptr->idd[0]; 297 did = ptr->idd[0];
293 idd = ptr->idd + 1; 298 idd = ptr->idd + 1;
@@ -301,12 +306,12 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
301 ptr->dev->evbit[0] = BIT(EV_ABS); 306 ptr->dev->evbit[0] = BIT(EV_ABS);
302 txt = "absolute"; 307 txt = "absolute";
303 } 308 }
304 if (!ptr->dev->evbit[0]) { 309 if (!ptr->dev->evbit[0])
305 goto bail2; 310 goto bail2;
306 }
307 311
308 ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); 312 ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd);
309 if (ptr->nbtn) ptr->dev->evbit[0] |= BIT(EV_KEY); 313 if (ptr->nbtn)
314 ptr->dev->evbit[0] |= BIT(EV_KEY);
310 315
311 naxsets = HIL_IDD_NUM_AXSETS(*idd); 316 naxsets = HIL_IDD_NUM_AXSETS(*idd);
312 ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); 317 ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd);
@@ -315,7 +320,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
315 did, txt); 320 did, txt);
316 printk(KERN_INFO PREFIX "HIL pointer has %i buttons and %i sets of %i axes\n", 321 printk(KERN_INFO PREFIX "HIL pointer has %i buttons and %i sets of %i axes\n",
317 ptr->nbtn, naxsets, ptr->naxes); 322 ptr->nbtn, naxsets, ptr->naxes);
318 323
319 btntype = BTN_MISC; 324 btntype = BTN_MISC;
320 if ((did & HIL_IDD_DID_ABS_TABLET_MASK) == HIL_IDD_DID_ABS_TABLET) 325 if ((did & HIL_IDD_DID_ABS_TABLET_MASK) == HIL_IDD_DID_ABS_TABLET)
321#ifdef TABLET_SIMULATES_MOUSE 326#ifdef TABLET_SIMULATES_MOUSE
@@ -325,7 +330,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
325#endif 330#endif
326 if ((did & HIL_IDD_DID_ABS_TSCREEN_MASK) == HIL_IDD_DID_ABS_TSCREEN) 331 if ((did & HIL_IDD_DID_ABS_TSCREEN_MASK) == HIL_IDD_DID_ABS_TSCREEN)
327 btntype = BTN_TOUCH; 332 btntype = BTN_TOUCH;
328 333
329 if ((did & HIL_IDD_DID_REL_MOUSE_MASK) == HIL_IDD_DID_REL_MOUSE) 334 if ((did & HIL_IDD_DID_REL_MOUSE_MASK) == HIL_IDD_DID_REL_MOUSE)
330 btntype = BTN_MOUSE; 335 btntype = BTN_MOUSE;
331 336
@@ -341,12 +346,10 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
341 } 346 }
342 347
343 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { 348 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) {
344 for (i = 0; i < ptr->naxes; i++) { 349 for (i = 0; i < ptr->naxes; i++)
345 set_bit(REL_X + i, ptr->dev->relbit); 350 set_bit(REL_X + i, ptr->dev->relbit);
346 } 351 for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++)
347 for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) {
348 set_bit(REL_X + i, ptr->dev->relbit); 352 set_bit(REL_X + i, ptr->dev->relbit);
349 }
350 } else { 353 } else {
351 for (i = 0; i < ptr->naxes; i++) { 354 for (i = 0; i < ptr->naxes; i++) {
352 set_bit(ABS_X + i, ptr->dev->absbit); 355 set_bit(ABS_X + i, ptr->dev->absbit);
@@ -375,7 +378,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
375 ptr->dev->id.vendor = PCI_VENDOR_ID_HP; 378 ptr->dev->id.vendor = PCI_VENDOR_ID_HP;
376 ptr->dev->id.product = 0x0001; /* TODO: get from ptr->rsc */ 379 ptr->dev->id.product = 0x0001; /* TODO: get from ptr->rsc */
377 ptr->dev->id.version = 0x0100; /* TODO: get from ptr->rsc */ 380 ptr->dev->id.version = 0x0100; /* TODO: get from ptr->rsc */
378 ptr->dev->cdev.dev = &serio->dev; 381 ptr->dev->dev.parent = &serio->dev;
379 382
380 input_register_device(ptr->dev); 383 input_register_device(ptr->dev);
381 printk(KERN_INFO "input: %s (%s), ID: %d\n", 384 printk(KERN_INFO "input: %s (%s), ID: %d\n",
@@ -419,11 +422,11 @@ static int __init hil_ptr_init(void)
419{ 422{
420 return serio_register_driver(&hil_ptr_serio_driver); 423 return serio_register_driver(&hil_ptr_serio_driver);
421} 424}
422 425
423static void __exit hil_ptr_exit(void) 426static void __exit hil_ptr_exit(void)
424{ 427{
425 serio_unregister_driver(&hil_ptr_serio_driver); 428 serio_unregister_driver(&hil_ptr_serio_driver);
426} 429}
427 430
428module_init(hil_ptr_init); 431module_init(hil_ptr_init);
429module_exit(hil_ptr_exit); 432module_exit(hil_ptr_exit);
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index 29542f0631cb..1740cadd9594 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -20,6 +20,27 @@
20#include "psmouse.h" 20#include "psmouse.h"
21#include "lifebook.h" 21#include "lifebook.h"
22 22
23struct lifebook_data {
24 struct input_dev *dev2; /* Relative device */
25 char phys[32];
26};
27
28static const char *desired_serio_phys;
29
30static int lifebook_set_serio_phys(struct dmi_system_id *d)
31{
32 desired_serio_phys = d->driver_data;
33 return 0;
34}
35
36static unsigned char lifebook_use_6byte_proto;
37
38static int lifebook_set_6byte_proto(struct dmi_system_id *d)
39{
40 lifebook_use_6byte_proto = 1;
41 return 0;
42}
43
23static struct dmi_system_id lifebook_dmi_table[] = { 44static struct dmi_system_id lifebook_dmi_table[] = {
24 { 45 {
25 .ident = "FLORA-ie 55mi", 46 .ident = "FLORA-ie 55mi",
@@ -56,6 +77,24 @@ static struct dmi_system_id lifebook_dmi_table[] = {
56 .matches = { 77 .matches = {
57 DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"), 78 DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
58 }, 79 },
80 .callback = lifebook_set_serio_phys,
81 .driver_data = "isa0060/serio3",
82 },
83 {
84 .ident = "Panasonic CF-28",
85 .matches = {
86 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
87 DMI_MATCH(DMI_PRODUCT_NAME, "CF-28"),
88 },
89 .callback = lifebook_set_6byte_proto,
90 },
91 {
92 .ident = "Panasonic CF-29",
93 .matches = {
94 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
95 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
96 },
97 .callback = lifebook_set_6byte_proto,
59 }, 98 },
60 { 99 {
61 .ident = "Lifebook B142", 100 .ident = "Lifebook B142",
@@ -68,30 +107,70 @@ static struct dmi_system_id lifebook_dmi_table[] = {
68 107
69static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse) 108static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse)
70{ 109{
110 struct lifebook_data *priv = psmouse->private;
111 struct input_dev *dev1 = psmouse->dev;
112 struct input_dev *dev2 = priv->dev2;
71 unsigned char *packet = psmouse->packet; 113 unsigned char *packet = psmouse->packet;
72 struct input_dev *dev = psmouse->dev; 114 int relative_packet = packet[0] & 0x08;
73 115
74 if (psmouse->pktcnt != 3) 116 if (relative_packet || !lifebook_use_6byte_proto) {
75 return PSMOUSE_GOOD_DATA; 117 if (psmouse->pktcnt != 3)
118 return PSMOUSE_GOOD_DATA;
119 } else {
120 switch (psmouse->pktcnt) {
121 case 1:
122 return (packet[0] & 0xf8) == 0x00 ?
123 PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;
124 case 2:
125 return PSMOUSE_GOOD_DATA;
126 case 3:
127 return ((packet[2] & 0x30) << 2) == (packet[2] & 0xc0) ?
128 PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;
129 case 4:
130 return (packet[3] & 0xf8) == 0xc0 ?
131 PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;
132 case 5:
133 return (packet[4] & 0xc0) == (packet[2] & 0xc0) ?
134 PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;
135 case 6:
136 if (((packet[5] & 0x30) << 2) != (packet[5] & 0xc0))
137 return PSMOUSE_BAD_DATA;
138 if ((packet[5] & 0xc0) != (packet[1] & 0xc0))
139 return PSMOUSE_BAD_DATA;
140 break; /* report data */
141 }
142 }
76 143
77 /* calculate X and Y */ 144 if (relative_packet) {
78 if ((packet[0] & 0x08) == 0x00) { 145 if (!dev2)
79 input_report_abs(dev, ABS_X, 146 printk(KERN_WARNING "lifebook.c: got relative packet "
147 "but no relative device set up\n");
148 } else if (lifebook_use_6byte_proto) {
149 input_report_abs(dev1, ABS_X,
150 ((packet[1] & 0x3f) << 6) | (packet[2] & 0x3f));
151 input_report_abs(dev1, ABS_Y,
152 4096 - (((packet[4] & 0x3f) << 6) | (packet[5] & 0x3f)));
153 } else {
154 input_report_abs(dev1, ABS_X,
80 (packet[1] | ((packet[0] & 0x30) << 4))); 155 (packet[1] | ((packet[0] & 0x30) << 4)));
81 input_report_abs(dev, ABS_Y, 156 input_report_abs(dev1, ABS_Y,
82 1024 - (packet[2] | ((packet[0] & 0xC0) << 2))); 157 1024 - (packet[2] | ((packet[0] & 0xC0) << 2)));
83 } else {
84 input_report_rel(dev, REL_X,
85 ((packet[0] & 0x10) ? packet[1] - 256 : packet[1]));
86 input_report_rel(dev, REL_Y,
87 -(int)((packet[0] & 0x20) ? packet[2] - 256 : packet[2]));
88 } 158 }
89 159
90 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 160 input_report_key(dev1, BTN_TOUCH, packet[0] & 0x04);
91 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); 161 input_sync(dev1);
92 input_report_key(dev, BTN_TOUCH, packet[0] & 0x04);
93 162
94 input_sync(dev); 163 if (dev2) {
164 if (relative_packet) {
165 input_report_rel(dev2, REL_X,
166 ((packet[0] & 0x10) ? packet[1] - 256 : packet[1]));
167 input_report_rel(dev2, REL_Y,
168 -(int)((packet[0] & 0x20) ? packet[2] - 256 : packet[2]));
169 }
170 input_report_key(dev2, BTN_LEFT, packet[0] & 0x01);
171 input_report_key(dev2, BTN_RIGHT, packet[0] & 0x02);
172 input_sync(dev2);
173 }
95 174
96 return PSMOUSE_FULL_PACKET; 175 return PSMOUSE_FULL_PACKET;
97} 176}
@@ -109,12 +188,20 @@ static int lifebook_absolute_mode(struct psmouse *psmouse)
109 you leave this call out the touchsreen will never send 188 you leave this call out the touchsreen will never send
110 absolute coordinates 189 absolute coordinates
111 */ 190 */
112 param = 0x07; 191 param = lifebook_use_6byte_proto ? 0x08 : 0x07;
113 ps2_command(ps2dev, &param, PSMOUSE_CMD_SETRES); 192 ps2_command(ps2dev, &param, PSMOUSE_CMD_SETRES);
114 193
115 return 0; 194 return 0;
116} 195}
117 196
197static void lifebook_relative_mode(struct psmouse *psmouse)
198{
199 struct ps2dev *ps2dev = &psmouse->ps2dev;
200 unsigned char param = 0x06;
201
202 ps2_command(ps2dev, &param, PSMOUSE_CMD_SETRES);
203}
204
118static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution) 205static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution)
119{ 206{
120 static const unsigned char params[] = { 0, 1, 2, 2, 3 }; 207 static const unsigned char params[] = { 0, 1, 2, 2, 3 };
@@ -131,6 +218,8 @@ static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolu
131static void lifebook_disconnect(struct psmouse *psmouse) 218static void lifebook_disconnect(struct psmouse *psmouse)
132{ 219{
133 psmouse_reset(psmouse); 220 psmouse_reset(psmouse);
221 kfree(psmouse->private);
222 psmouse->private = NULL;
134} 223}
135 224
136int lifebook_detect(struct psmouse *psmouse, int set_properties) 225int lifebook_detect(struct psmouse *psmouse, int set_properties)
@@ -138,6 +227,10 @@ int lifebook_detect(struct psmouse *psmouse, int set_properties)
138 if (!dmi_check_system(lifebook_dmi_table)) 227 if (!dmi_check_system(lifebook_dmi_table))
139 return -1; 228 return -1;
140 229
230 if (desired_serio_phys &&
231 strcmp(psmouse->ps2dev.serio->phys, desired_serio_phys))
232 return -1;
233
141 if (set_properties) { 234 if (set_properties) {
142 psmouse->vendor = "Fujitsu"; 235 psmouse->vendor = "Fujitsu";
143 psmouse->name = "Lifebook TouchScreen"; 236 psmouse->name = "Lifebook TouchScreen";
@@ -146,24 +239,78 @@ int lifebook_detect(struct psmouse *psmouse, int set_properties)
146 return 0; 239 return 0;
147} 240}
148 241
242static int lifebook_create_relative_device(struct psmouse *psmouse)
243{
244 struct input_dev *dev2;
245 struct lifebook_data *priv;
246 int error = -ENOMEM;
247
248 priv = kzalloc(sizeof(struct lifebook_data), GFP_KERNEL);
249 dev2 = input_allocate_device();
250 if (!priv || !dev2)
251 goto err_out;
252
253 priv->dev2 = dev2;
254 snprintf(priv->phys, sizeof(priv->phys),
255 "%s/input1", psmouse->ps2dev.serio->phys);
256
257 dev2->phys = priv->phys;
258 dev2->name = "PS/2 Touchpad";
259 dev2->id.bustype = BUS_I8042;
260 dev2->id.vendor = 0x0002;
261 dev2->id.product = PSMOUSE_LIFEBOOK;
262 dev2->id.version = 0x0000;
263 dev2->dev.parent = &psmouse->ps2dev.serio->dev;
264
265 dev2->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
266 dev2->relbit[LONG(REL_X)] = BIT(REL_X) | BIT(REL_Y);
267 dev2->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
268
269 error = input_register_device(priv->dev2);
270 if (error)
271 goto err_out;
272
273 psmouse->private = priv;
274 return 0;
275
276 err_out:
277 input_free_device(dev2);
278 kfree(priv);
279 return error;
280}
281
149int lifebook_init(struct psmouse *psmouse) 282int lifebook_init(struct psmouse *psmouse)
150{ 283{
151 struct input_dev *input_dev = psmouse->dev; 284 struct input_dev *dev1 = psmouse->dev;
285 int max_coord = lifebook_use_6byte_proto ? 1024 : 4096;
152 286
153 if (lifebook_absolute_mode(psmouse)) 287 if (lifebook_absolute_mode(psmouse))
154 return -1; 288 return -1;
155 289
156 input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); 290 dev1->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
157 input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 291 dev1->relbit[0] = 0;
158 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 292 dev1->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
159 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); 293 input_set_abs_params(dev1, ABS_X, 0, max_coord, 0, 0);
160 input_set_abs_params(input_dev, ABS_X, 0, 1024, 0, 0); 294 input_set_abs_params(dev1, ABS_Y, 0, max_coord, 0, 0);
161 input_set_abs_params(input_dev, ABS_Y, 0, 1024, 0, 0); 295
296 if (!desired_serio_phys) {
297 if (lifebook_create_relative_device(psmouse)) {
298 lifebook_relative_mode(psmouse);
299 return -1;
300 }
301 }
162 302
163 psmouse->protocol_handler = lifebook_process_byte; 303 psmouse->protocol_handler = lifebook_process_byte;
164 psmouse->set_resolution = lifebook_set_resolution; 304 psmouse->set_resolution = lifebook_set_resolution;
165 psmouse->disconnect = lifebook_disconnect; 305 psmouse->disconnect = lifebook_disconnect;
166 psmouse->reconnect = lifebook_absolute_mode; 306 psmouse->reconnect = lifebook_absolute_mode;
307
308 psmouse->model = lifebook_use_6byte_proto ? 6 : 3;
309
310 /*
311 * Use packet size = 3 even when using 6-byte protocol because
312 * that's what POLL will return on Lifebooks (according to spec).
313 */
167 psmouse->pktsize = 3; 314 psmouse->pktsize = 3;
168 315
169 return 0; 316 return 0;
diff --git a/drivers/input/mouse/lifebook.h b/drivers/input/mouse/lifebook.h
index be1c0943825d..c1647cf036c2 100644
--- a/drivers/input/mouse/lifebook.h
+++ b/drivers/input/mouse/lifebook.h
@@ -11,7 +11,18 @@
11#ifndef _LIFEBOOK_H 11#ifndef _LIFEBOOK_H
12#define _LIFEBOOK_H 12#define _LIFEBOOK_H
13 13
14#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
14int lifebook_detect(struct psmouse *psmouse, int set_properties); 15int lifebook_detect(struct psmouse *psmouse, int set_properties);
15int lifebook_init(struct psmouse *psmouse); 16int lifebook_init(struct psmouse *psmouse);
17#else
18inline int lifebook_detect(struct psmouse *psmouse, int set_properties)
19{
20 return -ENOSYS;
21}
22inline int lifebook_init(struct psmouse *psmouse)
23{
24 return -ENOSYS;
25}
26#endif
16 27
17#endif 28#endif
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index d3ddea26b8ca..9df74b72e6c4 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -200,6 +200,7 @@ static void ps2pp_disconnect(struct psmouse *psmouse)
200static const struct ps2pp_info *get_model_info(unsigned char model) 200static const struct ps2pp_info *get_model_info(unsigned char model)
201{ 201{
202 static const struct ps2pp_info ps2pp_list[] = { 202 static const struct ps2pp_info ps2pp_list[] = {
203 { 1, 0, 0 }, /* Simple 2-button mouse */
203 { 12, 0, PS2PP_SIDE_BTN}, 204 { 12, 0, PS2PP_SIDE_BTN},
204 { 13, 0, 0 }, 205 { 13, 0, 0 },
205 { 15, PS2PP_KIND_MX, /* MX1000 */ 206 { 15, PS2PP_KIND_MX, /* MX1000 */
@@ -338,12 +339,12 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties)
338 param[1] = 0; 339 param[1] = 0;
339 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO); 340 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO);
340 341
341 if (!param[1])
342 return -1;
343
344 model = ((param[0] >> 4) & 0x07) | ((param[0] << 3) & 0x78); 342 model = ((param[0] >> 4) & 0x07) | ((param[0] << 3) & 0x78);
345 buttons = param[1]; 343 buttons = param[1];
346 344
345 if (!model || !buttons)
346 return -1;
347
347 if ((model_info = get_model_info(model)) != NULL) { 348 if ((model_info = get_model_info(model)) != NULL) {
348 349
349/* 350/*
diff --git a/drivers/input/mouse/logips2pp.h b/drivers/input/mouse/logips2pp.h
index 64a8ec52ea6d..6e5712525fd6 100644
--- a/drivers/input/mouse/logips2pp.h
+++ b/drivers/input/mouse/logips2pp.h
@@ -11,6 +11,13 @@
11#ifndef _LOGIPS2PP_H 11#ifndef _LOGIPS2PP_H
12#define _LOGIPS2PP_H 12#define _LOGIPS2PP_H
13 13
14#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
14int ps2pp_init(struct psmouse *psmouse, int set_properties); 15int ps2pp_init(struct psmouse *psmouse, int set_properties);
16#else
17inline int ps2pp_init(struct psmouse *psmouse, int set_properties)
18{
19 return -ENOSYS;
20}
21#endif /* CONFIG_MOUSE_PS2_LOGIPS2PP */
15 22
16#endif 23#endif
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 0fe5869d7d4c..f15f695777f8 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -28,6 +28,7 @@
28#include "alps.h" 28#include "alps.h"
29#include "lifebook.h" 29#include "lifebook.h"
30#include "trackpoint.h" 30#include "trackpoint.h"
31#include "touchkit_ps2.h"
31 32
32#define DRIVER_DESC "PS/2 mouse driver" 33#define DRIVER_DESC "PS/2 mouse driver"
33 34
@@ -569,7 +570,9 @@ static int psmouse_extensions(struct psmouse *psmouse,
569 return PSMOUSE_THINKPS; 570 return PSMOUSE_THINKPS;
570 571
571/* 572/*
572 * Try Synaptics TouchPad 573 * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol
574 * support is disabled in config - we need to know if it is synaptics so we
575 * can reset it properly after probing for intellimouse.
573 */ 576 */
574 if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) { 577 if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) {
575 synaptics_hardware = 1; 578 synaptics_hardware = 1;
@@ -605,14 +608,20 @@ static int psmouse_extensions(struct psmouse *psmouse,
605 } 608 }
606 } 609 }
607 610
608 if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0) 611 if (max_proto > PSMOUSE_IMEX) {
609 return PSMOUSE_GENPS; 612
613 if (genius_detect(psmouse, set_properties) == 0)
614 return PSMOUSE_GENPS;
610 615
611 if (max_proto > PSMOUSE_IMEX && ps2pp_init(psmouse, set_properties) == 0) 616 if (ps2pp_init(psmouse, set_properties) == 0)
612 return PSMOUSE_PS2PP; 617 return PSMOUSE_PS2PP;
613 618
614 if (max_proto > PSMOUSE_IMEX && trackpoint_detect(psmouse, set_properties) == 0) 619 if (trackpoint_detect(psmouse, set_properties) == 0)
615 return PSMOUSE_TRACKPOINT; 620 return PSMOUSE_TRACKPOINT;
621
622 if (touchkit_ps2_detect(psmouse, set_properties) == 0)
623 return PSMOUSE_TOUCHKIT_PS2;
624 }
616 625
617/* 626/*
618 * Reset to defaults in case the device got confused by extended 627 * Reset to defaults in case the device got confused by extended
@@ -654,12 +663,14 @@ static const struct psmouse_protocol psmouse_protocols[] = {
654 .maxproto = 1, 663 .maxproto = 1,
655 .detect = ps2bare_detect, 664 .detect = ps2bare_detect,
656 }, 665 },
666#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
657 { 667 {
658 .type = PSMOUSE_PS2PP, 668 .type = PSMOUSE_PS2PP,
659 .name = "PS2++", 669 .name = "PS2++",
660 .alias = "logitech", 670 .alias = "logitech",
661 .detect = ps2pp_init, 671 .detect = ps2pp_init,
662 }, 672 },
673#endif
663 { 674 {
664 .type = PSMOUSE_THINKPS, 675 .type = PSMOUSE_THINKPS,
665 .name = "ThinkPS/2", 676 .name = "ThinkPS/2",
@@ -686,6 +697,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
686 .maxproto = 1, 697 .maxproto = 1,
687 .detect = im_explorer_detect, 698 .detect = im_explorer_detect,
688 }, 699 },
700#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
689 { 701 {
690 .type = PSMOUSE_SYNAPTICS, 702 .type = PSMOUSE_SYNAPTICS,
691 .name = "SynPS/2", 703 .name = "SynPS/2",
@@ -693,6 +705,8 @@ static const struct psmouse_protocol psmouse_protocols[] = {
693 .detect = synaptics_detect, 705 .detect = synaptics_detect,
694 .init = synaptics_init, 706 .init = synaptics_init,
695 }, 707 },
708#endif
709#ifdef CONFIG_MOUSE_PS2_ALPS
696 { 710 {
697 .type = PSMOUSE_ALPS, 711 .type = PSMOUSE_ALPS,
698 .name = "AlpsPS/2", 712 .name = "AlpsPS/2",
@@ -700,18 +714,31 @@ static const struct psmouse_protocol psmouse_protocols[] = {
700 .detect = alps_detect, 714 .detect = alps_detect,
701 .init = alps_init, 715 .init = alps_init,
702 }, 716 },
717#endif
718#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
703 { 719 {
704 .type = PSMOUSE_LIFEBOOK, 720 .type = PSMOUSE_LIFEBOOK,
705 .name = "LBPS/2", 721 .name = "LBPS/2",
706 .alias = "lifebook", 722 .alias = "lifebook",
707 .init = lifebook_init, 723 .init = lifebook_init,
708 }, 724 },
725#endif
726#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
709 { 727 {
710 .type = PSMOUSE_TRACKPOINT, 728 .type = PSMOUSE_TRACKPOINT,
711 .name = "TPPS/2", 729 .name = "TPPS/2",
712 .alias = "trackpoint", 730 .alias = "trackpoint",
713 .detect = trackpoint_detect, 731 .detect = trackpoint_detect,
714 }, 732 },
733#endif
734#ifdef CONFIG_MOUSE_PS2_TOUCHKIT
735 {
736 .type = PSMOUSE_TOUCHKIT_PS2,
737 .name = "touchkitPS/2",
738 .alias = "touchkit",
739 .detect = touchkit_ps2_detect,
740 },
741#endif
715 { 742 {
716 .type = PSMOUSE_AUTO, 743 .type = PSMOUSE_AUTO,
717 .name = "auto", 744 .name = "auto",
@@ -823,12 +850,6 @@ static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)
823static void psmouse_initialize(struct psmouse *psmouse) 850static void psmouse_initialize(struct psmouse *psmouse)
824{ 851{
825/* 852/*
826 * We set the mouse into streaming mode.
827 */
828
829 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM);
830
831/*
832 * We set the mouse report rate, resolution and scaling. 853 * We set the mouse report rate, resolution and scaling.
833 */ 854 */
834 855
@@ -1062,8 +1083,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse
1062{ 1083{
1063 struct input_dev *input_dev = psmouse->dev; 1084 struct input_dev *input_dev = psmouse->dev;
1064 1085
1065 input_dev->private = psmouse; 1086 input_dev->dev.parent = &psmouse->ps2dev.serio->dev;
1066 input_dev->cdev.dev = &psmouse->ps2dev.serio->dev;
1067 1087
1068 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 1088 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
1069 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 1089 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index cf1de95b6f27..3964e8acbc54 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -87,6 +87,7 @@ enum psmouse_type {
87 PSMOUSE_ALPS, 87 PSMOUSE_ALPS,
88 PSMOUSE_LIFEBOOK, 88 PSMOUSE_LIFEBOOK,
89 PSMOUSE_TRACKPOINT, 89 PSMOUSE_TRACKPOINT,
90 PSMOUSE_TOUCHKIT_PS2,
90 PSMOUSE_AUTO /* This one should always be last */ 91 PSMOUSE_AUTO /* This one should always be last */
91}; 92};
92 93
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
index a85d74710b44..77b8ee2b9651 100644
--- a/drivers/input/mouse/sermouse.c
+++ b/drivers/input/mouse/sermouse.c
@@ -69,7 +69,8 @@ static void sermouse_process_msc(struct sermouse *sermouse, signed char data)
69 switch (sermouse->count) { 69 switch (sermouse->count) {
70 70
71 case 0: 71 case 0:
72 if ((data & 0xf8) != 0x80) return; 72 if ((data & 0xf8) != 0x80)
73 return;
73 input_report_key(dev, BTN_LEFT, !(data & 4)); 74 input_report_key(dev, BTN_LEFT, !(data & 4));
74 input_report_key(dev, BTN_RIGHT, !(data & 1)); 75 input_report_key(dev, BTN_RIGHT, !(data & 1));
75 input_report_key(dev, BTN_MIDDLE, !(data & 2)); 76 input_report_key(dev, BTN_MIDDLE, !(data & 2));
@@ -107,7 +108,10 @@ static void sermouse_process_ms(struct sermouse *sermouse, signed char data)
107 struct input_dev *dev = sermouse->dev; 108 struct input_dev *dev = sermouse->dev;
108 signed char *buf = sermouse->buf; 109 signed char *buf = sermouse->buf;
109 110
110 if (data & 0x40) sermouse->count = 0; 111 if (data & 0x40)
112 sermouse->count = 0;
113 else if (sermouse->count == 0)
114 return;
111 115
112 switch (sermouse->count) { 116 switch (sermouse->count) {
113 117
@@ -169,7 +173,8 @@ static void sermouse_process_ms(struct sermouse *sermouse, signed char data)
169 173
170 case 5: 174 case 5:
171 case 7: /* Ignore anything besides MZ++ */ 175 case 7: /* Ignore anything besides MZ++ */
172 if (sermouse->type != SERIO_MZPP) break; 176 if (sermouse->type != SERIO_MZPP)
177 break;
173 178
174 switch (buf[1]) { 179 switch (buf[1]) {
175 180
@@ -206,13 +211,16 @@ static irqreturn_t sermouse_interrupt(struct serio *serio,
206{ 211{
207 struct sermouse *sermouse = serio_get_drvdata(serio); 212 struct sermouse *sermouse = serio_get_drvdata(serio);
208 213
209 if (time_after(jiffies, sermouse->last + HZ/10)) sermouse->count = 0; 214 if (time_after(jiffies, sermouse->last + HZ/10))
215 sermouse->count = 0;
216
210 sermouse->last = jiffies; 217 sermouse->last = jiffies;
211 218
212 if (sermouse->type > SERIO_SUN) 219 if (sermouse->type > SERIO_SUN)
213 sermouse_process_ms(sermouse, data); 220 sermouse_process_ms(sermouse, data);
214 else 221 else
215 sermouse_process_msc(sermouse, data); 222 sermouse_process_msc(sermouse, data);
223
216 return IRQ_HANDLED; 224 return IRQ_HANDLED;
217} 225}
218 226
@@ -258,12 +266,11 @@ static int sermouse_connect(struct serio *serio, struct serio_driver *drv)
258 input_dev->id.vendor = sermouse->type; 266 input_dev->id.vendor = sermouse->type;
259 input_dev->id.product = c; 267 input_dev->id.product = c;
260 input_dev->id.version = 0x0100; 268 input_dev->id.version = 0x0100;
261 input_dev->cdev.dev = &serio->dev; 269 input_dev->dev.parent = &serio->dev;
262 270
263 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 271 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
264 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); 272 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
265 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); 273 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
266 input_dev->private = sermouse;
267 274
268 if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit); 275 if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit);
269 if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit); 276 if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit);
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index f0f9413d762c..c77788bf932d 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -40,33 +40,70 @@
40#define YMIN_NOMINAL 1408 40#define YMIN_NOMINAL 1408
41#define YMAX_NOMINAL 4448 41#define YMAX_NOMINAL 4448
42 42
43
43/***************************************************************************** 44/*****************************************************************************
44 * Synaptics communications functions 45 * Stuff we need even when we do not want native Synaptics support
45 ****************************************************************************/ 46 ****************************************************************************/
46 47
47/* 48/*
48 * Send a command to the synpatics touchpad by special commands 49 * Set the synaptics touchpad mode byte by special commands
49 */ 50 */
50static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param) 51static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
51{ 52{
52 if (psmouse_sliced_command(psmouse, c)) 53 unsigned char param[1];
54
55 if (psmouse_sliced_command(psmouse, mode))
53 return -1; 56 return -1;
54 if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) 57 param[0] = SYN_PS_SET_MODE2;
58 if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE))
55 return -1; 59 return -1;
56 return 0; 60 return 0;
57} 61}
58 62
63int synaptics_detect(struct psmouse *psmouse, int set_properties)
64{
65 struct ps2dev *ps2dev = &psmouse->ps2dev;
66 unsigned char param[4];
67
68 param[0] = 0;
69
70 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
71 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
72 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
73 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
74 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO);
75
76 if (param[1] != 0x47)
77 return -ENODEV;
78
79 if (set_properties) {
80 psmouse->vendor = "Synaptics";
81 psmouse->name = "TouchPad";
82 }
83
84 return 0;
85}
86
87void synaptics_reset(struct psmouse *psmouse)
88{
89 /* reset touchpad back to relative mode, gestures enabled */
90 synaptics_mode_cmd(psmouse, 0);
91}
92
93#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
94
95/*****************************************************************************
96 * Synaptics communications functions
97 ****************************************************************************/
98
59/* 99/*
60 * Set the synaptics touchpad mode byte by special commands 100 * Send a command to the synpatics touchpad by special commands
61 */ 101 */
62static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode) 102static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param)
63{ 103{
64 unsigned char param[1]; 104 if (psmouse_sliced_command(psmouse, c))
65
66 if (psmouse_sliced_command(psmouse, mode))
67 return -1; 105 return -1;
68 param[0] = SYN_PS_SET_MODE2; 106 if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO))
69 if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE))
70 return -1; 107 return -1;
71 return 0; 108 return 0;
72} 109}
@@ -529,12 +566,6 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
529 clear_bit(REL_Y, dev->relbit); 566 clear_bit(REL_Y, dev->relbit);
530} 567}
531 568
532void synaptics_reset(struct psmouse *psmouse)
533{
534 /* reset touchpad back to relative mode, gestures enabled */
535 synaptics_mode_cmd(psmouse, 0);
536}
537
538static void synaptics_disconnect(struct psmouse *psmouse) 569static void synaptics_disconnect(struct psmouse *psmouse)
539{ 570{
540 synaptics_reset(psmouse); 571 synaptics_reset(psmouse);
@@ -569,30 +600,6 @@ static int synaptics_reconnect(struct psmouse *psmouse)
569 return 0; 600 return 0;
570} 601}
571 602
572int synaptics_detect(struct psmouse *psmouse, int set_properties)
573{
574 struct ps2dev *ps2dev = &psmouse->ps2dev;
575 unsigned char param[4];
576
577 param[0] = 0;
578
579 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
580 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
581 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
582 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
583 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO);
584
585 if (param[1] != 0x47)
586 return -1;
587
588 if (set_properties) {
589 psmouse->vendor = "Synaptics";
590 psmouse->name = "TouchPad";
591 }
592
593 return 0;
594}
595
596#if defined(__i386__) 603#if defined(__i386__)
597#include <linux/dmi.h> 604#include <linux/dmi.h>
598static struct dmi_system_id toshiba_dmi_table[] = { 605static struct dmi_system_id toshiba_dmi_table[] = {
@@ -648,6 +655,16 @@ int synaptics_init(struct psmouse *psmouse)
648 655
649 set_input_params(psmouse->dev, priv); 656 set_input_params(psmouse->dev, priv);
650 657
658 /*
659 * Encode touchpad model so that it can be used to set
660 * input device->id.version and be visible to userspace.
661 * Because version is __u16 we have to drop something.
662 * Hardware info bits seem to be good candidates as they
663 * are documented to be for Synaptics corp. internal use.
664 */
665 psmouse->model = ((priv->model_id & 0x00ff0000) >> 8) |
666 (priv->model_id & 0x000000ff);
667
651 psmouse->protocol_handler = synaptics_process_byte; 668 psmouse->protocol_handler = synaptics_process_byte;
652 psmouse->set_rate = synaptics_set_rate; 669 psmouse->set_rate = synaptics_set_rate;
653 psmouse->disconnect = synaptics_disconnect; 670 psmouse->disconnect = synaptics_disconnect;
@@ -680,4 +697,12 @@ int synaptics_init(struct psmouse *psmouse)
680 return -1; 697 return -1;
681} 698}
682 699
700#else /* CONFIG_MOUSE_PS2_SYNAPTICS */
701
702int synaptics_init(struct psmouse *psmouse)
703{
704 return -ENOSYS;
705}
706
707#endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
683 708
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 68fff1dcd7de..02aa4cf7bc77 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -9,10 +9,6 @@
9#ifndef _SYNAPTICS_H 9#ifndef _SYNAPTICS_H
10#define _SYNAPTICS_H 10#define _SYNAPTICS_H
11 11
12extern int synaptics_detect(struct psmouse *psmouse, int set_properties);
13extern int synaptics_init(struct psmouse *psmouse);
14extern void synaptics_reset(struct psmouse *psmouse);
15
16/* synaptics queries */ 12/* synaptics queries */
17#define SYN_QUE_IDENTIFY 0x00 13#define SYN_QUE_IDENTIFY 0x00
18#define SYN_QUE_MODES 0x01 14#define SYN_QUE_MODES 0x01
@@ -62,9 +58,9 @@ extern void synaptics_reset(struct psmouse *psmouse);
62#define SYN_MODE_WMODE(m) ((m) & (1 << 0)) 58#define SYN_MODE_WMODE(m) ((m) & (1 << 0))
63 59
64/* synaptics identify query bits */ 60/* synaptics identify query bits */
65#define SYN_ID_MODEL(i) (((i) >> 4) & 0x0f) 61#define SYN_ID_MODEL(i) (((i) >> 4) & 0x0f)
66#define SYN_ID_MAJOR(i) ((i) & 0x0f) 62#define SYN_ID_MAJOR(i) ((i) & 0x0f)
67#define SYN_ID_MINOR(i) (((i) >> 16) & 0xff) 63#define SYN_ID_MINOR(i) (((i) >> 16) & 0xff)
68#define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47) 64#define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47)
69 65
70/* synaptics special commands */ 66/* synaptics special commands */
@@ -98,8 +94,8 @@ struct synaptics_hw_state {
98struct synaptics_data { 94struct synaptics_data {
99 /* Data read from the touchpad */ 95 /* Data read from the touchpad */
100 unsigned long int model_id; /* Model-ID */ 96 unsigned long int model_id; /* Model-ID */
101 unsigned long int capabilities; /* Capabilities */ 97 unsigned long int capabilities; /* Capabilities */
102 unsigned long int ext_cap; /* Extended Capabilities */ 98 unsigned long int ext_cap; /* Extended Capabilities */
103 unsigned long int identity; /* Identification */ 99 unsigned long int identity; /* Identification */
104 100
105 unsigned char pkt_type; /* packet type - old, new, etc */ 101 unsigned char pkt_type; /* packet type - old, new, etc */
@@ -107,4 +103,8 @@ struct synaptics_data {
107 int scroll; 103 int scroll;
108}; 104};
109 105
106int synaptics_detect(struct psmouse *psmouse, int set_properties);
107int synaptics_init(struct psmouse *psmouse);
108void synaptics_reset(struct psmouse *psmouse);
109
110#endif /* _SYNAPTICS_H */ 110#endif /* _SYNAPTICS_H */
diff --git a/drivers/input/mouse/touchkit_ps2.c b/drivers/input/mouse/touchkit_ps2.c
new file mode 100644
index 000000000000..7b977fd23571
--- /dev/null
+++ b/drivers/input/mouse/touchkit_ps2.c
@@ -0,0 +1,100 @@
1/* ----------------------------------------------------------------------------
2 * touchkit_ps2.c -- Driver for eGalax TouchKit PS/2 Touchscreens
3 *
4 * Copyright (C) 2005 by Stefan Lucke
5 * Copyright (C) 2004 by Daniel Ritz
6 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Based upon touchkitusb.c
23 *
24 * Vendor documentation is available in support section of:
25 * http://www.egalax.com.tw/
26 */
27
28#include <linux/kernel.h>
29#include <linux/slab.h>
30
31#include <linux/input.h>
32#include <linux/serio.h>
33#include <linux/libps2.h>
34
35#include "psmouse.h"
36#include "touchkit_ps2.h"
37
38#define TOUCHKIT_MAX_XC 0x07ff
39#define TOUCHKIT_MAX_YC 0x07ff
40
41#define TOUCHKIT_CMD 0x0a
42#define TOUCHKIT_CMD_LENGTH 1
43
44#define TOUCHKIT_CMD_ACTIVE 'A'
45#define TOUCHKIT_CMD_FIRMWARE_VERSION 'D'
46#define TOUCHKIT_CMD_CONTROLLER_TYPE 'E'
47
48#define TOUCHKIT_SEND_PARMS(s, r, c) ((s) << 12 | (r) << 8 | (c))
49
50#define TOUCHKIT_GET_TOUCHED(packet) (((packet)[0]) & 0x01)
51#define TOUCHKIT_GET_X(packet) (((packet)[1] << 7) | (packet)[2])
52#define TOUCHKIT_GET_Y(packet) (((packet)[3] << 7) | (packet)[4])
53
54static psmouse_ret_t touchkit_ps2_process_byte(struct psmouse *psmouse)
55{
56 unsigned char *packet = psmouse->packet;
57 struct input_dev *dev = psmouse->dev;
58
59 if (psmouse->pktcnt != 5)
60 return PSMOUSE_GOOD_DATA;
61
62 input_report_abs(dev, ABS_X, TOUCHKIT_GET_X(packet));
63 input_report_abs(dev, ABS_Y, TOUCHKIT_GET_Y(packet));
64 input_report_key(dev, BTN_TOUCH, TOUCHKIT_GET_TOUCHED(packet));
65 input_sync(dev);
66
67 return PSMOUSE_FULL_PACKET;
68}
69
70int touchkit_ps2_detect(struct psmouse *psmouse, int set_properties)
71{
72 struct input_dev *dev = psmouse->dev;
73 unsigned char param[3];
74 int command;
75
76 param[0] = TOUCHKIT_CMD_LENGTH;
77 param[1] = TOUCHKIT_CMD_ACTIVE;
78 command = TOUCHKIT_SEND_PARMS(2, 3, TOUCHKIT_CMD);
79
80 if (ps2_command(&psmouse->ps2dev, param, command))
81 return -ENODEV;
82
83 if (param[0] != TOUCHKIT_CMD || param[1] != 0x01 ||
84 param[2] != TOUCHKIT_CMD_ACTIVE)
85 return -ENODEV;
86
87 if (set_properties) {
88 dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
89 set_bit(BTN_TOUCH, dev->keybit);
90 input_set_abs_params(dev, ABS_X, 0, TOUCHKIT_MAX_XC, 0, 0);
91 input_set_abs_params(dev, ABS_Y, 0, TOUCHKIT_MAX_YC, 0, 0);
92
93 psmouse->vendor = "eGalax";
94 psmouse->name = "Touchscreen";
95 psmouse->protocol_handler = touchkit_ps2_process_byte;
96 psmouse->pktsize = 5;
97 }
98
99 return 0;
100}
diff --git a/drivers/input/mouse/touchkit_ps2.h b/drivers/input/mouse/touchkit_ps2.h
new file mode 100644
index 000000000000..61e9dfd8419f
--- /dev/null
+++ b/drivers/input/mouse/touchkit_ps2.h
@@ -0,0 +1,24 @@
1/* ----------------------------------------------------------------------------
2 * touchkit_ps2.h -- Driver for eGalax TouchKit PS/2 Touchscreens
3 *
4 * Copyright (C) 2005 by Stefan Lucke
5 * Copyright (c) 2005 Vojtech Pavlik
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 version 2 as published by
9 * the Free Software Foundation.
10 */
11
12#ifndef _TOUCHKIT_PS2_H
13#define _TOUCHKIT_PS2_H
14
15#ifdef CONFIG_MOUSE_PS2_TOUCHKIT
16int touchkit_ps2_detect(struct psmouse *psmouse, int set_properties);
17#else
18inline int touchkit_ps2_detect(struct psmouse *psmouse, int set_properties)
19{
20 return -ENOSYS;
21}
22#endif /* CONFIG_MOUSE_PS2_TOUCHKIT */
23
24#endif
diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h
index 050298b1a09d..c10a6e7d0101 100644
--- a/drivers/input/mouse/trackpoint.h
+++ b/drivers/input/mouse/trackpoint.h
@@ -142,6 +142,13 @@ struct trackpoint_data
142 unsigned char ext_dev; 142 unsigned char ext_dev;
143}; 143};
144 144
145extern int trackpoint_detect(struct psmouse *psmouse, int set_properties); 145#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
146int trackpoint_detect(struct psmouse *psmouse, int set_properties);
147#else
148inline int trackpoint_detect(struct psmouse *psmouse, int set_properties)
149{
150 return -ENOSYS;
151}
152#endif /* CONFIG_MOUSE_PS2_TRACKPOINT */
146 153
147#endif /* _TRACKPOINT_H */ 154#endif /* _TRACKPOINT_H */
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index c3d64fcc858d..4a321576f345 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -508,8 +508,7 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
508 input_dev->name = mouse->name; 508 input_dev->name = mouse->name;
509 input_dev->phys = mouse->phys; 509 input_dev->phys = mouse->phys;
510 input_dev->id.bustype = BUS_RS232; 510 input_dev->id.bustype = BUS_RS232;
511 input_dev->cdev.dev = &serio->dev; 511 input_dev->dev.parent = &serio->dev;
512 input_dev->private = mouse;
513 512
514 set_bit (EV_KEY, input_dev->evbit); /* We have buttons */ 513 set_bit (EV_KEY, input_dev->evbit); /* We have buttons */
515 set_bit (EV_REL, input_dev->evbit); 514 set_bit (EV_REL, input_dev->evbit);
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 664bcc8116fc..7678e9876550 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -63,9 +63,12 @@ struct mousedev {
63 int minor; 63 int minor;
64 char name[16]; 64 char name[16];
65 wait_queue_head_t wait; 65 wait_queue_head_t wait;
66 struct list_head list; 66 struct list_head client_list;
67 struct input_handle handle; 67 struct input_handle handle;
68 68
69 struct list_head mixdev_node;
70 int mixdev_open;
71
69 struct mousedev_hw_data packet; 72 struct mousedev_hw_data packet;
70 unsigned int pkt_count; 73 unsigned int pkt_count;
71 int old_x[4], old_y[4]; 74 int old_x[4], old_y[4];
@@ -85,7 +88,7 @@ struct mousedev_motion {
85}; 88};
86 89
87#define PACKET_QUEUE_LEN 16 90#define PACKET_QUEUE_LEN 16
88struct mousedev_list { 91struct mousedev_client {
89 struct fasync_struct *fasync; 92 struct fasync_struct *fasync;
90 struct mousedev *mousedev; 93 struct mousedev *mousedev;
91 struct list_head node; 94 struct list_head node;
@@ -111,6 +114,7 @@ static struct input_handler mousedev_handler;
111 114
112static struct mousedev *mousedev_table[MOUSEDEV_MINORS]; 115static struct mousedev *mousedev_table[MOUSEDEV_MINORS];
113static struct mousedev mousedev_mix; 116static struct mousedev mousedev_mix;
117static LIST_HEAD(mousedev_mix_list);
114 118
115#define fx(i) (mousedev->old_x[(mousedev->pkt_count - (i)) & 03]) 119#define fx(i) (mousedev->old_x[(mousedev->pkt_count - (i)) & 03])
116#define fy(i) (mousedev->old_y[(mousedev->pkt_count - (i)) & 03]) 120#define fy(i) (mousedev->old_y[(mousedev->pkt_count - (i)) & 03])
@@ -120,32 +124,33 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous
120 int size, tmp; 124 int size, tmp;
121 enum { FRACTION_DENOM = 128 }; 125 enum { FRACTION_DENOM = 128 };
122 126
123 if (mousedev->touch) { 127 switch (code) {
124 size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; 128 case ABS_X:
125 if (size == 0) 129 fx(0) = value;
126 size = 256 * 2; 130 if (mousedev->touch && mousedev->pkt_count >= 2) {
127 131 size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
128 switch (code) { 132 if (size == 0)
129 case ABS_X: 133 size = 256 * 2;
130 fx(0) = value; 134 tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size;
131 if (mousedev->pkt_count >= 2) { 135 tmp += mousedev->frac_dx;
132 tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size; 136 mousedev->packet.dx = tmp / FRACTION_DENOM;
133 tmp += mousedev->frac_dx; 137 mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM;
134 mousedev->packet.dx = tmp / FRACTION_DENOM; 138 }
135 mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM; 139 break;
136 }
137 break;
138 140
139 case ABS_Y: 141 case ABS_Y:
140 fy(0) = value; 142 fy(0) = value;
141 if (mousedev->pkt_count >= 2) { 143 if (mousedev->touch && mousedev->pkt_count >= 2) {
142 tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size; 144 /* use X size to keep the same scale */
143 tmp += mousedev->frac_dy; 145 size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
144 mousedev->packet.dy = tmp / FRACTION_DENOM; 146 if (size == 0)
145 mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM; 147 size = 256 * 2;
146 } 148 tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
147 break; 149 tmp += mousedev->frac_dy;
148 } 150 mousedev->packet.dy = tmp / FRACTION_DENOM;
151 mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
152 }
153 break;
149 } 154 }
150} 155}
151 156
@@ -223,47 +228,47 @@ static void mousedev_key_event(struct mousedev *mousedev, unsigned int code, int
223 228
224static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_hw_data *packet) 229static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_hw_data *packet)
225{ 230{
226 struct mousedev_list *list; 231 struct mousedev_client *client;
227 struct mousedev_motion *p; 232 struct mousedev_motion *p;
228 unsigned long flags; 233 unsigned long flags;
229 int wake_readers = 0; 234 int wake_readers = 0;
230 235
231 list_for_each_entry(list, &mousedev->list, node) { 236 list_for_each_entry(client, &mousedev->client_list, node) {
232 spin_lock_irqsave(&list->packet_lock, flags); 237 spin_lock_irqsave(&client->packet_lock, flags);
233 238
234 p = &list->packets[list->head]; 239 p = &client->packets[client->head];
235 if (list->ready && p->buttons != mousedev->packet.buttons) { 240 if (client->ready && p->buttons != mousedev->packet.buttons) {
236 unsigned int new_head = (list->head + 1) % PACKET_QUEUE_LEN; 241 unsigned int new_head = (client->head + 1) % PACKET_QUEUE_LEN;
237 if (new_head != list->tail) { 242 if (new_head != client->tail) {
238 p = &list->packets[list->head = new_head]; 243 p = &client->packets[client->head = new_head];
239 memset(p, 0, sizeof(struct mousedev_motion)); 244 memset(p, 0, sizeof(struct mousedev_motion));
240 } 245 }
241 } 246 }
242 247
243 if (packet->abs_event) { 248 if (packet->abs_event) {
244 p->dx += packet->x - list->pos_x; 249 p->dx += packet->x - client->pos_x;
245 p->dy += packet->y - list->pos_y; 250 p->dy += packet->y - client->pos_y;
246 list->pos_x = packet->x; 251 client->pos_x = packet->x;
247 list->pos_y = packet->y; 252 client->pos_y = packet->y;
248 } 253 }
249 254
250 list->pos_x += packet->dx; 255 client->pos_x += packet->dx;
251 list->pos_x = list->pos_x < 0 ? 0 : (list->pos_x >= xres ? xres : list->pos_x); 256 client->pos_x = client->pos_x < 0 ? 0 : (client->pos_x >= xres ? xres : client->pos_x);
252 list->pos_y += packet->dy; 257 client->pos_y += packet->dy;
253 list->pos_y = list->pos_y < 0 ? 0 : (list->pos_y >= yres ? yres : list->pos_y); 258 client->pos_y = client->pos_y < 0 ? 0 : (client->pos_y >= yres ? yres : client->pos_y);
254 259
255 p->dx += packet->dx; 260 p->dx += packet->dx;
256 p->dy += packet->dy; 261 p->dy += packet->dy;
257 p->dz += packet->dz; 262 p->dz += packet->dz;
258 p->buttons = mousedev->packet.buttons; 263 p->buttons = mousedev->packet.buttons;
259 264
260 if (p->dx || p->dy || p->dz || p->buttons != list->last_buttons) 265 if (p->dx || p->dy || p->dz || p->buttons != client->last_buttons)
261 list->ready = 1; 266 client->ready = 1;
262 267
263 spin_unlock_irqrestore(&list->packet_lock, flags); 268 spin_unlock_irqrestore(&client->packet_lock, flags);
264 269
265 if (list->ready) { 270 if (client->ready) {
266 kill_fasync(&list->fasync, SIGIO, POLL_IN); 271 kill_fasync(&client->fasync, SIGIO, POLL_IN);
267 wake_readers = 1; 272 wake_readers = 1;
268 } 273 }
269 } 274 }
@@ -351,9 +356,9 @@ static void mousedev_event(struct input_handle *handle, unsigned int type, unsig
351static int mousedev_fasync(int fd, struct file *file, int on) 356static int mousedev_fasync(int fd, struct file *file, int on)
352{ 357{
353 int retval; 358 int retval;
354 struct mousedev_list *list = file->private_data; 359 struct mousedev_client *client = file->private_data;
355 360
356 retval = fasync_helper(fd, file, on, &list->fasync); 361 retval = fasync_helper(fd, file, on, &client->fasync);
357 362
358 return retval < 0 ? retval : 0; 363 return retval < 0 ? retval : 0;
359} 364}
@@ -364,50 +369,95 @@ static void mousedev_free(struct mousedev *mousedev)
364 kfree(mousedev); 369 kfree(mousedev);
365} 370}
366 371
367static void mixdev_release(void) 372static int mixdev_add_device(struct mousedev *mousedev)
368{ 373{
369 struct input_handle *handle; 374 int error;
370 375
371 list_for_each_entry(handle, &mousedev_handler.h_list, h_node) { 376 if (mousedev_mix.open) {
372 struct mousedev *mousedev = handle->private; 377 error = input_open_device(&mousedev->handle);
378 if (error)
379 return error;
373 380
374 if (!mousedev->open) { 381 mousedev->open++;
375 if (mousedev->exist) 382 mousedev->mixdev_open++;
376 input_close_device(&mousedev->handle); 383 }
377 else 384
378 mousedev_free(mousedev); 385 list_add_tail(&mousedev->mixdev_node, &mousedev_mix_list);
386
387 return 0;
388}
389
390static void mixdev_remove_device(struct mousedev *mousedev)
391{
392 if (mousedev->mixdev_open) {
393 mousedev->mixdev_open = 0;
394 if (!--mousedev->open && mousedev->exist)
395 input_close_device(&mousedev->handle);
396 }
397
398 list_del_init(&mousedev->mixdev_node);
399}
400
401static void mixdev_open_devices(void)
402{
403 struct mousedev *mousedev;
404
405 list_for_each_entry(mousedev, &mousedev_mix_list, mixdev_node) {
406 if (mousedev->exist && !mousedev->open) {
407 if (input_open_device(&mousedev->handle))
408 continue;
409
410 mousedev->open++;
411 mousedev->mixdev_open++;
412 }
413 }
414}
415
416static void mixdev_close_devices(void)
417{
418 struct mousedev *mousedev, *next;
419
420 list_for_each_entry_safe(mousedev, next, &mousedev_mix_list, mixdev_node) {
421 if (mousedev->mixdev_open) {
422 mousedev->mixdev_open = 0;
423 if (!--mousedev->open) {
424 if (mousedev->exist)
425 input_close_device(&mousedev->handle);
426 else
427 mousedev_free(mousedev);
428 }
379 } 429 }
380 } 430 }
381} 431}
382 432
383static int mousedev_release(struct inode * inode, struct file * file) 433static int mousedev_release(struct inode *inode, struct file *file)
384{ 434{
385 struct mousedev_list *list = file->private_data; 435 struct mousedev_client *client = file->private_data;
436 struct mousedev *mousedev = client->mousedev;
386 437
387 mousedev_fasync(-1, file, 0); 438 mousedev_fasync(-1, file, 0);
388 439
389 list_del(&list->node); 440 list_del(&client->node);
441 kfree(client);
390 442
391 if (!--list->mousedev->open) { 443 if (!--mousedev->open) {
392 if (list->mousedev->minor == MOUSEDEV_MIX) 444 if (mousedev->minor == MOUSEDEV_MIX)
393 mixdev_release(); 445 mixdev_close_devices();
394 else if (!mousedev_mix.open) { 446 else if (mousedev->exist)
395 if (list->mousedev->exist) 447 input_close_device(&mousedev->handle);
396 input_close_device(&list->mousedev->handle); 448 else
397 else 449 mousedev_free(mousedev);
398 mousedev_free(list->mousedev);
399 }
400 } 450 }
401 451
402 kfree(list);
403 return 0; 452 return 0;
404} 453}
405 454
406static int mousedev_open(struct inode * inode, struct file * file) 455
456static int mousedev_open(struct inode *inode, struct file *file)
407{ 457{
408 struct mousedev_list *list; 458 struct mousedev_client *client;
409 struct input_handle *handle;
410 struct mousedev *mousedev; 459 struct mousedev *mousedev;
460 int error;
411 int i; 461 int i;
412 462
413#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 463#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
@@ -417,31 +467,37 @@ static int mousedev_open(struct inode * inode, struct file * file)
417#endif 467#endif
418 i = iminor(inode) - MOUSEDEV_MINOR_BASE; 468 i = iminor(inode) - MOUSEDEV_MINOR_BASE;
419 469
420 if (i >= MOUSEDEV_MINORS || !mousedev_table[i]) 470 if (i >= MOUSEDEV_MINORS)
471 return -ENODEV;
472
473 mousedev = mousedev_table[i];
474 if (!mousedev)
421 return -ENODEV; 475 return -ENODEV;
422 476
423 if (!(list = kzalloc(sizeof(struct mousedev_list), GFP_KERNEL))) 477 client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
478 if (!client)
424 return -ENOMEM; 479 return -ENOMEM;
425 480
426 spin_lock_init(&list->packet_lock); 481 spin_lock_init(&client->packet_lock);
427 list->pos_x = xres / 2; 482 client->pos_x = xres / 2;
428 list->pos_y = yres / 2; 483 client->pos_y = yres / 2;
429 list->mousedev = mousedev_table[i]; 484 client->mousedev = mousedev;
430 list_add_tail(&list->node, &mousedev_table[i]->list); 485 list_add_tail(&client->node, &mousedev->client_list);
431 file->private_data = list; 486
432 487 if (!mousedev->open++) {
433 if (!list->mousedev->open++) { 488 if (mousedev->minor == MOUSEDEV_MIX)
434 if (list->mousedev->minor == MOUSEDEV_MIX) { 489 mixdev_open_devices();
435 list_for_each_entry(handle, &mousedev_handler.h_list, h_node) { 490 else if (mousedev->exist) {
436 mousedev = handle->private; 491 error = input_open_device(&mousedev->handle);
437 if (!mousedev->open && mousedev->exist) 492 if (error) {
438 input_open_device(handle); 493 list_del(&client->node);
494 kfree(client);
495 return error;
439 } 496 }
440 } else 497 }
441 if (!mousedev_mix.open && list->mousedev->exist)
442 input_open_device(&list->mousedev->handle);
443 } 498 }
444 499
500 file->private_data = client;
445 return 0; 501 return 0;
446} 502}
447 503
@@ -450,13 +506,13 @@ static inline int mousedev_limit_delta(int delta, int limit)
450 return delta > limit ? limit : (delta < -limit ? -limit : delta); 506 return delta > limit ? limit : (delta < -limit ? -limit : delta);
451} 507}
452 508
453static void mousedev_packet(struct mousedev_list *list, signed char *ps2_data) 509static void mousedev_packet(struct mousedev_client *client, signed char *ps2_data)
454{ 510{
455 struct mousedev_motion *p; 511 struct mousedev_motion *p;
456 unsigned long flags; 512 unsigned long flags;
457 513
458 spin_lock_irqsave(&list->packet_lock, flags); 514 spin_lock_irqsave(&client->packet_lock, flags);
459 p = &list->packets[list->tail]; 515 p = &client->packets[client->tail];
460 516
461 ps2_data[0] = 0x08 | ((p->dx < 0) << 4) | ((p->dy < 0) << 5) | (p->buttons & 0x07); 517 ps2_data[0] = 0x08 | ((p->dx < 0) << 4) | ((p->dy < 0) << 5) | (p->buttons & 0x07);
462 ps2_data[1] = mousedev_limit_delta(p->dx, 127); 518 ps2_data[1] = mousedev_limit_delta(p->dx, 127);
@@ -464,44 +520,44 @@ static void mousedev_packet(struct mousedev_list *list, signed char *ps2_data)
464 p->dx -= ps2_data[1]; 520 p->dx -= ps2_data[1];
465 p->dy -= ps2_data[2]; 521 p->dy -= ps2_data[2];
466 522
467 switch (list->mode) { 523 switch (client->mode) {
468 case MOUSEDEV_EMUL_EXPS: 524 case MOUSEDEV_EMUL_EXPS:
469 ps2_data[3] = mousedev_limit_delta(p->dz, 7); 525 ps2_data[3] = mousedev_limit_delta(p->dz, 7);
470 p->dz -= ps2_data[3]; 526 p->dz -= ps2_data[3];
471 ps2_data[3] = (ps2_data[3] & 0x0f) | ((p->buttons & 0x18) << 1); 527 ps2_data[3] = (ps2_data[3] & 0x0f) | ((p->buttons & 0x18) << 1);
472 list->bufsiz = 4; 528 client->bufsiz = 4;
473 break; 529 break;
474 530
475 case MOUSEDEV_EMUL_IMPS: 531 case MOUSEDEV_EMUL_IMPS:
476 ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); 532 ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1);
477 ps2_data[3] = mousedev_limit_delta(p->dz, 127); 533 ps2_data[3] = mousedev_limit_delta(p->dz, 127);
478 p->dz -= ps2_data[3]; 534 p->dz -= ps2_data[3];
479 list->bufsiz = 4; 535 client->bufsiz = 4;
480 break; 536 break;
481 537
482 case MOUSEDEV_EMUL_PS2: 538 case MOUSEDEV_EMUL_PS2:
483 default: 539 default:
484 ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); 540 ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1);
485 p->dz = 0; 541 p->dz = 0;
486 list->bufsiz = 3; 542 client->bufsiz = 3;
487 break; 543 break;
488 } 544 }
489 545
490 if (!p->dx && !p->dy && !p->dz) { 546 if (!p->dx && !p->dy && !p->dz) {
491 if (list->tail == list->head) { 547 if (client->tail == client->head) {
492 list->ready = 0; 548 client->ready = 0;
493 list->last_buttons = p->buttons; 549 client->last_buttons = p->buttons;
494 } else 550 } else
495 list->tail = (list->tail + 1) % PACKET_QUEUE_LEN; 551 client->tail = (client->tail + 1) % PACKET_QUEUE_LEN;
496 } 552 }
497 553
498 spin_unlock_irqrestore(&list->packet_lock, flags); 554 spin_unlock_irqrestore(&client->packet_lock, flags);
499} 555}
500 556
501 557
502static ssize_t mousedev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) 558static ssize_t mousedev_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
503{ 559{
504 struct mousedev_list *list = file->private_data; 560 struct mousedev_client *client = file->private_data;
505 unsigned char c; 561 unsigned char c;
506 unsigned int i; 562 unsigned int i;
507 563
@@ -510,95 +566,95 @@ static ssize_t mousedev_write(struct file * file, const char __user * buffer, si
510 if (get_user(c, buffer + i)) 566 if (get_user(c, buffer + i))
511 return -EFAULT; 567 return -EFAULT;
512 568
513 if (c == mousedev_imex_seq[list->imexseq]) { 569 if (c == mousedev_imex_seq[client->imexseq]) {
514 if (++list->imexseq == MOUSEDEV_SEQ_LEN) { 570 if (++client->imexseq == MOUSEDEV_SEQ_LEN) {
515 list->imexseq = 0; 571 client->imexseq = 0;
516 list->mode = MOUSEDEV_EMUL_EXPS; 572 client->mode = MOUSEDEV_EMUL_EXPS;
517 } 573 }
518 } else 574 } else
519 list->imexseq = 0; 575 client->imexseq = 0;
520 576
521 if (c == mousedev_imps_seq[list->impsseq]) { 577 if (c == mousedev_imps_seq[client->impsseq]) {
522 if (++list->impsseq == MOUSEDEV_SEQ_LEN) { 578 if (++client->impsseq == MOUSEDEV_SEQ_LEN) {
523 list->impsseq = 0; 579 client->impsseq = 0;
524 list->mode = MOUSEDEV_EMUL_IMPS; 580 client->mode = MOUSEDEV_EMUL_IMPS;
525 } 581 }
526 } else 582 } else
527 list->impsseq = 0; 583 client->impsseq = 0;
528 584
529 list->ps2[0] = 0xfa; 585 client->ps2[0] = 0xfa;
530 586
531 switch (c) { 587 switch (c) {
532 588
533 case 0xeb: /* Poll */ 589 case 0xeb: /* Poll */
534 mousedev_packet(list, &list->ps2[1]); 590 mousedev_packet(client, &client->ps2[1]);
535 list->bufsiz++; /* account for leading ACK */ 591 client->bufsiz++; /* account for leading ACK */
536 break; 592 break;
537 593
538 case 0xf2: /* Get ID */ 594 case 0xf2: /* Get ID */
539 switch (list->mode) { 595 switch (client->mode) {
540 case MOUSEDEV_EMUL_PS2: list->ps2[1] = 0; break; 596 case MOUSEDEV_EMUL_PS2: client->ps2[1] = 0; break;
541 case MOUSEDEV_EMUL_IMPS: list->ps2[1] = 3; break; 597 case MOUSEDEV_EMUL_IMPS: client->ps2[1] = 3; break;
542 case MOUSEDEV_EMUL_EXPS: list->ps2[1] = 4; break; 598 case MOUSEDEV_EMUL_EXPS: client->ps2[1] = 4; break;
543 } 599 }
544 list->bufsiz = 2; 600 client->bufsiz = 2;
545 break; 601 break;
546 602
547 case 0xe9: /* Get info */ 603 case 0xe9: /* Get info */
548 list->ps2[1] = 0x60; list->ps2[2] = 3; list->ps2[3] = 200; 604 client->ps2[1] = 0x60; client->ps2[2] = 3; client->ps2[3] = 200;
549 list->bufsiz = 4; 605 client->bufsiz = 4;
550 break; 606 break;
551 607
552 case 0xff: /* Reset */ 608 case 0xff: /* Reset */
553 list->impsseq = list->imexseq = 0; 609 client->impsseq = client->imexseq = 0;
554 list->mode = MOUSEDEV_EMUL_PS2; 610 client->mode = MOUSEDEV_EMUL_PS2;
555 list->ps2[1] = 0xaa; list->ps2[2] = 0x00; 611 client->ps2[1] = 0xaa; client->ps2[2] = 0x00;
556 list->bufsiz = 3; 612 client->bufsiz = 3;
557 break; 613 break;
558 614
559 default: 615 default:
560 list->bufsiz = 1; 616 client->bufsiz = 1;
561 break; 617 break;
562 } 618 }
563 619
564 list->buffer = list->bufsiz; 620 client->buffer = client->bufsiz;
565 } 621 }
566 622
567 kill_fasync(&list->fasync, SIGIO, POLL_IN); 623 kill_fasync(&client->fasync, SIGIO, POLL_IN);
568 624
569 wake_up_interruptible(&list->mousedev->wait); 625 wake_up_interruptible(&client->mousedev->wait);
570 626
571 return count; 627 return count;
572} 628}
573 629
574static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) 630static ssize_t mousedev_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
575{ 631{
576 struct mousedev_list *list = file->private_data; 632 struct mousedev_client *client = file->private_data;
577 int retval = 0; 633 int retval = 0;
578 634
579 if (!list->ready && !list->buffer && (file->f_flags & O_NONBLOCK)) 635 if (!client->ready && !client->buffer && (file->f_flags & O_NONBLOCK))
580 return -EAGAIN; 636 return -EAGAIN;
581 637
582 retval = wait_event_interruptible(list->mousedev->wait, 638 retval = wait_event_interruptible(client->mousedev->wait,
583 !list->mousedev->exist || list->ready || list->buffer); 639 !client->mousedev->exist || client->ready || client->buffer);
584 640
585 if (retval) 641 if (retval)
586 return retval; 642 return retval;
587 643
588 if (!list->mousedev->exist) 644 if (!client->mousedev->exist)
589 return -ENODEV; 645 return -ENODEV;
590 646
591 if (!list->buffer && list->ready) { 647 if (!client->buffer && client->ready) {
592 mousedev_packet(list, list->ps2); 648 mousedev_packet(client, client->ps2);
593 list->buffer = list->bufsiz; 649 client->buffer = client->bufsiz;
594 } 650 }
595 651
596 if (count > list->buffer) 652 if (count > client->buffer)
597 count = list->buffer; 653 count = client->buffer;
598 654
599 list->buffer -= count; 655 client->buffer -= count;
600 656
601 if (copy_to_user(buffer, list->ps2 + list->bufsiz - list->buffer - count, count)) 657 if (copy_to_user(buffer, client->ps2 + client->bufsiz - client->buffer - count, count))
602 return -EFAULT; 658 return -EFAULT;
603 659
604 return count; 660 return count;
@@ -607,11 +663,12 @@ static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t co
607/* No kernel lock - fine */ 663/* No kernel lock - fine */
608static unsigned int mousedev_poll(struct file *file, poll_table *wait) 664static unsigned int mousedev_poll(struct file *file, poll_table *wait)
609{ 665{
610 struct mousedev_list *list = file->private_data; 666 struct mousedev_client *client = file->private_data;
667 struct mousedev *mousedev = client->mousedev;
611 668
612 poll_wait(file, &list->mousedev->wait, wait); 669 poll_wait(file, &mousedev->wait, wait);
613 return ((list->ready || list->buffer) ? (POLLIN | POLLRDNORM) : 0) | 670 return ((client->ready || client->buffer) ? (POLLIN | POLLRDNORM) : 0) |
614 (list->mousedev->exist ? 0 : (POLLHUP | POLLERR)); 671 (mousedev->exist ? 0 : (POLLHUP | POLLERR));
615} 672}
616 673
617static const struct file_operations mousedev_fops = { 674static const struct file_operations mousedev_fops = {
@@ -624,23 +681,27 @@ static const struct file_operations mousedev_fops = {
624 .fasync = mousedev_fasync, 681 .fasync = mousedev_fasync,
625}; 682};
626 683
627static struct input_handle *mousedev_connect(struct input_handler *handler, struct input_dev *dev, 684static int mousedev_connect(struct input_handler *handler, struct input_dev *dev,
628 const struct input_device_id *id) 685 const struct input_device_id *id)
629{ 686{
630 struct mousedev *mousedev; 687 struct mousedev *mousedev;
631 struct class_device *cdev; 688 struct class_device *cdev;
632 int minor = 0; 689 dev_t devt;
690 int minor;
691 int error;
633 692
634 for (minor = 0; minor < MOUSEDEV_MINORS && mousedev_table[minor]; minor++); 693 for (minor = 0; minor < MOUSEDEV_MINORS && mousedev_table[minor]; minor++);
635 if (minor == MOUSEDEV_MINORS) { 694 if (minor == MOUSEDEV_MINORS) {
636 printk(KERN_ERR "mousedev: no more free mousedev devices\n"); 695 printk(KERN_ERR "mousedev: no more free mousedev devices\n");
637 return NULL; 696 return -ENFILE;
638 } 697 }
639 698
640 if (!(mousedev = kzalloc(sizeof(struct mousedev), GFP_KERNEL))) 699 mousedev = kzalloc(sizeof(struct mousedev), GFP_KERNEL);
641 return NULL; 700 if (!mousedev)
701 return -ENOMEM;
642 702
643 INIT_LIST_HEAD(&mousedev->list); 703 INIT_LIST_HEAD(&mousedev->client_list);
704 INIT_LIST_HEAD(&mousedev->mixdev_node);
644 init_waitqueue_head(&mousedev->wait); 705 init_waitqueue_head(&mousedev->wait);
645 706
646 mousedev->minor = minor; 707 mousedev->minor = minor;
@@ -651,42 +712,66 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
651 mousedev->handle.private = mousedev; 712 mousedev->handle.private = mousedev;
652 sprintf(mousedev->name, "mouse%d", minor); 713 sprintf(mousedev->name, "mouse%d", minor);
653 714
654 if (mousedev_mix.open)
655 input_open_device(&mousedev->handle);
656
657 mousedev_table[minor] = mousedev; 715 mousedev_table[minor] = mousedev;
658 716
659 cdev = class_device_create(&input_class, &dev->cdev, 717 devt = MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
660 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), 718
661 dev->cdev.dev, mousedev->name); 719 cdev = class_device_create(&input_class, &dev->cdev, devt,
720 dev->cdev.dev, mousedev->name);
721 if (IS_ERR(cdev)) {
722 error = PTR_ERR(cdev);
723 goto err_free_mousedev;
724 }
662 725
663 /* temporary symlink to keep userspace happy */ 726 /* temporary symlink to keep userspace happy */
664 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, 727 error = sysfs_create_link(&input_class.subsys.kobj,
665 mousedev->name); 728 &cdev->kobj, mousedev->name);
729 if (error)
730 goto err_cdev_destroy;
731
732 error = input_register_handle(&mousedev->handle);
733 if (error)
734 goto err_remove_link;
735
736 error = mixdev_add_device(mousedev);
737 if (error)
738 goto err_unregister_handle;
739
740 return 0;
666 741
667 return &mousedev->handle; 742 err_unregister_handle:
743 input_unregister_handle(&mousedev->handle);
744 err_remove_link:
745 sysfs_remove_link(&input_class.subsys.kobj, mousedev->name);
746 err_cdev_destroy:
747 class_device_destroy(&input_class, devt);
748 err_free_mousedev:
749 mousedev_table[minor] = NULL;
750 kfree(mousedev);
751 return error;
668} 752}
669 753
670static void mousedev_disconnect(struct input_handle *handle) 754static void mousedev_disconnect(struct input_handle *handle)
671{ 755{
672 struct mousedev *mousedev = handle->private; 756 struct mousedev *mousedev = handle->private;
673 struct mousedev_list *list; 757 struct mousedev_client *client;
674 758
675 sysfs_remove_link(&input_class.subsys.kset.kobj, mousedev->name); 759 input_unregister_handle(handle);
760
761 sysfs_remove_link(&input_class.subsys.kobj, mousedev->name);
676 class_device_destroy(&input_class, 762 class_device_destroy(&input_class,
677 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor)); 763 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
678 mousedev->exist = 0; 764 mousedev->exist = 0;
679 765
766 mixdev_remove_device(mousedev);
767
680 if (mousedev->open) { 768 if (mousedev->open) {
681 input_close_device(handle); 769 input_close_device(handle);
682 wake_up_interruptible(&mousedev->wait); 770 wake_up_interruptible(&mousedev->wait);
683 list_for_each_entry(list, &mousedev->list, node) 771 list_for_each_entry(client, &mousedev->client_list, node)
684 kill_fasync(&list->fasync, SIGIO, POLL_HUP); 772 kill_fasync(&client->fasync, SIGIO, POLL_HUP);
685 } else { 773 } else
686 if (mousedev_mix.open)
687 input_close_device(handle);
688 mousedev_free(mousedev); 774 mousedev_free(mousedev);
689 }
690} 775}
691 776
692static const struct input_device_id mousedev_ids[] = { 777static const struct input_device_id mousedev_ids[] = {
@@ -714,7 +799,7 @@ static const struct input_device_id mousedev_ids[] = {
714 .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_TOOL_WIDTH) }, 799 .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_TOOL_WIDTH) },
715 }, /* A touchpad */ 800 }, /* A touchpad */
716 801
717 { }, /* Terminating entry */ 802 { }, /* Terminating entry */
718}; 803};
719 804
720MODULE_DEVICE_TABLE(input, mousedev_ids); 805MODULE_DEVICE_TABLE(input, mousedev_ids);
@@ -746,7 +831,7 @@ static int __init mousedev_init(void)
746 return error; 831 return error;
747 832
748 memset(&mousedev_mix, 0, sizeof(struct mousedev)); 833 memset(&mousedev_mix, 0, sizeof(struct mousedev));
749 INIT_LIST_HEAD(&mousedev_mix.list); 834 INIT_LIST_HEAD(&mousedev_mix.client_list);
750 init_waitqueue_head(&mousedev_mix.wait); 835 init_waitqueue_head(&mousedev_mix.wait);
751 mousedev_table[MOUSEDEV_MIX] = &mousedev_mix; 836 mousedev_table[MOUSEDEV_MIX] = &mousedev_mix;
752 mousedev_mix.exist = 1; 837 mousedev_mix.exist = 1;
diff --git a/drivers/input/power.c b/drivers/input/power.c
deleted file mode 100644
index ee82464a2fa7..000000000000
--- a/drivers/input/power.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*
2 * $Id: power.c,v 1.10 2001/09/25 09:17:15 vojtech Exp $
3 *
4 * Copyright (c) 2001 "Crazy" James Simmons
5 *
6 * Input driver Power Management.
7 *
8 * Sponsored by Transvirtual Technology.
9 */
10
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 * Should you need to contact me, the author, you can do so by
27 * e-mail - mail your message to <jsimmons@transvirtual.com>.
28 */
29
30#include <linux/module.h>
31#include <linux/input.h>
32#include <linux/slab.h>
33#include <linux/init.h>
34#include <linux/tty.h>
35#include <linux/delay.h>
36#include <linux/pm.h>
37
38static struct input_handler power_handler;
39
40/*
41 * Power management can't be done in a interrupt context. So we have to
42 * use keventd.
43 */
44static int suspend_button_pushed = 0;
45static void suspend_button_task_handler(void *data)
46{
47 udelay(200); /* debounce */
48 suspend_button_pushed = 0;
49}
50
51static DECLARE_WORK(suspend_button_task, suspend_button_task_handler, NULL);
52
53static void power_event(struct input_handle *handle, unsigned int type,
54 unsigned int code, int down)
55{
56 struct input_dev *dev = handle->dev;
57
58 printk("Entering power_event\n");
59
60 if (type == EV_PWR) {
61 switch (code) {
62 case KEY_SUSPEND:
63 printk("Powering down entire device\n");
64
65 if (!suspend_button_pushed) {
66 suspend_button_pushed = 1;
67 schedule_work(&suspend_button_task);
68 }
69 break;
70 case KEY_POWER:
71 /* Hum power down the machine. */
72 break;
73 default:
74 return;
75 }
76 }
77
78 if (type == EV_KEY) {
79 switch (code) {
80 case KEY_SUSPEND:
81 printk("Powering down input device\n");
82 /* This is risky. See pm.h for details. */
83 if (dev->state != PM_RESUME)
84 dev->state = PM_RESUME;
85 else
86 dev->state = PM_SUSPEND;
87 pm_send(dev->pm_dev, dev->state, dev);
88 break;
89 case KEY_POWER:
90 /* Turn the input device off completely ? */
91 break;
92 default:
93 return;
94 }
95 }
96 return;
97}
98
99static struct input_handle *power_connect(struct input_handler *handler,
100 struct input_dev *dev,
101 const struct input_device_id *id)
102{
103 struct input_handle *handle;
104
105 if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
106 return NULL;
107
108 handle->dev = dev;
109 handle->handler = handler;
110
111 input_open_device(handle);
112
113 printk(KERN_INFO "power.c: Adding power management to input layer\n");
114 return handle;
115}
116
117static void power_disconnect(struct input_handle *handle)
118{
119 input_close_device(handle);
120 kfree(handle);
121}
122
123static const struct input_device_id power_ids[] = {
124 {
125 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
126 .evbit = { BIT(EV_KEY) },
127 .keybit = { [LONG(KEY_SUSPEND)] = BIT(KEY_SUSPEND) }
128 },
129 {
130 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
131 .evbit = { BIT(EV_KEY) },
132 .keybit = { [LONG(KEY_POWER)] = BIT(KEY_POWER) }
133 },
134 {
135 .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
136 .evbit = { BIT(EV_PWR) },
137 },
138 { }, /* Terminating entry */
139};
140
141MODULE_DEVICE_TABLE(input, power_ids);
142
143static struct input_handler power_handler = {
144 .event = power_event,
145 .connect = power_connect,
146 .disconnect = power_disconnect,
147 .name = "power",
148 .id_table = power_ids,
149};
150
151static int __init power_init(void)
152{
153 return input_register_handler(&power_handler);
154}
155
156static void __exit power_exit(void)
157{
158 input_unregister_handler(&power_handler);
159}
160
161module_init(power_init);
162module_exit(power_exit);
163
164MODULE_AUTHOR("James Simmons <jsimmons@transvirtual.com>");
165MODULE_DESCRIPTION("Input Power Management driver");
166MODULE_LICENSE("GPL");
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index 4fa93ff30919..93a1a6ba216a 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -32,11 +32,11 @@
32 * 32 *
33 * Driver theory of operation: 33 * Driver theory of operation:
34 * 34 *
35 * Some access methods and an ISR is defined by the sub-driver 35 * Some access methods and an ISR is defined by the sub-driver
36 * (e.g. hp_sdc_mlc.c). These methods are expected to provide a 36 * (e.g. hp_sdc_mlc.c). These methods are expected to provide a
37 * few bits of logic in addition to raw access to the HIL MLC, 37 * few bits of logic in addition to raw access to the HIL MLC,
38 * specifically, the ISR, which is entirely registered by the 38 * specifically, the ISR, which is entirely registered by the
39 * sub-driver and invoked directly, must check for record 39 * sub-driver and invoked directly, must check for record
40 * termination or packet match, at which point a semaphore must 40 * termination or packet match, at which point a semaphore must
41 * be cleared and then the hil_mlcs_tasklet must be scheduled. 41 * be cleared and then the hil_mlcs_tasklet must be scheduled.
42 * 42 *
@@ -47,7 +47,7 @@
47 * itself if output is pending. (This rescheduling should be replaced 47 * itself if output is pending. (This rescheduling should be replaced
48 * at some point with a sub-driver-specific mechanism.) 48 * at some point with a sub-driver-specific mechanism.)
49 * 49 *
50 * A timer task prods the tasklet once per second to prevent 50 * A timer task prods the tasklet once per second to prevent
51 * hangups when attached devices do not return expected data 51 * hangups when attached devices do not return expected data
52 * and to initiate probes of the loop for new devices. 52 * and to initiate probes of the loop for new devices.
53 */ 53 */
@@ -83,69 +83,85 @@ DECLARE_TASKLET_DISABLED(hil_mlcs_tasklet, hil_mlcs_process, 0);
83 83
84/********************** Device info/instance management **********************/ 84/********************** Device info/instance management **********************/
85 85
86static void hil_mlc_clear_di_map (hil_mlc *mlc, int val) { 86static void hil_mlc_clear_di_map(hil_mlc *mlc, int val)
87{
87 int j; 88 int j;
88 for (j = val; j < 7 ; j++) { 89
90 for (j = val; j < 7 ; j++)
89 mlc->di_map[j] = -1; 91 mlc->di_map[j] = -1;
90 }
91} 92}
92 93
93static void hil_mlc_clear_di_scratch (hil_mlc *mlc) { 94static void hil_mlc_clear_di_scratch(hil_mlc *mlc)
94 memset(&(mlc->di_scratch), 0, sizeof(mlc->di_scratch)); 95{
96 memset(&mlc->di_scratch, 0, sizeof(mlc->di_scratch));
95} 97}
96 98
97static void hil_mlc_copy_di_scratch (hil_mlc *mlc, int idx) { 99static void hil_mlc_copy_di_scratch(hil_mlc *mlc, int idx)
98 memcpy(&(mlc->di[idx]), &(mlc->di_scratch), sizeof(mlc->di_scratch)); 100{
101 memcpy(&mlc->di[idx], &mlc->di_scratch, sizeof(mlc->di_scratch));
99} 102}
100 103
101static int hil_mlc_match_di_scratch (hil_mlc *mlc) { 104static int hil_mlc_match_di_scratch(hil_mlc *mlc)
105{
102 int idx; 106 int idx;
103 107
104 for (idx = 0; idx < HIL_MLC_DEVMEM; idx++) { 108 for (idx = 0; idx < HIL_MLC_DEVMEM; idx++) {
105 int j, found; 109 int j, found = 0;
106 110
107 /* In-use slots are not eligible. */ 111 /* In-use slots are not eligible. */
108 found = 0; 112 for (j = 0; j < 7 ; j++)
109 for (j = 0; j < 7 ; j++) { 113 if (mlc->di_map[j] == idx)
110 if (mlc->di_map[j] == idx) found++; 114 found++;
111 } 115
112 if (found) continue; 116 if (found)
113 if (!memcmp(mlc->di + idx, 117 continue;
114 &(mlc->di_scratch), 118
115 sizeof(mlc->di_scratch))) break; 119 if (!memcmp(mlc->di + idx, &mlc->di_scratch,
120 sizeof(mlc->di_scratch)))
121 break;
116 } 122 }
117 return((idx >= HIL_MLC_DEVMEM) ? -1 : idx); 123 return idx >= HIL_MLC_DEVMEM ? -1 : idx;
118} 124}
119 125
120static int hil_mlc_find_free_di(hil_mlc *mlc) { 126static int hil_mlc_find_free_di(hil_mlc *mlc)
127{
121 int idx; 128 int idx;
122 /* TODO: Pick all-zero slots first, failing that, 129
123 * randomize the slot picked among those eligible. 130 /* TODO: Pick all-zero slots first, failing that,
131 * randomize the slot picked among those eligible.
124 */ 132 */
125 for (idx = 0; idx < HIL_MLC_DEVMEM; idx++) { 133 for (idx = 0; idx < HIL_MLC_DEVMEM; idx++) {
126 int j, found; 134 int j, found = 0;
127 found = 0; 135
128 for (j = 0; j < 7 ; j++) { 136 for (j = 0; j < 7 ; j++)
129 if (mlc->di_map[j] == idx) found++; 137 if (mlc->di_map[j] == idx)
130 } 138 found++;
131 if (!found) break; 139
140 if (!found)
141 break;
132 } 142 }
133 return(idx); /* Note: It is guaranteed at least one above will match */ 143
144 return idx; /* Note: It is guaranteed at least one above will match */
134} 145}
135 146
136static inline void hil_mlc_clean_serio_map(hil_mlc *mlc) { 147static inline void hil_mlc_clean_serio_map(hil_mlc *mlc)
148{
137 int idx; 149 int idx;
150
138 for (idx = 0; idx < HIL_MLC_DEVMEM; idx++) { 151 for (idx = 0; idx < HIL_MLC_DEVMEM; idx++) {
139 int j, found; 152 int j, found = 0;
140 found = 0; 153
141 for (j = 0; j < 7 ; j++) { 154 for (j = 0; j < 7 ; j++)
142 if (mlc->di_map[j] == idx) found++; 155 if (mlc->di_map[j] == idx)
143 } 156 found++;
144 if (!found) mlc->serio_map[idx].di_revmap = -1; 157
158 if (!found)
159 mlc->serio_map[idx].di_revmap = -1;
145 } 160 }
146} 161}
147 162
148static void hil_mlc_send_polls(hil_mlc *mlc) { 163static void hil_mlc_send_polls(hil_mlc *mlc)
164{
149 int did, i, cnt; 165 int did, i, cnt;
150 struct serio *serio; 166 struct serio *serio;
151 struct serio_driver *drv; 167 struct serio_driver *drv;
@@ -157,26 +173,31 @@ static void hil_mlc_send_polls(hil_mlc *mlc) {
157 173
158 while (mlc->icount < 15 - i) { 174 while (mlc->icount < 15 - i) {
159 hil_packet p; 175 hil_packet p;
176
160 p = mlc->ipacket[i]; 177 p = mlc->ipacket[i];
161 if (did != (p & HIL_PKT_ADDR_MASK) >> 8) { 178 if (did != (p & HIL_PKT_ADDR_MASK) >> 8) {
162 if (drv == NULL || drv->interrupt == NULL) goto skip; 179 if (drv && drv->interrupt) {
180 drv->interrupt(serio, 0, 0);
181 drv->interrupt(serio, HIL_ERR_INT >> 16, 0);
182 drv->interrupt(serio, HIL_PKT_CMD >> 8, 0);
183 drv->interrupt(serio, HIL_CMD_POL + cnt, 0);
184 }
163 185
164 drv->interrupt(serio, 0, 0);
165 drv->interrupt(serio, HIL_ERR_INT >> 16, 0);
166 drv->interrupt(serio, HIL_PKT_CMD >> 8, 0);
167 drv->interrupt(serio, HIL_CMD_POL + cnt, 0);
168 skip:
169 did = (p & HIL_PKT_ADDR_MASK) >> 8; 186 did = (p & HIL_PKT_ADDR_MASK) >> 8;
170 serio = did ? mlc->serio[mlc->di_map[did-1]] : NULL; 187 serio = did ? mlc->serio[mlc->di_map[did-1]] : NULL;
171 drv = (serio != NULL) ? serio->drv : NULL; 188 drv = (serio != NULL) ? serio->drv : NULL;
172 cnt = 0; 189 cnt = 0;
173 } 190 }
174 cnt++; i++; 191
175 if (drv == NULL || drv->interrupt == NULL) continue; 192 cnt++;
176 drv->interrupt(serio, (p >> 24), 0); 193 i++;
177 drv->interrupt(serio, (p >> 16) & 0xff, 0); 194
178 drv->interrupt(serio, (p >> 8) & ~HIL_PKT_ADDR_MASK, 0); 195 if (drv && drv->interrupt) {
179 drv->interrupt(serio, p & 0xff, 0); 196 drv->interrupt(serio, (p >> 24), 0);
197 drv->interrupt(serio, (p >> 16) & 0xff, 0);
198 drv->interrupt(serio, (p >> 8) & ~HIL_PKT_ADDR_MASK, 0);
199 drv->interrupt(serio, p & 0xff, 0);
200 }
180 } 201 }
181} 202}
182 203
@@ -215,12 +236,16 @@ static void hil_mlc_send_polls(hil_mlc *mlc) {
215#define HILSEN_DOZE (HILSEN_SAME | HILSEN_SCHED | HILSEN_BREAK) 236#define HILSEN_DOZE (HILSEN_SAME | HILSEN_SCHED | HILSEN_BREAK)
216#define HILSEN_SLEEP (HILSEN_SAME | HILSEN_BREAK) 237#define HILSEN_SLEEP (HILSEN_SAME | HILSEN_BREAK)
217 238
218static int hilse_match(hil_mlc *mlc, int unused) { 239static int hilse_match(hil_mlc *mlc, int unused)
240{
219 int rc; 241 int rc;
242
220 rc = hil_mlc_match_di_scratch(mlc); 243 rc = hil_mlc_match_di_scratch(mlc);
221 if (rc == -1) { 244 if (rc == -1) {
222 rc = hil_mlc_find_free_di(mlc); 245 rc = hil_mlc_find_free_di(mlc);
223 if (rc == -1) goto err; 246 if (rc == -1)
247 goto err;
248
224#ifdef HIL_MLC_DEBUG 249#ifdef HIL_MLC_DEBUG
225 printk(KERN_DEBUG PREFIX "new in slot %i\n", rc); 250 printk(KERN_DEBUG PREFIX "new in slot %i\n", rc);
226#endif 251#endif
@@ -231,6 +256,7 @@ static int hilse_match(hil_mlc *mlc, int unused) {
231 serio_rescan(mlc->serio[rc]); 256 serio_rescan(mlc->serio[rc]);
232 return -1; 257 return -1;
233 } 258 }
259
234 mlc->di_map[mlc->ddi] = rc; 260 mlc->di_map[mlc->ddi] = rc;
235#ifdef HIL_MLC_DEBUG 261#ifdef HIL_MLC_DEBUG
236 printk(KERN_DEBUG PREFIX "same in slot %i\n", rc); 262 printk(KERN_DEBUG PREFIX "same in slot %i\n", rc);
@@ -238,152 +264,177 @@ static int hilse_match(hil_mlc *mlc, int unused) {
238 mlc->serio_map[rc].di_revmap = mlc->ddi; 264 mlc->serio_map[rc].di_revmap = mlc->ddi;
239 hil_mlc_clean_serio_map(mlc); 265 hil_mlc_clean_serio_map(mlc);
240 return 0; 266 return 0;
267
241 err: 268 err:
242 printk(KERN_ERR PREFIX "Residual device slots exhausted, close some serios!\n"); 269 printk(KERN_ERR PREFIX "Residual device slots exhausted, close some serios!\n");
243 return 1; 270 return 1;
244} 271}
245 272
246/* An LCV used to prevent runaway loops, forces 5 second sleep when reset. */ 273/* An LCV used to prevent runaway loops, forces 5 second sleep when reset. */
247static int hilse_init_lcv(hil_mlc *mlc, int unused) { 274static int hilse_init_lcv(hil_mlc *mlc, int unused)
275{
248 struct timeval tv; 276 struct timeval tv;
249 277
250 do_gettimeofday(&tv); 278 do_gettimeofday(&tv);
251 279
252 if(mlc->lcv == 0) goto restart; /* First init, no need to dally */ 280 if (mlc->lcv && (tv.tv_sec - mlc->lcv_tv.tv_sec) < 5)
253 if(tv.tv_sec - mlc->lcv_tv.tv_sec < 5) return -1; 281 return -1;
254 restart: 282
255 mlc->lcv_tv = tv; 283 mlc->lcv_tv = tv;
256 mlc->lcv = 0; 284 mlc->lcv = 0;
285
257 return 0; 286 return 0;
258} 287}
259 288
260static int hilse_inc_lcv(hil_mlc *mlc, int lim) { 289static int hilse_inc_lcv(hil_mlc *mlc, int lim)
261 if (mlc->lcv++ >= lim) return -1; 290{
262 return 0; 291 return mlc->lcv++ >= lim ? -1 : 0;
263} 292}
264 293
265#if 0 294#if 0
266static int hilse_set_lcv(hil_mlc *mlc, int val) { 295static int hilse_set_lcv(hil_mlc *mlc, int val)
296{
267 mlc->lcv = val; 297 mlc->lcv = val;
298
268 return 0; 299 return 0;
269} 300}
270#endif 301#endif
271 302
272/* Management of the discovered device index (zero based, -1 means no devs) */ 303/* Management of the discovered device index (zero based, -1 means no devs) */
273static int hilse_set_ddi(hil_mlc *mlc, int val) { 304static int hilse_set_ddi(hil_mlc *mlc, int val)
305{
274 mlc->ddi = val; 306 mlc->ddi = val;
275 hil_mlc_clear_di_map(mlc, val + 1); 307 hil_mlc_clear_di_map(mlc, val + 1);
308
276 return 0; 309 return 0;
277} 310}
278 311
279static int hilse_dec_ddi(hil_mlc *mlc, int unused) { 312static int hilse_dec_ddi(hil_mlc *mlc, int unused)
313{
280 mlc->ddi--; 314 mlc->ddi--;
281 if (mlc->ddi <= -1) { 315 if (mlc->ddi <= -1) {
282 mlc->ddi = -1; 316 mlc->ddi = -1;
283 hil_mlc_clear_di_map(mlc, 0); 317 hil_mlc_clear_di_map(mlc, 0);
284 return -1; 318 return -1;
285 } 319 }
286 hil_mlc_clear_di_map(mlc, mlc->ddi + 1); 320 hil_mlc_clear_di_map(mlc, mlc->ddi + 1);
321
287 return 0; 322 return 0;
288} 323}
289 324
290static int hilse_inc_ddi(hil_mlc *mlc, int unused) { 325static int hilse_inc_ddi(hil_mlc *mlc, int unused)
291 if (mlc->ddi >= 6) { 326{
292 BUG(); 327 BUG_ON(mlc->ddi >= 6);
293 return -1;
294 }
295 mlc->ddi++; 328 mlc->ddi++;
329
296 return 0; 330 return 0;
297} 331}
298 332
299static int hilse_take_idd(hil_mlc *mlc, int unused) { 333static int hilse_take_idd(hil_mlc *mlc, int unused)
334{
300 int i; 335 int i;
301 336
302 /* Help the state engine: 337 /* Help the state engine:
303 * Is this a real IDD response or just an echo? 338 * Is this a real IDD response or just an echo?
304 * 339 *
305 * Real IDD response does not start with a command. 340 * Real IDD response does not start with a command.
306 */ 341 */
307 if (mlc->ipacket[0] & HIL_PKT_CMD) goto bail; 342 if (mlc->ipacket[0] & HIL_PKT_CMD)
343 goto bail;
344
308 /* Should have the command echoed further down. */ 345 /* Should have the command echoed further down. */
309 for (i = 1; i < 16; i++) { 346 for (i = 1; i < 16; i++) {
310 if (((mlc->ipacket[i] & HIL_PKT_ADDR_MASK) == 347 if (((mlc->ipacket[i] & HIL_PKT_ADDR_MASK) ==
311 (mlc->ipacket[0] & HIL_PKT_ADDR_MASK)) && 348 (mlc->ipacket[0] & HIL_PKT_ADDR_MASK)) &&
312 (mlc->ipacket[i] & HIL_PKT_CMD) && 349 (mlc->ipacket[i] & HIL_PKT_CMD) &&
313 ((mlc->ipacket[i] & HIL_PKT_DATA_MASK) == HIL_CMD_IDD)) 350 ((mlc->ipacket[i] & HIL_PKT_DATA_MASK) == HIL_CMD_IDD))
314 break; 351 break;
315 } 352 }
316 if (i > 15) goto bail; 353 if (i > 15)
354 goto bail;
355
317 /* And the rest of the packets should still be clear. */ 356 /* And the rest of the packets should still be clear. */
318 while (++i < 16) { 357 while (++i < 16)
319 if (mlc->ipacket[i]) break; 358 if (mlc->ipacket[i])
320 } 359 break;
321 if (i < 16) goto bail; 360
322 for (i = 0; i < 16; i++) { 361 if (i < 16)
323 mlc->di_scratch.idd[i] = 362 goto bail;
363
364 for (i = 0; i < 16; i++)
365 mlc->di_scratch.idd[i] =
324 mlc->ipacket[i] & HIL_PKT_DATA_MASK; 366 mlc->ipacket[i] & HIL_PKT_DATA_MASK;
325 } 367
326 /* Next step is to see if RSC supported */ 368 /* Next step is to see if RSC supported */
327 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_RSC) 369 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_RSC)
328 return HILSEN_NEXT; 370 return HILSEN_NEXT;
329 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_EXD) 371
372 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_EXD)
330 return HILSEN_DOWN | 4; 373 return HILSEN_DOWN | 4;
374
331 return 0; 375 return 0;
376
332 bail: 377 bail:
333 mlc->ddi--; 378 mlc->ddi--;
379
334 return -1; /* This should send us off to ACF */ 380 return -1; /* This should send us off to ACF */
335} 381}
336 382
337static int hilse_take_rsc(hil_mlc *mlc, int unused) { 383static int hilse_take_rsc(hil_mlc *mlc, int unused)
384{
338 int i; 385 int i;
339 386
340 for (i = 0; i < 16; i++) { 387 for (i = 0; i < 16; i++)
341 mlc->di_scratch.rsc[i] = 388 mlc->di_scratch.rsc[i] =
342 mlc->ipacket[i] & HIL_PKT_DATA_MASK; 389 mlc->ipacket[i] & HIL_PKT_DATA_MASK;
343 } 390
344 /* Next step is to see if EXD supported (IDD has already been read) */ 391 /* Next step is to see if EXD supported (IDD has already been read) */
345 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_EXD) 392 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_EXD)
346 return HILSEN_NEXT; 393 return HILSEN_NEXT;
394
347 return 0; 395 return 0;
348} 396}
349 397
350static int hilse_take_exd(hil_mlc *mlc, int unused) { 398static int hilse_take_exd(hil_mlc *mlc, int unused)
399{
351 int i; 400 int i;
352 401
353 for (i = 0; i < 16; i++) { 402 for (i = 0; i < 16; i++)
354 mlc->di_scratch.exd[i] = 403 mlc->di_scratch.exd[i] =
355 mlc->ipacket[i] & HIL_PKT_DATA_MASK; 404 mlc->ipacket[i] & HIL_PKT_DATA_MASK;
356 } 405
357 /* Next step is to see if RNM supported. */ 406 /* Next step is to see if RNM supported. */
358 if (mlc->di_scratch.exd[0] & HIL_EXD_HEADER_RNM) 407 if (mlc->di_scratch.exd[0] & HIL_EXD_HEADER_RNM)
359 return HILSEN_NEXT; 408 return HILSEN_NEXT;
409
360 return 0; 410 return 0;
361} 411}
362 412
363static int hilse_take_rnm(hil_mlc *mlc, int unused) { 413static int hilse_take_rnm(hil_mlc *mlc, int unused)
414{
364 int i; 415 int i;
365 416
366 for (i = 0; i < 16; i++) { 417 for (i = 0; i < 16; i++)
367 mlc->di_scratch.rnm[i] = 418 mlc->di_scratch.rnm[i] =
368 mlc->ipacket[i] & HIL_PKT_DATA_MASK; 419 mlc->ipacket[i] & HIL_PKT_DATA_MASK;
369 } 420
370 do { 421 printk(KERN_INFO PREFIX "Device name gotten: %16s\n",
371 char nam[17]; 422 mlc->di_scratch.rnm);
372 snprintf(nam, 16, "%s", mlc->di_scratch.rnm); 423
373 nam[16] = '\0';
374 printk(KERN_INFO PREFIX "Device name gotten: %s\n", nam);
375 } while (0);
376 return 0; 424 return 0;
377} 425}
378 426
379static int hilse_operate(hil_mlc *mlc, int repoll) { 427static int hilse_operate(hil_mlc *mlc, int repoll)
428{
380 429
381 if (mlc->opercnt == 0) hil_mlcs_probe = 0; 430 if (mlc->opercnt == 0)
431 hil_mlcs_probe = 0;
382 mlc->opercnt = 1; 432 mlc->opercnt = 1;
383 433
384 hil_mlc_send_polls(mlc); 434 hil_mlc_send_polls(mlc);
385 435
386 if (!hil_mlcs_probe) return 0; 436 if (!hil_mlcs_probe)
437 return 0;
387 hil_mlcs_probe = 0; 438 hil_mlcs_probe = 0;
388 mlc->opercnt = 0; 439 mlc->opercnt = 0;
389 return 1; 440 return 1;
@@ -408,7 +459,7 @@ static int hilse_operate(hil_mlc *mlc, int repoll) {
408#define OUT_LAST(pack) \ 459#define OUT_LAST(pack) \
409{ HILSE_OUT_LAST, { .packet = pack }, 0, 0, 0, 0 }, 460{ HILSE_OUT_LAST, { .packet = pack }, 0, 0, 0, 0 },
410 461
411struct hilse_node hil_mlc_se[HILSEN_END] = { 462const struct hilse_node hil_mlc_se[HILSEN_END] = {
412 463
413 /* 0 HILSEN_START */ 464 /* 0 HILSEN_START */
414 FUNC(hilse_init_lcv, 0, HILSEN_NEXT, HILSEN_SLEEP, 0) 465 FUNC(hilse_init_lcv, 0, HILSEN_NEXT, HILSEN_SLEEP, 0)
@@ -428,7 +479,7 @@ struct hilse_node hil_mlc_se[HILSEN_END] = {
428 EXPECT(HIL_ERR_INT | TEST_PACKET(0xa), 479 EXPECT(HIL_ERR_INT | TEST_PACKET(0xa),
429 2000, HILSEN_NEXT, HILSEN_RESTART, HILSEN_RESTART) 480 2000, HILSEN_NEXT, HILSEN_RESTART, HILSEN_RESTART)
430 OUT(HIL_CTRL_ONLY | 0) /* Disable test mode */ 481 OUT(HIL_CTRL_ONLY | 0) /* Disable test mode */
431 482
432 /* 9 HILSEN_DHR */ 483 /* 9 HILSEN_DHR */
433 FUNC(hilse_init_lcv, 0, HILSEN_NEXT, HILSEN_SLEEP, 0) 484 FUNC(hilse_init_lcv, 0, HILSEN_NEXT, HILSEN_SLEEP, 0)
434 485
@@ -439,7 +490,7 @@ struct hilse_node hil_mlc_se[HILSEN_END] = {
439 IN(300000, HILSEN_DHR2, HILSEN_DHR2, HILSEN_NEXT) 490 IN(300000, HILSEN_DHR2, HILSEN_DHR2, HILSEN_NEXT)
440 491
441 /* 14 HILSEN_IFC */ 492 /* 14 HILSEN_IFC */
442 OUT(HIL_PKT_CMD | HIL_CMD_IFC) 493 OUT(HIL_PKT_CMD | HIL_CMD_IFC)
443 EXPECT(HIL_PKT_CMD | HIL_CMD_IFC | HIL_ERR_INT, 494 EXPECT(HIL_PKT_CMD | HIL_CMD_IFC | HIL_ERR_INT,
444 20000, HILSEN_DISC, HILSEN_DHR2, HILSEN_NEXT ) 495 20000, HILSEN_DISC, HILSEN_DHR2, HILSEN_NEXT )
445 496
@@ -455,7 +506,7 @@ struct hilse_node hil_mlc_se[HILSEN_END] = {
455 506
456 /* 18 HILSEN_HEAL */ 507 /* 18 HILSEN_HEAL */
457 OUT_LAST(HIL_CMD_ELB) 508 OUT_LAST(HIL_CMD_ELB)
458 EXPECT_LAST(HIL_CMD_ELB | HIL_ERR_INT, 509 EXPECT_LAST(HIL_CMD_ELB | HIL_ERR_INT,
459 20000, HILSEN_REPOLL, HILSEN_DSR, HILSEN_NEXT) 510 20000, HILSEN_REPOLL, HILSEN_DSR, HILSEN_NEXT)
460 FUNC(hilse_dec_ddi, 0, HILSEN_HEAL, HILSEN_NEXT, 0) 511 FUNC(hilse_dec_ddi, 0, HILSEN_HEAL, HILSEN_NEXT, 0)
461 512
@@ -503,7 +554,7 @@ struct hilse_node hil_mlc_se[HILSEN_END] = {
503 554
504 /* 44 HILSEN_PROBE */ 555 /* 44 HILSEN_PROBE */
505 OUT_LAST(HIL_PKT_CMD | HIL_CMD_EPT) 556 OUT_LAST(HIL_PKT_CMD | HIL_CMD_EPT)
506 IN(10000, HILSEN_DISC, HILSEN_DSR, HILSEN_NEXT) 557 IN(10000, HILSEN_DISC, HILSEN_DSR, HILSEN_NEXT)
507 OUT_DISC(HIL_PKT_CMD | HIL_CMD_ELB) 558 OUT_DISC(HIL_PKT_CMD | HIL_CMD_ELB)
508 IN(10000, HILSEN_DISC, HILSEN_DSR, HILSEN_NEXT) 559 IN(10000, HILSEN_DISC, HILSEN_DSR, HILSEN_NEXT)
509 OUT(HIL_PKT_CMD | HIL_CMD_ACF | 1) 560 OUT(HIL_PKT_CMD | HIL_CMD_ACF | 1)
@@ -514,7 +565,7 @@ struct hilse_node hil_mlc_se[HILSEN_END] = {
514 /* 52 HILSEN_DSR */ 565 /* 52 HILSEN_DSR */
515 FUNC(hilse_set_ddi, -1, HILSEN_NEXT, 0, 0) 566 FUNC(hilse_set_ddi, -1, HILSEN_NEXT, 0, 0)
516 OUT(HIL_PKT_CMD | HIL_CMD_DSR) 567 OUT(HIL_PKT_CMD | HIL_CMD_DSR)
517 IN(20000, HILSEN_DHR, HILSEN_DHR, HILSEN_IFC) 568 IN(20000, HILSEN_DHR, HILSEN_DHR, HILSEN_IFC)
518 569
519 /* 55 HILSEN_REPOLL */ 570 /* 55 HILSEN_REPOLL */
520 OUT(HIL_PKT_CMD | HIL_CMD_RPL) 571 OUT(HIL_PKT_CMD | HIL_CMD_RPL)
@@ -523,14 +574,15 @@ struct hilse_node hil_mlc_se[HILSEN_END] = {
523 FUNC(hilse_operate, 1, HILSEN_OPERATE, HILSEN_IFC, HILSEN_PROBE) 574 FUNC(hilse_operate, 1, HILSEN_OPERATE, HILSEN_IFC, HILSEN_PROBE)
524 575
525 /* 58 HILSEN_IFCACF */ 576 /* 58 HILSEN_IFCACF */
526 OUT(HIL_PKT_CMD | HIL_CMD_IFC) 577 OUT(HIL_PKT_CMD | HIL_CMD_IFC)
527 EXPECT(HIL_PKT_CMD | HIL_CMD_IFC | HIL_ERR_INT, 578 EXPECT(HIL_PKT_CMD | HIL_CMD_IFC | HIL_ERR_INT,
528 20000, HILSEN_ACF2, HILSEN_DHR2, HILSEN_HEAL) 579 20000, HILSEN_ACF2, HILSEN_DHR2, HILSEN_HEAL)
529 580
530 /* 60 HILSEN_END */ 581 /* 60 HILSEN_END */
531}; 582};
532 583
533static inline void hilse_setup_input(hil_mlc *mlc, struct hilse_node *node) { 584static inline void hilse_setup_input(hil_mlc *mlc, const struct hilse_node *node)
585{
534 586
535 switch (node->act) { 587 switch (node->act) {
536 case HILSE_EXPECT_DISC: 588 case HILSE_EXPECT_DISC:
@@ -555,29 +607,27 @@ static inline void hilse_setup_input(hil_mlc *mlc, struct hilse_node *node) {
555 do_gettimeofday(&(mlc->instart)); 607 do_gettimeofday(&(mlc->instart));
556 mlc->icount = 15; 608 mlc->icount = 15;
557 memset(mlc->ipacket, 0, 16 * sizeof(hil_packet)); 609 memset(mlc->ipacket, 0, 16 * sizeof(hil_packet));
558 BUG_ON(down_trylock(&(mlc->isem))); 610 BUG_ON(down_trylock(&mlc->isem));
559
560 return;
561} 611}
562 612
563#ifdef HIL_MLC_DEBUG 613#ifdef HIL_MLC_DEBUG
564static int doze = 0; 614static int doze;
565static int seidx; /* For debug */ 615static int seidx; /* For debug */
566static int kick = 1;
567#endif 616#endif
568 617
569static int hilse_donode (hil_mlc *mlc) { 618static int hilse_donode(hil_mlc *mlc)
570 struct hilse_node *node; 619{
620 const struct hilse_node *node;
571 int nextidx = 0; 621 int nextidx = 0;
572 int sched_long = 0; 622 int sched_long = 0;
573 unsigned long flags; 623 unsigned long flags;
574 624
575#ifdef HIL_MLC_DEBUG 625#ifdef HIL_MLC_DEBUG
576 if (mlc->seidx && (mlc->seidx != seidx) && mlc->seidx != 41 && mlc->seidx != 42 && mlc->seidx != 43) { 626 if (mlc->seidx && mlc->seidx != seidx &&
577 printk(KERN_DEBUG PREFIX "z%i \n%s {%i}", doze, kick ? "K" : "", mlc->seidx); 627 mlc->seidx != 41 && mlc->seidx != 42 && mlc->seidx != 43) {
628 printk(KERN_DEBUG PREFIX "z%i \n {%i}", doze, mlc->seidx);
578 doze = 0; 629 doze = 0;
579 } 630 }
580 kick = 0;
581 631
582 seidx = mlc->seidx; 632 seidx = mlc->seidx;
583#endif 633#endif
@@ -588,52 +638,61 @@ static int hilse_donode (hil_mlc *mlc) {
588 hil_packet pack; 638 hil_packet pack;
589 639
590 case HILSE_FUNC: 640 case HILSE_FUNC:
591 if (node->object.func == NULL) break; 641 BUG_ON(node->object.func == NULL);
592 rc = node->object.func(mlc, node->arg); 642 rc = node->object.func(mlc, node->arg);
593 nextidx = (rc > 0) ? node->ugly : 643 nextidx = (rc > 0) ? node->ugly :
594 ((rc < 0) ? node->bad : node->good); 644 ((rc < 0) ? node->bad : node->good);
595 if (nextidx == HILSEN_FOLLOW) nextidx = rc; 645 if (nextidx == HILSEN_FOLLOW)
646 nextidx = rc;
596 break; 647 break;
648
597 case HILSE_EXPECT_LAST: 649 case HILSE_EXPECT_LAST:
598 case HILSE_EXPECT_DISC: 650 case HILSE_EXPECT_DISC:
599 case HILSE_EXPECT: 651 case HILSE_EXPECT:
600 case HILSE_IN: 652 case HILSE_IN:
601 /* Already set up from previous HILSE_OUT_* */ 653 /* Already set up from previous HILSE_OUT_* */
602 write_lock_irqsave(&(mlc->lock), flags); 654 write_lock_irqsave(&mlc->lock, flags);
603 rc = mlc->in(mlc, node->arg); 655 rc = mlc->in(mlc, node->arg);
604 if (rc == 2) { 656 if (rc == 2) {
605 nextidx = HILSEN_DOZE; 657 nextidx = HILSEN_DOZE;
606 sched_long = 1; 658 sched_long = 1;
607 write_unlock_irqrestore(&(mlc->lock), flags); 659 write_unlock_irqrestore(&mlc->lock, flags);
608 break; 660 break;
609 } 661 }
610 if (rc == 1) nextidx = node->ugly; 662 if (rc == 1)
611 else if (rc == 0) nextidx = node->good; 663 nextidx = node->ugly;
612 else nextidx = node->bad; 664 else if (rc == 0)
665 nextidx = node->good;
666 else
667 nextidx = node->bad;
613 mlc->istarted = 0; 668 mlc->istarted = 0;
614 write_unlock_irqrestore(&(mlc->lock), flags); 669 write_unlock_irqrestore(&mlc->lock, flags);
615 break; 670 break;
671
616 case HILSE_OUT_LAST: 672 case HILSE_OUT_LAST:
617 write_lock_irqsave(&(mlc->lock), flags); 673 write_lock_irqsave(&mlc->lock, flags);
618 pack = node->object.packet; 674 pack = node->object.packet;
619 pack |= ((mlc->ddi + 1) << HIL_PKT_ADDR_SHIFT); 675 pack |= ((mlc->ddi + 1) << HIL_PKT_ADDR_SHIFT);
620 goto out; 676 goto out;
677
621 case HILSE_OUT_DISC: 678 case HILSE_OUT_DISC:
622 write_lock_irqsave(&(mlc->lock), flags); 679 write_lock_irqsave(&mlc->lock, flags);
623 pack = node->object.packet; 680 pack = node->object.packet;
624 pack |= ((mlc->ddi + 2) << HIL_PKT_ADDR_SHIFT); 681 pack |= ((mlc->ddi + 2) << HIL_PKT_ADDR_SHIFT);
625 goto out; 682 goto out;
683
626 case HILSE_OUT: 684 case HILSE_OUT:
627 write_lock_irqsave(&(mlc->lock), flags); 685 write_lock_irqsave(&mlc->lock, flags);
628 pack = node->object.packet; 686 pack = node->object.packet;
629 out: 687 out:
630 if (mlc->istarted) goto out2; 688 if (mlc->istarted)
689 goto out2;
631 /* Prepare to receive input */ 690 /* Prepare to receive input */
632 if ((node + 1)->act & HILSE_IN) 691 if ((node + 1)->act & HILSE_IN)
633 hilse_setup_input(mlc, node + 1); 692 hilse_setup_input(mlc, node + 1);
634 693
635 out2: 694 out2:
636 write_unlock_irqrestore(&(mlc->lock), flags); 695 write_unlock_irqrestore(&mlc->lock, flags);
637 696
638 if (down_trylock(&mlc->osem)) { 697 if (down_trylock(&mlc->osem)) {
639 nextidx = HILSEN_DOZE; 698 nextidx = HILSEN_DOZE;
@@ -641,60 +700,71 @@ static int hilse_donode (hil_mlc *mlc) {
641 } 700 }
642 up(&mlc->osem); 701 up(&mlc->osem);
643 702
644 write_lock_irqsave(&(mlc->lock), flags); 703 write_lock_irqsave(&mlc->lock, flags);
645 if (!(mlc->ostarted)) { 704 if (!mlc->ostarted) {
646 mlc->ostarted = 1; 705 mlc->ostarted = 1;
647 mlc->opacket = pack; 706 mlc->opacket = pack;
648 mlc->out(mlc); 707 mlc->out(mlc);
649 nextidx = HILSEN_DOZE; 708 nextidx = HILSEN_DOZE;
650 write_unlock_irqrestore(&(mlc->lock), flags); 709 write_unlock_irqrestore(&mlc->lock, flags);
651 break; 710 break;
652 } 711 }
653 mlc->ostarted = 0; 712 mlc->ostarted = 0;
654 do_gettimeofday(&(mlc->instart)); 713 do_gettimeofday(&(mlc->instart));
655 write_unlock_irqrestore(&(mlc->lock), flags); 714 write_unlock_irqrestore(&mlc->lock, flags);
656 nextidx = HILSEN_NEXT; 715 nextidx = HILSEN_NEXT;
657 break; 716 break;
717
658 case HILSE_CTS: 718 case HILSE_CTS:
719 write_lock_irqsave(&mlc->lock, flags);
659 nextidx = mlc->cts(mlc) ? node->bad : node->good; 720 nextidx = mlc->cts(mlc) ? node->bad : node->good;
721 write_unlock_irqrestore(&mlc->lock, flags);
660 break; 722 break;
723
661 default: 724 default:
662 BUG(); 725 BUG();
663 nextidx = 0;
664 break;
665 } 726 }
666 727
667#ifdef HIL_MLC_DEBUG 728#ifdef HIL_MLC_DEBUG
668 if (nextidx == HILSEN_DOZE) doze++; 729 if (nextidx == HILSEN_DOZE)
730 doze++;
669#endif 731#endif
670 732
671 while (nextidx & HILSEN_SCHED) { 733 while (nextidx & HILSEN_SCHED) {
672 struct timeval tv; 734 struct timeval tv;
673 735
674 if (!sched_long) goto sched; 736 if (!sched_long)
737 goto sched;
675 738
676 do_gettimeofday(&tv); 739 do_gettimeofday(&tv);
677 tv.tv_usec += 1000000 * (tv.tv_sec - mlc->instart.tv_sec); 740 tv.tv_usec += USEC_PER_SEC * (tv.tv_sec - mlc->instart.tv_sec);
678 tv.tv_usec -= mlc->instart.tv_usec; 741 tv.tv_usec -= mlc->instart.tv_usec;
679 if (tv.tv_usec >= mlc->intimeout) goto sched; 742 if (tv.tv_usec >= mlc->intimeout) goto sched;
680 tv.tv_usec = (mlc->intimeout - tv.tv_usec) * HZ / 1000000; 743 tv.tv_usec = (mlc->intimeout - tv.tv_usec) * HZ / USEC_PER_SEC;
681 if (!tv.tv_usec) goto sched; 744 if (!tv.tv_usec) goto sched;
682 mod_timer(&hil_mlcs_kicker, jiffies + tv.tv_usec); 745 mod_timer(&hil_mlcs_kicker, jiffies + tv.tv_usec);
683 break; 746 break;
684 sched: 747 sched:
685 tasklet_schedule(&hil_mlcs_tasklet); 748 tasklet_schedule(&hil_mlcs_tasklet);
686 break; 749 break;
687 } 750 }
688 if (nextidx & HILSEN_DOWN) mlc->seidx += nextidx & HILSEN_MASK; 751
689 else if (nextidx & HILSEN_UP) mlc->seidx -= nextidx & HILSEN_MASK; 752 if (nextidx & HILSEN_DOWN)
690 else mlc->seidx = nextidx & HILSEN_MASK; 753 mlc->seidx += nextidx & HILSEN_MASK;
754 else if (nextidx & HILSEN_UP)
755 mlc->seidx -= nextidx & HILSEN_MASK;
756 else
757 mlc->seidx = nextidx & HILSEN_MASK;
758
759 if (nextidx & HILSEN_BREAK)
760 return 1;
691 761
692 if (nextidx & HILSEN_BREAK) return 1;
693 return 0; 762 return 0;
694} 763}
695 764
696/******************** tasklet context functions **************************/ 765/******************** tasklet context functions **************************/
697static void hil_mlcs_process(unsigned long unused) { 766static void hil_mlcs_process(unsigned long unused)
767{
698 struct list_head *tmp; 768 struct list_head *tmp;
699 769
700 read_lock(&hil_mlcs_lock); 770 read_lock(&hil_mlcs_lock);
@@ -702,19 +772,20 @@ static void hil_mlcs_process(unsigned long unused) {
702 struct hil_mlc *mlc = list_entry(tmp, hil_mlc, list); 772 struct hil_mlc *mlc = list_entry(tmp, hil_mlc, list);
703 while (hilse_donode(mlc) == 0) { 773 while (hilse_donode(mlc) == 0) {
704#ifdef HIL_MLC_DEBUG 774#ifdef HIL_MLC_DEBUG
705 if (mlc->seidx != 41 && 775 if (mlc->seidx != 41 &&
706 mlc->seidx != 42 && 776 mlc->seidx != 42 &&
707 mlc->seidx != 43) 777 mlc->seidx != 43)
708 printk(KERN_DEBUG PREFIX " + "); 778 printk(KERN_DEBUG PREFIX " + ");
709#endif 779#endif
710 }; 780 }
711 } 781 }
712 read_unlock(&hil_mlcs_lock); 782 read_unlock(&hil_mlcs_lock);
713} 783}
714 784
715/************************* Keepalive timer task *********************/ 785/************************* Keepalive timer task *********************/
716 786
717void hil_mlcs_timer (unsigned long data) { 787void hil_mlcs_timer(unsigned long data)
788{
718 hil_mlcs_probe = 1; 789 hil_mlcs_probe = 1;
719 tasklet_schedule(&hil_mlcs_tasklet); 790 tasklet_schedule(&hil_mlcs_tasklet);
720 /* Re-insert the periodic task. */ 791 /* Re-insert the periodic task. */
@@ -724,28 +795,25 @@ void hil_mlcs_timer (unsigned long data) {
724 795
725/******************** user/kernel context functions **********************/ 796/******************** user/kernel context functions **********************/
726 797
727static int hil_mlc_serio_write(struct serio *serio, unsigned char c) { 798static int hil_mlc_serio_write(struct serio *serio, unsigned char c)
799{
728 struct hil_mlc_serio_map *map; 800 struct hil_mlc_serio_map *map;
729 struct hil_mlc *mlc; 801 struct hil_mlc *mlc;
730 struct serio_driver *drv; 802 struct serio_driver *drv;
731 uint8_t *idx, *last; 803 uint8_t *idx, *last;
732 804
733 map = serio->port_data; 805 map = serio->port_data;
734 if (map == NULL) { 806 BUG_ON(map == NULL);
735 BUG(); 807
736 return -EIO;
737 }
738 mlc = map->mlc; 808 mlc = map->mlc;
739 if (mlc == NULL) { 809 BUG_ON(mlc == NULL);
740 BUG(); 810
741 return -EIO; 811 mlc->serio_opacket[map->didx] |=
742 }
743 mlc->serio_opacket[map->didx] |=
744 ((hil_packet)c) << (8 * (3 - mlc->serio_oidx[map->didx])); 812 ((hil_packet)c) << (8 * (3 - mlc->serio_oidx[map->didx]));
745 813
746 if (mlc->serio_oidx[map->didx] >= 3) { 814 if (mlc->serio_oidx[map->didx] >= 3) {
747 /* for now only commands */ 815 /* for now only commands */
748 if (!(mlc->serio_opacket[map->didx] & HIL_PKT_CMD)) 816 if (!(mlc->serio_opacket[map->didx] & HIL_PKT_CMD))
749 return -EIO; 817 return -EIO;
750 switch (mlc->serio_opacket[map->didx] & HIL_PKT_DATA_MASK) { 818 switch (mlc->serio_opacket[map->didx] & HIL_PKT_DATA_MASK) {
751 case HIL_CMD_IDD: 819 case HIL_CMD_IDD:
@@ -771,12 +839,11 @@ static int hil_mlc_serio_write(struct serio *serio, unsigned char c) {
771 return -EIO; 839 return -EIO;
772 emu: 840 emu:
773 drv = serio->drv; 841 drv = serio->drv;
774 if (drv == NULL) { 842 BUG_ON(drv == NULL);
775 BUG(); 843
776 return -EIO;
777 }
778 last = idx + 15; 844 last = idx + 15;
779 while ((last != idx) && (*last == 0)) last--; 845 while ((last != idx) && (*last == 0))
846 last--;
780 847
781 while (idx != last) { 848 while (idx != last) {
782 drv->interrupt(serio, 0, 0); 849 drv->interrupt(serio, 0, 0);
@@ -789,14 +856,15 @@ static int hil_mlc_serio_write(struct serio *serio, unsigned char c) {
789 drv->interrupt(serio, HIL_ERR_INT >> 16, 0); 856 drv->interrupt(serio, HIL_ERR_INT >> 16, 0);
790 drv->interrupt(serio, HIL_PKT_CMD >> 8, 0); 857 drv->interrupt(serio, HIL_PKT_CMD >> 8, 0);
791 drv->interrupt(serio, *idx, 0); 858 drv->interrupt(serio, *idx, 0);
792 859
793 mlc->serio_oidx[map->didx] = 0; 860 mlc->serio_oidx[map->didx] = 0;
794 mlc->serio_opacket[map->didx] = 0; 861 mlc->serio_opacket[map->didx] = 0;
795 862
796 return 0; 863 return 0;
797} 864}
798 865
799static int hil_mlc_serio_open(struct serio *serio) { 866static int hil_mlc_serio_open(struct serio *serio)
867{
800 struct hil_mlc_serio_map *map; 868 struct hil_mlc_serio_map *map;
801 struct hil_mlc *mlc; 869 struct hil_mlc *mlc;
802 870
@@ -804,67 +872,57 @@ static int hil_mlc_serio_open(struct serio *serio) {
804 return -EBUSY; 872 return -EBUSY;
805 873
806 map = serio->port_data; 874 map = serio->port_data;
807 if (map == NULL) { 875 BUG_ON(map == NULL);
808 BUG(); 876
809 return -ENODEV;
810 }
811 mlc = map->mlc; 877 mlc = map->mlc;
812 if (mlc == NULL) { 878 BUG_ON(mlc == NULL);
813 BUG();
814 return -ENODEV;
815 }
816 879
817 return 0; 880 return 0;
818} 881}
819 882
820static void hil_mlc_serio_close(struct serio *serio) { 883static void hil_mlc_serio_close(struct serio *serio)
884{
821 struct hil_mlc_serio_map *map; 885 struct hil_mlc_serio_map *map;
822 struct hil_mlc *mlc; 886 struct hil_mlc *mlc;
823 887
824 map = serio->port_data; 888 map = serio->port_data;
825 if (map == NULL) { 889 BUG_ON(map == NULL);
826 BUG(); 890
827 return;
828 }
829 mlc = map->mlc; 891 mlc = map->mlc;
830 if (mlc == NULL) { 892 BUG_ON(mlc == NULL);
831 BUG();
832 return;
833 }
834 893
835 serio_set_drvdata(serio, NULL); 894 serio_set_drvdata(serio, NULL);
836 serio->drv = NULL; 895 serio->drv = NULL;
837 /* TODO wake up interruptable */ 896 /* TODO wake up interruptable */
838} 897}
839 898
840static struct serio_device_id hil_mlc_serio_id = { 899static const struct serio_device_id hil_mlc_serio_id = {
841 .type = SERIO_HIL_MLC, 900 .type = SERIO_HIL_MLC,
842 .proto = SERIO_HIL, 901 .proto = SERIO_HIL,
843 .extra = SERIO_ANY, 902 .extra = SERIO_ANY,
844 .id = SERIO_ANY, 903 .id = SERIO_ANY,
845}; 904};
846 905
847int hil_mlc_register(hil_mlc *mlc) { 906int hil_mlc_register(hil_mlc *mlc)
907{
848 int i; 908 int i;
849 unsigned long flags; 909 unsigned long flags;
850 910
851 if (mlc == NULL) { 911 BUG_ON(mlc == NULL);
852 return -EINVAL;
853 }
854 912
855 mlc->istarted = 0; 913 mlc->istarted = 0;
856 mlc->ostarted = 0; 914 mlc->ostarted = 0;
857 915
858 rwlock_init(&mlc->lock); 916 rwlock_init(&mlc->lock);
859 init_MUTEX(&(mlc->osem)); 917 init_MUTEX(&mlc->osem);
860 918
861 init_MUTEX(&(mlc->isem)); 919 init_MUTEX(&mlc->isem);
862 mlc->icount = -1; 920 mlc->icount = -1;
863 mlc->imatch = 0; 921 mlc->imatch = 0;
864 922
865 mlc->opercnt = 0; 923 mlc->opercnt = 0;
866 924
867 init_MUTEX_LOCKED(&(mlc->csem)); 925 init_MUTEX_LOCKED(&(mlc->csem));
868 926
869 hil_mlc_clear_di_scratch(mlc); 927 hil_mlc_clear_di_scratch(mlc);
870 hil_mlc_clear_di_map(mlc, 0); 928 hil_mlc_clear_di_map(mlc, 0);
@@ -873,6 +931,8 @@ int hil_mlc_register(hil_mlc *mlc) {
873 hil_mlc_copy_di_scratch(mlc, i); 931 hil_mlc_copy_di_scratch(mlc, i);
874 mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL); 932 mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL);
875 mlc->serio[i] = mlc_serio; 933 mlc->serio[i] = mlc_serio;
934 snprintf(mlc_serio->name, sizeof(mlc_serio->name)-1, "HIL_SERIO%d", i);
935 snprintf(mlc_serio->phys, sizeof(mlc_serio->phys)-1, "HIL%d", i);
876 mlc_serio->id = hil_mlc_serio_id; 936 mlc_serio->id = hil_mlc_serio_id;
877 mlc_serio->write = hil_mlc_serio_write; 937 mlc_serio->write = hil_mlc_serio_write;
878 mlc_serio->open = hil_mlc_serio_open; 938 mlc_serio->open = hil_mlc_serio_open;
@@ -897,19 +957,18 @@ int hil_mlc_register(hil_mlc *mlc) {
897 return 0; 957 return 0;
898} 958}
899 959
900int hil_mlc_unregister(hil_mlc *mlc) { 960int hil_mlc_unregister(hil_mlc *mlc)
961{
901 struct list_head *tmp; 962 struct list_head *tmp;
902 unsigned long flags; 963 unsigned long flags;
903 int i; 964 int i;
904 965
905 if (mlc == NULL) 966 BUG_ON(mlc == NULL);
906 return -EINVAL;
907 967
908 write_lock_irqsave(&hil_mlcs_lock, flags); 968 write_lock_irqsave(&hil_mlcs_lock, flags);
909 list_for_each(tmp, &hil_mlcs) { 969 list_for_each(tmp, &hil_mlcs)
910 if (list_entry(tmp, hil_mlc, list) == mlc) 970 if (list_entry(tmp, hil_mlc, list) == mlc)
911 goto found; 971 goto found;
912 }
913 972
914 /* not found in list */ 973 /* not found in list */
915 write_unlock_irqrestore(&hil_mlcs_lock, flags); 974 write_unlock_irqrestore(&hil_mlcs_lock, flags);
@@ -918,7 +977,7 @@ int hil_mlc_unregister(hil_mlc *mlc) {
918 977
919 found: 978 found:
920 list_del(tmp); 979 list_del(tmp);
921 write_unlock_irqrestore(&hil_mlcs_lock, flags); 980 write_unlock_irqrestore(&hil_mlcs_lock, flags);
922 981
923 for (i = 0; i < HIL_MLC_DEVMEM; i++) { 982 for (i = 0; i < HIL_MLC_DEVMEM; i++) {
924 serio_unregister_port(mlc->serio[i]); 983 serio_unregister_port(mlc->serio[i]);
@@ -942,7 +1001,7 @@ static int __init hil_mlc_init(void)
942 1001
943 return 0; 1002 return 0;
944} 1003}
945 1004
946static void __exit hil_mlc_exit(void) 1005static void __exit hil_mlc_exit(void)
947{ 1006{
948 del_timer(&hil_mlcs_kicker); 1007 del_timer(&hil_mlcs_kicker);
@@ -950,6 +1009,6 @@ static void __exit hil_mlc_exit(void)
950 tasklet_disable(&hil_mlcs_tasklet); 1009 tasklet_disable(&hil_mlcs_tasklet);
951 tasklet_kill(&hil_mlcs_tasklet); 1010 tasklet_kill(&hil_mlcs_tasklet);
952} 1011}
953 1012
954module_init(hil_mlc_init); 1013module_init(hil_mlc_init);
955module_exit(hil_mlc_exit); 1014module_exit(hil_mlc_exit);
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index b57370dc4e3d..6af199805ffc 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -34,27 +34,27 @@
34 * 34 *
35 * Driver theory of operation: 35 * Driver theory of operation:
36 * 36 *
37 * hp_sdc_put does all writing to the SDC. ISR can run on a different 37 * hp_sdc_put does all writing to the SDC. ISR can run on a different
38 * CPU than hp_sdc_put, but only one CPU runs hp_sdc_put at a time 38 * CPU than hp_sdc_put, but only one CPU runs hp_sdc_put at a time
39 * (it cannot really benefit from SMP anyway.) A tasket fit this perfectly. 39 * (it cannot really benefit from SMP anyway.) A tasket fit this perfectly.
40 * 40 *
41 * All data coming back from the SDC is sent via interrupt and can be read 41 * All data coming back from the SDC is sent via interrupt and can be read
42 * fully in the ISR, so there are no latency/throughput problems there. 42 * fully in the ISR, so there are no latency/throughput problems there.
43 * The problem is with output, due to the slow clock speed of the SDC 43 * The problem is with output, due to the slow clock speed of the SDC
44 * compared to the CPU. This should not be too horrible most of the time, 44 * compared to the CPU. This should not be too horrible most of the time,
45 * but if used with HIL devices that support the multibyte transfer command, 45 * but if used with HIL devices that support the multibyte transfer command,
46 * keeping outbound throughput flowing at the 6500KBps that the HIL is 46 * keeping outbound throughput flowing at the 6500KBps that the HIL is
47 * capable of is more than can be done at HZ=100. 47 * capable of is more than can be done at HZ=100.
48 * 48 *
49 * Busy polling for IBF clear wastes CPU cycles and bus cycles. hp_sdc.ibf 49 * Busy polling for IBF clear wastes CPU cycles and bus cycles. hp_sdc.ibf
50 * is set to 0 when the IBF flag in the status register has cleared. ISR 50 * is set to 0 when the IBF flag in the status register has cleared. ISR
51 * may do this, and may also access the parts of queued transactions related 51 * may do this, and may also access the parts of queued transactions related
52 * to reading data back from the SDC, but otherwise will not touch the 52 * to reading data back from the SDC, but otherwise will not touch the
53 * hp_sdc state. Whenever a register is written hp_sdc.ibf is set to 1. 53 * hp_sdc state. Whenever a register is written hp_sdc.ibf is set to 1.
54 * 54 *
55 * The i8042 write index and the values in the 4-byte input buffer 55 * The i8042 write index and the values in the 4-byte input buffer
56 * starting at 0x70 are kept track of in hp_sdc.wi, and .r7[], respectively, 56 * starting at 0x70 are kept track of in hp_sdc.wi, and .r7[], respectively,
57 * to minimize the amount of IO needed to the SDC. However these values 57 * to minimize the amount of IO needed to the SDC. However these values
58 * do not need to be locked since they are only ever accessed by hp_sdc_put. 58 * do not need to be locked since they are only ever accessed by hp_sdc_put.
59 * 59 *
60 * A timer task schedules the tasklet once per second just to make 60 * A timer task schedules the tasklet once per second just to make
@@ -100,39 +100,46 @@ EXPORT_SYMBOL(hp_sdc_release_timer_irq);
100EXPORT_SYMBOL(hp_sdc_release_hil_irq); 100EXPORT_SYMBOL(hp_sdc_release_hil_irq);
101EXPORT_SYMBOL(hp_sdc_release_cooked_irq); 101EXPORT_SYMBOL(hp_sdc_release_cooked_irq);
102 102
103EXPORT_SYMBOL(__hp_sdc_enqueue_transaction);
103EXPORT_SYMBOL(hp_sdc_enqueue_transaction); 104EXPORT_SYMBOL(hp_sdc_enqueue_transaction);
104EXPORT_SYMBOL(hp_sdc_dequeue_transaction); 105EXPORT_SYMBOL(hp_sdc_dequeue_transaction);
105 106
106static hp_i8042_sdc hp_sdc; /* All driver state is kept in here. */ 107static hp_i8042_sdc hp_sdc; /* All driver state is kept in here. */
107 108
108/*************** primitives for use in any context *********************/ 109/*************** primitives for use in any context *********************/
109static inline uint8_t hp_sdc_status_in8 (void) { 110static inline uint8_t hp_sdc_status_in8(void)
111{
110 uint8_t status; 112 uint8_t status;
111 unsigned long flags; 113 unsigned long flags;
112 114
113 write_lock_irqsave(&hp_sdc.ibf_lock, flags); 115 write_lock_irqsave(&hp_sdc.ibf_lock, flags);
114 status = sdc_readb(hp_sdc.status_io); 116 status = sdc_readb(hp_sdc.status_io);
115 if (!(status & HP_SDC_STATUS_IBF)) hp_sdc.ibf = 0; 117 if (!(status & HP_SDC_STATUS_IBF))
118 hp_sdc.ibf = 0;
116 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags); 119 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
117 120
118 return status; 121 return status;
119} 122}
120 123
121static inline uint8_t hp_sdc_data_in8 (void) { 124static inline uint8_t hp_sdc_data_in8(void)
122 return sdc_readb(hp_sdc.data_io); 125{
126 return sdc_readb(hp_sdc.data_io);
123} 127}
124 128
125static inline void hp_sdc_status_out8 (uint8_t val) { 129static inline void hp_sdc_status_out8(uint8_t val)
130{
126 unsigned long flags; 131 unsigned long flags;
127 132
128 write_lock_irqsave(&hp_sdc.ibf_lock, flags); 133 write_lock_irqsave(&hp_sdc.ibf_lock, flags);
129 hp_sdc.ibf = 1; 134 hp_sdc.ibf = 1;
130 if ((val & 0xf0) == 0xe0) hp_sdc.wi = 0xff; 135 if ((val & 0xf0) == 0xe0)
136 hp_sdc.wi = 0xff;
131 sdc_writeb(val, hp_sdc.status_io); 137 sdc_writeb(val, hp_sdc.status_io);
132 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags); 138 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
133} 139}
134 140
135static inline void hp_sdc_data_out8 (uint8_t val) { 141static inline void hp_sdc_data_out8(uint8_t val)
142{
136 unsigned long flags; 143 unsigned long flags;
137 144
138 write_lock_irqsave(&hp_sdc.ibf_lock, flags); 145 write_lock_irqsave(&hp_sdc.ibf_lock, flags);
@@ -141,11 +148,12 @@ static inline void hp_sdc_data_out8 (uint8_t val) {
141 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags); 148 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
142} 149}
143 150
144/* Care must be taken to only invoke hp_sdc_spin_ibf when 151/* Care must be taken to only invoke hp_sdc_spin_ibf when
145 * absolutely needed, or in rarely invoked subroutines. 152 * absolutely needed, or in rarely invoked subroutines.
146 * Not only does it waste CPU cycles, it also wastes bus cycles. 153 * Not only does it waste CPU cycles, it also wastes bus cycles.
147 */ 154 */
148static inline void hp_sdc_spin_ibf(void) { 155static inline void hp_sdc_spin_ibf(void)
156{
149 unsigned long flags; 157 unsigned long flags;
150 rwlock_t *lock; 158 rwlock_t *lock;
151 159
@@ -158,19 +166,21 @@ static inline void hp_sdc_spin_ibf(void) {
158 } 166 }
159 read_unlock(lock); 167 read_unlock(lock);
160 write_lock(lock); 168 write_lock(lock);
161 while (sdc_readb(hp_sdc.status_io) & HP_SDC_STATUS_IBF) {}; 169 while (sdc_readb(hp_sdc.status_io) & HP_SDC_STATUS_IBF)
170 { }
162 hp_sdc.ibf = 0; 171 hp_sdc.ibf = 0;
163 write_unlock_irqrestore(lock, flags); 172 write_unlock_irqrestore(lock, flags);
164} 173}
165 174
166 175
167/************************ Interrupt context functions ************************/ 176/************************ Interrupt context functions ************************/
168static void hp_sdc_take (int irq, void *dev_id, uint8_t status, uint8_t data) { 177static void hp_sdc_take(int irq, void *dev_id, uint8_t status, uint8_t data)
178{
169 hp_sdc_transaction *curr; 179 hp_sdc_transaction *curr;
170 180
171 read_lock(&hp_sdc.rtq_lock); 181 read_lock(&hp_sdc.rtq_lock);
172 if (hp_sdc.rcurr < 0) { 182 if (hp_sdc.rcurr < 0) {
173 read_unlock(&hp_sdc.rtq_lock); 183 read_unlock(&hp_sdc.rtq_lock);
174 return; 184 return;
175 } 185 }
176 curr = hp_sdc.tq[hp_sdc.rcurr]; 186 curr = hp_sdc.tq[hp_sdc.rcurr];
@@ -183,25 +193,27 @@ static void hp_sdc_take (int irq, void *dev_id, uint8_t status, uint8_t data) {
183 193
184 if (hp_sdc.rqty <= 0) { 194 if (hp_sdc.rqty <= 0) {
185 /* All data has been gathered. */ 195 /* All data has been gathered. */
186 if(curr->seq[curr->actidx] & HP_SDC_ACT_SEMAPHORE) { 196 if (curr->seq[curr->actidx] & HP_SDC_ACT_SEMAPHORE)
187 if (curr->act.semaphore) up(curr->act.semaphore); 197 if (curr->act.semaphore)
188 } 198 up(curr->act.semaphore);
189 if(curr->seq[curr->actidx] & HP_SDC_ACT_CALLBACK) { 199
200 if (curr->seq[curr->actidx] & HP_SDC_ACT_CALLBACK)
190 if (curr->act.irqhook) 201 if (curr->act.irqhook)
191 curr->act.irqhook(irq, dev_id, status, data); 202 curr->act.irqhook(irq, dev_id, status, data);
192 } 203
193 curr->actidx = curr->idx; 204 curr->actidx = curr->idx;
194 curr->idx++; 205 curr->idx++;
195 /* Return control of this transaction */ 206 /* Return control of this transaction */
196 write_lock(&hp_sdc.rtq_lock); 207 write_lock(&hp_sdc.rtq_lock);
197 hp_sdc.rcurr = -1; 208 hp_sdc.rcurr = -1;
198 hp_sdc.rqty = 0; 209 hp_sdc.rqty = 0;
199 write_unlock(&hp_sdc.rtq_lock); 210 write_unlock(&hp_sdc.rtq_lock);
200 tasklet_schedule(&hp_sdc.task); 211 tasklet_schedule(&hp_sdc.task);
201 } 212 }
202} 213}
203 214
204static irqreturn_t hp_sdc_isr(int irq, void *dev_id) { 215static irqreturn_t hp_sdc_isr(int irq, void *dev_id)
216{
205 uint8_t status, data; 217 uint8_t status, data;
206 218
207 status = hp_sdc_status_in8(); 219 status = hp_sdc_status_in8();
@@ -209,67 +221,74 @@ static irqreturn_t hp_sdc_isr(int irq, void *dev_id) {
209 data = hp_sdc_data_in8(); 221 data = hp_sdc_data_in8();
210 222
211 /* For now we are ignoring these until we get the SDC to behave. */ 223 /* For now we are ignoring these until we get the SDC to behave. */
212 if (((status & 0xf1) == 0x51) && data == 0x82) { 224 if (((status & 0xf1) == 0x51) && data == 0x82)
213 return IRQ_HANDLED; 225 return IRQ_HANDLED;
214 }
215 226
216 switch(status & HP_SDC_STATUS_IRQMASK) { 227 switch (status & HP_SDC_STATUS_IRQMASK) {
217 case 0: /* This case is not documented. */ 228 case 0: /* This case is not documented. */
218 break; 229 break;
219 case HP_SDC_STATUS_USERTIMER: 230
220 case HP_SDC_STATUS_PERIODIC: 231 case HP_SDC_STATUS_USERTIMER:
221 case HP_SDC_STATUS_TIMER: 232 case HP_SDC_STATUS_PERIODIC:
233 case HP_SDC_STATUS_TIMER:
222 read_lock(&hp_sdc.hook_lock); 234 read_lock(&hp_sdc.hook_lock);
223 if (hp_sdc.timer != NULL) 235 if (hp_sdc.timer != NULL)
224 hp_sdc.timer(irq, dev_id, status, data); 236 hp_sdc.timer(irq, dev_id, status, data);
225 read_unlock(&hp_sdc.hook_lock); 237 read_unlock(&hp_sdc.hook_lock);
226 break; 238 break;
227 case HP_SDC_STATUS_REG: 239
240 case HP_SDC_STATUS_REG:
228 hp_sdc_take(irq, dev_id, status, data); 241 hp_sdc_take(irq, dev_id, status, data);
229 break; 242 break;
230 case HP_SDC_STATUS_HILCMD: 243
231 case HP_SDC_STATUS_HILDATA: 244 case HP_SDC_STATUS_HILCMD:
245 case HP_SDC_STATUS_HILDATA:
232 read_lock(&hp_sdc.hook_lock); 246 read_lock(&hp_sdc.hook_lock);
233 if (hp_sdc.hil != NULL) 247 if (hp_sdc.hil != NULL)
234 hp_sdc.hil(irq, dev_id, status, data); 248 hp_sdc.hil(irq, dev_id, status, data);
235 read_unlock(&hp_sdc.hook_lock); 249 read_unlock(&hp_sdc.hook_lock);
236 break; 250 break;
237 case HP_SDC_STATUS_PUP: 251
252 case HP_SDC_STATUS_PUP:
238 read_lock(&hp_sdc.hook_lock); 253 read_lock(&hp_sdc.hook_lock);
239 if (hp_sdc.pup != NULL) 254 if (hp_sdc.pup != NULL)
240 hp_sdc.pup(irq, dev_id, status, data); 255 hp_sdc.pup(irq, dev_id, status, data);
241 else printk(KERN_INFO PREFIX "HP SDC reports successful PUP.\n"); 256 else
257 printk(KERN_INFO PREFIX "HP SDC reports successful PUP.\n");
242 read_unlock(&hp_sdc.hook_lock); 258 read_unlock(&hp_sdc.hook_lock);
243 break; 259 break;
244 default: 260
261 default:
245 read_lock(&hp_sdc.hook_lock); 262 read_lock(&hp_sdc.hook_lock);
246 if (hp_sdc.cooked != NULL) 263 if (hp_sdc.cooked != NULL)
247 hp_sdc.cooked(irq, dev_id, status, data); 264 hp_sdc.cooked(irq, dev_id, status, data);
248 read_unlock(&hp_sdc.hook_lock); 265 read_unlock(&hp_sdc.hook_lock);
249 break; 266 break;
250 } 267 }
268
251 return IRQ_HANDLED; 269 return IRQ_HANDLED;
252} 270}
253 271
254 272
255static irqreturn_t hp_sdc_nmisr(int irq, void *dev_id) { 273static irqreturn_t hp_sdc_nmisr(int irq, void *dev_id)
274{
256 int status; 275 int status;
257 276
258 status = hp_sdc_status_in8(); 277 status = hp_sdc_status_in8();
259 printk(KERN_WARNING PREFIX "NMI !\n"); 278 printk(KERN_WARNING PREFIX "NMI !\n");
260 279
261#if 0 280#if 0
262 if (status & HP_SDC_NMISTATUS_FHS) { 281 if (status & HP_SDC_NMISTATUS_FHS) {
263 read_lock(&hp_sdc.hook_lock); 282 read_lock(&hp_sdc.hook_lock);
264 if (hp_sdc.timer != NULL) 283 if (hp_sdc.timer != NULL)
265 hp_sdc.timer(irq, dev_id, status, 0); 284 hp_sdc.timer(irq, dev_id, status, 0);
266 read_unlock(&hp_sdc.hook_lock); 285 read_unlock(&hp_sdc.hook_lock);
267 } 286 } else {
268 else {
269 /* TODO: pass this on to the HIL handler, or do SAK here? */ 287 /* TODO: pass this on to the HIL handler, or do SAK here? */
270 printk(KERN_WARNING PREFIX "HIL NMI\n"); 288 printk(KERN_WARNING PREFIX "HIL NMI\n");
271 } 289 }
272#endif 290#endif
291
273 return IRQ_HANDLED; 292 return IRQ_HANDLED;
274} 293}
275 294
@@ -278,13 +297,17 @@ static irqreturn_t hp_sdc_nmisr(int irq, void *dev_id) {
278 297
279unsigned long hp_sdc_put(void); 298unsigned long hp_sdc_put(void);
280 299
281static void hp_sdc_tasklet(unsigned long foo) { 300static void hp_sdc_tasklet(unsigned long foo)
282 301{
283 write_lock_irq(&hp_sdc.rtq_lock); 302 write_lock_irq(&hp_sdc.rtq_lock);
303
284 if (hp_sdc.rcurr >= 0) { 304 if (hp_sdc.rcurr >= 0) {
285 struct timeval tv; 305 struct timeval tv;
306
286 do_gettimeofday(&tv); 307 do_gettimeofday(&tv);
287 if (tv.tv_sec > hp_sdc.rtv.tv_sec) tv.tv_usec += 1000000; 308 if (tv.tv_sec > hp_sdc.rtv.tv_sec)
309 tv.tv_usec += USEC_PER_SEC;
310
288 if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) { 311 if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) {
289 hp_sdc_transaction *curr; 312 hp_sdc_transaction *curr;
290 uint8_t tmp; 313 uint8_t tmp;
@@ -300,27 +323,29 @@ static void hp_sdc_tasklet(unsigned long foo) {
300 hp_sdc.rqty = 0; 323 hp_sdc.rqty = 0;
301 tmp = curr->seq[curr->actidx]; 324 tmp = curr->seq[curr->actidx];
302 curr->seq[curr->actidx] |= HP_SDC_ACT_DEAD; 325 curr->seq[curr->actidx] |= HP_SDC_ACT_DEAD;
303 if(tmp & HP_SDC_ACT_SEMAPHORE) { 326 if (tmp & HP_SDC_ACT_SEMAPHORE)
304 if (curr->act.semaphore) 327 if (curr->act.semaphore)
305 up(curr->act.semaphore); 328 up(curr->act.semaphore);
306 } 329
307 if(tmp & HP_SDC_ACT_CALLBACK) { 330 if (tmp & HP_SDC_ACT_CALLBACK) {
308 /* Note this means that irqhooks may be called 331 /* Note this means that irqhooks may be called
309 * in tasklet/bh context. 332 * in tasklet/bh context.
310 */ 333 */
311 if (curr->act.irqhook) 334 if (curr->act.irqhook)
312 curr->act.irqhook(0, NULL, 0, 0); 335 curr->act.irqhook(0, NULL, 0, 0);
313 } 336 }
337
314 curr->actidx = curr->idx; 338 curr->actidx = curr->idx;
315 curr->idx++; 339 curr->idx++;
316 hp_sdc.rcurr = -1; 340 hp_sdc.rcurr = -1;
317 } 341 }
318 } 342 }
319 write_unlock_irq(&hp_sdc.rtq_lock); 343 write_unlock_irq(&hp_sdc.rtq_lock);
320 hp_sdc_put(); 344 hp_sdc_put();
321} 345}
322 346
323unsigned long hp_sdc_put(void) { 347unsigned long hp_sdc_put(void)
348{
324 hp_sdc_transaction *curr; 349 hp_sdc_transaction *curr;
325 uint8_t act; 350 uint8_t act;
326 int idx, curridx; 351 int idx, curridx;
@@ -333,19 +358,24 @@ unsigned long hp_sdc_put(void) {
333 requires output, so we skip to the administrativa. */ 358 requires output, so we skip to the administrativa. */
334 if (hp_sdc.ibf) { 359 if (hp_sdc.ibf) {
335 hp_sdc_status_in8(); 360 hp_sdc_status_in8();
336 if (hp_sdc.ibf) goto finish; 361 if (hp_sdc.ibf)
362 goto finish;
337 } 363 }
338 364
339 anew: 365 anew:
340 /* See if we are in the middle of a sequence. */ 366 /* See if we are in the middle of a sequence. */
341 if (hp_sdc.wcurr < 0) hp_sdc.wcurr = 0; 367 if (hp_sdc.wcurr < 0)
368 hp_sdc.wcurr = 0;
342 read_lock_irq(&hp_sdc.rtq_lock); 369 read_lock_irq(&hp_sdc.rtq_lock);
343 if (hp_sdc.rcurr == hp_sdc.wcurr) hp_sdc.wcurr++; 370 if (hp_sdc.rcurr == hp_sdc.wcurr)
371 hp_sdc.wcurr++;
344 read_unlock_irq(&hp_sdc.rtq_lock); 372 read_unlock_irq(&hp_sdc.rtq_lock);
345 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) hp_sdc.wcurr = 0; 373 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
374 hp_sdc.wcurr = 0;
346 curridx = hp_sdc.wcurr; 375 curridx = hp_sdc.wcurr;
347 376
348 if (hp_sdc.tq[curridx] != NULL) goto start; 377 if (hp_sdc.tq[curridx] != NULL)
378 goto start;
349 379
350 while (++curridx != hp_sdc.wcurr) { 380 while (++curridx != hp_sdc.wcurr) {
351 if (curridx >= HP_SDC_QUEUE_LEN) { 381 if (curridx >= HP_SDC_QUEUE_LEN) {
@@ -358,7 +388,8 @@ unsigned long hp_sdc_put(void) {
358 continue; 388 continue;
359 } 389 }
360 read_unlock_irq(&hp_sdc.rtq_lock); 390 read_unlock_irq(&hp_sdc.rtq_lock);
361 if (hp_sdc.tq[curridx] != NULL) break; /* Found one. */ 391 if (hp_sdc.tq[curridx] != NULL)
392 break; /* Found one. */
362 } 393 }
363 if (curridx == hp_sdc.wcurr) { /* There's nothing queued to do. */ 394 if (curridx == hp_sdc.wcurr) { /* There's nothing queued to do. */
364 curridx = -1; 395 curridx = -1;
@@ -374,7 +405,8 @@ unsigned long hp_sdc_put(void) {
374 goto finish; 405 goto finish;
375 } 406 }
376 407
377 if (hp_sdc.wcurr == -1) goto done; 408 if (hp_sdc.wcurr == -1)
409 goto done;
378 410
379 curr = hp_sdc.tq[curridx]; 411 curr = hp_sdc.tq[curridx];
380 idx = curr->actidx; 412 idx = curr->actidx;
@@ -383,20 +415,23 @@ unsigned long hp_sdc_put(void) {
383 hp_sdc.tq[curridx] = NULL; 415 hp_sdc.tq[curridx] = NULL;
384 /* Interleave outbound data between the transactions. */ 416 /* Interleave outbound data between the transactions. */
385 hp_sdc.wcurr++; 417 hp_sdc.wcurr++;
386 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) hp_sdc.wcurr = 0; 418 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
387 goto finish; 419 hp_sdc.wcurr = 0;
420 goto finish;
388 } 421 }
389 422
390 act = curr->seq[idx]; 423 act = curr->seq[idx];
391 idx++; 424 idx++;
392 425
393 if (curr->idx >= curr->endidx) { 426 if (curr->idx >= curr->endidx) {
394 if (act & HP_SDC_ACT_DEALLOC) kfree(curr); 427 if (act & HP_SDC_ACT_DEALLOC)
428 kfree(curr);
395 hp_sdc.tq[curridx] = NULL; 429 hp_sdc.tq[curridx] = NULL;
396 /* Interleave outbound data between the transactions. */ 430 /* Interleave outbound data between the transactions. */
397 hp_sdc.wcurr++; 431 hp_sdc.wcurr++;
398 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) hp_sdc.wcurr = 0; 432 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
399 goto finish; 433 hp_sdc.wcurr = 0;
434 goto finish;
400 } 435 }
401 436
402 while (act & HP_SDC_ACT_PRECMD) { 437 while (act & HP_SDC_ACT_PRECMD) {
@@ -409,9 +444,10 @@ unsigned long hp_sdc_put(void) {
409 curr->idx++; 444 curr->idx++;
410 /* act finished? */ 445 /* act finished? */
411 if ((act & HP_SDC_ACT_DURING) == HP_SDC_ACT_PRECMD) 446 if ((act & HP_SDC_ACT_DURING) == HP_SDC_ACT_PRECMD)
412 goto actdone; 447 goto actdone;
413 /* skip quantity field if data-out sequence follows. */ 448 /* skip quantity field if data-out sequence follows. */
414 if (act & HP_SDC_ACT_DATAOUT) curr->idx++; 449 if (act & HP_SDC_ACT_DATAOUT)
450 curr->idx++;
415 goto finish; 451 goto finish;
416 } 452 }
417 if (act & HP_SDC_ACT_DATAOUT) { 453 if (act & HP_SDC_ACT_DATAOUT) {
@@ -423,15 +459,15 @@ unsigned long hp_sdc_put(void) {
423 hp_sdc_data_out8(curr->seq[curr->idx]); 459 hp_sdc_data_out8(curr->seq[curr->idx]);
424 curr->idx++; 460 curr->idx++;
425 /* act finished? */ 461 /* act finished? */
426 if ((curr->idx - idx >= qty) && 462 if (curr->idx - idx >= qty &&
427 ((act & HP_SDC_ACT_DURING) == HP_SDC_ACT_DATAOUT)) 463 (act & HP_SDC_ACT_DURING) == HP_SDC_ACT_DATAOUT)
428 goto actdone; 464 goto actdone;
429 goto finish; 465 goto finish;
430 } 466 }
431 idx += qty; 467 idx += qty;
432 act &= ~HP_SDC_ACT_DATAOUT; 468 act &= ~HP_SDC_ACT_DATAOUT;
433 } 469 } else
434 else while (act & HP_SDC_ACT_DATAREG) { 470 while (act & HP_SDC_ACT_DATAREG) {
435 int mask; 471 int mask;
436 uint8_t w7[4]; 472 uint8_t w7[4];
437 473
@@ -445,26 +481,30 @@ unsigned long hp_sdc_put(void) {
445 act &= ~HP_SDC_ACT_DATAREG; 481 act &= ~HP_SDC_ACT_DATAREG;
446 break; 482 break;
447 } 483 }
448 484
449 w7[0] = (mask & 1) ? curr->seq[++idx] : hp_sdc.r7[0]; 485 w7[0] = (mask & 1) ? curr->seq[++idx] : hp_sdc.r7[0];
450 w7[1] = (mask & 2) ? curr->seq[++idx] : hp_sdc.r7[1]; 486 w7[1] = (mask & 2) ? curr->seq[++idx] : hp_sdc.r7[1];
451 w7[2] = (mask & 4) ? curr->seq[++idx] : hp_sdc.r7[2]; 487 w7[2] = (mask & 4) ? curr->seq[++idx] : hp_sdc.r7[2];
452 w7[3] = (mask & 8) ? curr->seq[++idx] : hp_sdc.r7[3]; 488 w7[3] = (mask & 8) ? curr->seq[++idx] : hp_sdc.r7[3];
453 489
454 if (hp_sdc.wi > 0x73 || hp_sdc.wi < 0x70 || 490 if (hp_sdc.wi > 0x73 || hp_sdc.wi < 0x70 ||
455 w7[hp_sdc.wi-0x70] == hp_sdc.r7[hp_sdc.wi-0x70]) { 491 w7[hp_sdc.wi - 0x70] == hp_sdc.r7[hp_sdc.wi - 0x70]) {
456 int i = 0; 492 int i = 0;
457 493
458 /* Need to point the write index register */ 494 /* Need to point the write index register */
459 while ((i < 4) && w7[i] == hp_sdc.r7[i]) i++; 495 while (i < 4 && w7[i] == hp_sdc.r7[i])
496 i++;
497
460 if (i < 4) { 498 if (i < 4) {
461 hp_sdc_status_out8(HP_SDC_CMD_SET_D0 + i); 499 hp_sdc_status_out8(HP_SDC_CMD_SET_D0 + i);
462 hp_sdc.wi = 0x70 + i; 500 hp_sdc.wi = 0x70 + i;
463 goto finish; 501 goto finish;
464 } 502 }
503
465 idx++; 504 idx++;
466 if ((act & HP_SDC_ACT_DURING) == HP_SDC_ACT_DATAREG) 505 if ((act & HP_SDC_ACT_DURING) == HP_SDC_ACT_DATAREG)
467 goto actdone; 506 goto actdone;
507
468 curr->idx = idx; 508 curr->idx = idx;
469 act &= ~HP_SDC_ACT_DATAREG; 509 act &= ~HP_SDC_ACT_DATAREG;
470 break; 510 break;
@@ -476,12 +516,13 @@ unsigned long hp_sdc_put(void) {
476 { 516 {
477 int i = 0; 517 int i = 0;
478 518
479 while ((i < 4) && w7[i] == hp_sdc.r7[i]) i++; 519 while ((i < 4) && w7[i] == hp_sdc.r7[i])
520 i++;
480 if (i >= 4) { 521 if (i >= 4) {
481 curr->idx = idx + 1; 522 curr->idx = idx + 1;
482 if ((act & HP_SDC_ACT_DURING) == 523 if ((act & HP_SDC_ACT_DURING) ==
483 HP_SDC_ACT_DATAREG) 524 HP_SDC_ACT_DATAREG)
484 goto actdone; 525 goto actdone;
485 } 526 }
486 } 527 }
487 goto finish; 528 goto finish;
@@ -497,7 +538,7 @@ unsigned long hp_sdc_put(void) {
497 538
498 539
499 if (act & HP_SDC_ACT_POSTCMD) { 540 if (act & HP_SDC_ACT_POSTCMD) {
500 uint8_t postcmd; 541 uint8_t postcmd;
501 542
502 /* curr->idx should == idx at this point. */ 543 /* curr->idx should == idx at this point. */
503 postcmd = curr->seq[idx]; 544 postcmd = curr->seq[idx];
@@ -505,12 +546,12 @@ unsigned long hp_sdc_put(void) {
505 if (act & HP_SDC_ACT_DATAIN) { 546 if (act & HP_SDC_ACT_DATAIN) {
506 547
507 /* Start a new read */ 548 /* Start a new read */
508 hp_sdc.rqty = curr->seq[curr->idx]; 549 hp_sdc.rqty = curr->seq[curr->idx];
509 do_gettimeofday(&hp_sdc.rtv); 550 do_gettimeofday(&hp_sdc.rtv);
510 curr->idx++; 551 curr->idx++;
511 /* Still need to lock here in case of spurious irq. */ 552 /* Still need to lock here in case of spurious irq. */
512 write_lock_irq(&hp_sdc.rtq_lock); 553 write_lock_irq(&hp_sdc.rtq_lock);
513 hp_sdc.rcurr = curridx; 554 hp_sdc.rcurr = curridx;
514 write_unlock_irq(&hp_sdc.rtq_lock); 555 write_unlock_irq(&hp_sdc.rtq_lock);
515 hp_sdc_status_out8(postcmd); 556 hp_sdc_status_out8(postcmd);
516 goto finish; 557 goto finish;
@@ -519,75 +560,86 @@ unsigned long hp_sdc_put(void) {
519 goto actdone; 560 goto actdone;
520 } 561 }
521 562
522actdone: 563 actdone:
523 if (act & HP_SDC_ACT_SEMAPHORE) { 564 if (act & HP_SDC_ACT_SEMAPHORE)
524 up(curr->act.semaphore); 565 up(curr->act.semaphore);
525 } 566 else if (act & HP_SDC_ACT_CALLBACK)
526 else if (act & HP_SDC_ACT_CALLBACK) {
527 curr->act.irqhook(0,NULL,0,0); 567 curr->act.irqhook(0,NULL,0,0);
528 } 568
529 if (curr->idx >= curr->endidx) { /* This transaction is over. */ 569 if (curr->idx >= curr->endidx) { /* This transaction is over. */
530 if (act & HP_SDC_ACT_DEALLOC) kfree(curr); 570 if (act & HP_SDC_ACT_DEALLOC)
571 kfree(curr);
531 hp_sdc.tq[curridx] = NULL; 572 hp_sdc.tq[curridx] = NULL;
532 } 573 } else {
533 else {
534 curr->actidx = idx + 1; 574 curr->actidx = idx + 1;
535 curr->idx = idx + 2; 575 curr->idx = idx + 2;
536 } 576 }
537 /* Interleave outbound data between the transactions. */ 577 /* Interleave outbound data between the transactions. */
538 hp_sdc.wcurr++; 578 hp_sdc.wcurr++;
539 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) hp_sdc.wcurr = 0; 579 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
580 hp_sdc.wcurr = 0;
540 581
541 finish: 582 finish:
542 /* If by some quirk IBF has cleared and our ISR has run to 583 /* If by some quirk IBF has cleared and our ISR has run to
543 see that that has happened, do it all again. */ 584 see that that has happened, do it all again. */
544 if (!hp_sdc.ibf && limit++ < 20) goto anew; 585 if (!hp_sdc.ibf && limit++ < 20)
586 goto anew;
545 587
546 done: 588 done:
547 if (hp_sdc.wcurr >= 0) tasklet_schedule(&hp_sdc.task); 589 if (hp_sdc.wcurr >= 0)
590 tasklet_schedule(&hp_sdc.task);
548 write_unlock(&hp_sdc.lock); 591 write_unlock(&hp_sdc.lock);
592
549 return 0; 593 return 0;
550} 594}
551 595
552/******* Functions called in either user or kernel context ****/ 596/******* Functions called in either user or kernel context ****/
553int hp_sdc_enqueue_transaction(hp_sdc_transaction *this) { 597int __hp_sdc_enqueue_transaction(hp_sdc_transaction *this)
554 unsigned long flags; 598{
555 int i; 599 int i;
556 600
557 if (this == NULL) { 601 if (this == NULL) {
558 tasklet_schedule(&hp_sdc.task); 602 BUG();
559 return -EINVAL; 603 return -EINVAL;
560 }; 604 }
561
562 write_lock_irqsave(&hp_sdc.lock, flags);
563 605
564 /* Can't have same transaction on queue twice */ 606 /* Can't have same transaction on queue twice */
565 for (i=0; i < HP_SDC_QUEUE_LEN; i++) 607 for (i = 0; i < HP_SDC_QUEUE_LEN; i++)
566 if (hp_sdc.tq[i] == this) goto fail; 608 if (hp_sdc.tq[i] == this)
609 goto fail;
567 610
568 this->actidx = 0; 611 this->actidx = 0;
569 this->idx = 1; 612 this->idx = 1;
570 613
571 /* Search for empty slot */ 614 /* Search for empty slot */
572 for (i=0; i < HP_SDC_QUEUE_LEN; i++) { 615 for (i = 0; i < HP_SDC_QUEUE_LEN; i++)
573 if (hp_sdc.tq[i] == NULL) { 616 if (hp_sdc.tq[i] == NULL) {
574 hp_sdc.tq[i] = this; 617 hp_sdc.tq[i] = this;
575 write_unlock_irqrestore(&hp_sdc.lock, flags);
576 tasklet_schedule(&hp_sdc.task); 618 tasklet_schedule(&hp_sdc.task);
577 return 0; 619 return 0;
578 } 620 }
579 } 621
580 write_unlock_irqrestore(&hp_sdc.lock, flags);
581 printk(KERN_WARNING PREFIX "No free slot to add transaction.\n"); 622 printk(KERN_WARNING PREFIX "No free slot to add transaction.\n");
582 return -EBUSY; 623 return -EBUSY;
583 624
584 fail: 625 fail:
585 write_unlock_irqrestore(&hp_sdc.lock,flags);
586 printk(KERN_WARNING PREFIX "Transaction add failed: transaction already queued?\n"); 626 printk(KERN_WARNING PREFIX "Transaction add failed: transaction already queued?\n");
587 return -EINVAL; 627 return -EINVAL;
588} 628}
589 629
590int hp_sdc_dequeue_transaction(hp_sdc_transaction *this) { 630int hp_sdc_enqueue_transaction(hp_sdc_transaction *this) {
631 unsigned long flags;
632 int ret;
633
634 write_lock_irqsave(&hp_sdc.lock, flags);
635 ret = __hp_sdc_enqueue_transaction(this);
636 write_unlock_irqrestore(&hp_sdc.lock,flags);
637
638 return ret;
639}
640
641int hp_sdc_dequeue_transaction(hp_sdc_transaction *this)
642{
591 unsigned long flags; 643 unsigned long flags;
592 int i; 644 int i;
593 645
@@ -595,8 +647,9 @@ int hp_sdc_dequeue_transaction(hp_sdc_transaction *this) {
595 647
596 /* TODO: don't remove it if it's not done. */ 648 /* TODO: don't remove it if it's not done. */
597 649
598 for (i=0; i < HP_SDC_QUEUE_LEN; i++) 650 for (i = 0; i < HP_SDC_QUEUE_LEN; i++)
599 if (hp_sdc.tq[i] == this) hp_sdc.tq[i] = NULL; 651 if (hp_sdc.tq[i] == this)
652 hp_sdc.tq[i] = NULL;
600 653
601 write_unlock_irqrestore(&hp_sdc.lock, flags); 654 write_unlock_irqrestore(&hp_sdc.lock, flags);
602 return 0; 655 return 0;
@@ -605,11 +658,11 @@ int hp_sdc_dequeue_transaction(hp_sdc_transaction *this) {
605 658
606 659
607/********************** User context functions **************************/ 660/********************** User context functions **************************/
608int hp_sdc_request_timer_irq(hp_sdc_irqhook *callback) { 661int hp_sdc_request_timer_irq(hp_sdc_irqhook *callback)
609 662{
610 if (callback == NULL || hp_sdc.dev == NULL) { 663 if (callback == NULL || hp_sdc.dev == NULL)
611 return -EINVAL; 664 return -EINVAL;
612 } 665
613 write_lock_irq(&hp_sdc.hook_lock); 666 write_lock_irq(&hp_sdc.hook_lock);
614 if (hp_sdc.timer != NULL) { 667 if (hp_sdc.timer != NULL) {
615 write_unlock_irq(&hp_sdc.hook_lock); 668 write_unlock_irq(&hp_sdc.hook_lock);
@@ -629,11 +682,11 @@ int hp_sdc_request_timer_irq(hp_sdc_irqhook *callback) {
629 return 0; 682 return 0;
630} 683}
631 684
632int hp_sdc_request_hil_irq(hp_sdc_irqhook *callback) { 685int hp_sdc_request_hil_irq(hp_sdc_irqhook *callback)
633 686{
634 if (callback == NULL || hp_sdc.dev == NULL) { 687 if (callback == NULL || hp_sdc.dev == NULL)
635 return -EINVAL; 688 return -EINVAL;
636 } 689
637 write_lock_irq(&hp_sdc.hook_lock); 690 write_lock_irq(&hp_sdc.hook_lock);
638 if (hp_sdc.hil != NULL) { 691 if (hp_sdc.hil != NULL) {
639 write_unlock_irq(&hp_sdc.hook_lock); 692 write_unlock_irq(&hp_sdc.hook_lock);
@@ -650,11 +703,11 @@ int hp_sdc_request_hil_irq(hp_sdc_irqhook *callback) {
650 return 0; 703 return 0;
651} 704}
652 705
653int hp_sdc_request_cooked_irq(hp_sdc_irqhook *callback) { 706int hp_sdc_request_cooked_irq(hp_sdc_irqhook *callback)
654 707{
655 if (callback == NULL || hp_sdc.dev == NULL) { 708 if (callback == NULL || hp_sdc.dev == NULL)
656 return -EINVAL; 709 return -EINVAL;
657 } 710
658 write_lock_irq(&hp_sdc.hook_lock); 711 write_lock_irq(&hp_sdc.hook_lock);
659 if (hp_sdc.cooked != NULL) { 712 if (hp_sdc.cooked != NULL) {
660 write_unlock_irq(&hp_sdc.hook_lock); 713 write_unlock_irq(&hp_sdc.hook_lock);
@@ -672,9 +725,8 @@ int hp_sdc_request_cooked_irq(hp_sdc_irqhook *callback) {
672 return 0; 725 return 0;
673} 726}
674 727
675int hp_sdc_release_timer_irq(hp_sdc_irqhook *callback) { 728int hp_sdc_release_timer_irq(hp_sdc_irqhook *callback)
676 729{
677
678 write_lock_irq(&hp_sdc.hook_lock); 730 write_lock_irq(&hp_sdc.hook_lock);
679 if ((callback != hp_sdc.timer) || 731 if ((callback != hp_sdc.timer) ||
680 (hp_sdc.timer == NULL)) { 732 (hp_sdc.timer == NULL)) {
@@ -694,8 +746,8 @@ int hp_sdc_release_timer_irq(hp_sdc_irqhook *callback) {
694 return 0; 746 return 0;
695} 747}
696 748
697int hp_sdc_release_hil_irq(hp_sdc_irqhook *callback) { 749int hp_sdc_release_hil_irq(hp_sdc_irqhook *callback)
698 750{
699 write_lock_irq(&hp_sdc.hook_lock); 751 write_lock_irq(&hp_sdc.hook_lock);
700 if ((callback != hp_sdc.hil) || 752 if ((callback != hp_sdc.hil) ||
701 (hp_sdc.hil == NULL)) { 753 (hp_sdc.hil == NULL)) {
@@ -715,8 +767,8 @@ int hp_sdc_release_hil_irq(hp_sdc_irqhook *callback) {
715 return 0; 767 return 0;
716} 768}
717 769
718int hp_sdc_release_cooked_irq(hp_sdc_irqhook *callback) { 770int hp_sdc_release_cooked_irq(hp_sdc_irqhook *callback)
719 771{
720 write_lock_irq(&hp_sdc.hook_lock); 772 write_lock_irq(&hp_sdc.hook_lock);
721 if ((callback != hp_sdc.cooked) || 773 if ((callback != hp_sdc.cooked) ||
722 (hp_sdc.cooked == NULL)) { 774 (hp_sdc.cooked == NULL)) {
@@ -738,7 +790,8 @@ int hp_sdc_release_cooked_irq(hp_sdc_irqhook *callback) {
738 790
739/************************* Keepalive timer task *********************/ 791/************************* Keepalive timer task *********************/
740 792
741void hp_sdc_kicker (unsigned long data) { 793void hp_sdc_kicker (unsigned long data)
794{
742 tasklet_schedule(&hp_sdc.task); 795 tasklet_schedule(&hp_sdc.task);
743 /* Re-insert the periodic task. */ 796 /* Re-insert the periodic task. */
744 mod_timer(&hp_sdc.kicker, jiffies + HZ); 797 mod_timer(&hp_sdc.kicker, jiffies + HZ);
@@ -748,12 +801,12 @@ void hp_sdc_kicker (unsigned long data) {
748 801
749#if defined(__hppa__) 802#if defined(__hppa__)
750 803
751static struct parisc_device_id hp_sdc_tbl[] = { 804static const struct parisc_device_id hp_sdc_tbl[] = {
752 { 805 {
753 .hw_type = HPHW_FIO, 806 .hw_type = HPHW_FIO,
754 .hversion_rev = HVERSION_REV_ANY_ID, 807 .hversion_rev = HVERSION_REV_ANY_ID,
755 .hversion = HVERSION_ANY_ID, 808 .hversion = HVERSION_ANY_ID,
756 .sversion = 0x73, 809 .sversion = 0x73,
757 }, 810 },
758 { 0, } 811 { 0, }
759}; 812};
@@ -772,16 +825,15 @@ static struct parisc_driver hp_sdc_driver = {
772 825
773static int __init hp_sdc_init(void) 826static int __init hp_sdc_init(void)
774{ 827{
775 int i;
776 char *errstr; 828 char *errstr;
777 hp_sdc_transaction t_sync; 829 hp_sdc_transaction t_sync;
778 uint8_t ts_sync[6]; 830 uint8_t ts_sync[6];
779 struct semaphore s_sync; 831 struct semaphore s_sync;
780 832
781 rwlock_init(&hp_sdc.lock); 833 rwlock_init(&hp_sdc.lock);
782 rwlock_init(&hp_sdc.ibf_lock); 834 rwlock_init(&hp_sdc.ibf_lock);
783 rwlock_init(&hp_sdc.rtq_lock); 835 rwlock_init(&hp_sdc.rtq_lock);
784 rwlock_init(&hp_sdc.hook_lock); 836 rwlock_init(&hp_sdc.hook_lock);
785 837
786 hp_sdc.timer = NULL; 838 hp_sdc.timer = NULL;
787 hp_sdc.hil = NULL; 839 hp_sdc.hil = NULL;
@@ -796,7 +848,8 @@ static int __init hp_sdc_init(void)
796 hp_sdc.r7[3] = 0xff; 848 hp_sdc.r7[3] = 0xff;
797 hp_sdc.ibf = 1; 849 hp_sdc.ibf = 1;
798 850
799 for (i = 0; i < HP_SDC_QUEUE_LEN; i++) hp_sdc.tq[i] = NULL; 851 memset(&hp_sdc.tq, 0, sizeof(hp_sdc.tq));
852
800 hp_sdc.wcurr = -1; 853 hp_sdc.wcurr = -1;
801 hp_sdc.rcurr = -1; 854 hp_sdc.rcurr = -1;
802 hp_sdc.rqty = 0; 855 hp_sdc.rqty = 0;
@@ -804,27 +857,32 @@ static int __init hp_sdc_init(void)
804 hp_sdc.dev_err = -ENODEV; 857 hp_sdc.dev_err = -ENODEV;
805 858
806 errstr = "IO not found for"; 859 errstr = "IO not found for";
807 if (!hp_sdc.base_io) goto err0; 860 if (!hp_sdc.base_io)
861 goto err0;
808 862
809 errstr = "IRQ not found for"; 863 errstr = "IRQ not found for";
810 if (!hp_sdc.irq) goto err0; 864 if (!hp_sdc.irq)
865 goto err0;
811 866
812 hp_sdc.dev_err = -EBUSY; 867 hp_sdc.dev_err = -EBUSY;
813 868
814#if defined(__hppa__) 869#if defined(__hppa__)
815 errstr = "IO not available for"; 870 errstr = "IO not available for";
816 if (request_region(hp_sdc.data_io, 2, hp_sdc_driver.name)) goto err0; 871 if (request_region(hp_sdc.data_io, 2, hp_sdc_driver.name))
817#endif 872 goto err0;
873#endif
818 874
819 errstr = "IRQ not available for"; 875 errstr = "IRQ not available for";
820 if(request_irq(hp_sdc.irq, &hp_sdc_isr, 0, "HP SDC", 876 if (request_irq(hp_sdc.irq, &hp_sdc_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM,
821 (void *) hp_sdc.base_io)) goto err1; 877 "HP SDC", &hp_sdc))
878 goto err1;
822 879
823 errstr = "NMI not available for"; 880 errstr = "NMI not available for";
824 if (request_irq(hp_sdc.nmi, &hp_sdc_nmisr, 0, "HP SDC NMI", 881 if (request_irq(hp_sdc.nmi, &hp_sdc_nmisr, IRQF_SHARED,
825 (void *) hp_sdc.base_io)) goto err2; 882 "HP SDC NMI", &hp_sdc))
883 goto err2;
826 884
827 printk(KERN_INFO PREFIX "HP SDC at 0x%p, IRQ %d (NMI IRQ %d)\n", 885 printk(KERN_INFO PREFIX "HP SDC at 0x%p, IRQ %d (NMI IRQ %d)\n",
828 (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi); 886 (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi);
829 887
830 hp_sdc_status_in8(); 888 hp_sdc_status_in8();
@@ -854,13 +912,14 @@ static int __init hp_sdc_init(void)
854 hp_sdc.dev_err = 0; 912 hp_sdc.dev_err = 0;
855 return 0; 913 return 0;
856 err2: 914 err2:
857 free_irq(hp_sdc.irq, NULL); 915 free_irq(hp_sdc.irq, &hp_sdc);
858 err1: 916 err1:
859 release_region(hp_sdc.data_io, 2); 917 release_region(hp_sdc.data_io, 2);
860 err0: 918 err0:
861 printk(KERN_WARNING PREFIX ": %s SDC IO=0x%p IRQ=0x%x NMI=0x%x\n", 919 printk(KERN_WARNING PREFIX ": %s SDC IO=0x%p IRQ=0x%x NMI=0x%x\n",
862 errstr, (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi); 920 errstr, (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi);
863 hp_sdc.dev = NULL; 921 hp_sdc.dev = NULL;
922
864 return hp_sdc.dev_err; 923 return hp_sdc.dev_err;
865} 924}
866 925
@@ -868,8 +927,10 @@ static int __init hp_sdc_init(void)
868 927
869static int __init hp_sdc_init_hppa(struct parisc_device *d) 928static int __init hp_sdc_init_hppa(struct parisc_device *d)
870{ 929{
871 if (!d) return 1; 930 if (!d)
872 if (hp_sdc.dev != NULL) return 1; /* We only expect one SDC */ 931 return 1;
932 if (hp_sdc.dev != NULL)
933 return 1; /* We only expect one SDC */
873 934
874 hp_sdc.dev = d; 935 hp_sdc.dev = d;
875 hp_sdc.irq = d->irq; 936 hp_sdc.irq = d->irq;
@@ -898,18 +959,16 @@ static void hp_sdc_exit(void)
898 /* Wait until we know this has been processed by the i8042 */ 959 /* Wait until we know this has been processed by the i8042 */
899 hp_sdc_spin_ibf(); 960 hp_sdc_spin_ibf();
900 961
901 free_irq(hp_sdc.nmi, NULL); 962 free_irq(hp_sdc.nmi, &hp_sdc);
902 free_irq(hp_sdc.irq, NULL); 963 free_irq(hp_sdc.irq, &hp_sdc);
903 write_unlock_irq(&hp_sdc.lock); 964 write_unlock_irq(&hp_sdc.lock);
904 965
905 del_timer(&hp_sdc.kicker); 966 del_timer(&hp_sdc.kicker);
906 967
907 tasklet_kill(&hp_sdc.task); 968 tasklet_kill(&hp_sdc.task);
908 969
909/* release_region(hp_sdc.data_io, 2); */
910
911#if defined(__hppa__) 970#if defined(__hppa__)
912 if (unregister_parisc_driver(&hp_sdc_driver)) 971 if (unregister_parisc_driver(&hp_sdc_driver))
913 printk(KERN_WARNING PREFIX "Error unregistering HP SDC"); 972 printk(KERN_WARNING PREFIX "Error unregistering HP SDC");
914#endif 973#endif
915} 974}
@@ -923,7 +982,7 @@ static int __init hp_sdc_register(void)
923 mm_segment_t fs; 982 mm_segment_t fs;
924 unsigned char i; 983 unsigned char i;
925#endif 984#endif
926 985
927 hp_sdc.dev = NULL; 986 hp_sdc.dev = NULL;
928 hp_sdc.dev_err = 0; 987 hp_sdc.dev_err = 0;
929#if defined(__hppa__) 988#if defined(__hppa__)
@@ -960,8 +1019,8 @@ static int __init hp_sdc_register(void)
960 tq_init.seq = tq_init_seq; 1019 tq_init.seq = tq_init_seq;
961 tq_init.act.semaphore = &tq_init_sem; 1020 tq_init.act.semaphore = &tq_init_sem;
962 1021
963 tq_init_seq[0] = 1022 tq_init_seq[0] =
964 HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE; 1023 HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE;
965 tq_init_seq[1] = HP_SDC_CMD_READ_KCC; 1024 tq_init_seq[1] = HP_SDC_CMD_READ_KCC;
966 tq_init_seq[2] = 1; 1025 tq_init_seq[2] = 1;
967 tq_init_seq[3] = 0; 1026 tq_init_seq[3] = 0;
@@ -979,13 +1038,13 @@ static int __init hp_sdc_register(void)
979 } 1038 }
980 hp_sdc.r11 = tq_init_seq[4]; 1039 hp_sdc.r11 = tq_init_seq[4];
981 if (hp_sdc.r11 & HP_SDC_CFG_NEW) { 1040 if (hp_sdc.r11 & HP_SDC_CFG_NEW) {
982 char *str; 1041 const char *str;
983 printk(KERN_INFO PREFIX "New style SDC\n"); 1042 printk(KERN_INFO PREFIX "New style SDC\n");
984 tq_init_seq[1] = HP_SDC_CMD_READ_XTD; 1043 tq_init_seq[1] = HP_SDC_CMD_READ_XTD;
985 tq_init.actidx = 0; 1044 tq_init.actidx = 0;
986 tq_init.idx = 1; 1045 tq_init.idx = 1;
987 down(&tq_init_sem); 1046 down(&tq_init_sem);
988 hp_sdc_enqueue_transaction(&tq_init); 1047 hp_sdc_enqueue_transaction(&tq_init);
989 down(&tq_init_sem); 1048 down(&tq_init_sem);
990 up(&tq_init_sem); 1049 up(&tq_init_sem);
991 if ((tq_init_seq[0] & HP_SDC_ACT_DEAD) == HP_SDC_ACT_DEAD) { 1050 if ((tq_init_seq[0] & HP_SDC_ACT_DEAD) == HP_SDC_ACT_DEAD) {
@@ -995,15 +1054,13 @@ static int __init hp_sdc_register(void)
995 hp_sdc.r7e = tq_init_seq[4]; 1054 hp_sdc.r7e = tq_init_seq[4];
996 HP_SDC_XTD_REV_STRINGS(hp_sdc.r7e & HP_SDC_XTD_REV, str) 1055 HP_SDC_XTD_REV_STRINGS(hp_sdc.r7e & HP_SDC_XTD_REV, str)
997 printk(KERN_INFO PREFIX "Revision: %s\n", str); 1056 printk(KERN_INFO PREFIX "Revision: %s\n", str);
998 if (hp_sdc.r7e & HP_SDC_XTD_BEEPER) { 1057 if (hp_sdc.r7e & HP_SDC_XTD_BEEPER)
999 printk(KERN_INFO PREFIX "TI SN76494 beeper present\n"); 1058 printk(KERN_INFO PREFIX "TI SN76494 beeper present\n");
1000 } 1059 if (hp_sdc.r7e & HP_SDC_XTD_BBRTC)
1001 if (hp_sdc.r7e & HP_SDC_XTD_BBRTC) {
1002 printk(KERN_INFO PREFIX "OKI MSM-58321 BBRTC present\n"); 1060 printk(KERN_INFO PREFIX "OKI MSM-58321 BBRTC present\n");
1003 }
1004 printk(KERN_INFO PREFIX "Spunking the self test register to force PUP " 1061 printk(KERN_INFO PREFIX "Spunking the self test register to force PUP "
1005 "on next firmware reset.\n"); 1062 "on next firmware reset.\n");
1006 tq_init_seq[0] = HP_SDC_ACT_PRECMD | 1063 tq_init_seq[0] = HP_SDC_ACT_PRECMD |
1007 HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE; 1064 HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE;
1008 tq_init_seq[1] = HP_SDC_CMD_SET_STR; 1065 tq_init_seq[1] = HP_SDC_CMD_SET_STR;
1009 tq_init_seq[2] = 1; 1066 tq_init_seq[2] = 1;
@@ -1012,14 +1069,12 @@ static int __init hp_sdc_register(void)
1012 tq_init.idx = 1; 1069 tq_init.idx = 1;
1013 tq_init.endidx = 4; 1070 tq_init.endidx = 4;
1014 down(&tq_init_sem); 1071 down(&tq_init_sem);
1015 hp_sdc_enqueue_transaction(&tq_init); 1072 hp_sdc_enqueue_transaction(&tq_init);
1016 down(&tq_init_sem); 1073 down(&tq_init_sem);
1017 up(&tq_init_sem); 1074 up(&tq_init_sem);
1018 } 1075 } else
1019 else { 1076 printk(KERN_INFO PREFIX "Old style SDC (1820-%s).\n",
1020 printk(KERN_INFO PREFIX "Old style SDC (1820-%s).\n",
1021 (hp_sdc.r11 & HP_SDC_CFG_REV) ? "3300" : "2564/3087"); 1077 (hp_sdc.r11 & HP_SDC_CFG_REV) ? "3300" : "2564/3087");
1022 }
1023 1078
1024 return 0; 1079 return 0;
1025} 1080}
@@ -1027,13 +1082,13 @@ static int __init hp_sdc_register(void)
1027module_init(hp_sdc_register); 1082module_init(hp_sdc_register);
1028module_exit(hp_sdc_exit); 1083module_exit(hp_sdc_exit);
1029 1084
1030/* Timing notes: These measurements taken on my 64MHz 7100-LC (715/64) 1085/* Timing notes: These measurements taken on my 64MHz 7100-LC (715/64)
1031 * cycles cycles-adj time 1086 * cycles cycles-adj time
1032 * between two consecutive mfctl(16)'s: 4 n/a 63ns 1087 * between two consecutive mfctl(16)'s: 4 n/a 63ns
1033 * hp_sdc_spin_ibf when idle: 119 115 1.7us 1088 * hp_sdc_spin_ibf when idle: 119 115 1.7us
1034 * gsc_writeb status register: 83 79 1.2us 1089 * gsc_writeb status register: 83 79 1.2us
1035 * IBF to clear after sending SET_IM: 6204 6006 93us 1090 * IBF to clear after sending SET_IM: 6204 6006 93us
1036 * IBF to clear after sending LOAD_RT: 4467 4352 68us 1091 * IBF to clear after sending LOAD_RT: 4467 4352 68us
1037 * IBF to clear after sending two LOAD_RTs: 18974 18859 295us 1092 * IBF to clear after sending two LOAD_RTs: 18974 18859 295us
1038 * READ_T1, read status/data, IRQ, call handler: 35564 n/a 556us 1093 * READ_T1, read status/data, IRQ, call handler: 35564 n/a 556us
1039 * cmd to ~IBF READ_T1 2nd time right after: 5158403 n/a 81ms 1094 * cmd to ~IBF READ_T1 2nd time right after: 5158403 n/a 81ms
diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c
index aa4a8a4ccfdb..c45ea74d53e4 100644
--- a/drivers/input/serio/hp_sdc_mlc.c
+++ b/drivers/input/serio/hp_sdc_mlc.c
@@ -58,12 +58,13 @@ struct hp_sdc_mlc_priv_s {
58} hp_sdc_mlc_priv; 58} hp_sdc_mlc_priv;
59 59
60/************************* Interrupt context ******************************/ 60/************************* Interrupt context ******************************/
61static void hp_sdc_mlc_isr (int irq, void *dev_id, 61static void hp_sdc_mlc_isr (int irq, void *dev_id,
62 uint8_t status, uint8_t data) { 62 uint8_t status, uint8_t data)
63 int idx; 63{
64 int idx;
64 hil_mlc *mlc = &hp_sdc_mlc; 65 hil_mlc *mlc = &hp_sdc_mlc;
65 66
66 write_lock(&(mlc->lock)); 67 write_lock(&mlc->lock);
67 if (mlc->icount < 0) { 68 if (mlc->icount < 0) {
68 printk(KERN_WARNING PREFIX "HIL Overflow!\n"); 69 printk(KERN_WARNING PREFIX "HIL Overflow!\n");
69 up(&mlc->isem); 70 up(&mlc->isem);
@@ -73,239 +74,232 @@ static void hp_sdc_mlc_isr (int irq, void *dev_id,
73 if ((status & HP_SDC_STATUS_IRQMASK) == HP_SDC_STATUS_HILDATA) { 74 if ((status & HP_SDC_STATUS_IRQMASK) == HP_SDC_STATUS_HILDATA) {
74 mlc->ipacket[idx] |= data | HIL_ERR_INT; 75 mlc->ipacket[idx] |= data | HIL_ERR_INT;
75 mlc->icount--; 76 mlc->icount--;
76 if (hp_sdc_mlc_priv.got5x) goto check; 77 if (hp_sdc_mlc_priv.got5x || !idx)
77 if (!idx) goto check; 78 goto check;
78 if ((mlc->ipacket[idx-1] & HIL_PKT_ADDR_MASK) != 79 if ((mlc->ipacket[idx - 1] & HIL_PKT_ADDR_MASK) !=
79 (mlc->ipacket[idx] & HIL_PKT_ADDR_MASK)) { 80 (mlc->ipacket[idx] & HIL_PKT_ADDR_MASK)) {
80 mlc->ipacket[idx] &= ~HIL_PKT_ADDR_MASK; 81 mlc->ipacket[idx] &= ~HIL_PKT_ADDR_MASK;
81 mlc->ipacket[idx] |= (mlc->ipacket[idx-1] 82 mlc->ipacket[idx] |= (mlc->ipacket[idx - 1]
82 & HIL_PKT_ADDR_MASK); 83 & HIL_PKT_ADDR_MASK);
83 } 84 }
84 goto check; 85 goto check;
85 } 86 }
86 /* We know status is 5X */ 87 /* We know status is 5X */
87 if (data & HP_SDC_HIL_ISERR) goto err; 88 if (data & HP_SDC_HIL_ISERR)
88 mlc->ipacket[idx] = 89 goto err;
90 mlc->ipacket[idx] =
89 (data & HP_SDC_HIL_R1MASK) << HIL_PKT_ADDR_SHIFT; 91 (data & HP_SDC_HIL_R1MASK) << HIL_PKT_ADDR_SHIFT;
90 hp_sdc_mlc_priv.got5x = 1; 92 hp_sdc_mlc_priv.got5x = 1;
91 goto out; 93 goto out;
92 94
93 check: 95 check:
94 hp_sdc_mlc_priv.got5x = 0; 96 hp_sdc_mlc_priv.got5x = 0;
95 if (mlc->imatch == 0) goto done; 97 if (mlc->imatch == 0)
96 if ((mlc->imatch == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) 98 goto done;
97 && (mlc->ipacket[idx] == (mlc->imatch | idx))) goto done; 99 if ((mlc->imatch == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
98 if (mlc->ipacket[idx] == mlc->imatch) goto done; 100 && (mlc->ipacket[idx] == (mlc->imatch | idx)))
101 goto done;
102 if (mlc->ipacket[idx] == mlc->imatch)
103 goto done;
99 goto out; 104 goto out;
100 105
101 err: 106 err:
102 printk(KERN_DEBUG PREFIX "err code %x\n", data); 107 printk(KERN_DEBUG PREFIX "err code %x\n", data);
108
103 switch (data) { 109 switch (data) {
104 case HP_SDC_HIL_RC_DONE: 110 case HP_SDC_HIL_RC_DONE:
105 printk(KERN_WARNING PREFIX "Bastard SDC reconfigured loop!\n"); 111 printk(KERN_WARNING PREFIX "Bastard SDC reconfigured loop!\n");
106 break; 112 break;
113
107 case HP_SDC_HIL_ERR: 114 case HP_SDC_HIL_ERR:
108 mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_PERR | 115 mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_PERR |
109 HIL_ERR_FERR | HIL_ERR_FOF; 116 HIL_ERR_FERR | HIL_ERR_FOF;
110 break; 117 break;
118
111 case HP_SDC_HIL_TO: 119 case HP_SDC_HIL_TO:
112 mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_LERR; 120 mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_LERR;
113 break; 121 break;
122
114 case HP_SDC_HIL_RC: 123 case HP_SDC_HIL_RC:
115 printk(KERN_WARNING PREFIX "Bastard SDC decided to reconfigure loop!\n"); 124 printk(KERN_WARNING PREFIX "Bastard SDC decided to reconfigure loop!\n");
116 break; 125 break;
126
117 default: 127 default:
118 printk(KERN_WARNING PREFIX "Unkown HIL Error status (%x)!\n", data); 128 printk(KERN_WARNING PREFIX "Unkown HIL Error status (%x)!\n", data);
119 break; 129 break;
120 } 130 }
131
121 /* No more data will be coming due to an error. */ 132 /* No more data will be coming due to an error. */
122 done: 133 done:
123 tasklet_schedule(mlc->tasklet); 134 tasklet_schedule(mlc->tasklet);
124 up(&(mlc->isem)); 135 up(&mlc->isem);
125 out: 136 out:
126 write_unlock(&(mlc->lock)); 137 write_unlock(&mlc->lock);
127} 138}
128 139
129 140
130/******************** Tasklet or userspace context functions ****************/ 141/******************** Tasklet or userspace context functions ****************/
131 142
132static int hp_sdc_mlc_in (hil_mlc *mlc, suseconds_t timeout) { 143static int hp_sdc_mlc_in(hil_mlc *mlc, suseconds_t timeout)
133 unsigned long flags; 144{
134 struct hp_sdc_mlc_priv_s *priv; 145 struct hp_sdc_mlc_priv_s *priv;
135 int rc = 2; 146 int rc = 2;
136 147
137 priv = mlc->priv; 148 priv = mlc->priv;
138 149
139 write_lock_irqsave(&(mlc->lock), flags);
140
141 /* Try to down the semaphore */ 150 /* Try to down the semaphore */
142 if (down_trylock(&(mlc->isem))) { 151 if (down_trylock(&mlc->isem)) {
143 struct timeval tv; 152 struct timeval tv;
144 if (priv->emtestmode) { 153 if (priv->emtestmode) {
145 mlc->ipacket[0] = 154 mlc->ipacket[0] =
146 HIL_ERR_INT | (mlc->opacket & 155 HIL_ERR_INT | (mlc->opacket &
147 (HIL_PKT_CMD | 156 (HIL_PKT_CMD |
148 HIL_PKT_ADDR_MASK | 157 HIL_PKT_ADDR_MASK |
149 HIL_PKT_DATA_MASK)); 158 HIL_PKT_DATA_MASK));
150 mlc->icount = 14; 159 mlc->icount = 14;
151 /* printk(KERN_DEBUG PREFIX ">[%x]\n", mlc->ipacket[0]); */ 160 /* printk(KERN_DEBUG PREFIX ">[%x]\n", mlc->ipacket[0]); */
152 goto wasup; 161 goto wasup;
153 } 162 }
154 do_gettimeofday(&tv); 163 do_gettimeofday(&tv);
155 tv.tv_usec += 1000000 * (tv.tv_sec - mlc->instart.tv_sec); 164 tv.tv_usec += USEC_PER_SEC * (tv.tv_sec - mlc->instart.tv_sec);
156 if (tv.tv_usec - mlc->instart.tv_usec > mlc->intimeout) { 165 if (tv.tv_usec - mlc->instart.tv_usec > mlc->intimeout) {
157 /* printk("!%i %i", 166 /* printk("!%i %i",
158 tv.tv_usec - mlc->instart.tv_usec, 167 tv.tv_usec - mlc->instart.tv_usec,
159 mlc->intimeout); 168 mlc->intimeout);
160 */ 169 */
161 rc = 1; 170 rc = 1;
162 up(&(mlc->isem)); 171 up(&mlc->isem);
163 } 172 }
164 goto done; 173 goto done;
165 } 174 }
166 wasup: 175 wasup:
167 up(&(mlc->isem)); 176 up(&mlc->isem);
168 rc = 0; 177 rc = 0;
169 goto done;
170 done: 178 done:
171 write_unlock_irqrestore(&(mlc->lock), flags);
172 return rc; 179 return rc;
173} 180}
174 181
175static int hp_sdc_mlc_cts (hil_mlc *mlc) { 182static int hp_sdc_mlc_cts(hil_mlc *mlc)
183{
176 struct hp_sdc_mlc_priv_s *priv; 184 struct hp_sdc_mlc_priv_s *priv;
177 unsigned long flags;
178 185
179 priv = mlc->priv; 186 priv = mlc->priv;
180
181 write_lock_irqsave(&(mlc->lock), flags);
182 187
183 /* Try to down the semaphores -- they should be up. */ 188 /* Try to down the semaphores -- they should be up. */
184 if (down_trylock(&(mlc->isem))) { 189 BUG_ON(down_trylock(&mlc->isem));
185 BUG(); 190 BUG_ON(down_trylock(&mlc->osem));
186 goto busy; 191
187 } 192 up(&mlc->isem);
188 if (down_trylock(&(mlc->osem))) { 193 up(&mlc->osem);
189 BUG();
190 up(&(mlc->isem));
191 goto busy;
192 }
193 up(&(mlc->isem));
194 up(&(mlc->osem));
195 194
196 if (down_trylock(&(mlc->csem))) { 195 if (down_trylock(&mlc->csem)) {
197 if (priv->trans.act.semaphore != &(mlc->csem)) goto poll; 196 if (priv->trans.act.semaphore != &mlc->csem)
198 goto busy; 197 goto poll;
198 else
199 goto busy;
199 } 200 }
200 if (!(priv->tseq[4] & HP_SDC_USE_LOOP)) goto done; 201
202 if (!(priv->tseq[4] & HP_SDC_USE_LOOP))
203 goto done;
201 204
202 poll: 205 poll:
203 priv->trans.act.semaphore = &(mlc->csem); 206 priv->trans.act.semaphore = &mlc->csem;
204 priv->trans.actidx = 0; 207 priv->trans.actidx = 0;
205 priv->trans.idx = 1; 208 priv->trans.idx = 1;
206 priv->trans.endidx = 5; 209 priv->trans.endidx = 5;
207 priv->tseq[0] = 210 priv->tseq[0] =
208 HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE; 211 HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE;
209 priv->tseq[1] = HP_SDC_CMD_READ_USE; 212 priv->tseq[1] = HP_SDC_CMD_READ_USE;
210 priv->tseq[2] = 1; 213 priv->tseq[2] = 1;
211 priv->tseq[3] = 0; 214 priv->tseq[3] = 0;
212 priv->tseq[4] = 0; 215 priv->tseq[4] = 0;
213 hp_sdc_enqueue_transaction(&(priv->trans)); 216 __hp_sdc_enqueue_transaction(&priv->trans);
214 busy: 217 busy:
215 write_unlock_irqrestore(&(mlc->lock), flags);
216 return 1; 218 return 1;
217 done: 219 done:
218 priv->trans.act.semaphore = &(mlc->osem); 220 priv->trans.act.semaphore = &mlc->osem;
219 up(&(mlc->csem)); 221 up(&mlc->csem);
220 write_unlock_irqrestore(&(mlc->lock), flags);
221 return 0; 222 return 0;
222} 223}
223 224
224static void hp_sdc_mlc_out (hil_mlc *mlc) { 225static void hp_sdc_mlc_out(hil_mlc *mlc)
226{
225 struct hp_sdc_mlc_priv_s *priv; 227 struct hp_sdc_mlc_priv_s *priv;
226 unsigned long flags;
227 228
228 priv = mlc->priv; 229 priv = mlc->priv;
229 230
230 write_lock_irqsave(&(mlc->lock), flags);
231
232 /* Try to down the semaphore -- it should be up. */ 231 /* Try to down the semaphore -- it should be up. */
233 if (down_trylock(&(mlc->osem))) { 232 BUG_ON(down_trylock(&mlc->osem));
234 BUG();
235 goto done;
236 }
237 233
238 if (mlc->opacket & HIL_DO_ALTER_CTRL) goto do_control; 234 if (mlc->opacket & HIL_DO_ALTER_CTRL)
235 goto do_control;
239 236
240 do_data: 237 do_data:
241 if (priv->emtestmode) { 238 if (priv->emtestmode) {
242 up(&(mlc->osem)); 239 up(&mlc->osem);
243 goto done; 240 return;
244 } 241 }
245 /* Shouldn't be sending commands when loop may be busy */ 242 /* Shouldn't be sending commands when loop may be busy */
246 if (down_trylock(&(mlc->csem))) { 243 BUG_ON(down_trylock(&mlc->csem));
247 BUG(); 244 up(&mlc->csem);
248 goto done;
249 }
250 up(&(mlc->csem));
251 245
252 priv->trans.actidx = 0; 246 priv->trans.actidx = 0;
253 priv->trans.idx = 1; 247 priv->trans.idx = 1;
254 priv->trans.act.semaphore = &(mlc->osem); 248 priv->trans.act.semaphore = &mlc->osem;
255 priv->trans.endidx = 6; 249 priv->trans.endidx = 6;
256 priv->tseq[0] = 250 priv->tseq[0] =
257 HP_SDC_ACT_DATAREG | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_SEMAPHORE; 251 HP_SDC_ACT_DATAREG | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_SEMAPHORE;
258 priv->tseq[1] = 0x7; 252 priv->tseq[1] = 0x7;
259 priv->tseq[2] = 253 priv->tseq[2] =
260 (mlc->opacket & 254 (mlc->opacket &
261 (HIL_PKT_ADDR_MASK | HIL_PKT_CMD)) 255 (HIL_PKT_ADDR_MASK | HIL_PKT_CMD))
262 >> HIL_PKT_ADDR_SHIFT; 256 >> HIL_PKT_ADDR_SHIFT;
263 priv->tseq[3] = 257 priv->tseq[3] =
264 (mlc->opacket & HIL_PKT_DATA_MASK) 258 (mlc->opacket & HIL_PKT_DATA_MASK)
265 >> HIL_PKT_DATA_SHIFT; 259 >> HIL_PKT_DATA_SHIFT;
266 priv->tseq[4] = 0; /* No timeout */ 260 priv->tseq[4] = 0; /* No timeout */
267 if (priv->tseq[3] == HIL_CMD_DHR) priv->tseq[4] = 1; 261 if (priv->tseq[3] == HIL_CMD_DHR)
262 priv->tseq[4] = 1;
268 priv->tseq[5] = HP_SDC_CMD_DO_HIL; 263 priv->tseq[5] = HP_SDC_CMD_DO_HIL;
269 goto enqueue; 264 goto enqueue;
270 265
271 do_control: 266 do_control:
272 priv->emtestmode = mlc->opacket & HIL_CTRL_TEST; 267 priv->emtestmode = mlc->opacket & HIL_CTRL_TEST;
273 268
274 /* we cannot emulate this, it should not be used. */ 269 /* we cannot emulate this, it should not be used. */
275 BUG_ON((mlc->opacket & (HIL_CTRL_APE | HIL_CTRL_IPF)) == HIL_CTRL_APE); 270 BUG_ON((mlc->opacket & (HIL_CTRL_APE | HIL_CTRL_IPF)) == HIL_CTRL_APE);
276 271
277 if ((mlc->opacket & HIL_CTRL_ONLY) == HIL_CTRL_ONLY) goto control_only; 272 if ((mlc->opacket & HIL_CTRL_ONLY) == HIL_CTRL_ONLY)
278 if (mlc->opacket & HIL_CTRL_APE) { 273 goto control_only;
279 BUG(); /* Should not send command/data after engaging APE */ 274
280 goto done; 275 /* Should not send command/data after engaging APE */
281 } 276 BUG_ON(mlc->opacket & HIL_CTRL_APE);
282 /* Disengaging APE this way would not be valid either since 277
278 /* Disengaging APE this way would not be valid either since
283 * the loop must be allowed to idle. 279 * the loop must be allowed to idle.
284 * 280 *
285 * So, it works out that we really never actually send control 281 * So, it works out that we really never actually send control
286 * and data when using SDC, we just send the data. 282 * and data when using SDC, we just send the data.
287 */ 283 */
288 goto do_data; 284 goto do_data;
289 285
290 control_only: 286 control_only:
291 priv->trans.actidx = 0; 287 priv->trans.actidx = 0;
292 priv->trans.idx = 1; 288 priv->trans.idx = 1;
293 priv->trans.act.semaphore = &(mlc->osem); 289 priv->trans.act.semaphore = &mlc->osem;
294 priv->trans.endidx = 4; 290 priv->trans.endidx = 4;
295 priv->tseq[0] = 291 priv->tseq[0] =
296 HP_SDC_ACT_PRECMD | HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE; 292 HP_SDC_ACT_PRECMD | HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE;
297 priv->tseq[1] = HP_SDC_CMD_SET_LPC; 293 priv->tseq[1] = HP_SDC_CMD_SET_LPC;
298 priv->tseq[2] = 1; 294 priv->tseq[2] = 1;
299 // priv->tseq[3] = (mlc->ddc + 1) | HP_SDC_LPS_ACSUCC; 295 /* priv->tseq[3] = (mlc->ddc + 1) | HP_SDC_LPS_ACSUCC; */
300 priv->tseq[3] = 0; 296 priv->tseq[3] = 0;
301 if (mlc->opacket & HIL_CTRL_APE) { 297 if (mlc->opacket & HIL_CTRL_APE) {
302 priv->tseq[3] |= HP_SDC_LPC_APE_IPF; 298 priv->tseq[3] |= HP_SDC_LPC_APE_IPF;
303 down_trylock(&(mlc->csem)); 299 down_trylock(&mlc->csem);
304 } 300 }
305 enqueue: 301 enqueue:
306 hp_sdc_enqueue_transaction(&(priv->trans)); 302 hp_sdc_enqueue_transaction(&priv->trans);
307 done:
308 write_unlock_irqrestore(&(mlc->lock), flags);
309} 303}
310 304
311static int __init hp_sdc_mlc_init(void) 305static int __init hp_sdc_mlc_init(void)
@@ -316,18 +310,18 @@ static int __init hp_sdc_mlc_init(void)
316 310
317 hp_sdc_mlc_priv.emtestmode = 0; 311 hp_sdc_mlc_priv.emtestmode = 0;
318 hp_sdc_mlc_priv.trans.seq = hp_sdc_mlc_priv.tseq; 312 hp_sdc_mlc_priv.trans.seq = hp_sdc_mlc_priv.tseq;
319 hp_sdc_mlc_priv.trans.act.semaphore = &(mlc->osem); 313 hp_sdc_mlc_priv.trans.act.semaphore = &mlc->osem;
320 hp_sdc_mlc_priv.got5x = 0; 314 hp_sdc_mlc_priv.got5x = 0;
321 315
322 mlc->cts = &hp_sdc_mlc_cts; 316 mlc->cts = &hp_sdc_mlc_cts;
323 mlc->in = &hp_sdc_mlc_in; 317 mlc->in = &hp_sdc_mlc_in;
324 mlc->out = &hp_sdc_mlc_out; 318 mlc->out = &hp_sdc_mlc_out;
319 mlc->priv = &hp_sdc_mlc_priv;
325 320
326 if (hil_mlc_register(mlc)) { 321 if (hil_mlc_register(mlc)) {
327 printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n"); 322 printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n");
328 goto err0; 323 goto err0;
329 } 324 }
330 mlc->priv = &hp_sdc_mlc_priv;
331 325
332 if (hp_sdc_request_hil_irq(&hp_sdc_mlc_isr)) { 326 if (hp_sdc_request_hil_irq(&hp_sdc_mlc_isr)) {
333 printk(KERN_WARNING PREFIX "Request for raw HIL ISR hook denied\n"); 327 printk(KERN_WARNING PREFIX "Request for raw HIL ISR hook denied\n");
@@ -335,10 +329,9 @@ static int __init hp_sdc_mlc_init(void)
335 } 329 }
336 return 0; 330 return 0;
337 err1: 331 err1:
338 if (hil_mlc_unregister(mlc)) { 332 if (hil_mlc_unregister(mlc))
339 printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" 333 printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n"
340 "This is bad. Could cause an oops.\n"); 334 "This is bad. Could cause an oops.\n");
341 }
342 err0: 335 err0:
343 return -EBUSY; 336 return -EBUSY;
344} 337}
@@ -346,14 +339,14 @@ static int __init hp_sdc_mlc_init(void)
346static void __exit hp_sdc_mlc_exit(void) 339static void __exit hp_sdc_mlc_exit(void)
347{ 340{
348 hil_mlc *mlc = &hp_sdc_mlc; 341 hil_mlc *mlc = &hp_sdc_mlc;
349 if (hp_sdc_release_hil_irq(&hp_sdc_mlc_isr)) { 342
343 if (hp_sdc_release_hil_irq(&hp_sdc_mlc_isr))
350 printk(KERN_ERR PREFIX "Failed to release the raw HIL ISR hook.\n" 344 printk(KERN_ERR PREFIX "Failed to release the raw HIL ISR hook.\n"
351 "This is bad. Could cause an oops.\n"); 345 "This is bad. Could cause an oops.\n");
352 } 346
353 if (hil_mlc_unregister(mlc)) { 347 if (hil_mlc_unregister(mlc))
354 printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" 348 printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n"
355 "This is bad. Could cause an oops.\n"); 349 "This is bad. Could cause an oops.\n");
356 }
357} 350}
358 351
359module_init(hp_sdc_mlc_init); 352module_init(hp_sdc_mlc_init);
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index d36bd5475b6d..6858bc58f0fd 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -160,6 +160,28 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
160 }, 160 },
161 }, 161 },
162 { 162 {
163 /*
164 * No data is coming from the touchscreen unless KBC
165 * is in legacy mode.
166 */
167 .ident = "Panasonic CF-29",
168 .matches = {
169 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
170 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
171 },
172 },
173 {
174 /*
175 * Errors on MUX ports are reported without raising AUXDATA
176 * causing "spurious NAK" messages.
177 */
178 .ident = "HP Pavilion DV4017EA",
179 .matches = {
180 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
181 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
182 },
183 },
184 {
163 .ident = "Toshiba P10", 185 .ident = "Toshiba P10",
164 .matches = { 186 .matches = {
165 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 187 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
@@ -280,6 +302,8 @@ static struct pnp_driver i8042_pnp_kbd_driver = {
280}; 302};
281 303
282static struct pnp_device_id pnp_aux_devids[] = { 304static struct pnp_device_id pnp_aux_devids[] = {
305 { .id = "FJC6000", .driver_data = 0 },
306 { .id = "FJC6001", .driver_data = 0 },
283 { .id = "PNP0f03", .driver_data = 0 }, 307 { .id = "PNP0f03", .driver_data = 0 },
284 { .id = "PNP0f0b", .driver_data = 0 }, 308 { .id = "PNP0f0b", .driver_data = 0 },
285 { .id = "PNP0f0e", .driver_data = 0 }, 309 { .id = "PNP0f0e", .driver_data = 0 },
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index db9cca3b65e0..7c17377a65b9 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -768,6 +768,13 @@ static void i8042_controller_reset(void)
768 i8042_flush(); 768 i8042_flush();
769 769
770/* 770/*
771 * Disable both KBD and AUX interfaces so they don't get in the way
772 */
773
774 i8042_ctr |= I8042_CTR_KBDDIS | I8042_CTR_AUXDIS;
775 i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT);
776
777/*
771 * Disable MUX mode if present. 778 * Disable MUX mode if present.
772 */ 779 */
773 780
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 0a26e0663542..693e3b2a65a3 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -39,7 +39,8 @@
39/* 39/*
40 * This code has been heavily tested on a Nokia 770, and lightly 40 * This code has been heavily tested on a Nokia 770, and lightly
41 * tested on other ads7846 devices (OSK/Mistral, Lubbock). 41 * tested on other ads7846 devices (OSK/Mistral, Lubbock).
42 * Support for ads7843 and ads7845 has only been stubbed in. 42 * Support for ads7843 tested on Atmel at91sam926x-EK.
43 * Support for ads7845 has only been stubbed in.
43 * 44 *
44 * IRQ handling needs a workaround because of a shortcoming in handling 45 * IRQ handling needs a workaround because of a shortcoming in handling
45 * edge triggered IRQs on some platforms like the OMAP1/2. These 46 * edge triggered IRQs on some platforms like the OMAP1/2. These
@@ -246,18 +247,16 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
246 247
247 /* REVISIT: take a few more samples, and compare ... */ 248 /* REVISIT: take a few more samples, and compare ... */
248 249
249 /* maybe off internal vREF */ 250 /* converter in low power mode & enable PENIRQ */
250 if (use_internal) { 251 req->ref_off = PWRDOWN;
251 req->ref_off = REF_OFF; 252 req->xfer[4].tx_buf = &req->ref_off;
252 req->xfer[4].tx_buf = &req->ref_off; 253 req->xfer[4].len = 1;
253 req->xfer[4].len = 1; 254 spi_message_add_tail(&req->xfer[4], &req->msg);
254 spi_message_add_tail(&req->xfer[4], &req->msg); 255
255 256 req->xfer[5].rx_buf = &req->scratch;
256 req->xfer[5].rx_buf = &req->scratch; 257 req->xfer[5].len = 2;
257 req->xfer[5].len = 2; 258 CS_CHANGE(req->xfer[5]);
258 CS_CHANGE(req->xfer[5]); 259 spi_message_add_tail(&req->xfer[5], &req->msg);
259 spi_message_add_tail(&req->xfer[5], &req->msg);
260 }
261 260
262 ts->irq_disabled = 1; 261 ts->irq_disabled = 1;
263 disable_irq(spi->irq); 262 disable_irq(spi->irq);
@@ -536,6 +535,9 @@ static void ads7846_rx(void *ads)
536 } else 535 } else
537 Rt = 0; 536 Rt = 0;
538 537
538 if (ts->model == 7843)
539 Rt = ts->pressure_max / 2;
540
539 /* Sample found inconsistent by debouncing or pressure is beyond 541 /* Sample found inconsistent by debouncing or pressure is beyond
540 * the maximum. Don't report it to user space, repeat at least 542 * the maximum. Don't report it to user space, repeat at least
541 * once more the measurement 543 * once more the measurement
@@ -897,7 +899,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
897 899
898 input_dev->name = "ADS784x Touchscreen"; 900 input_dev->name = "ADS784x Touchscreen";
899 input_dev->phys = ts->phys; 901 input_dev->phys = ts->phys;
900 input_dev->cdev.dev = &spi->dev; 902 input_dev->dev.parent = &spi->dev;
901 903
902 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 904 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
903 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 905 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index e2945582828e..e6a31d118786 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -300,8 +300,7 @@ static int __init corgits_probe(struct platform_device *pdev)
300 input_dev->id.vendor = 0x0001; 300 input_dev->id.vendor = 0x0001;
301 input_dev->id.product = 0x0002; 301 input_dev->id.product = 0x0002;
302 input_dev->id.version = 0x0100; 302 input_dev->id.version = 0x0100;
303 input_dev->cdev.dev = &pdev->dev; 303 input_dev->dev.parent = &pdev->dev;
304 input_dev->private = corgi_ts;
305 304
306 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 305 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
307 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 306 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 9d61cd133d01..557d781719f1 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -312,14 +312,13 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
312 init_completion(&elo->cmd_done); 312 init_completion(&elo->cmd_done);
313 snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys); 313 snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys);
314 314
315 input_dev->private = elo;
316 input_dev->name = "Elo Serial TouchScreen"; 315 input_dev->name = "Elo Serial TouchScreen";
317 input_dev->phys = elo->phys; 316 input_dev->phys = elo->phys;
318 input_dev->id.bustype = BUS_RS232; 317 input_dev->id.bustype = BUS_RS232;
319 input_dev->id.vendor = SERIO_ELO; 318 input_dev->id.vendor = SERIO_ELO;
320 input_dev->id.product = elo->id; 319 input_dev->id.product = elo->id;
321 input_dev->id.version = 0x0100; 320 input_dev->id.version = 0x0100;
322 input_dev->cdev.dev = &serio->dev; 321 input_dev->dev.parent = &serio->dev;
323 322
324 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 323 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
325 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 324 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
index 9157eb148e84..39d602600d7c 100644
--- a/drivers/input/touchscreen/gunze.c
+++ b/drivers/input/touchscreen/gunze.c
@@ -130,13 +130,13 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv)
130 gunze->dev = input_dev; 130 gunze->dev = input_dev;
131 snprintf(gunze->phys, sizeof(serio->phys), "%s/input0", serio->phys); 131 snprintf(gunze->phys, sizeof(serio->phys), "%s/input0", serio->phys);
132 132
133 input_dev->private = gunze;
134 input_dev->name = "Gunze AHL-51S TouchScreen"; 133 input_dev->name = "Gunze AHL-51S TouchScreen";
135 input_dev->phys = gunze->phys; 134 input_dev->phys = gunze->phys;
136 input_dev->id.bustype = BUS_RS232; 135 input_dev->id.bustype = BUS_RS232;
137 input_dev->id.vendor = SERIO_GUNZE; 136 input_dev->id.vendor = SERIO_GUNZE;
138 input_dev->id.product = 0x0051; 137 input_dev->id.product = 0x0051;
139 input_dev->id.version = 0x0100; 138 input_dev->id.version = 0x0100;
139 input_dev->dev.parent = &serio->dev;
140 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 140 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
141 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 141 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
142 input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0); 142 input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0);
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
index c4116d4f64e7..09ed7803cb8f 100644
--- a/drivers/input/touchscreen/h3600_ts_input.c
+++ b/drivers/input/touchscreen/h3600_ts_input.c
@@ -147,7 +147,7 @@ enum flite_pwr {
147unsigned int h3600_flite_power(struct input_dev *dev, enum flite_pwr pwr) 147unsigned int h3600_flite_power(struct input_dev *dev, enum flite_pwr pwr)
148{ 148{
149 unsigned char brightness = (pwr == FLITE_PWR_OFF) ? 0 : flite_brightness; 149 unsigned char brightness = (pwr == FLITE_PWR_OFF) ? 0 : flite_brightness;
150 struct h3600_dev *ts = dev->private; 150 struct h3600_dev *ts = input_get_drvdata(dev);
151 151
152 /* Must be in this order */ 152 /* Must be in this order */
153 ts->serio->write(ts->serio, 1); 153 ts->serio->write(ts->serio, 1);
@@ -260,7 +260,7 @@ static int h3600ts_event(struct input_dev *dev, unsigned int type,
260 unsigned int code, int value) 260 unsigned int code, int value)
261{ 261{
262#if 0 262#if 0
263 struct h3600_dev *ts = dev->private; 263 struct h3600_dev *ts = input_get_drvdata(dev);
264 264
265 switch (type) { 265 switch (type) {
266 case EV_LED: { 266 case EV_LED: {
@@ -367,8 +367,9 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
367 input_dev->id.vendor = SERIO_H3600; 367 input_dev->id.vendor = SERIO_H3600;
368 input_dev->id.product = 0x0666; /* FIXME !!! We can ask the hardware */ 368 input_dev->id.product = 0x0666; /* FIXME !!! We can ask the hardware */
369 input_dev->id.version = 0x0100; 369 input_dev->id.version = 0x0100;
370 input_dev->cdev.dev = &serio->dev; 370 input_dev->dev.parent = &serio->dev;
371 input_dev->private = ts; 371
372 input_set_drvdata(input_dev, ts);
372 373
373 input_dev->event = h3600ts_event; 374 input_dev->event = h3600ts_event;
374 375
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c
index c3c2d735d0ec..4ec3b1f940c8 100644
--- a/drivers/input/touchscreen/mtouch.c
+++ b/drivers/input/touchscreen/mtouch.c
@@ -144,13 +144,13 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
144 mtouch->dev = input_dev; 144 mtouch->dev = input_dev;
145 snprintf(mtouch->phys, sizeof(mtouch->phys), "%s/input0", serio->phys); 145 snprintf(mtouch->phys, sizeof(mtouch->phys), "%s/input0", serio->phys);
146 146
147 input_dev->private = mtouch;
148 input_dev->name = "MicroTouch Serial TouchScreen"; 147 input_dev->name = "MicroTouch Serial TouchScreen";
149 input_dev->phys = mtouch->phys; 148 input_dev->phys = mtouch->phys;
150 input_dev->id.bustype = BUS_RS232; 149 input_dev->id.bustype = BUS_RS232;
151 input_dev->id.vendor = SERIO_MICROTOUCH; 150 input_dev->id.vendor = SERIO_MICROTOUCH;
152 input_dev->id.product = 0; 151 input_dev->id.product = 0;
153 input_dev->id.version = 0x0100; 152 input_dev->id.version = 0x0100;
153 input_dev->dev.parent = &serio->dev;
154 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 154 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
155 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 155 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
156 input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0); 156 input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c
index bd2767991ae9..f2c0d3c7149c 100644
--- a/drivers/input/touchscreen/penmount.c
+++ b/drivers/input/touchscreen/penmount.c
@@ -105,14 +105,13 @@ static int pm_connect(struct serio *serio, struct serio_driver *drv)
105 pm->dev = input_dev; 105 pm->dev = input_dev;
106 snprintf(pm->phys, sizeof(pm->phys), "%s/input0", serio->phys); 106 snprintf(pm->phys, sizeof(pm->phys), "%s/input0", serio->phys);
107 107
108 input_dev->private = pm;
109 input_dev->name = "Penmount Serial TouchScreen"; 108 input_dev->name = "Penmount Serial TouchScreen";
110 input_dev->phys = pm->phys; 109 input_dev->phys = pm->phys;
111 input_dev->id.bustype = BUS_RS232; 110 input_dev->id.bustype = BUS_RS232;
112 input_dev->id.vendor = SERIO_PENMOUNT; 111 input_dev->id.vendor = SERIO_PENMOUNT;
113 input_dev->id.product = 0; 112 input_dev->id.product = 0;
114 input_dev->id.version = 0x0100; 113 input_dev->id.version = 0x0100;
115 input_dev->cdev.dev = &serio->dev; 114 input_dev->dev.parent = &serio->dev;
116 115
117 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 116 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
118 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 117 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
diff --git a/drivers/input/touchscreen/touchright.c b/drivers/input/touchscreen/touchright.c
index 35ba46c6ad2d..3def7bb1df44 100644
--- a/drivers/input/touchscreen/touchright.c
+++ b/drivers/input/touchscreen/touchright.c
@@ -118,13 +118,13 @@ static int tr_connect(struct serio *serio, struct serio_driver *drv)
118 tr->dev = input_dev; 118 tr->dev = input_dev;
119 snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys); 119 snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys);
120 120
121 input_dev->private = tr;
122 input_dev->name = "Touchright Serial TouchScreen"; 121 input_dev->name = "Touchright Serial TouchScreen";
123 input_dev->phys = tr->phys; 122 input_dev->phys = tr->phys;
124 input_dev->id.bustype = BUS_RS232; 123 input_dev->id.bustype = BUS_RS232;
125 input_dev->id.vendor = SERIO_TOUCHRIGHT; 124 input_dev->id.vendor = SERIO_TOUCHRIGHT;
126 input_dev->id.product = 0; 125 input_dev->id.product = 0;
127 input_dev->id.version = 0x0100; 126 input_dev->id.version = 0x0100;
127 input_dev->dev.parent = &serio->dev;
128 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 128 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
129 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 129 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
130 input_set_abs_params(tr->dev, ABS_X, TR_MIN_XC, TR_MAX_XC, 0, 0); 130 input_set_abs_params(tr->dev, ABS_X, TR_MIN_XC, TR_MAX_XC, 0, 0);
diff --git a/drivers/input/touchscreen/touchwin.c b/drivers/input/touchscreen/touchwin.c
index 4dc073dacabb..ac4bdcf18666 100644
--- a/drivers/input/touchscreen/touchwin.c
+++ b/drivers/input/touchscreen/touchwin.c
@@ -125,13 +125,13 @@ static int tw_connect(struct serio *serio, struct serio_driver *drv)
125 tw->dev = input_dev; 125 tw->dev = input_dev;
126 snprintf(tw->phys, sizeof(tw->phys), "%s/input0", serio->phys); 126 snprintf(tw->phys, sizeof(tw->phys), "%s/input0", serio->phys);
127 127
128 input_dev->private = tw;
129 input_dev->name = "Touchwindow Serial TouchScreen"; 128 input_dev->name = "Touchwindow Serial TouchScreen";
130 input_dev->phys = tw->phys; 129 input_dev->phys = tw->phys;
131 input_dev->id.bustype = BUS_RS232; 130 input_dev->id.bustype = BUS_RS232;
132 input_dev->id.vendor = SERIO_TOUCHWIN; 131 input_dev->id.vendor = SERIO_TOUCHWIN;
133 input_dev->id.product = 0; 132 input_dev->id.product = 0;
134 input_dev->id.version = 0x0100; 133 input_dev->id.version = 0x0100;
134 input_dev->dev.parent = &serio->dev;
135 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 135 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
136 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 136 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
137 input_set_abs_params(tw->dev, ABS_X, TW_MIN_XC, TW_MAX_XC, 0, 0); 137 input_set_abs_params(tw->dev, ABS_X, TW_MIN_XC, TW_MAX_XC, 0, 0);
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index e8606c48c9c3..6582816a0477 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -97,6 +97,8 @@ struct ucb1400 {
97}; 97};
98 98
99static int adcsync; 99static int adcsync;
100static int ts_delay = 55; /* us */
101static int ts_delay_pressure; /* us */
100 102
101static inline u16 ucb1400_reg_read(struct ucb1400 *ucb, u16 reg) 103static inline u16 ucb1400_reg_read(struct ucb1400 *ucb, u16 reg)
102{ 104{
@@ -159,6 +161,7 @@ static inline unsigned int ucb1400_ts_read_pressure(struct ucb1400 *ucb)
159 UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | 161 UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
160 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | 162 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
161 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); 163 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
164 udelay(ts_delay_pressure);
162 return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY); 165 return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY);
163} 166}
164 167
@@ -180,7 +183,7 @@ static inline unsigned int ucb1400_ts_read_xpos(struct ucb1400 *ucb)
180 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | 183 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
181 UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); 184 UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
182 185
183 udelay(55); 186 udelay(ts_delay);
184 187
185 return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY); 188 return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY);
186} 189}
@@ -203,7 +206,7 @@ static inline unsigned int ucb1400_ts_read_ypos(struct ucb1400 *ucb)
203 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | 206 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
204 UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); 207 UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
205 208
206 udelay(55); 209 udelay(ts_delay);
207 210
208 return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPX); 211 return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPX);
209} 212}
@@ -369,7 +372,7 @@ static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid)
369 372
370static int ucb1400_ts_open(struct input_dev *idev) 373static int ucb1400_ts_open(struct input_dev *idev)
371{ 374{
372 struct ucb1400 *ucb = idev->private; 375 struct ucb1400 *ucb = input_get_drvdata(idev);
373 int ret = 0; 376 int ret = 0;
374 377
375 BUG_ON(ucb->ts_task); 378 BUG_ON(ucb->ts_task);
@@ -385,7 +388,7 @@ static int ucb1400_ts_open(struct input_dev *idev)
385 388
386static void ucb1400_ts_close(struct input_dev *idev) 389static void ucb1400_ts_close(struct input_dev *idev)
387{ 390{
388 struct ucb1400 *ucb = idev->private; 391 struct ucb1400 *ucb = input_get_drvdata(idev);
389 392
390 if (ucb->ts_task) 393 if (ucb->ts_task)
391 kthread_stop(ucb->ts_task); 394 kthread_stop(ucb->ts_task);
@@ -507,8 +510,9 @@ static int ucb1400_ts_probe(struct device *dev)
507 } 510 }
508 printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq); 511 printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq);
509 512
510 idev->private = ucb; 513 input_set_drvdata(idev, ucb);
511 idev->cdev.dev = dev; 514
515 idev->dev.parent = dev;
512 idev->name = "UCB1400 touchscreen interface"; 516 idev->name = "UCB1400 touchscreen interface";
513 idev->id.vendor = ucb1400_reg_read(ucb, AC97_VENDOR_ID1); 517 idev->id.vendor = ucb1400_reg_read(ucb, AC97_VENDOR_ID1);
514 idev->id.product = id; 518 idev->id.product = id;
@@ -571,7 +575,15 @@ static void __exit ucb1400_ts_exit(void)
571 driver_unregister(&ucb1400_ts_driver); 575 driver_unregister(&ucb1400_ts_driver);
572} 576}
573 577
574module_param(adcsync, int, 0444); 578module_param(adcsync, bool, 0444);
579MODULE_PARM_DESC(adcsync, "Synchronize touch readings with ADCSYNC pin.");
580
581module_param(ts_delay, int, 0444);
582MODULE_PARM_DESC(ts_delay, "Delay between panel setup and position read. Default = 55us.");
583
584module_param(ts_delay_pressure, int, 0444);
585MODULE_PARM_DESC(ts_delay_pressure,
586 "delay between panel setup and pressure read. Default = 0us.");
575 587
576module_init(ucb1400_ts_init); 588module_init(ucb1400_ts_init);
577module_exit(ucb1400_ts_exit); 589module_exit(ucb1400_ts_exit);
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index 0300dca8591d..5e5b5c91d75b 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -111,13 +111,13 @@ struct tsdev {
111 int minor; 111 int minor;
112 char name[8]; 112 char name[8];
113 wait_queue_head_t wait; 113 wait_queue_head_t wait;
114 struct list_head list; 114 struct list_head client_list;
115 struct input_handle handle; 115 struct input_handle handle;
116 int x, y, pressure; 116 int x, y, pressure;
117 struct ts_calibration cal; 117 struct ts_calibration cal;
118}; 118};
119 119
120struct tsdev_list { 120struct tsdev_client {
121 struct fasync_struct *fasync; 121 struct fasync_struct *fasync;
122 struct list_head node; 122 struct list_head node;
123 struct tsdev *tsdev; 123 struct tsdev *tsdev;
@@ -139,38 +139,49 @@ static struct tsdev *tsdev_table[TSDEV_MINORS/2];
139 139
140static int tsdev_fasync(int fd, struct file *file, int on) 140static int tsdev_fasync(int fd, struct file *file, int on)
141{ 141{
142 struct tsdev_list *list = file->private_data; 142 struct tsdev_client *client = file->private_data;
143 int retval; 143 int retval;
144 144
145 retval = fasync_helper(fd, file, on, &list->fasync); 145 retval = fasync_helper(fd, file, on, &client->fasync);
146 return retval < 0 ? retval : 0; 146 return retval < 0 ? retval : 0;
147} 147}
148 148
149static int tsdev_open(struct inode *inode, struct file *file) 149static int tsdev_open(struct inode *inode, struct file *file)
150{ 150{
151 int i = iminor(inode) - TSDEV_MINOR_BASE; 151 int i = iminor(inode) - TSDEV_MINOR_BASE;
152 struct tsdev_list *list; 152 struct tsdev_client *client;
153 struct tsdev *tsdev;
154 int error;
153 155
154 printk(KERN_WARNING "tsdev (compaq touchscreen emulation) is scheduled " 156 printk(KERN_WARNING "tsdev (compaq touchscreen emulation) is scheduled "
155 "for removal.\nSee Documentation/feature-removal-schedule.txt " 157 "for removal.\nSee Documentation/feature-removal-schedule.txt "
156 "for details.\n"); 158 "for details.\n");
157 159
158 if (i >= TSDEV_MINORS || !tsdev_table[i & TSDEV_MINOR_MASK]) 160 if (i >= TSDEV_MINORS)
161 return -ENODEV;
162
163 tsdev = tsdev_table[i & TSDEV_MINOR_MASK];
164 if (!tsdev || !tsdev->exist)
159 return -ENODEV; 165 return -ENODEV;
160 166
161 if (!(list = kzalloc(sizeof(struct tsdev_list), GFP_KERNEL))) 167 client = kzalloc(sizeof(struct tsdev_client), GFP_KERNEL);
168 if (!client)
162 return -ENOMEM; 169 return -ENOMEM;
163 170
164 list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0; 171 client->tsdev = tsdev;
172 client->raw = (i >= TSDEV_MINORS / 2) ? 1 : 0;
173 list_add_tail(&client->node, &tsdev->client_list);
165 174
166 i &= TSDEV_MINOR_MASK; 175 if (!tsdev->open++ && tsdev->exist) {
167 list->tsdev = tsdev_table[i]; 176 error = input_open_device(&tsdev->handle);
168 list_add_tail(&list->node, &tsdev_table[i]->list); 177 if (error) {
169 file->private_data = list; 178 list_del(&client->node);
179 kfree(client);
180 return error;
181 }
182 }
170 183
171 if (!list->tsdev->open++) 184 file->private_data = client;
172 if (list->tsdev->exist)
173 input_open_device(&list->tsdev->handle);
174 return 0; 185 return 0;
175} 186}
176 187
@@ -182,45 +193,48 @@ static void tsdev_free(struct tsdev *tsdev)
182 193
183static int tsdev_release(struct inode *inode, struct file *file) 194static int tsdev_release(struct inode *inode, struct file *file)
184{ 195{
185 struct tsdev_list *list = file->private_data; 196 struct tsdev_client *client = file->private_data;
197 struct tsdev *tsdev = client->tsdev;
186 198
187 tsdev_fasync(-1, file, 0); 199 tsdev_fasync(-1, file, 0);
188 list_del(&list->node);
189 200
190 if (!--list->tsdev->open) { 201 list_del(&client->node);
191 if (list->tsdev->exist) 202 kfree(client);
192 input_close_device(&list->tsdev->handle); 203
204 if (!--tsdev->open) {
205 if (tsdev->exist)
206 input_close_device(&tsdev->handle);
193 else 207 else
194 tsdev_free(list->tsdev); 208 tsdev_free(tsdev);
195 } 209 }
196 kfree(list); 210
197 return 0; 211 return 0;
198} 212}
199 213
200static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count, 214static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count,
201 loff_t * ppos) 215 loff_t *ppos)
202{ 216{
203 struct tsdev_list *list = file->private_data; 217 struct tsdev_client *client = file->private_data;
218 struct tsdev *tsdev = client->tsdev;
204 int retval = 0; 219 int retval = 0;
205 220
206 if (list->head == list->tail && list->tsdev->exist && (file->f_flags & O_NONBLOCK)) 221 if (client->head == client->tail && tsdev->exist && (file->f_flags & O_NONBLOCK))
207 return -EAGAIN; 222 return -EAGAIN;
208 223
209 retval = wait_event_interruptible(list->tsdev->wait, 224 retval = wait_event_interruptible(tsdev->wait,
210 list->head != list->tail || !list->tsdev->exist); 225 client->head != client->tail || !tsdev->exist);
211
212 if (retval) 226 if (retval)
213 return retval; 227 return retval;
214 228
215 if (!list->tsdev->exist) 229 if (!tsdev->exist)
216 return -ENODEV; 230 return -ENODEV;
217 231
218 while (list->head != list->tail && 232 while (client->head != client->tail &&
219 retval + sizeof (struct ts_event) <= count) { 233 retval + sizeof (struct ts_event) <= count) {
220 if (copy_to_user (buffer + retval, list->event + list->tail, 234 if (copy_to_user (buffer + retval, client->event + client->tail,
221 sizeof (struct ts_event))) 235 sizeof (struct ts_event)))
222 return -EFAULT; 236 return -EFAULT;
223 list->tail = (list->tail + 1) & (TSDEV_BUFFER_SIZE - 1); 237 client->tail = (client->tail + 1) & (TSDEV_BUFFER_SIZE - 1);
224 retval += sizeof (struct ts_event); 238 retval += sizeof (struct ts_event);
225 } 239 }
226 240
@@ -228,32 +242,33 @@ static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count,
228} 242}
229 243
230/* No kernel lock - fine */ 244/* No kernel lock - fine */
231static unsigned int tsdev_poll(struct file *file, poll_table * wait) 245static unsigned int tsdev_poll(struct file *file, poll_table *wait)
232{ 246{
233 struct tsdev_list *list = file->private_data; 247 struct tsdev_client *client = file->private_data;
248 struct tsdev *tsdev = client->tsdev;
234 249
235 poll_wait(file, &list->tsdev->wait, wait); 250 poll_wait(file, &tsdev->wait, wait);
236 return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | 251 return ((client->head == client->tail) ? 0 : (POLLIN | POLLRDNORM)) |
237 (list->tsdev->exist ? 0 : (POLLHUP | POLLERR)); 252 (tsdev->exist ? 0 : (POLLHUP | POLLERR));
238} 253}
239 254
240static int tsdev_ioctl(struct inode *inode, struct file *file, 255static int tsdev_ioctl(struct inode *inode, struct file *file,
241 unsigned int cmd, unsigned long arg) 256 unsigned int cmd, unsigned long arg)
242{ 257{
243 struct tsdev_list *list = file->private_data; 258 struct tsdev_client *client = file->private_data;
244 struct tsdev *tsdev = list->tsdev; 259 struct tsdev *tsdev = client->tsdev;
245 int retval = 0; 260 int retval = 0;
246 261
247 switch (cmd) { 262 switch (cmd) {
248 case TS_GET_CAL: 263 case TS_GET_CAL:
249 if (copy_to_user ((void __user *)arg, &tsdev->cal, 264 if (copy_to_user((void __user *)arg, &tsdev->cal,
250 sizeof (struct ts_calibration))) 265 sizeof (struct ts_calibration)))
251 retval = -EFAULT; 266 retval = -EFAULT;
252 break; 267 break;
253 268
254 case TS_SET_CAL: 269 case TS_SET_CAL:
255 if (copy_from_user (&tsdev->cal, (void __user *)arg, 270 if (copy_from_user(&tsdev->cal, (void __user *)arg,
256 sizeof (struct ts_calibration))) 271 sizeof (struct ts_calibration)))
257 retval = -EFAULT; 272 retval = -EFAULT;
258 break; 273 break;
259 274
@@ -279,7 +294,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
279 unsigned int code, int value) 294 unsigned int code, int value)
280{ 295{
281 struct tsdev *tsdev = handle->private; 296 struct tsdev *tsdev = handle->private;
282 struct tsdev_list *list; 297 struct tsdev_client *client;
283 struct timeval time; 298 struct timeval time;
284 299
285 switch (type) { 300 switch (type) {
@@ -343,18 +358,18 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
343 if (type != EV_SYN || code != SYN_REPORT) 358 if (type != EV_SYN || code != SYN_REPORT)
344 return; 359 return;
345 360
346 list_for_each_entry(list, &tsdev->list, node) { 361 list_for_each_entry(client, &tsdev->client_list, node) {
347 int x, y, tmp; 362 int x, y, tmp;
348 363
349 do_gettimeofday(&time); 364 do_gettimeofday(&time);
350 list->event[list->head].millisecs = time.tv_usec / 100; 365 client->event[client->head].millisecs = time.tv_usec / 100;
351 list->event[list->head].pressure = tsdev->pressure; 366 client->event[client->head].pressure = tsdev->pressure;
352 367
353 x = tsdev->x; 368 x = tsdev->x;
354 y = tsdev->y; 369 y = tsdev->y;
355 370
356 /* Calibration */ 371 /* Calibration */
357 if (!list->raw) { 372 if (!client->raw) {
358 x = ((x * tsdev->cal.xscale) >> 8) + tsdev->cal.xtrans; 373 x = ((x * tsdev->cal.xscale) >> 8) + tsdev->cal.xtrans;
359 y = ((y * tsdev->cal.yscale) >> 8) + tsdev->cal.ytrans; 374 y = ((y * tsdev->cal.yscale) >> 8) + tsdev->cal.ytrans;
360 if (tsdev->cal.xyswap) { 375 if (tsdev->cal.xyswap) {
@@ -362,33 +377,35 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
362 } 377 }
363 } 378 }
364 379
365 list->event[list->head].x = x; 380 client->event[client->head].x = x;
366 list->event[list->head].y = y; 381 client->event[client->head].y = y;
367 list->head = (list->head + 1) & (TSDEV_BUFFER_SIZE - 1); 382 client->head = (client->head + 1) & (TSDEV_BUFFER_SIZE - 1);
368 kill_fasync(&list->fasync, SIGIO, POLL_IN); 383 kill_fasync(&client->fasync, SIGIO, POLL_IN);
369 } 384 }
370 wake_up_interruptible(&tsdev->wait); 385 wake_up_interruptible(&tsdev->wait);
371} 386}
372 387
373static struct input_handle *tsdev_connect(struct input_handler *handler, 388static int tsdev_connect(struct input_handler *handler, struct input_dev *dev,
374 struct input_dev *dev, 389 const struct input_device_id *id)
375 const struct input_device_id *id)
376{ 390{
377 struct tsdev *tsdev; 391 struct tsdev *tsdev;
378 struct class_device *cdev; 392 struct class_device *cdev;
393 dev_t devt;
379 int minor, delta; 394 int minor, delta;
395 int error;
380 396
381 for (minor = 0; minor < TSDEV_MINORS / 2 && tsdev_table[minor]; minor++); 397 for (minor = 0; minor < TSDEV_MINORS / 2 && tsdev_table[minor]; minor++);
382 if (minor >= TSDEV_MINORS / 2) { 398 if (minor >= TSDEV_MINORS / 2) {
383 printk(KERN_ERR 399 printk(KERN_ERR
384 "tsdev: You have way too many touchscreens\n"); 400 "tsdev: You have way too many touchscreens\n");
385 return NULL; 401 return -ENFILE;
386 } 402 }
387 403
388 if (!(tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL))) 404 tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL);
389 return NULL; 405 if (!tsdev)
406 return -ENOMEM;
390 407
391 INIT_LIST_HEAD(&tsdev->list); 408 INIT_LIST_HEAD(&tsdev->client_list);
392 init_waitqueue_head(&tsdev->wait); 409 init_waitqueue_head(&tsdev->wait);
393 410
394 sprintf(tsdev->name, "ts%d", minor); 411 sprintf(tsdev->name, "ts%d", minor);
@@ -415,23 +432,45 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
415 432
416 tsdev_table[minor] = tsdev; 433 tsdev_table[minor] = tsdev;
417 434
418 cdev = class_device_create(&input_class, &dev->cdev, 435 devt = MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
419 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), 436
420 dev->cdev.dev, tsdev->name); 437 cdev = class_device_create(&input_class, &dev->cdev, devt,
438 dev->cdev.dev, tsdev->name);
439 if (IS_ERR(cdev)) {
440 error = PTR_ERR(cdev);
441 goto err_free_tsdev;
442 }
421 443
422 /* temporary symlink to keep userspace happy */ 444 /* temporary symlink to keep userspace happy */
423 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, 445 error = sysfs_create_link(&input_class.subsys.kobj,
424 tsdev->name); 446 &cdev->kobj, tsdev->name);
447 if (error)
448 goto err_cdev_destroy;
449
450 error = input_register_handle(&tsdev->handle);
451 if (error)
452 goto err_remove_link;
425 453
426 return &tsdev->handle; 454 return 0;
455
456 err_remove_link:
457 sysfs_remove_link(&input_class.subsys.kobj, tsdev->name);
458 err_cdev_destroy:
459 class_device_destroy(&input_class, devt);
460 err_free_tsdev:
461 tsdev_table[minor] = NULL;
462 kfree(tsdev);
463 return error;
427} 464}
428 465
429static void tsdev_disconnect(struct input_handle *handle) 466static void tsdev_disconnect(struct input_handle *handle)
430{ 467{
431 struct tsdev *tsdev = handle->private; 468 struct tsdev *tsdev = handle->private;
432 struct tsdev_list *list; 469 struct tsdev_client *client;
470
471 input_unregister_handle(handle);
433 472
434 sysfs_remove_link(&input_class.subsys.kset.kobj, tsdev->name); 473 sysfs_remove_link(&input_class.subsys.kobj, tsdev->name);
435 class_device_destroy(&input_class, 474 class_device_destroy(&input_class,
436 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); 475 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
437 tsdev->exist = 0; 476 tsdev->exist = 0;
@@ -439,8 +478,8 @@ static void tsdev_disconnect(struct input_handle *handle)
439 if (tsdev->open) { 478 if (tsdev->open) {
440 input_close_device(handle); 479 input_close_device(handle);
441 wake_up_interruptible(&tsdev->wait); 480 wake_up_interruptible(&tsdev->wait);
442 list_for_each_entry(list, &tsdev->list, node) 481 list_for_each_entry(client, &tsdev->client_list, node)
443 kill_fasync(&list->fasync, SIGIO, POLL_HUP); 482 kill_fasync(&client->fasync, SIGIO, POLL_HUP);
444 } else 483 } else
445 tsdev_free(tsdev); 484 tsdev_free(tsdev);
446} 485}
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
index 38f648f9b0ed..02c6fbaeccf8 100644
--- a/drivers/isdn/hisax/netjet.c
+++ b/drivers/isdn/hisax/netjet.c
@@ -19,7 +19,6 @@
19#include "isac.h" 19#include "isac.h"
20#include "hscx.h" 20#include "hscx.h"
21#include "isdnl1.h" 21#include "isdnl1.h"
22#include <linux/pci.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/ppp_defs.h> 23#include <linux/ppp_defs.h>
25#include <asm/io.h> 24#include <asm/io.h>
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index f7e83a86f444..4c7dedac0e51 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -13,7 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/poll.h> 14#include <linux/poll.h>
15#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
16#include <linux/pci.h>
17#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
18 17
19#include "hysdn_defs.h" 18#include "hysdn_defs.h"
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 35233de460ad..3d0354e96a97 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -459,7 +459,8 @@ therm_of_probe( struct of_device *dev, const struct of_device_id *match )
459static int 459static int
460therm_of_remove( struct of_device *dev ) 460therm_of_remove( struct of_device *dev )
461{ 461{
462 return i2c_del_driver( &g4fan_driver ); 462 i2c_del_driver( &g4fan_driver );
463 return 0;
463} 464}
464 465
465static struct of_device_id therm_of_match[] = {{ 466static struct of_device_id therm_of_match[] = {{
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index 76d21775fc35..741a93a3eb61 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -82,6 +82,7 @@ static unsigned char cuda_rbuf[16];
82static unsigned char *reply_ptr; 82static unsigned char *reply_ptr;
83static int reading_reply; 83static int reading_reply;
84static int data_index; 84static int data_index;
85static int cuda_irq;
85#ifdef CONFIG_PPC 86#ifdef CONFIG_PPC
86static struct device_node *vias; 87static struct device_node *vias;
87#endif 88#endif
@@ -160,10 +161,8 @@ int __init find_via_cuda(void)
160 /* Clear and enable interrupts, but only on PPC. On 68K it's done */ 161 /* Clear and enable interrupts, but only on PPC. On 68K it's done */
161 /* for us by the main VIA driver in arch/m68k/mac/via.c */ 162 /* for us by the main VIA driver in arch/m68k/mac/via.c */
162 163
163#ifndef CONFIG_MAC
164 out_8(&via[IFR], 0x7f); /* clear interrupts by writing 1s */ 164 out_8(&via[IFR], 0x7f); /* clear interrupts by writing 1s */
165 out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */ 165 out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */
166#endif
167 166
168 /* enable autopoll */ 167 /* enable autopoll */
169 cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, 1); 168 cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, 1);
@@ -181,24 +180,22 @@ int __init find_via_cuda(void)
181 180
182static int __init via_cuda_start(void) 181static int __init via_cuda_start(void)
183{ 182{
184 unsigned int irq;
185
186 if (via == NULL) 183 if (via == NULL)
187 return -ENODEV; 184 return -ENODEV;
188 185
189#ifdef CONFIG_MAC 186#ifdef CONFIG_MAC
190 irq = IRQ_MAC_ADB; 187 cuda_irq = IRQ_MAC_ADB;
191#else /* CONFIG_MAC */ 188#else /* CONFIG_MAC */
192 irq = irq_of_parse_and_map(vias, 0); 189 cuda_irq = irq_of_parse_and_map(vias, 0);
193 if (irq == NO_IRQ) { 190 if (cuda_irq == NO_IRQ) {
194 printk(KERN_ERR "via-cuda: can't map interrupts for %s\n", 191 printk(KERN_ERR "via-cuda: can't map interrupts for %s\n",
195 vias->full_name); 192 vias->full_name);
196 return -ENODEV; 193 return -ENODEV;
197 } 194 }
198#endif /* CONFIG_MAP */ 195#endif /* CONFIG_MAC */
199 196
200 if (request_irq(irq, cuda_interrupt, 0, "ADB", cuda_interrupt)) { 197 if (request_irq(cuda_irq, cuda_interrupt, 0, "ADB", cuda_interrupt)) {
201 printk(KERN_ERR "via-cuda: can't request irq %d\n", irq); 198 printk(KERN_ERR "via-cuda: can't request irq %d\n", cuda_irq);
202 return -EAGAIN; 199 return -EAGAIN;
203 } 200 }
204 201
@@ -238,6 +235,7 @@ cuda_init(void)
238 printk(KERN_ERR "cuda_init_via() failed\n"); 235 printk(KERN_ERR "cuda_init_via() failed\n");
239 return -ENODEV; 236 return -ENODEV;
240 } 237 }
238 out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */
241 239
242 return via_cuda_start(); 240 return via_cuda_start();
243#endif 241#endif
@@ -263,15 +261,17 @@ cuda_init_via(void)
263 out_8(&via[B], in_8(&via[B]) | TACK | TIP); /* negate them */ 261 out_8(&via[B], in_8(&via[B]) | TACK | TIP); /* negate them */
264 out_8(&via[ACR] ,(in_8(&via[ACR]) & ~SR_CTRL) | SR_EXT); /* SR data in */ 262 out_8(&via[ACR] ,(in_8(&via[ACR]) & ~SR_CTRL) | SR_EXT); /* SR data in */
265 (void)in_8(&via[SR]); /* clear any left-over data */ 263 (void)in_8(&via[SR]); /* clear any left-over data */
266#ifndef CONFIG_MAC 264#ifdef CONFIG_PPC
267 out_8(&via[IER], 0x7f); /* disable interrupts from VIA */ 265 out_8(&via[IER], 0x7f); /* disable interrupts from VIA */
268 (void)in_8(&via[IER]); 266 (void)in_8(&via[IER]);
267#else
268 out_8(&via[IER], SR_INT); /* disable SR interrupt from VIA */
269#endif 269#endif
270 270
271 /* delay 4ms and then clear any pending interrupt */ 271 /* delay 4ms and then clear any pending interrupt */
272 mdelay(4); 272 mdelay(4);
273 (void)in_8(&via[SR]); 273 (void)in_8(&via[SR]);
274 out_8(&via[IFR], in_8(&via[IFR]) & 0x7f); 274 out_8(&via[IFR], SR_INT);
275 275
276 /* sync with the CUDA - assert TACK without TIP */ 276 /* sync with the CUDA - assert TACK without TIP */
277 out_8(&via[B], in_8(&via[B]) & ~TACK); 277 out_8(&via[B], in_8(&via[B]) & ~TACK);
@@ -282,7 +282,7 @@ cuda_init_via(void)
282 /* wait for the interrupt and then clear it */ 282 /* wait for the interrupt and then clear it */
283 WAIT_FOR(in_8(&via[IFR]) & SR_INT, "CUDA response to sync (2)"); 283 WAIT_FOR(in_8(&via[IFR]) & SR_INT, "CUDA response to sync (2)");
284 (void)in_8(&via[SR]); 284 (void)in_8(&via[SR]);
285 out_8(&via[IFR], in_8(&via[IFR]) & 0x7f); 285 out_8(&via[IFR], SR_INT);
286 286
287 /* finish the sync by negating TACK */ 287 /* finish the sync by negating TACK */
288 out_8(&via[B], in_8(&via[B]) | TACK); 288 out_8(&via[B], in_8(&via[B]) | TACK);
@@ -291,7 +291,7 @@ cuda_init_via(void)
291 WAIT_FOR(in_8(&via[B]) & TREQ, "CUDA response to sync (3)"); 291 WAIT_FOR(in_8(&via[B]) & TREQ, "CUDA response to sync (3)");
292 WAIT_FOR(in_8(&via[IFR]) & SR_INT, "CUDA response to sync (4)"); 292 WAIT_FOR(in_8(&via[IFR]) & SR_INT, "CUDA response to sync (4)");
293 (void)in_8(&via[SR]); 293 (void)in_8(&via[SR]);
294 out_8(&via[IFR], in_8(&via[IFR]) & 0x7f); 294 out_8(&via[IFR], SR_INT);
295 out_8(&via[B], in_8(&via[B]) | TIP); /* should be unnecessary */ 295 out_8(&via[B], in_8(&via[B]) | TIP); /* should be unnecessary */
296 296
297 return 0; 297 return 0;
@@ -428,16 +428,12 @@ cuda_start(void)
428void 428void
429cuda_poll(void) 429cuda_poll(void)
430{ 430{
431 unsigned long flags;
432
433 /* cuda_interrupt only takes a normal lock, we disable 431 /* cuda_interrupt only takes a normal lock, we disable
434 * interrupts here to avoid re-entering and thus deadlocking. 432 * interrupts here to avoid re-entering and thus deadlocking.
435 * An option would be to disable only the IRQ source with
436 * disable_irq(), would that work on m68k ? --BenH
437 */ 433 */
438 local_irq_save(flags); 434 disable_irq(cuda_irq);
439 cuda_interrupt(0, NULL); 435 cuda_interrupt(0, NULL);
440 local_irq_restore(flags); 436 enable_irq(cuda_irq);
441} 437}
442 438
443static irqreturn_t 439static irqreturn_t
@@ -448,15 +444,25 @@ cuda_interrupt(int irq, void *arg)
448 unsigned char ibuf[16]; 444 unsigned char ibuf[16];
449 int ibuf_len = 0; 445 int ibuf_len = 0;
450 int complete = 0; 446 int complete = 0;
451 unsigned char virq;
452 447
453 spin_lock(&cuda_lock); 448 spin_lock(&cuda_lock);
454 449
455 virq = in_8(&via[IFR]) & 0x7f; 450 /* On powermacs, this handler is registered for the VIA IRQ. But it uses
456 out_8(&via[IFR], virq); 451 * just the shift register IRQ -- other VIA interrupt sources are disabled.
457 if ((virq & SR_INT) == 0) { 452 * On m68k macs, the VIA IRQ sources are dispatched individually. Unless
458 spin_unlock(&cuda_lock); 453 * we are polling, the shift register IRQ flag has already been cleared.
459 return IRQ_NONE; 454 */
455
456#ifdef CONFIG_MAC
457 if (!arg)
458#endif
459 {
460 if ((in_8(&via[IFR]) & SR_INT) == 0) {
461 spin_unlock(&cuda_lock);
462 return IRQ_NONE;
463 } else {
464 out_8(&via[IFR], SR_INT);
465 }
460 } 466 }
461 467
462 status = (~in_8(&via[B]) & (TIP|TREQ)) | (in_8(&via[ACR]) & SR_OUT); 468 status = (~in_8(&via[B]) & (TIP|TREQ)) | (in_8(&via[ACR]) & SR_OUT);
diff --git a/drivers/macintosh/via-macii.c b/drivers/macintosh/via-macii.c
index 1b3bad62a1be..01b8eca7ccd5 100644
--- a/drivers/macintosh/via-macii.c
+++ b/drivers/macintosh/via-macii.c
@@ -12,6 +12,15 @@
12 * 1999-08-02 (jmt) - Initial rewrite for Unified ADB. 12 * 1999-08-02 (jmt) - Initial rewrite for Unified ADB.
13 * 2000-03-29 Tony Mantler <tonym@mac.linux-m68k.org> 13 * 2000-03-29 Tony Mantler <tonym@mac.linux-m68k.org>
14 * - Big overhaul, should actually work now. 14 * - Big overhaul, should actually work now.
15 * 2006-12-31 Finn Thain <fthain@telegraphics.com.au> - Another overhaul.
16 *
17 * Suggested reading:
18 * Inside Macintosh, ch. 5 ADB Manager
19 * Guide to the Macinstosh Family Hardware, ch. 8 Apple Desktop Bus
20 * Rockwell R6522 VIA datasheet
21 *
22 * Apple's "ADB Analyzer" bus sniffer is invaluable:
23 * ftp://ftp.apple.com/developer/Tool_Chest/Devices_-_Hardware/Apple_Desktop_Bus/
15 */ 24 */
16 25
17#include <stdarg.h> 26#include <stdarg.h>
@@ -26,7 +35,6 @@
26#include <asm/macints.h> 35#include <asm/macints.h>
27#include <asm/machw.h> 36#include <asm/machw.h>
28#include <asm/mac_via.h> 37#include <asm/mac_via.h>
29#include <asm/io.h>
30#include <asm/system.h> 38#include <asm/system.h>
31 39
32static volatile unsigned char *via; 40static volatile unsigned char *via;
@@ -51,9 +59,7 @@ static volatile unsigned char *via;
51#define ANH (15*RS) /* A-side data, no handshake */ 59#define ANH (15*RS) /* A-side data, no handshake */
52 60
53/* Bits in B data register: all active low */ 61/* Bits in B data register: all active low */
54#define TREQ 0x08 /* Transfer request (input) */ 62#define CTLR_IRQ 0x08 /* Controller rcv status (input) */
55#define TACK 0x10 /* Transfer acknowledge (output) */
56#define TIP 0x20 /* Transfer in progress (output) */
57#define ST_MASK 0x30 /* mask for selecting ADB state bits */ 63#define ST_MASK 0x30 /* mask for selecting ADB state bits */
58 64
59/* Bits in ACR */ 65/* Bits in ACR */
@@ -65,8 +71,6 @@ static volatile unsigned char *via;
65#define IER_SET 0x80 /* set bits in IER */ 71#define IER_SET 0x80 /* set bits in IER */
66#define IER_CLR 0 /* clear bits in IER */ 72#define IER_CLR 0 /* clear bits in IER */
67#define SR_INT 0x04 /* Shift register full/empty */ 73#define SR_INT 0x04 /* Shift register full/empty */
68#define SR_DATA 0x08 /* Shift register data */
69#define SR_CLOCK 0x10 /* Shift register clock */
70 74
71/* ADB transaction states according to GMHW */ 75/* ADB transaction states according to GMHW */
72#define ST_CMD 0x00 /* ADB state: command byte */ 76#define ST_CMD 0x00 /* ADB state: command byte */
@@ -77,7 +81,6 @@ static volatile unsigned char *via;
77static int macii_init_via(void); 81static int macii_init_via(void);
78static void macii_start(void); 82static void macii_start(void);
79static irqreturn_t macii_interrupt(int irq, void *arg); 83static irqreturn_t macii_interrupt(int irq, void *arg);
80static void macii_retransmit(int);
81static void macii_queue_poll(void); 84static void macii_queue_poll(void);
82 85
83static int macii_probe(void); 86static int macii_probe(void);
@@ -103,29 +106,37 @@ static enum macii_state {
103 sending, 106 sending,
104 reading, 107 reading,
105 read_done, 108 read_done,
106 awaiting_reply
107} macii_state; 109} macii_state;
108 110
109static int need_poll; 111static struct adb_request *current_req; /* first request struct in the queue */
110static int command_byte; 112static struct adb_request *last_req; /* last request struct in the queue */
111static int last_reply; 113static unsigned char reply_buf[16]; /* storage for autopolled replies */
112static int last_active; 114static unsigned char *reply_ptr; /* next byte in req->data or reply_buf */
113 115static int reading_reply; /* store reply in reply_buf else req->reply */
114static struct adb_request *current_req; 116static int data_index; /* index of the next byte to send from req->data */
115static struct adb_request *last_req; 117static int reply_len; /* number of bytes received in reply_buf or req->reply */
116static struct adb_request *retry_req; 118static int status; /* VIA's ADB status bits captured upon interrupt */
117static unsigned char reply_buf[16]; 119static int last_status; /* status bits as at previous interrupt */
118static unsigned char *reply_ptr; 120static int srq_asserted; /* have to poll for the device that asserted it */
119static int reply_len; 121static int command_byte; /* the most recent command byte transmitted */
120static int reading_reply; 122static int autopoll_devs; /* bits set are device addresses to be polled */
121static int data_index; 123
122static int first_byte; 124/* Sanity check for request queue. Doesn't check for cycles. */
123static int prefix_len; 125static int request_is_queued(struct adb_request *req) {
124static int status = ST_IDLE|TREQ; 126 struct adb_request *cur;
125static int last_status; 127 unsigned long flags;
126static int driver_running; 128 local_irq_save(flags);
127 129 cur = current_req;
128/* debug level 10 required for ADB logging (should be && debug_adb, ideally) */ 130 while (cur) {
131 if (cur == req) {
132 local_irq_restore(flags);
133 return 1;
134 }
135 cur = cur->next;
136 }
137 local_irq_restore(flags);
138 return 0;
139}
129 140
130/* Check for MacII style ADB */ 141/* Check for MacII style ADB */
131static int macii_probe(void) 142static int macii_probe(void)
@@ -147,15 +158,16 @@ int macii_init(void)
147 local_irq_save(flags); 158 local_irq_save(flags);
148 159
149 err = macii_init_via(); 160 err = macii_init_via();
150 if (err) return err; 161 if (err) goto out;
151 162
152 err = request_irq(IRQ_MAC_ADB, macii_interrupt, IRQ_FLG_LOCK, "ADB", 163 err = request_irq(IRQ_MAC_ADB, macii_interrupt, IRQ_FLG_LOCK, "ADB",
153 macii_interrupt); 164 macii_interrupt);
154 if (err) return err; 165 if (err) goto out;
155 166
156 macii_state = idle; 167 macii_state = idle;
168out:
157 local_irq_restore(flags); 169 local_irq_restore(flags);
158 return 0; 170 return err;
159} 171}
160 172
161/* initialize the hardware */ 173/* initialize the hardware */
@@ -163,12 +175,12 @@ static int macii_init_via(void)
163{ 175{
164 unsigned char x; 176 unsigned char x;
165 177
166 /* Set the lines up. We want TREQ as input TACK|TIP as output */ 178 /* We want CTLR_IRQ as input and ST_EVEN | ST_ODD as output lines. */
167 via[DIRB] = (via[DIRB] | TACK | TIP) & ~TREQ; 179 via[DIRB] = (via[DIRB] | ST_EVEN | ST_ODD) & ~CTLR_IRQ;
168 180
169 /* Set up state: idle */ 181 /* Set up state: idle */
170 via[B] |= ST_IDLE; 182 via[B] |= ST_IDLE;
171 last_status = via[B] & (ST_MASK|TREQ); 183 last_status = via[B] & (ST_MASK|CTLR_IRQ);
172 184
173 /* Shift register on input */ 185 /* Shift register on input */
174 via[ACR] = (via[ACR] & ~SR_CTRL) | SR_EXT; 186 via[ACR] = (via[ACR] & ~SR_CTRL) | SR_EXT;
@@ -179,81 +191,72 @@ static int macii_init_via(void)
179 return 0; 191 return 0;
180} 192}
181 193
182/* Send an ADB poll (Talk Register 0 command, tagged on the front of the request queue) */ 194/* Send an ADB poll (Talk Register 0 command prepended to the request queue) */
183static void macii_queue_poll(void) 195static void macii_queue_poll(void)
184{ 196{
185 static int device = 0; 197 /* No point polling the active device as it will never assert SRQ, so
186 static int in_poll=0; 198 * poll the next device in the autopoll list. This could leave us
199 * stuck in a polling loop if an unprobed device is asserting SRQ.
200 * In theory, that could only happen if a device was plugged in after
201 * probing started. Unplugging it again will break the cycle.
202 * (Simply polling the next higher device often ends up polling almost
203 * every device (after wrapping around), which takes too long.)
204 */
205 int device_mask;
206 int next_device;
187 static struct adb_request req; 207 static struct adb_request req;
188 unsigned long flags;
189
190 if (in_poll) printk("macii_queue_poll: double poll!\n");
191
192 in_poll++;
193 if (++device > 15) device = 1;
194
195 adb_request(&req, NULL, ADBREQ_REPLY|ADBREQ_NOSEND, 1,
196 ADB_READREG(device, 0));
197
198 local_irq_save(flags);
199
200 req.next = current_req;
201 current_req = &req;
202 208
203 local_irq_restore(flags); 209 if (!autopoll_devs) return;
204 macii_start();
205 in_poll--;
206}
207 210
208/* Send an ADB retransmit (Talk, appended to the request queue) */ 211 device_mask = (1 << (((command_byte & 0xF0) >> 4) + 1)) - 1;
209static void macii_retransmit(int device) 212 if (autopoll_devs & ~device_mask)
210{ 213 next_device = ffs(autopoll_devs & ~device_mask) - 1;
211 static int in_retransmit = 0; 214 else
212 static struct adb_request rt; 215 next_device = ffs(autopoll_devs) - 1;
213 unsigned long flags;
214
215 if (in_retransmit) printk("macii_retransmit: double retransmit!\n");
216 216
217 in_retransmit++; 217 BUG_ON(request_is_queued(&req));
218 218
219 adb_request(&rt, NULL, ADBREQ_REPLY|ADBREQ_NOSEND, 1, 219 adb_request(&req, NULL, ADBREQ_NOSEND, 1,
220 ADB_READREG(device, 0)); 220 ADB_READREG(next_device, 0));
221 221
222 local_irq_save(flags); 222 req.sent = 0;
223 req.complete = 0;
224 req.reply_len = 0;
225 req.next = current_req;
223 226
224 if (current_req != NULL) { 227 if (current_req != NULL) {
225 last_req->next = &rt; 228 current_req = &req;
226 last_req = &rt;
227 } else { 229 } else {
228 current_req = &rt; 230 current_req = &req;
229 last_req = &rt; 231 last_req = &req;
230 } 232 }
231
232 if (macii_state == idle) macii_start();
233
234 local_irq_restore(flags);
235 in_retransmit--;
236} 233}
237 234
238/* Send an ADB request; if sync, poll out the reply 'till it's done */ 235/* Send an ADB request; if sync, poll out the reply 'till it's done */
239static int macii_send_request(struct adb_request *req, int sync) 236static int macii_send_request(struct adb_request *req, int sync)
240{ 237{
241 int i; 238 int err;
239 unsigned long flags;
242 240
243 i = macii_write(req); 241 BUG_ON(request_is_queued(req));
244 if (i) return i;
245 242
246 if (sync) { 243 local_irq_save(flags);
247 while (!req->complete) macii_poll(); 244 err = macii_write(req);
245 local_irq_restore(flags);
246
247 if (!err && sync) {
248 while (!req->complete) {
249 macii_poll();
250 }
251 BUG_ON(request_is_queued(req));
248 } 252 }
249 return 0; 253
254 return err;
250} 255}
251 256
252/* Send an ADB request */ 257/* Send an ADB request (append to request queue) */
253static int macii_write(struct adb_request *req) 258static int macii_write(struct adb_request *req)
254{ 259{
255 unsigned long flags;
256
257 if (req->nbytes < 2 || req->data[0] != ADB_PACKET || req->nbytes > 15) { 260 if (req->nbytes < 2 || req->data[0] != ADB_PACKET || req->nbytes > 15) {
258 req->complete = 1; 261 req->complete = 1;
259 return -EINVAL; 262 return -EINVAL;
@@ -264,8 +267,6 @@ static int macii_write(struct adb_request *req)
264 req->complete = 0; 267 req->complete = 0;
265 req->reply_len = 0; 268 req->reply_len = 0;
266 269
267 local_irq_save(flags);
268
269 if (current_req != NULL) { 270 if (current_req != NULL) {
270 last_req->next = req; 271 last_req->next = req;
271 last_req = req; 272 last_req = req;
@@ -274,28 +275,52 @@ static int macii_write(struct adb_request *req)
274 last_req = req; 275 last_req = req;
275 if (macii_state == idle) macii_start(); 276 if (macii_state == idle) macii_start();
276 } 277 }
277
278 local_irq_restore(flags);
279 return 0; 278 return 0;
280} 279}
281 280
282/* Start auto-polling */ 281/* Start auto-polling */
283static int macii_autopoll(int devs) 282static int macii_autopoll(int devs)
284{ 283{
285 /* Just ping a random default address */ 284 static struct adb_request req;
286 if (!(current_req || retry_req)) 285 unsigned long flags;
287 macii_retransmit( (last_active < 16 && last_active > 0) ? last_active : 3); 286 int err = 0;
288 return 0; 287
288 /* bit 1 == device 1, and so on. */
289 autopoll_devs = devs & 0xFFFE;
290
291 if (!autopoll_devs) return 0;
292
293 local_irq_save(flags);
294
295 if (current_req == NULL) {
296 /* Send a Talk Reg 0. The controller will repeatedly transmit
297 * this as long as it is idle.
298 */
299 adb_request(&req, NULL, ADBREQ_NOSEND, 1,
300 ADB_READREG(ffs(autopoll_devs) - 1, 0));
301 err = macii_write(&req);
302 }
303
304 local_irq_restore(flags);
305 return err;
306}
307
308static inline int need_autopoll(void) {
309 /* Was the last command Talk Reg 0
310 * and is the target on the autopoll list?
311 */
312 if ((command_byte & 0x0F) == 0x0C &&
313 ((1 << ((command_byte & 0xF0) >> 4)) & autopoll_devs))
314 return 0;
315 return 1;
289} 316}
290 317
291/* Prod the chip without interrupts */ 318/* Prod the chip without interrupts */
292static void macii_poll(void) 319static void macii_poll(void)
293{ 320{
294 unsigned long flags; 321 disable_irq(IRQ_MAC_ADB);
295 322 macii_interrupt(0, NULL);
296 local_irq_save(flags); 323 enable_irq(IRQ_MAC_ADB);
297 if (via[IFR] & SR_INT) macii_interrupt(0, NULL);
298 local_irq_restore(flags);
299} 324}
300 325
301/* Reset the bus */ 326/* Reset the bus */
@@ -303,73 +328,34 @@ static int macii_reset_bus(void)
303{ 328{
304 static struct adb_request req; 329 static struct adb_request req;
305 330
331 if (request_is_queued(&req))
332 return 0;
333
306 /* Command = 0, Address = ignored */ 334 /* Command = 0, Address = ignored */
307 adb_request(&req, NULL, 0, 1, ADB_BUSRESET); 335 adb_request(&req, NULL, 0, 1, ADB_BUSRESET);
308 336
337 /* Don't want any more requests during the Global Reset low time. */
338 udelay(3000);
339
309 return 0; 340 return 0;
310} 341}
311 342
312/* Start sending ADB packet */ 343/* Start sending ADB packet */
313static void macii_start(void) 344static void macii_start(void)
314{ 345{
315 unsigned long flags;
316 struct adb_request *req; 346 struct adb_request *req;
317 347
318 req = current_req; 348 req = current_req;
319 if (!req) return;
320
321 /* assert macii_state == idle */
322 if (macii_state != idle) {
323 printk("macii_start: called while driver busy (%p %x %x)!\n",
324 req, macii_state, (uint) via1[B] & (ST_MASK|TREQ));
325 return;
326 }
327 349
328 local_irq_save(flags); 350 BUG_ON(req == NULL);
329 351
330 /* 352 BUG_ON(macii_state != idle);
331 * IRQ signaled ?? (means ADB controller wants to send, or might 353
332 * be end of packet if we were reading) 354 /* Now send it. Be careful though, that first byte of the request
333 */ 355 * is actually ADB_PACKET; the real data begins at index 1!
334#if 0 /* FIXME: This is broke broke broke, for some reason */ 356 * And req->nbytes is the number of bytes of real data plus one.
335 if ((via[B] & TREQ) == 0) {
336 printk("macii_start: weird poll stuff. huh?\n");
337 /*
338 * FIXME - we need to restart this on a timer
339 * or a collision at boot hangs us.
340 * Never set macii_state to idle here, or macii_start
341 * won't be called again from send_request!
342 * (need to re-check other cases ...)
343 */
344 /*
345 * if the interrupt handler set the need_poll
346 * flag, it's hopefully a SRQ poll or re-Talk
347 * so we try to send here anyway
348 */
349 if (!need_poll) {
350 if (console_loglevel == 10)
351 printk("macii_start: device busy - retry %p state %d status %x!\n",
352 req, macii_state,
353 (uint) via[B] & (ST_MASK|TREQ));
354 retry_req = req;
355 /* set ADB status here ? */
356 local_irq_restore(flags);
357 return;
358 } else {
359 need_poll = 0;
360 }
361 }
362#endif
363 /*
364 * Another retry pending? (sanity check)
365 */ 357 */
366 if (retry_req) {
367 retry_req = NULL;
368 }
369 358
370 /* Now send it. Be careful though, that first byte of the request */
371 /* is actually ADB_PACKET; the real data begins at index 1! */
372
373 /* store command byte */ 359 /* store command byte */
374 command_byte = req->data[1]; 360 command_byte = req->data[1];
375 /* Output mode */ 361 /* Output mode */
@@ -381,115 +367,97 @@ static void macii_start(void)
381 367
382 macii_state = sending; 368 macii_state = sending;
383 data_index = 2; 369 data_index = 2;
384
385 local_irq_restore(flags);
386} 370}
387 371
388/* 372/*
389 * The notorious ADB interrupt handler - does all of the protocol handling, 373 * The notorious ADB interrupt handler - does all of the protocol handling.
390 * except for starting new send operations. Relies heavily on the ADB 374 * Relies on the ADB controller sending and receiving data, thereby
391 * controller sending and receiving data, thereby generating SR interrupts 375 * generating shift register interrupts (SR_INT) for us. This means there has
392 * for us. This means there has to be always activity on the ADB bus, otherwise 376 * to be activity on the ADB bus. The chip will poll to achieve this.
393 * the whole process dies and has to be re-kicked by sending TALK requests ...
394 * CUDA-based Macs seem to solve this with the autopoll option, for MacII-type
395 * ADB the problem isn't solved yet (retransmit of the latest active TALK seems
396 * a good choice; either on timeout or on a timer interrupt).
397 * 377 *
398 * The basic ADB state machine was left unchanged from the original MacII code 378 * The basic ADB state machine was left unchanged from the original MacII code
399 * by Alan Cox, which was based on the CUDA driver for PowerMac. 379 * by Alan Cox, which was based on the CUDA driver for PowerMac.
400 * The syntax of the ADB status lines seems to be totally different on MacII, 380 * The syntax of the ADB status lines is totally different on MacII,
401 * though. MacII uses the states Command -> Even -> Odd -> Even ->...-> Idle for 381 * though. MacII uses the states Command -> Even -> Odd -> Even ->...-> Idle
402 * sending, and Idle -> Even -> Odd -> Even ->...-> Idle for receiving. Start 382 * for sending and Idle -> Even -> Odd -> Even ->...-> Idle for receiving.
403 * and end of a receive packet are signaled by asserting /IRQ on the interrupt 383 * Start and end of a receive packet are signalled by asserting /IRQ on the
404 * line. Timeouts are signaled by a sequence of 4 0xFF, with /IRQ asserted on 384 * interrupt line (/IRQ means the CTLR_IRQ bit in port B; not to be confused
405 * every other byte. SRQ is probably signaled by 3 or more 0xFF tacked on the 385 * with the VIA shift register interrupt. /IRQ never actually interrupts the
406 * end of a packet. (Thanks to Guido Koerber for eavesdropping on the ADB 386 * processor, it's just an ordinary input.)
407 * protocol with a logic analyzer!!)
408 *
409 * Note: As of 21/10/97, the MacII ADB part works including timeout detection
410 * and retransmit (Talk to the last active device).
411 */ 387 */
412static irqreturn_t macii_interrupt(int irq, void *arg) 388static irqreturn_t macii_interrupt(int irq, void *arg)
413{ 389{
414 int x, adbdir; 390 int x;
415 unsigned long flags; 391 static int entered;
416 struct adb_request *req; 392 struct adb_request *req;
417 393
418 last_status = status; 394 if (!arg) {
419 395 /* Clear the SR IRQ flag when polling. */
420 /* prevent races due to SCSI enabling ints */ 396 if (via[IFR] & SR_INT)
421 local_irq_save(flags); 397 via[IFR] = SR_INT;
422 398 else
423 if (driver_running) { 399 return IRQ_NONE;
424 local_irq_restore(flags);
425 return IRQ_NONE;
426 } 400 }
427 401
428 driver_running = 1; 402 BUG_ON(entered++);
429 403
430 status = via[B] & (ST_MASK|TREQ); 404 last_status = status;
431 adbdir = via[ACR] & SR_OUT; 405 status = via[B] & (ST_MASK|CTLR_IRQ);
432 406
433 switch (macii_state) { 407 switch (macii_state) {
434 case idle: 408 case idle:
409 if (reading_reply) {
410 reply_ptr = current_req->reply;
411 } else {
412 BUG_ON(current_req != NULL);
413 reply_ptr = reply_buf;
414 }
415
435 x = via[SR]; 416 x = via[SR];
436 first_byte = x;
437 /* set ADB state = even for first data byte */
438 via[B] = (via[B] & ~ST_MASK) | ST_EVEN;
439 417
440 reply_buf[0] = first_byte; /* was command_byte?? */ 418 if ((status & CTLR_IRQ) && (x == 0xFF)) {
441 reply_ptr = reply_buf + 1; 419 /* Bus timeout without SRQ sequence:
442 reply_len = 1; 420 * data is "FF" while CTLR_IRQ is "H"
443 prefix_len = 1; 421 */
444 reading_reply = 0; 422 reply_len = 0;
445 423 srq_asserted = 0;
446 macii_state = reading; 424 macii_state = read_done;
447 break; 425 } else {
426 macii_state = reading;
427 *reply_ptr = x;
428 reply_len = 1;
429 }
448 430
449 case awaiting_reply:
450 /* handshake etc. for II ?? */
451 x = via[SR];
452 first_byte = x;
453 /* set ADB state = even for first data byte */ 431 /* set ADB state = even for first data byte */
454 via[B] = (via[B] & ~ST_MASK) | ST_EVEN; 432 via[B] = (via[B] & ~ST_MASK) | ST_EVEN;
455
456 current_req->reply[0] = first_byte;
457 reply_ptr = current_req->reply + 1;
458 reply_len = 1;
459 prefix_len = 1;
460 reading_reply = 1;
461
462 macii_state = reading;
463 break; 433 break;
464 434
465 case sending: 435 case sending:
466 req = current_req; 436 req = current_req;
467 if (data_index >= req->nbytes) { 437 if (data_index >= req->nbytes) {
468 /* print an error message if a listen command has no data */
469 if (((command_byte & 0x0C) == 0x08)
470 /* && (console_loglevel == 10) */
471 && (data_index == 2))
472 printk("MacII ADB: listen command with no data: %x!\n",
473 command_byte);
474 /* reset to shift in */
475 via[ACR] &= ~SR_OUT;
476 x = via[SR];
477 /* set ADB state idle - might get SRQ */
478 via[B] = (via[B] & ~ST_MASK) | ST_IDLE;
479
480 req->sent = 1; 438 req->sent = 1;
439 macii_state = idle;
481 440
482 if (req->reply_expected) { 441 if (req->reply_expected) {
483 macii_state = awaiting_reply; 442 reading_reply = 1;
484 } else { 443 } else {
485 req->complete = 1; 444 req->complete = 1;
486 current_req = req->next; 445 current_req = req->next;
487 if (req->done) (*req->done)(req); 446 if (req->done) (*req->done)(req);
488 macii_state = idle; 447
489 if (current_req || retry_req) 448 if (current_req)
490 macii_start(); 449 macii_start();
491 else 450 else
492 macii_retransmit((command_byte & 0xF0) >> 4); 451 if (need_autopoll())
452 macii_autopoll(autopoll_devs);
453 }
454
455 if (macii_state == idle) {
456 /* reset to shift in */
457 via[ACR] &= ~SR_OUT;
458 x = via[SR];
459 /* set ADB state idle - might get SRQ */
460 via[B] = (via[B] & ~ST_MASK) | ST_IDLE;
493 } 461 }
494 } else { 462 } else {
495 via[SR] = req->data[data_index++]; 463 via[SR] = req->data[data_index++];
@@ -505,147 +473,79 @@ static irqreturn_t macii_interrupt(int irq, void *arg)
505 break; 473 break;
506 474
507 case reading: 475 case reading:
476 x = via[SR];
477 BUG_ON((status & ST_MASK) == ST_CMD ||
478 (status & ST_MASK) == ST_IDLE);
479
480 /* Bus timeout with SRQ sequence:
481 * data is "XX FF" while CTLR_IRQ is "L L"
482 * End of packet without SRQ sequence:
483 * data is "XX...YY 00" while CTLR_IRQ is "L...H L"
484 * End of packet SRQ sequence:
485 * data is "XX...YY 00" while CTLR_IRQ is "L...L L"
486 * (where XX is the first response byte and
487 * YY is the last byte of valid response data.)
488 */
508 489
509 /* timeout / SRQ handling for II hw */ 490 srq_asserted = 0;
510 if( (first_byte == 0xFF && (reply_len-prefix_len)==2 491 if (!(status & CTLR_IRQ)) {
511 && memcmp(reply_ptr-2,"\xFF\xFF",2)==0) || 492 if (x == 0xFF) {
512 ((reply_len-prefix_len)==3 493 if (!(last_status & CTLR_IRQ)) {
513 && memcmp(reply_ptr-3,"\xFF\xFF\xFF",3)==0)) 494 macii_state = read_done;
514 { 495 reply_len = 0;
515 /* 496 srq_asserted = 1;
516 * possible timeout (in fact, most probably a 497 }
517 * timeout, since SRQ can't be signaled without 498 } else if (x == 0x00) {
518 * transfer on the bus). 499 macii_state = read_done;
519 * The last three bytes seen were FF, together 500 if (!(last_status & CTLR_IRQ))
520 * with the starting byte (in case we started 501 srq_asserted = 1;
521 * on 'idle' or 'awaiting_reply') this probably
522 * makes four. So this is mostl likely #5!
523 * The timeout signal is a pattern 1 0 1 0 0..
524 * on /INT, meaning we missed it :-(
525 */
526 x = via[SR];
527 if (x != 0xFF) printk("MacII ADB: mistaken timeout/SRQ!\n");
528
529 if ((status & TREQ) == (last_status & TREQ)) {
530 /* Not a timeout. Unsolicited SRQ? weird. */
531 /* Terminate the SRQ packet and poll */
532 need_poll = 1;
533 } 502 }
534 /* There's no packet to get, so reply is blank */ 503 }
535 via[B] ^= ST_MASK; 504
536 reply_ptr -= (reply_len-prefix_len); 505 if (macii_state == reading) {
537 reply_len = prefix_len; 506 BUG_ON(reply_len > 15);
538 macii_state = read_done;
539 break;
540 } /* end timeout / SRQ handling for II hw. */
541
542 if((reply_len-prefix_len)>3
543 && memcmp(reply_ptr-3,"\xFF\xFF\xFF",3)==0)
544 {
545 /* SRQ tacked on data packet */
546 /* Terminate the packet (SRQ never ends) */
547 x = via[SR];
548 macii_state = read_done;
549 reply_len -= 3;
550 reply_ptr -= 3;
551 need_poll = 1;
552 /* need to continue; next byte not seen else */
553 } else {
554 /* Sanity check */
555 if (reply_len > 15) reply_len = 0;
556 /* read byte */
557 x = via[SR];
558 *reply_ptr = x;
559 reply_ptr++; 507 reply_ptr++;
508 *reply_ptr = x;
560 reply_len++; 509 reply_len++;
561 } 510 }
562 /* The usual handshake ... */
563
564 /*
565 * NetBSD hints that the next to last byte
566 * is sent with IRQ !!
567 * Guido found out it's the last one (0x0),
568 * but IRQ should be asserted already.
569 * Problem with timeout detection: First
570 * transition to /IRQ might be second
571 * byte of timeout packet!
572 * Timeouts are signaled by 4x FF.
573 */
574 if (((status & TREQ) == 0) && (x == 0x00)) { /* != 0xFF */
575 /* invert state bits, toggle ODD/EVEN */
576 via[B] ^= ST_MASK;
577 511
578 /* adjust packet length */ 512 /* invert state bits, toggle ODD/EVEN */
579 reply_len--; 513 via[B] ^= ST_MASK;
580 reply_ptr--;
581 macii_state = read_done;
582 } else {
583 /* not caught: ST_CMD */
584 /* required for re-entry 'reading'! */
585 if ((status & ST_MASK) == ST_IDLE) {
586 /* (in)sanity check - set even */
587 via[B] = (via[B] & ~ST_MASK) | ST_EVEN;
588 } else {
589 /* invert state bits */
590 via[B] ^= ST_MASK;
591 }
592 }
593 break; 514 break;
594 515
595 case read_done: 516 case read_done:
596 x = via[SR]; 517 x = via[SR];
518
597 if (reading_reply) { 519 if (reading_reply) {
520 reading_reply = 0;
598 req = current_req; 521 req = current_req;
599 req->reply_len = reply_ptr - req->reply; 522 req->reply_len = reply_len;
600 req->complete = 1; 523 req->complete = 1;
601 current_req = req->next; 524 current_req = req->next;
602 if (req->done) (*req->done)(req); 525 if (req->done) (*req->done)(req);
603 } else { 526 } else if (reply_len && autopoll_devs)
604 adb_input(reply_buf, reply_ptr - reply_buf, 0); 527 adb_input(reply_buf, reply_len, 0);
605 }
606 528
607 /* 529 macii_state = idle;
608 * remember this device ID; it's the latest we got a
609 * reply from!
610 */
611 last_reply = command_byte;
612 last_active = (command_byte & 0xF0) >> 4;
613 530
614 /* SRQ seen before, initiate poll now */ 531 /* SRQ seen before, initiate poll now */
615 if (need_poll) { 532 if (srq_asserted)
616 macii_state = idle;
617 macii_queue_poll(); 533 macii_queue_poll();
618 need_poll = 0;
619 break;
620 }
621
622 /* set ADB state to idle */
623 via[B] = (via[B] & ~ST_MASK) | ST_IDLE;
624
625 /* /IRQ seen, so the ADB controller has data for us */
626 if ((via[B] & TREQ) != 0) {
627 macii_state = reading;
628 534
629 reply_buf[0] = command_byte; 535 if (current_req)
630 reply_ptr = reply_buf + 1; 536 macii_start();
631 reply_len = 1; 537 else
632 prefix_len = 1; 538 if (need_autopoll())
633 reading_reply = 0; 539 macii_autopoll(autopoll_devs);
634 } else { 540
635 /* no IRQ, send next packet or wait */ 541 if (macii_state == idle)
636 macii_state = idle; 542 via[B] = (via[B] & ~ST_MASK) | ST_IDLE;
637 if (current_req)
638 macii_start();
639 else
640 macii_retransmit(last_active);
641 }
642 break; 543 break;
643 544
644 default: 545 default:
645 break; 546 break;
646 } 547 }
647 /* reset mutex and interrupts */ 548
648 driver_running = 0; 549 entered--;
649 local_irq_restore(flags);
650 return IRQ_HANDLED; 550 return IRQ_HANDLED;
651} 551}
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c
index 356c7216a179..dfdf11c1eec4 100644
--- a/drivers/macintosh/via-pmu68k.c
+++ b/drivers/macintosh/via-pmu68k.c
@@ -111,7 +111,6 @@ static int pmu_send_request(struct adb_request *req, int sync);
111static int pmu_autopoll(int devs); 111static int pmu_autopoll(int devs);
112void pmu_poll(void); 112void pmu_poll(void);
113static int pmu_reset_bus(void); 113static int pmu_reset_bus(void);
114static int pmu_queue_request(struct adb_request *req);
115 114
116static void pmu_start(void); 115static void pmu_start(void);
117static void send_byte(int x); 116static void send_byte(int x);
@@ -475,7 +474,7 @@ pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
475 return pmu_queue_request(req); 474 return pmu_queue_request(req);
476} 475}
477 476
478static int 477int
479pmu_queue_request(struct adb_request *req) 478pmu_queue_request(struct adb_request *req)
480{ 479{
481 unsigned long flags; 480 unsigned long flags;
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
index 5347a406fff7..02a0ea6e1c17 100644
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -183,7 +183,8 @@ int flexcop_i2c_init(struct flexcop_device *fc)
183 mutex_init(&fc->i2c_mutex); 183 mutex_init(&fc->i2c_mutex);
184 184
185 memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter)); 185 memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter));
186 strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",I2C_NAME_SIZE); 186 strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",
187 sizeof(fc->i2c_adap.name));
187 188
188 i2c_set_adapdata(&fc->i2c_adap,fc); 189 i2c_set_adapdata(&fc->i2c_adap,fc);
189 190
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index a6cbbdd262d6..34d7abc900d7 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -26,11 +26,11 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/pci.h>
30#include <linux/input.h> 29#include <linux/input.h>
31#include <linux/dvb/frontend.h> 30#include <linux/dvb/frontend.h>
32#include <linux/mutex.h> 31#include <linux/mutex.h>
33#include <linux/mm.h> 32#include <linux/mm.h>
33#include <asm/io.h>
34 34
35#include "dmxdev.h" 35#include "dmxdev.h"
36#include "dvb_demux.h" 36#include "dvb_demux.h"
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
index 70df31b0a8a9..088b6dee3a7f 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
@@ -19,7 +19,7 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
19 return -EINVAL; 19 return -EINVAL;
20 } 20 }
21 21
22 strncpy(d->i2c_adap.name,d->desc->name,I2C_NAME_SIZE); 22 strncpy(d->i2c_adap.name, d->desc->name, sizeof(d->i2c_adap.name));
23#ifdef I2C_ADAP_CLASS_TV_DIGITAL 23#ifdef I2C_ADAP_CLASS_TV_DIGITAL
24 d->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL, 24 d->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL,
25#else 25#else
diff --git a/drivers/media/dvb/frontends/dibx000_common.c b/drivers/media/dvb/frontends/dibx000_common.c
index a18c8f45a2ee..315e09e95b0c 100644
--- a/drivers/media/dvb/frontends/dibx000_common.c
+++ b/drivers/media/dvb/frontends/dibx000_common.c
@@ -105,9 +105,9 @@ struct i2c_adapter * dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst, enu
105} 105}
106EXPORT_SYMBOL(dibx000_get_i2c_adapter); 106EXPORT_SYMBOL(dibx000_get_i2c_adapter);
107 107
108static int i2c_adapter_init(struct i2c_adapter *i2c_adap, struct i2c_algorithm *algo, const char name[I2C_NAME_SIZE], struct dibx000_i2c_master *mst) 108static int i2c_adapter_init(struct i2c_adapter *i2c_adap, struct i2c_algorithm *algo, const char *name, struct dibx000_i2c_master *mst)
109{ 109{
110 strncpy(i2c_adap->name, name, I2C_NAME_SIZE); 110 strncpy(i2c_adap->name, name, sizeof(i2c_adap->name));
111 i2c_adap->class = I2C_CLASS_TV_DIGITAL, 111 i2c_adap->class = I2C_CLASS_TV_DIGITAL,
112 i2c_adap->algo = algo; 112 i2c_adap->algo = algo;
113 i2c_adap->algo_data = NULL; 113 i2c_adap->algo_data = NULL;
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 2aa9ce920607..823cd6cc471e 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index a3246a283aa4..05c7820fe53e 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -33,7 +33,6 @@
33#include <linux/major.h> 33#include <linux/major.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/pci.h>
37#include <linux/signal.h> 36#include <linux/signal.h>
38#include <asm/io.h> 37#include <asm/io.h>
39#include <asm/pgtable.h> 38#include <asm/pgtable.h>
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 68673863d5c9..59a43603b5cb 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 42e2299dcb22..853b1a3d6a1d 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c
index 772fd52d551a..2e4cf1efdd21 100644
--- a/drivers/media/video/bt866.c
+++ b/drivers/media/video/bt866.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 88dbdddeec42..d73c86aeeaac 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29#include <linux/i2c.h>
30 29
31#include <media/tuner.h> 30#include <media/tuner.h>
32#include <media/cx2341x.h> 31#include <media/cx2341x.h>
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 97ef421dd093..e627062fde3a 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -43,7 +43,6 @@
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/poll.h> 45#include <linux/poll.h>
46#include <linux/pci.h>
47#include <linux/signal.h> 46#include <linux/signal.h>
48#include <linux/ioport.h> 47#include <linux/ioport.h>
49#include <linux/types.h> 48#include <linux/types.h>
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index ed882ebc7b95..418ea8b7f85a 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -23,7 +23,6 @@
23 23
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/pci.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
28#include <linux/i2c.h> 27#include <linux/i2c.h>
29#include <linux/usb.h> 28#include <linux/usb.h>
diff --git a/drivers/media/video/ovcamchip/ovcamchip_priv.h b/drivers/media/video/ovcamchip/ovcamchip_priv.h
index 1231335a9f4a..50c7763d44b3 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_priv.h
+++ b/drivers/media/video/ovcamchip/ovcamchip_priv.h
@@ -15,6 +15,7 @@
15#ifndef __LINUX_OVCAMCHIP_PRIV_H 15#ifndef __LINUX_OVCAMCHIP_PRIV_H
16#define __LINUX_OVCAMCHIP_PRIV_H 16#define __LINUX_OVCAMCHIP_PRIV_H
17 17
18#include <linux/i2c.h>
18#include <media/ovcamchip.h> 19#include <media/ovcamchip.h>
19 20
20#ifdef DEBUG 21#ifdef DEBUG
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 44dc7479119c..74839f98b7c4 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -36,7 +36,6 @@
36#include <linux/major.h> 36#include <linux/major.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/pci.h>
40#include <linux/signal.h> 39#include <linux/signal.h>
41#include <asm/io.h> 40#include <asm/io.h>
42#include <asm/pgtable.h> 41#include <asm/pgtable.h>
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 2ce3321ab995..87c3144ec7fc 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -39,7 +39,6 @@
39#include <linux/slab.h> 39#include <linux/slab.h>
40 40
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/pci.h>
43#include <linux/signal.h> 42#include <linux/signal.h>
44#include <asm/io.h> 43#include <asm/io.h>
45#include <asm/pgtable.h> 44#include <asm/pgtable.h>
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index 269d7114a93a..80bf91187856 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -30,7 +30,6 @@
30#include <linux/major.h> 30#include <linux/major.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/pci.h>
34#include <linux/signal.h> 33#include <linux/signal.h>
35#include <asm/io.h> 34#include <asm/io.h>
36#include <asm/pgtable.h> 35#include <asm/pgtable.h>
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index e0fdb1ab7580..339592e7722d 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -33,7 +33,6 @@
33#include <linux/major.h> 33#include <linux/major.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/pci.h>
37#include <linux/signal.h> 36#include <linux/signal.h>
38#include <asm/io.h> 37#include <asm/io.h>
39#include <asm/pgtable.h> 38#include <asm/pgtable.h>
diff --git a/drivers/media/video/usbvision/usbvision-cards.c b/drivers/media/video/usbvision/usbvision-cards.c
index 13f69fe6360d..51ab265d566a 100644
--- a/drivers/media/video/usbvision/usbvision-cards.c
+++ b/drivers/media/video/usbvision/usbvision-cards.c
@@ -24,7 +24,6 @@
24 24
25 25
26#include <linux/list.h> 26#include <linux/list.h>
27#include <linux/i2c.h>
28#include <media/v4l2-dev.h> 27#include <media/v4l2-dev.h>
29#include <media/tuner.h> 28#include <media/tuner.h>
30#include "usbvision.h" 29#include "usbvision.h"
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 083acfd91d8b..97471af4309c 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1531,6 +1531,7 @@ mpt_resume(struct pci_dev *pdev)
1531 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1531 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1532 u32 device_state = pdev->current_state; 1532 u32 device_state = pdev->current_state;
1533 int recovery_state; 1533 int recovery_state;
1534 int err;
1534 1535
1535 printk(MYIOC_s_INFO_FMT 1536 printk(MYIOC_s_INFO_FMT
1536 "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n", 1537 "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n",
@@ -1538,7 +1539,9 @@ mpt_resume(struct pci_dev *pdev)
1538 1539
1539 pci_set_power_state(pdev, 0); 1540 pci_set_power_state(pdev, 0);
1540 pci_restore_state(pdev); 1541 pci_restore_state(pdev);
1541 pci_enable_device(pdev); 1542 err = pci_enable_device(pdev);
1543 if (err)
1544 return err;
1542 1545
1543 /* enable interrupts */ 1546 /* enable interrupts */
1544 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); 1547 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM);
@@ -4739,12 +4742,8 @@ mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum)
4739} 4742}
4740 4743
4741/** 4744/**
4742 * mpt_inactive_raid_list_free 4745 * mpt_inactive_raid_list_free - This clears this link list.
4743 * 4746 * @ioc : pointer to per adapter structure
4744 * This clears this link list.
4745 *
4746 * @ioc - pointer to per adapter structure
4747 *
4748 **/ 4747 **/
4749static void 4748static void
4750mpt_inactive_raid_list_free(MPT_ADAPTER *ioc) 4749mpt_inactive_raid_list_free(MPT_ADAPTER *ioc)
@@ -4764,15 +4763,11 @@ mpt_inactive_raid_list_free(MPT_ADAPTER *ioc)
4764} 4763}
4765 4764
4766/** 4765/**
4767 * mpt_inactive_raid_volumes 4766 * mpt_inactive_raid_volumes - sets up link list of phy_disk_nums for devices belonging in an inactive volume
4768 *
4769 * This sets up link list of phy_disk_nums for devices belonging in an inactive volume
4770 *
4771 * @ioc - pointer to per adapter structure
4772 * @channel - volume channel
4773 * @id - volume target id
4774 *
4775 * 4767 *
4768 * @ioc : pointer to per adapter structure
4769 * @channel : volume channel
4770 * @id : volume target id
4776 **/ 4771 **/
4777static void 4772static void
4778mpt_inactive_raid_volumes(MPT_ADAPTER *ioc, u8 channel, u8 id) 4773mpt_inactive_raid_volumes(MPT_ADAPTER *ioc, u8 channel, u8 id)
@@ -6663,7 +6658,7 @@ union loginfo_type {
6663/** 6658/**
6664 * mpt_iocstatus_info_config - IOCSTATUS information for config pages 6659 * mpt_iocstatus_info_config - IOCSTATUS information for config pages
6665 * @ioc: Pointer to MPT_ADAPTER structure 6660 * @ioc: Pointer to MPT_ADAPTER structure
6666 * ioc_status: U32 IOCStatus word from IOC 6661 * @ioc_status: U32 IOCStatus word from IOC
6667 * @mf: Pointer to MPT request frame 6662 * @mf: Pointer to MPT request frame
6668 * 6663 *
6669 * Refer to lsi/mpi.h. 6664 * Refer to lsi/mpi.h.
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index e3a39272aad6..d25d3be8fcd2 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -994,6 +994,7 @@ typedef struct _MPT_SCSI_HOST {
994 int scandv_wait_done; 994 int scandv_wait_done;
995 long last_queue_full; 995 long last_queue_full;
996 u16 tm_iocstatus; 996 u16 tm_iocstatus;
997 u16 spi_pending;
997 struct list_head target_reset_list; 998 struct list_head target_reset_list;
998} MPT_SCSI_HOST; 999} MPT_SCSI_HOST;
999 1000
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 2a3e9e66d4ef..fa0f7761652a 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -819,10 +819,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
819 sc->resid=0; 819 sc->resid=0;
820 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ 820 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */
821 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */ 821 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */
822 if (scsi_status == MPI_SCSI_STATUS_BUSY) 822 sc->result = (DID_OK << 16) | scsi_status;
823 sc->result = (DID_BUS_BUSY << 16) | scsi_status;
824 else
825 sc->result = (DID_OK << 16) | scsi_status;
826 if (scsi_state == 0) { 823 if (scsi_state == 0) {
827 ; 824 ;
828 } else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) { 825 } else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) {
@@ -1188,20 +1185,7 @@ mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1188int 1185int
1189mptscsih_resume(struct pci_dev *pdev) 1186mptscsih_resume(struct pci_dev *pdev)
1190{ 1187{
1191 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1188 return mpt_resume(pdev);
1192 struct Scsi_Host *host = ioc->sh;
1193 MPT_SCSI_HOST *hd;
1194
1195 mpt_resume(pdev);
1196
1197 if(!host)
1198 return 0;
1199
1200 hd = (MPT_SCSI_HOST *)host->hostdata;
1201 if(!hd)
1202 return 0;
1203
1204 return 0;
1205} 1189}
1206 1190
1207#endif 1191#endif
@@ -1537,21 +1521,23 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
1537/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1521/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1538/** 1522/**
1539 * mptscsih_TMHandler - Generic handler for SCSI Task Management. 1523 * mptscsih_TMHandler - Generic handler for SCSI Task Management.
1540 * Fall through to mpt_HardResetHandler if: not operational, too many 1524 * @hd: Pointer to MPT SCSI HOST structure
1541 * failed TM requests or handshake failure.
1542 *
1543 * @ioc: Pointer to MPT_ADAPTER structure
1544 * @type: Task Management type 1525 * @type: Task Management type
1526 * @channel: channel number for task management
1545 * @id: Logical Target ID for reset (if appropriate) 1527 * @id: Logical Target ID for reset (if appropriate)
1546 * @lun: Logical Unit for reset (if appropriate) 1528 * @lun: Logical Unit for reset (if appropriate)
1547 * @ctx2abort: Context for the task to be aborted (if appropriate) 1529 * @ctx2abort: Context for the task to be aborted (if appropriate)
1530 * @timeout: timeout for task management control
1531 *
1532 * Fall through to mpt_HardResetHandler if: not operational, too many
1533 * failed TM requests or handshake failure.
1548 * 1534 *
1549 * Remark: Currently invoked from a non-interrupt thread (_bh). 1535 * Remark: Currently invoked from a non-interrupt thread (_bh).
1550 * 1536 *
1551 * Remark: With old EH code, at most 1 SCSI TaskMgmt function per IOC 1537 * Remark: With old EH code, at most 1 SCSI TaskMgmt function per IOC
1552 * will be active. 1538 * will be active.
1553 * 1539 *
1554 * Returns 0 for SUCCESS, or FAILED. 1540 * Returns 0 for SUCCESS, or %FAILED.
1555 **/ 1541 **/
1556int 1542int
1557mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout) 1543mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout)
@@ -1650,9 +1636,11 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c
1650 * mptscsih_IssueTaskMgmt - Generic send Task Management function. 1636 * mptscsih_IssueTaskMgmt - Generic send Task Management function.
1651 * @hd: Pointer to MPT_SCSI_HOST structure 1637 * @hd: Pointer to MPT_SCSI_HOST structure
1652 * @type: Task Management type 1638 * @type: Task Management type
1639 * @channel: channel number for task management
1653 * @id: Logical Target ID for reset (if appropriate) 1640 * @id: Logical Target ID for reset (if appropriate)
1654 * @lun: Logical Unit for reset (if appropriate) 1641 * @lun: Logical Unit for reset (if appropriate)
1655 * @ctx2abort: Context for the task to be aborted (if appropriate) 1642 * @ctx2abort: Context for the task to be aborted (if appropriate)
1643 * @timeout: timeout for task management control
1656 * 1644 *
1657 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer) 1645 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer)
1658 * or a non-interrupt thread. In the former, must not call schedule(). 1646 * or a non-interrupt thread. In the former, must not call schedule().
@@ -2022,6 +2010,7 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
2022/** 2010/**
2023 * mptscsih_tm_wait_for_completion - wait for completion of TM task 2011 * mptscsih_tm_wait_for_completion - wait for completion of TM task
2024 * @hd: Pointer to MPT host structure. 2012 * @hd: Pointer to MPT host structure.
2013 * @timeout: timeout value
2025 * 2014 *
2026 * Returns {SUCCESS,FAILED}. 2015 * Returns {SUCCESS,FAILED}.
2027 */ 2016 */
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 85f21b54cb7d..d75f7ffbb02e 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -96,14 +96,13 @@ static int mptspiTaskCtx = -1;
96static int mptspiInternalCtx = -1; /* Used only for internal commands */ 96static int mptspiInternalCtx = -1; /* Used only for internal commands */
97 97
98/** 98/**
99 * mptspi_setTargetNegoParms - Update the target negotiation 99 * mptspi_setTargetNegoParms - Update the target negotiation parameters
100 * parameters based on the the Inquiry data, adapter capabilities,
101 * and NVRAM settings
102 *
103 * @hd: Pointer to a SCSI Host Structure 100 * @hd: Pointer to a SCSI Host Structure
104 * @vtarget: per target private data 101 * @target: per target private data
105 * @sdev: SCSI device 102 * @sdev: SCSI device
106 * 103 *
104 * Update the target negotiation parameters based on the the Inquiry
105 * data, adapter capabilities, and NVRAM settings.
107 **/ 106 **/
108static void 107static void
109mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, 108mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
@@ -234,7 +233,7 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
234/** 233/**
235 * mptspi_writeIOCPage4 - write IOC Page 4 234 * mptspi_writeIOCPage4 - write IOC Page 4
236 * @hd: Pointer to a SCSI Host Structure 235 * @hd: Pointer to a SCSI Host Structure
237 * @channel: 236 * @channel: channel number
238 * @id: write IOC Page4 for this ID & Bus 237 * @id: write IOC Page4 for this ID & Bus
239 * 238 *
240 * Return: -EAGAIN if unable to obtain a Message Frame 239 * Return: -EAGAIN if unable to obtain a Message Frame
@@ -446,7 +445,7 @@ static int mptspi_target_alloc(struct scsi_target *starget)
446 return 0; 445 return 0;
447} 446}
448 447
449void 448static void
450mptspi_target_destroy(struct scsi_target *starget) 449mptspi_target_destroy(struct scsi_target *starget)
451{ 450{
452 if (starget->hostdata) 451 if (starget->hostdata)
@@ -677,7 +676,9 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd,
677 return; 676 return;
678 } 677 }
679 678
679 hd->spi_pending |= (1 << sdev->id);
680 spi_dv_device(sdev); 680 spi_dv_device(sdev);
681 hd->spi_pending &= ~(1 << sdev->id);
681 682
682 if (sdev->channel == 1 && 683 if (sdev->channel == 1 &&
683 mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) 684 mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0)
@@ -1203,11 +1204,27 @@ mptspi_dv_renegotiate_work(struct work_struct *work)
1203 container_of(work, struct work_queue_wrapper, work); 1204 container_of(work, struct work_queue_wrapper, work);
1204 struct _MPT_SCSI_HOST *hd = wqw->hd; 1205 struct _MPT_SCSI_HOST *hd = wqw->hd;
1205 struct scsi_device *sdev; 1206 struct scsi_device *sdev;
1207 struct scsi_target *starget;
1208 struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1;
1209 u32 nego;
1206 1210
1207 kfree(wqw); 1211 kfree(wqw);
1208 1212
1209 shost_for_each_device(sdev, hd->ioc->sh) 1213 if (hd->spi_pending) {
1210 mptspi_dv_device(hd, sdev); 1214 shost_for_each_device(sdev, hd->ioc->sh) {
1215 if (hd->spi_pending & (1 << sdev->id))
1216 continue;
1217 starget = scsi_target(sdev);
1218 nego = mptspi_getRP(starget);
1219 pg1.RequestedParameters = cpu_to_le32(nego);
1220 pg1.Reserved = 0;
1221 pg1.Configuration = 0;
1222 mptspi_write_spi_device_pg1(starget, &pg1);
1223 }
1224 } else {
1225 shost_for_each_device(sdev, hd->ioc->sh)
1226 mptspi_dv_device(hd, sdev);
1227 }
1211} 1228}
1212 1229
1213static void 1230static void
@@ -1453,6 +1470,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1453 init_waitqueue_head(&hd->scandv_waitq); 1470 init_waitqueue_head(&hd->scandv_waitq);
1454 hd->scandv_wait_done = 0; 1471 hd->scandv_wait_done = 0;
1455 hd->last_queue_full = 0; 1472 hd->last_queue_full = 0;
1473 hd->spi_pending = 0;
1456 1474
1457 /* Some versions of the firmware don't support page 0; without 1475 /* Some versions of the firmware don't support page 0; without
1458 * that we can't get the parameters */ 1476 * that we can't get the parameters */
diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c
index ca86f113f36a..276ba3c5143f 100644
--- a/drivers/misc/hdpuftrs/hdpu_cpustate.c
+++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -18,7 +18,6 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/pci.h>
22#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
23#include <linux/platform_device.h> 22#include <linux/platform_device.h>
24#include <asm/uaccess.h> 23#include <asm/uaccess.h>
diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c
index 6a51e99a8079..60c8b26f0678 100644
--- a/drivers/misc/hdpuftrs/hdpu_nexus.c
+++ b/drivers/misc/hdpuftrs/hdpu_nexus.c
@@ -18,7 +18,6 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/hdpu_features.h> 20#include <linux/hdpu_features.h>
21#include <linux/pci.h>
22 21
23#include <linux/platform_device.h> 22#include <linux/platform_device.h>
24 23
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c
index bc60e2fc3c2c..1ba6c085419a 100644
--- a/drivers/misc/tifm_7xx1.c
+++ b/drivers/misc/tifm_7xx1.c
@@ -11,10 +11,20 @@
11 11
12#include <linux/tifm.h> 12#include <linux/tifm.h>
13#include <linux/dma-mapping.h> 13#include <linux/dma-mapping.h>
14#include <linux/freezer.h>
15 14
16#define DRIVER_NAME "tifm_7xx1" 15#define DRIVER_NAME "tifm_7xx1"
17#define DRIVER_VERSION "0.7" 16#define DRIVER_VERSION "0.8"
17
18#define TIFM_IRQ_ENABLE 0x80000000
19#define TIFM_IRQ_SOCKMASK(x) (x)
20#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
21#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
22#define TIFM_IRQ_SETALL 0xffffffff
23
24static void tifm_7xx1_dummy_eject(struct tifm_adapter *fm,
25 struct tifm_dev *sock)
26{
27}
18 28
19static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock) 29static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
20{ 30{
@@ -22,7 +32,7 @@ static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
22 32
23 spin_lock_irqsave(&fm->lock, flags); 33 spin_lock_irqsave(&fm->lock, flags);
24 fm->socket_change_set |= 1 << sock->socket_id; 34 fm->socket_change_set |= 1 << sock->socket_id;
25 wake_up_all(&fm->change_set_notify); 35 tifm_queue_work(&fm->media_switcher);
26 spin_unlock_irqrestore(&fm->lock, flags); 36 spin_unlock_irqrestore(&fm->lock, flags);
27} 37}
28 38
@@ -30,8 +40,7 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
30{ 40{
31 struct tifm_adapter *fm = dev_id; 41 struct tifm_adapter *fm = dev_id;
32 struct tifm_dev *sock; 42 struct tifm_dev *sock;
33 unsigned int irq_status; 43 unsigned int irq_status, cnt;
34 unsigned int sock_irq_status, cnt;
35 44
36 spin_lock(&fm->lock); 45 spin_lock(&fm->lock);
37 irq_status = readl(fm->addr + FM_INTERRUPT_STATUS); 46 irq_status = readl(fm->addr + FM_INTERRUPT_STATUS);
@@ -45,12 +54,12 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
45 54
46 for (cnt = 0; cnt < fm->num_sockets; cnt++) { 55 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
47 sock = fm->sockets[cnt]; 56 sock = fm->sockets[cnt];
48 sock_irq_status = (irq_status >> cnt) 57 if (sock) {
49 & (TIFM_IRQ_FIFOMASK(1) 58 if ((irq_status >> cnt) & TIFM_IRQ_FIFOMASK(1))
50 | TIFM_IRQ_CARDMASK(1)); 59 sock->data_event(sock);
51 60 if ((irq_status >> cnt) & TIFM_IRQ_CARDMASK(1))
52 if (sock && sock_irq_status) 61 sock->card_event(sock);
53 sock->signal_irq(sock, sock_irq_status); 62 }
54 } 63 }
55 64
56 fm->socket_change_set |= irq_status 65 fm->socket_change_set |= irq_status
@@ -58,57 +67,57 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
58 } 67 }
59 writel(irq_status, fm->addr + FM_INTERRUPT_STATUS); 68 writel(irq_status, fm->addr + FM_INTERRUPT_STATUS);
60 69
61 if (!fm->socket_change_set) 70 if (fm->finish_me)
71 complete_all(fm->finish_me);
72 else if (!fm->socket_change_set)
62 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE); 73 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
63 else 74 else
64 wake_up_all(&fm->change_set_notify); 75 tifm_queue_work(&fm->media_switcher);
65 76
66 spin_unlock(&fm->lock); 77 spin_unlock(&fm->lock);
67 return IRQ_HANDLED; 78 return IRQ_HANDLED;
68} 79}
69 80
70static tifm_media_id tifm_7xx1_toggle_sock_power(char __iomem *sock_addr, 81static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr)
71 int is_x2)
72{ 82{
73 unsigned int s_state; 83 unsigned int s_state;
74 int cnt; 84 int cnt;
75 85
76 writel(0x0e00, sock_addr + SOCK_CONTROL); 86 writel(0x0e00, sock_addr + SOCK_CONTROL);
77 87
78 for (cnt = 0; cnt < 100; cnt++) { 88 for (cnt = 16; cnt <= 256; cnt <<= 1) {
79 if (!(TIFM_SOCK_STATE_POWERED 89 if (!(TIFM_SOCK_STATE_POWERED
80 & readl(sock_addr + SOCK_PRESENT_STATE))) 90 & readl(sock_addr + SOCK_PRESENT_STATE)))
81 break; 91 break;
82 msleep(10); 92
93 msleep(cnt);
83 } 94 }
84 95
85 s_state = readl(sock_addr + SOCK_PRESENT_STATE); 96 s_state = readl(sock_addr + SOCK_PRESENT_STATE);
86 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state)) 97 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state))
87 return FM_NULL; 98 return 0;
88
89 if (is_x2) {
90 writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL);
91 } else {
92 // SmartMedia cards need extra 40 msec
93 if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7) == 1)
94 msleep(40);
95 writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
96 sock_addr + SOCK_CONTROL);
97 msleep(10);
98 writel((s_state & 0x7) | 0x0c00 | TIFM_CTRL_LED,
99 sock_addr + SOCK_CONTROL);
100 }
101 99
102 for (cnt = 0; cnt < 100; cnt++) { 100 writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
101 sock_addr + SOCK_CONTROL);
102
103 /* xd needs some extra time before power on */
104 if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7)
105 == TIFM_TYPE_XD)
106 msleep(40);
107
108 writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL);
109 /* wait for power to stabilize */
110 msleep(20);
111 for (cnt = 16; cnt <= 256; cnt <<= 1) {
103 if ((TIFM_SOCK_STATE_POWERED 112 if ((TIFM_SOCK_STATE_POWERED
104 & readl(sock_addr + SOCK_PRESENT_STATE))) 113 & readl(sock_addr + SOCK_PRESENT_STATE)))
105 break; 114 break;
106 msleep(10); 115
116 msleep(cnt);
107 } 117 }
108 118
109 if (!is_x2) 119 writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED),
110 writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED), 120 sock_addr + SOCK_CONTROL);
111 sock_addr + SOCK_CONTROL);
112 121
113 return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7; 122 return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7;
114} 123}
@@ -119,127 +128,77 @@ tifm_7xx1_sock_addr(char __iomem *base_addr, unsigned int sock_num)
119 return base_addr + ((sock_num + 1) << 10); 128 return base_addr + ((sock_num + 1) << 10);
120} 129}
121 130
122static int tifm_7xx1_switch_media(void *data) 131static void tifm_7xx1_switch_media(struct work_struct *work)
123{ 132{
124 struct tifm_adapter *fm = data; 133 struct tifm_adapter *fm = container_of(work, struct tifm_adapter,
125 unsigned long flags; 134 media_switcher);
126 tifm_media_id media_id;
127 char *card_name = "xx";
128 int cnt, rc;
129 struct tifm_dev *sock; 135 struct tifm_dev *sock;
130 unsigned int socket_change_set; 136 unsigned long flags;
131 137 unsigned char media_id;
132 while (1) { 138 unsigned int socket_change_set, cnt;
133 rc = wait_event_interruptible(fm->change_set_notify,
134 fm->socket_change_set);
135 if (rc == -ERESTARTSYS)
136 try_to_freeze();
137 139
138 spin_lock_irqsave(&fm->lock, flags); 140 spin_lock_irqsave(&fm->lock, flags);
139 socket_change_set = fm->socket_change_set; 141 socket_change_set = fm->socket_change_set;
140 fm->socket_change_set = 0; 142 fm->socket_change_set = 0;
141 143
142 dev_dbg(fm->dev, "checking media set %x\n", 144 dev_dbg(fm->cdev.dev, "checking media set %x\n",
143 socket_change_set); 145 socket_change_set);
144 146
145 if (kthread_should_stop()) 147 if (!socket_change_set) {
146 socket_change_set = (1 << fm->num_sockets) - 1;
147 spin_unlock_irqrestore(&fm->lock, flags); 148 spin_unlock_irqrestore(&fm->lock, flags);
149 return;
150 }
148 151
149 if (!socket_change_set) 152 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
153 if (!(socket_change_set & (1 << cnt)))
150 continue; 154 continue;
151 155 sock = fm->sockets[cnt];
152 spin_lock_irqsave(&fm->lock, flags); 156 if (sock) {
153 for (cnt = 0; cnt < fm->num_sockets; cnt++) { 157 printk(KERN_INFO
154 if (!(socket_change_set & (1 << cnt))) 158 "%s : demand removing card from socket %u:%u\n",
155 continue; 159 fm->cdev.class_id, fm->id, cnt);
156 sock = fm->sockets[cnt]; 160 fm->sockets[cnt] = NULL;
157 if (sock) {
158 printk(KERN_INFO DRIVER_NAME
159 ": demand removing card from socket %d\n",
160 cnt);
161 fm->sockets[cnt] = NULL;
162 spin_unlock_irqrestore(&fm->lock, flags);
163 device_unregister(&sock->dev);
164 spin_lock_irqsave(&fm->lock, flags);
165 writel(0x0e00,
166 tifm_7xx1_sock_addr(fm->addr, cnt)
167 + SOCK_CONTROL);
168 }
169 if (kthread_should_stop())
170 continue;
171
172 spin_unlock_irqrestore(&fm->lock, flags); 161 spin_unlock_irqrestore(&fm->lock, flags);
173 media_id = tifm_7xx1_toggle_sock_power( 162 device_unregister(&sock->dev);
174 tifm_7xx1_sock_addr(fm->addr, cnt), 163 spin_lock_irqsave(&fm->lock, flags);
175 fm->num_sockets == 2); 164 writel(0x0e00, tifm_7xx1_sock_addr(fm->addr, cnt)
176 if (media_id) { 165 + SOCK_CONTROL);
177 sock = tifm_alloc_device(fm);
178 if (sock) {
179 sock->addr = tifm_7xx1_sock_addr(fm->addr,
180 cnt);
181 sock->media_id = media_id;
182 sock->socket_id = cnt;
183 switch (media_id) {
184 case 1:
185 card_name = "xd";
186 break;
187 case 2:
188 card_name = "ms";
189 break;
190 case 3:
191 card_name = "sd";
192 break;
193 default:
194 tifm_free_device(&sock->dev);
195 spin_lock_irqsave(&fm->lock, flags);
196 continue;
197 }
198 snprintf(sock->dev.bus_id, BUS_ID_SIZE,
199 "tifm_%s%u:%u", card_name,
200 fm->id, cnt);
201 printk(KERN_INFO DRIVER_NAME
202 ": %s card detected in socket %d\n",
203 card_name, cnt);
204 if (!device_register(&sock->dev)) {
205 spin_lock_irqsave(&fm->lock, flags);
206 if (!fm->sockets[cnt]) {
207 fm->sockets[cnt] = sock;
208 sock = NULL;
209 }
210 spin_unlock_irqrestore(&fm->lock, flags);
211 }
212 if (sock)
213 tifm_free_device(&sock->dev);
214 }
215 spin_lock_irqsave(&fm->lock, flags);
216 }
217 } 166 }
218 167
219 if (!kthread_should_stop()) { 168 spin_unlock_irqrestore(&fm->lock, flags);
220 writel(TIFM_IRQ_FIFOMASK(socket_change_set) 169
221 | TIFM_IRQ_CARDMASK(socket_change_set), 170 media_id = tifm_7xx1_toggle_sock_power(
222 fm->addr + FM_CLEAR_INTERRUPT_ENABLE); 171 tifm_7xx1_sock_addr(fm->addr, cnt));
223 writel(TIFM_IRQ_FIFOMASK(socket_change_set) 172
224 | TIFM_IRQ_CARDMASK(socket_change_set), 173 // tifm_alloc_device will check if media_id is valid
225 fm->addr + FM_SET_INTERRUPT_ENABLE); 174 sock = tifm_alloc_device(fm, cnt, media_id);
226 writel(TIFM_IRQ_ENABLE, 175 if (sock) {
227 fm->addr + FM_SET_INTERRUPT_ENABLE); 176 sock->addr = tifm_7xx1_sock_addr(fm->addr, cnt);
228 spin_unlock_irqrestore(&fm->lock, flags); 177
229 } else { 178 if (!device_register(&sock->dev)) {
230 for (cnt = 0; cnt < fm->num_sockets; cnt++) { 179 spin_lock_irqsave(&fm->lock, flags);
231 if (fm->sockets[cnt]) 180 if (!fm->sockets[cnt]) {
232 fm->socket_change_set |= 1 << cnt; 181 fm->sockets[cnt] = sock;
233 } 182 sock = NULL;
234 if (!fm->socket_change_set) { 183 }
235 spin_unlock_irqrestore(&fm->lock, flags);
236 return 0;
237 } else {
238 spin_unlock_irqrestore(&fm->lock, flags); 184 spin_unlock_irqrestore(&fm->lock, flags);
239 } 185 }
186 if (sock)
187 tifm_free_device(&sock->dev);
240 } 188 }
189 spin_lock_irqsave(&fm->lock, flags);
241 } 190 }
242 return 0; 191
192 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
193 | TIFM_IRQ_CARDMASK(socket_change_set),
194 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
195
196 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
197 | TIFM_IRQ_CARDMASK(socket_change_set),
198 fm->addr + FM_SET_INTERRUPT_ENABLE);
199
200 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
201 spin_unlock_irqrestore(&fm->lock, flags);
243} 202}
244 203
245#ifdef CONFIG_PM 204#ifdef CONFIG_PM
@@ -258,9 +217,11 @@ static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state)
258static int tifm_7xx1_resume(struct pci_dev *dev) 217static int tifm_7xx1_resume(struct pci_dev *dev)
259{ 218{
260 struct tifm_adapter *fm = pci_get_drvdata(dev); 219 struct tifm_adapter *fm = pci_get_drvdata(dev);
261 int cnt, rc; 220 int rc;
221 unsigned int good_sockets = 0, bad_sockets = 0;
262 unsigned long flags; 222 unsigned long flags;
263 tifm_media_id new_ids[fm->num_sockets]; 223 unsigned char new_ids[fm->num_sockets];
224 DECLARE_COMPLETION_ONSTACK(finish_resume);
264 225
265 pci_set_power_state(dev, PCI_D0); 226 pci_set_power_state(dev, PCI_D0);
266 pci_restore_state(dev); 227 pci_restore_state(dev);
@@ -271,45 +232,49 @@ static int tifm_7xx1_resume(struct pci_dev *dev)
271 232
272 dev_dbg(&dev->dev, "resuming host\n"); 233 dev_dbg(&dev->dev, "resuming host\n");
273 234
274 for (cnt = 0; cnt < fm->num_sockets; cnt++) 235 for (rc = 0; rc < fm->num_sockets; rc++)
275 new_ids[cnt] = tifm_7xx1_toggle_sock_power( 236 new_ids[rc] = tifm_7xx1_toggle_sock_power(
276 tifm_7xx1_sock_addr(fm->addr, cnt), 237 tifm_7xx1_sock_addr(fm->addr, rc));
277 fm->num_sockets == 2);
278 spin_lock_irqsave(&fm->lock, flags); 238 spin_lock_irqsave(&fm->lock, flags);
279 fm->socket_change_set = 0; 239 for (rc = 0; rc < fm->num_sockets; rc++) {
280 for (cnt = 0; cnt < fm->num_sockets; cnt++) { 240 if (fm->sockets[rc]) {
281 if (fm->sockets[cnt]) { 241 if (fm->sockets[rc]->type == new_ids[rc])
282 if (fm->sockets[cnt]->media_id == new_ids[cnt]) 242 good_sockets |= 1 << rc;
283 fm->socket_change_set |= 1 << cnt; 243 else
284 244 bad_sockets |= 1 << rc;
285 fm->sockets[cnt]->media_id = new_ids[cnt];
286 } 245 }
287 } 246 }
288 247
289 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1), 248 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
290 fm->addr + FM_SET_INTERRUPT_ENABLE); 249 fm->addr + FM_SET_INTERRUPT_ENABLE);
291 if (!fm->socket_change_set) { 250 dev_dbg(&dev->dev, "change sets on resume: good %x, bad %x\n",
292 spin_unlock_irqrestore(&fm->lock, flags); 251 good_sockets, bad_sockets);
293 return 0; 252
294 } else { 253 fm->socket_change_set = 0;
295 fm->socket_change_set = 0; 254 if (good_sockets) {
255 fm->finish_me = &finish_resume;
296 spin_unlock_irqrestore(&fm->lock, flags); 256 spin_unlock_irqrestore(&fm->lock, flags);
257 rc = wait_for_completion_timeout(&finish_resume, HZ);
258 dev_dbg(&dev->dev, "wait returned %d\n", rc);
259 writel(TIFM_IRQ_FIFOMASK(good_sockets)
260 | TIFM_IRQ_CARDMASK(good_sockets),
261 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
262 writel(TIFM_IRQ_FIFOMASK(good_sockets)
263 | TIFM_IRQ_CARDMASK(good_sockets),
264 fm->addr + FM_SET_INTERRUPT_ENABLE);
265 spin_lock_irqsave(&fm->lock, flags);
266 fm->finish_me = NULL;
267 fm->socket_change_set ^= good_sockets & fm->socket_change_set;
297 } 268 }
298 269
299 wait_event_timeout(fm->change_set_notify, fm->socket_change_set, HZ); 270 fm->socket_change_set |= bad_sockets;
271 if (fm->socket_change_set)
272 tifm_queue_work(&fm->media_switcher);
300 273
301 spin_lock_irqsave(&fm->lock, flags); 274 spin_unlock_irqrestore(&fm->lock, flags);
302 writel(TIFM_IRQ_FIFOMASK(fm->socket_change_set)
303 | TIFM_IRQ_CARDMASK(fm->socket_change_set),
304 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
305 writel(TIFM_IRQ_FIFOMASK(fm->socket_change_set)
306 | TIFM_IRQ_CARDMASK(fm->socket_change_set),
307 fm->addr + FM_SET_INTERRUPT_ENABLE);
308 writel(TIFM_IRQ_ENABLE, 275 writel(TIFM_IRQ_ENABLE,
309 fm->addr + FM_SET_INTERRUPT_ENABLE); 276 fm->addr + FM_SET_INTERRUPT_ENABLE);
310 fm->socket_change_set = 0;
311 277
312 spin_unlock_irqrestore(&fm->lock, flags);
313 return 0; 278 return 0;
314} 279}
315 280
@@ -345,20 +310,14 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
345 310
346 pci_intx(dev, 1); 311 pci_intx(dev, 1);
347 312
348 fm = tifm_alloc_adapter(); 313 fm = tifm_alloc_adapter(dev->device == PCI_DEVICE_ID_TI_XX21_XX11_FM
314 ? 4 : 2, &dev->dev);
349 if (!fm) { 315 if (!fm) {
350 rc = -ENOMEM; 316 rc = -ENOMEM;
351 goto err_out_int; 317 goto err_out_int;
352 } 318 }
353 319
354 fm->dev = &dev->dev; 320 INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media);
355 fm->num_sockets = (dev->device == PCI_DEVICE_ID_TI_XX21_XX11_FM)
356 ? 4 : 2;
357 fm->sockets = kzalloc(sizeof(struct tifm_dev*) * fm->num_sockets,
358 GFP_KERNEL);
359 if (!fm->sockets)
360 goto err_out_free;
361
362 fm->eject = tifm_7xx1_eject; 321 fm->eject = tifm_7xx1_eject;
363 pci_set_drvdata(dev, fm); 322 pci_set_drvdata(dev, fm);
364 323
@@ -367,19 +326,16 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
367 if (!fm->addr) 326 if (!fm->addr)
368 goto err_out_free; 327 goto err_out_free;
369 328
370 rc = request_irq(dev->irq, tifm_7xx1_isr, IRQF_SHARED, DRIVER_NAME, fm); 329 rc = request_irq(dev->irq, tifm_7xx1_isr, SA_SHIRQ, DRIVER_NAME, fm);
371 if (rc) 330 if (rc)
372 goto err_out_unmap; 331 goto err_out_unmap;
373 332
374 init_waitqueue_head(&fm->change_set_notify); 333 rc = tifm_add_adapter(fm);
375 rc = tifm_add_adapter(fm, tifm_7xx1_switch_media);
376 if (rc) 334 if (rc)
377 goto err_out_irq; 335 goto err_out_irq;
378 336
379 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
380 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1), 337 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
381 fm->addr + FM_SET_INTERRUPT_ENABLE); 338 fm->addr + FM_SET_INTERRUPT_ENABLE);
382 wake_up_process(fm->media_switcher);
383 return 0; 339 return 0;
384 340
385err_out_irq: 341err_out_irq:
@@ -401,18 +357,12 @@ err_out:
401static void tifm_7xx1_remove(struct pci_dev *dev) 357static void tifm_7xx1_remove(struct pci_dev *dev)
402{ 358{
403 struct tifm_adapter *fm = pci_get_drvdata(dev); 359 struct tifm_adapter *fm = pci_get_drvdata(dev);
404 unsigned long flags;
405 360
361 fm->eject = tifm_7xx1_dummy_eject;
406 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE); 362 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
407 mmiowb(); 363 mmiowb();
408 free_irq(dev->irq, fm); 364 free_irq(dev->irq, fm);
409 365
410 spin_lock_irqsave(&fm->lock, flags);
411 fm->socket_change_set = (1 << fm->num_sockets) - 1;
412 spin_unlock_irqrestore(&fm->lock, flags);
413
414 kthread_stop(fm->media_switcher);
415
416 tifm_remove_adapter(fm); 366 tifm_remove_adapter(fm);
417 367
418 pci_set_drvdata(dev, NULL); 368 pci_set_drvdata(dev, NULL);
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index 6b10ebe9d936..d195fb088f4a 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -14,71 +14,124 @@
14#include <linux/idr.h> 14#include <linux/idr.h>
15 15
16#define DRIVER_NAME "tifm_core" 16#define DRIVER_NAME "tifm_core"
17#define DRIVER_VERSION "0.7" 17#define DRIVER_VERSION "0.8"
18 18
19static struct workqueue_struct *workqueue;
19static DEFINE_IDR(tifm_adapter_idr); 20static DEFINE_IDR(tifm_adapter_idr);
20static DEFINE_SPINLOCK(tifm_adapter_lock); 21static DEFINE_SPINLOCK(tifm_adapter_lock);
21 22
22static tifm_media_id *tifm_device_match(tifm_media_id *ids, 23static const char *tifm_media_type_name(unsigned char type, unsigned char nt)
23 struct tifm_dev *dev)
24{ 24{
25 while (*ids) { 25 const char *card_type_name[3][3] = {
26 if (dev->media_id == *ids) 26 { "SmartMedia/xD", "MemoryStick", "MMC/SD" },
27 return ids; 27 { "XD", "MS", "SD"},
28 ids++; 28 { "xd", "ms", "sd"}
29 } 29 };
30 return NULL; 30
31 if (nt > 2 || type < 1 || type > 3)
32 return NULL;
33 return card_type_name[nt][type - 1];
31} 34}
32 35
33static int tifm_match(struct device *dev, struct device_driver *drv) 36static int tifm_dev_match(struct tifm_dev *sock, struct tifm_device_id *id)
34{ 37{
35 struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev); 38 if (sock->type == id->type)
36 struct tifm_driver *fm_drv;
37
38 fm_drv = container_of(drv, struct tifm_driver, driver);
39 if (!fm_drv->id_table)
40 return -EINVAL;
41 if (tifm_device_match(fm_drv->id_table, fm_dev))
42 return 1; 39 return 1;
43 return -ENODEV; 40 return 0;
41}
42
43static int tifm_bus_match(struct device *dev, struct device_driver *drv)
44{
45 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
46 struct tifm_driver *fm_drv = container_of(drv, struct tifm_driver,
47 driver);
48 struct tifm_device_id *ids = fm_drv->id_table;
49
50 if (ids) {
51 while (ids->type) {
52 if (tifm_dev_match(sock, ids))
53 return 1;
54 ++ids;
55 }
56 }
57 return 0;
44} 58}
45 59
46static int tifm_uevent(struct device *dev, char **envp, int num_envp, 60static int tifm_uevent(struct device *dev, char **envp, int num_envp,
47 char *buffer, int buffer_size) 61 char *buffer, int buffer_size)
48{ 62{
49 struct tifm_dev *fm_dev; 63 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
50 int i = 0; 64 int i = 0;
51 int length = 0; 65 int length = 0;
52 const char *card_type_name[] = {"INV", "SM", "MS", "SD"};
53 66
54 if (!dev || !(fm_dev = container_of(dev, struct tifm_dev, dev)))
55 return -ENODEV;
56 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 67 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
57 "TIFM_CARD_TYPE=%s", card_type_name[fm_dev->media_id])) 68 "TIFM_CARD_TYPE=%s",
69 tifm_media_type_name(sock->type, 1)))
58 return -ENOMEM; 70 return -ENOMEM;
59 71
60 return 0; 72 return 0;
61} 73}
62 74
75static int tifm_device_probe(struct device *dev)
76{
77 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
78 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
79 driver);
80 int rc = -ENODEV;
81
82 get_device(dev);
83 if (dev->driver && drv->probe) {
84 rc = drv->probe(sock);
85 if (!rc)
86 return 0;
87 }
88 put_device(dev);
89 return rc;
90}
91
92static void tifm_dummy_event(struct tifm_dev *sock)
93{
94 return;
95}
96
97static int tifm_device_remove(struct device *dev)
98{
99 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
100 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
101 driver);
102
103 if (dev->driver && drv->remove) {
104 sock->card_event = tifm_dummy_event;
105 sock->data_event = tifm_dummy_event;
106 drv->remove(sock);
107 sock->dev.driver = NULL;
108 }
109
110 put_device(dev);
111 return 0;
112}
113
63#ifdef CONFIG_PM 114#ifdef CONFIG_PM
64 115
65static int tifm_device_suspend(struct device *dev, pm_message_t state) 116static int tifm_device_suspend(struct device *dev, pm_message_t state)
66{ 117{
67 struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev); 118 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
68 struct tifm_driver *drv = fm_dev->drv; 119 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
120 driver);
69 121
70 if (drv && drv->suspend) 122 if (dev->driver && drv->suspend)
71 return drv->suspend(fm_dev, state); 123 return drv->suspend(sock, state);
72 return 0; 124 return 0;
73} 125}
74 126
75static int tifm_device_resume(struct device *dev) 127static int tifm_device_resume(struct device *dev)
76{ 128{
77 struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev); 129 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
78 struct tifm_driver *drv = fm_dev->drv; 130 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
131 driver);
79 132
80 if (drv && drv->resume) 133 if (dev->driver && drv->resume)
81 return drv->resume(fm_dev); 134 return drv->resume(sock);
82 return 0; 135 return 0;
83} 136}
84 137
@@ -89,19 +142,33 @@ static int tifm_device_resume(struct device *dev)
89 142
90#endif /* CONFIG_PM */ 143#endif /* CONFIG_PM */
91 144
145static ssize_t type_show(struct device *dev, struct device_attribute *attr,
146 char *buf)
147{
148 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
149 return sprintf(buf, "%x", sock->type);
150}
151
152static struct device_attribute tifm_dev_attrs[] = {
153 __ATTR(type, S_IRUGO, type_show, NULL),
154 __ATTR_NULL
155};
156
92static struct bus_type tifm_bus_type = { 157static struct bus_type tifm_bus_type = {
93 .name = "tifm", 158 .name = "tifm",
94 .match = tifm_match, 159 .dev_attrs = tifm_dev_attrs,
95 .uevent = tifm_uevent, 160 .match = tifm_bus_match,
96 .suspend = tifm_device_suspend, 161 .uevent = tifm_uevent,
97 .resume = tifm_device_resume 162 .probe = tifm_device_probe,
163 .remove = tifm_device_remove,
164 .suspend = tifm_device_suspend,
165 .resume = tifm_device_resume
98}; 166};
99 167
100static void tifm_free(struct class_device *cdev) 168static void tifm_free(struct class_device *cdev)
101{ 169{
102 struct tifm_adapter *fm = container_of(cdev, struct tifm_adapter, cdev); 170 struct tifm_adapter *fm = container_of(cdev, struct tifm_adapter, cdev);
103 171
104 kfree(fm->sockets);
105 kfree(fm); 172 kfree(fm);
106} 173}
107 174
@@ -110,28 +177,25 @@ static struct class tifm_adapter_class = {
110 .release = tifm_free 177 .release = tifm_free
111}; 178};
112 179
113struct tifm_adapter *tifm_alloc_adapter(void) 180struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
181 struct device *dev)
114{ 182{
115 struct tifm_adapter *fm; 183 struct tifm_adapter *fm;
116 184
117 fm = kzalloc(sizeof(struct tifm_adapter), GFP_KERNEL); 185 fm = kzalloc(sizeof(struct tifm_adapter)
186 + sizeof(struct tifm_dev*) * num_sockets, GFP_KERNEL);
118 if (fm) { 187 if (fm) {
119 fm->cdev.class = &tifm_adapter_class; 188 fm->cdev.class = &tifm_adapter_class;
120 spin_lock_init(&fm->lock); 189 fm->cdev.dev = dev;
121 class_device_initialize(&fm->cdev); 190 class_device_initialize(&fm->cdev);
191 spin_lock_init(&fm->lock);
192 fm->num_sockets = num_sockets;
122 } 193 }
123 return fm; 194 return fm;
124} 195}
125EXPORT_SYMBOL(tifm_alloc_adapter); 196EXPORT_SYMBOL(tifm_alloc_adapter);
126 197
127void tifm_free_adapter(struct tifm_adapter *fm) 198int tifm_add_adapter(struct tifm_adapter *fm)
128{
129 class_device_put(&fm->cdev);
130}
131EXPORT_SYMBOL(tifm_free_adapter);
132
133int tifm_add_adapter(struct tifm_adapter *fm,
134 int (*mediathreadfn)(void *data))
135{ 199{
136 int rc; 200 int rc;
137 201
@@ -141,59 +205,80 @@ int tifm_add_adapter(struct tifm_adapter *fm,
141 spin_lock(&tifm_adapter_lock); 205 spin_lock(&tifm_adapter_lock);
142 rc = idr_get_new(&tifm_adapter_idr, fm, &fm->id); 206 rc = idr_get_new(&tifm_adapter_idr, fm, &fm->id);
143 spin_unlock(&tifm_adapter_lock); 207 spin_unlock(&tifm_adapter_lock);
144 if (!rc) { 208 if (rc)
145 snprintf(fm->cdev.class_id, BUS_ID_SIZE, "tifm%u", fm->id); 209 return rc;
146 fm->media_switcher = kthread_create(mediathreadfn,
147 fm, "tifm/%u", fm->id);
148
149 if (!IS_ERR(fm->media_switcher))
150 return class_device_add(&fm->cdev);
151 210
211 snprintf(fm->cdev.class_id, BUS_ID_SIZE, "tifm%u", fm->id);
212 rc = class_device_add(&fm->cdev);
213 if (rc) {
152 spin_lock(&tifm_adapter_lock); 214 spin_lock(&tifm_adapter_lock);
153 idr_remove(&tifm_adapter_idr, fm->id); 215 idr_remove(&tifm_adapter_idr, fm->id);
154 spin_unlock(&tifm_adapter_lock); 216 spin_unlock(&tifm_adapter_lock);
155 rc = -ENOMEM;
156 } 217 }
218
157 return rc; 219 return rc;
158} 220}
159EXPORT_SYMBOL(tifm_add_adapter); 221EXPORT_SYMBOL(tifm_add_adapter);
160 222
161void tifm_remove_adapter(struct tifm_adapter *fm) 223void tifm_remove_adapter(struct tifm_adapter *fm)
162{ 224{
163 class_device_del(&fm->cdev); 225 unsigned int cnt;
226
227 flush_workqueue(workqueue);
228 for (cnt = 0; cnt < fm->num_sockets; ++cnt) {
229 if (fm->sockets[cnt])
230 device_unregister(&fm->sockets[cnt]->dev);
231 }
164 232
165 spin_lock(&tifm_adapter_lock); 233 spin_lock(&tifm_adapter_lock);
166 idr_remove(&tifm_adapter_idr, fm->id); 234 idr_remove(&tifm_adapter_idr, fm->id);
167 spin_unlock(&tifm_adapter_lock); 235 spin_unlock(&tifm_adapter_lock);
236 class_device_del(&fm->cdev);
168} 237}
169EXPORT_SYMBOL(tifm_remove_adapter); 238EXPORT_SYMBOL(tifm_remove_adapter);
170 239
171void tifm_free_device(struct device *dev) 240void tifm_free_adapter(struct tifm_adapter *fm)
172{ 241{
173 struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev); 242 class_device_put(&fm->cdev);
174 kfree(fm_dev);
175} 243}
176EXPORT_SYMBOL(tifm_free_device); 244EXPORT_SYMBOL(tifm_free_adapter);
177 245
178static void tifm_dummy_signal_irq(struct tifm_dev *sock, 246void tifm_free_device(struct device *dev)
179 unsigned int sock_irq_status)
180{ 247{
181 return; 248 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
249 kfree(sock);
182} 250}
251EXPORT_SYMBOL(tifm_free_device);
183 252
184struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm) 253struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id,
254 unsigned char type)
185{ 255{
186 struct tifm_dev *dev = kzalloc(sizeof(struct tifm_dev), GFP_KERNEL); 256 struct tifm_dev *sock = NULL;
187 257
188 if (dev) { 258 if (!tifm_media_type_name(type, 0))
189 spin_lock_init(&dev->lock); 259 return sock;
190 260
191 dev->dev.parent = fm->dev; 261 sock = kzalloc(sizeof(struct tifm_dev), GFP_KERNEL);
192 dev->dev.bus = &tifm_bus_type; 262 if (sock) {
193 dev->dev.release = tifm_free_device; 263 spin_lock_init(&sock->lock);
194 dev->signal_irq = tifm_dummy_signal_irq; 264 sock->type = type;
265 sock->socket_id = id;
266 sock->card_event = tifm_dummy_event;
267 sock->data_event = tifm_dummy_event;
268
269 sock->dev.parent = fm->cdev.dev;
270 sock->dev.bus = &tifm_bus_type;
271 sock->dev.dma_mask = fm->cdev.dev->dma_mask;
272 sock->dev.release = tifm_free_device;
273
274 snprintf(sock->dev.bus_id, BUS_ID_SIZE,
275 "tifm_%s%u:%u", tifm_media_type_name(type, 2),
276 fm->id, id);
277 printk(KERN_INFO DRIVER_NAME
278 ": %s card detected in socket %u:%u\n",
279 tifm_media_type_name(type, 0), fm->id, id);
195 } 280 }
196 return dev; 281 return sock;
197} 282}
198EXPORT_SYMBOL(tifm_alloc_device); 283EXPORT_SYMBOL(tifm_alloc_device);
199 284
@@ -218,54 +303,15 @@ void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
218} 303}
219EXPORT_SYMBOL(tifm_unmap_sg); 304EXPORT_SYMBOL(tifm_unmap_sg);
220 305
221static int tifm_device_probe(struct device *dev) 306void tifm_queue_work(struct work_struct *work)
222{
223 struct tifm_driver *drv;
224 struct tifm_dev *fm_dev;
225 int rc = 0;
226 const tifm_media_id *id;
227
228 drv = container_of(dev->driver, struct tifm_driver, driver);
229 fm_dev = container_of(dev, struct tifm_dev, dev);
230 get_device(dev);
231 if (!fm_dev->drv && drv->probe && drv->id_table) {
232 rc = -ENODEV;
233 id = tifm_device_match(drv->id_table, fm_dev);
234 if (id)
235 rc = drv->probe(fm_dev);
236 if (rc >= 0) {
237 rc = 0;
238 fm_dev->drv = drv;
239 }
240 }
241 if (rc)
242 put_device(dev);
243 return rc;
244}
245
246static int tifm_device_remove(struct device *dev)
247{ 307{
248 struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev); 308 queue_work(workqueue, work);
249 struct tifm_driver *drv = fm_dev->drv;
250
251 if (drv) {
252 fm_dev->signal_irq = tifm_dummy_signal_irq;
253 if (drv->remove)
254 drv->remove(fm_dev);
255 fm_dev->drv = NULL;
256 }
257
258 put_device(dev);
259 return 0;
260} 309}
310EXPORT_SYMBOL(tifm_queue_work);
261 311
262int tifm_register_driver(struct tifm_driver *drv) 312int tifm_register_driver(struct tifm_driver *drv)
263{ 313{
264 drv->driver.bus = &tifm_bus_type; 314 drv->driver.bus = &tifm_bus_type;
265 drv->driver.probe = tifm_device_probe;
266 drv->driver.remove = tifm_device_remove;
267 drv->driver.suspend = tifm_device_suspend;
268 drv->driver.resume = tifm_device_resume;
269 315
270 return driver_register(&drv->driver); 316 return driver_register(&drv->driver);
271} 317}
@@ -279,13 +325,25 @@ EXPORT_SYMBOL(tifm_unregister_driver);
279 325
280static int __init tifm_init(void) 326static int __init tifm_init(void)
281{ 327{
282 int rc = bus_register(&tifm_bus_type); 328 int rc;
283 329
284 if (!rc) { 330 workqueue = create_freezeable_workqueue("tifm");
285 rc = class_register(&tifm_adapter_class); 331 if (!workqueue)
286 if (rc) 332 return -ENOMEM;
287 bus_unregister(&tifm_bus_type); 333
288 } 334 rc = bus_register(&tifm_bus_type);
335
336 if (rc)
337 goto err_out_wq;
338
339 rc = class_register(&tifm_adapter_class);
340 if (!rc)
341 return 0;
342
343 bus_unregister(&tifm_bus_type);
344
345err_out_wq:
346 destroy_workqueue(workqueue);
289 347
290 return rc; 348 return rc;
291} 349}
@@ -294,6 +352,7 @@ static void __exit tifm_exit(void)
294{ 352{
295 class_unregister(&tifm_adapter_class); 353 class_unregister(&tifm_adapter_class);
296 bus_unregister(&tifm_bus_type); 354 bus_unregister(&tifm_bus_type);
355 destroy_workqueue(workqueue);
297} 356}
298 357
299subsys_initcall(tifm_init); 358subsys_initcall(tifm_init);
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 12af9c718764..6c97491543db 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -19,110 +19,10 @@ config MMC_DEBUG
19 This is an option for use by developers; most people should 19 This is an option for use by developers; most people should
20 say N here. This enables MMC core and driver debugging. 20 say N here. This enables MMC core and driver debugging.
21 21
22config MMC_BLOCK 22source "drivers/mmc/core/Kconfig"
23 tristate "MMC block device driver"
24 depends on MMC && BLOCK
25 default y
26 help
27 Say Y here to enable the MMC block device driver support.
28 This provides a block device driver, which you can use to
29 mount the filesystem. Almost everyone wishing MMC support
30 should say Y or M here.
31
32config MMC_ARMMMCI
33 tristate "ARM AMBA Multimedia Card Interface support"
34 depends on ARM_AMBA && MMC
35 help
36 This selects the ARM(R) AMBA(R) PrimeCell Multimedia Card
37 Interface (PL180 and PL181) support. If you have an ARM(R)
38 platform with a Multimedia Card slot, say Y or M here.
39
40 If unsure, say N.
41
42config MMC_PXA
43 tristate "Intel PXA25x/26x/27x Multimedia Card Interface support"
44 depends on ARCH_PXA && MMC
45 help
46 This selects the Intel(R) PXA(R) Multimedia card Interface.
47 If you have a PXA(R) platform with a Multimedia Card slot,
48 say Y or M here.
49
50 If unsure, say N.
51
52config MMC_SDHCI
53 tristate "Secure Digital Host Controller Interface support (EXPERIMENTAL)"
54 depends on PCI && MMC && EXPERIMENTAL
55 help
56 This select the generic Secure Digital Host Controller Interface.
57 It is used by manufacturers such as Texas Instruments(R), Ricoh(R)
58 and Toshiba(R). Most controllers found in laptops are of this type.
59 If you have a controller with this interface, say Y or M here.
60
61 If unsure, say N.
62
63config MMC_OMAP
64 tristate "TI OMAP Multimedia Card Interface support"
65 depends on ARCH_OMAP && MMC
66 select TPS65010 if MACH_OMAP_H2
67 help
68 This selects the TI OMAP Multimedia card Interface.
69 If you have an OMAP board with a Multimedia Card slot,
70 say Y or M here.
71
72 If unsure, say N.
73 23
74config MMC_WBSD 24source "drivers/mmc/card/Kconfig"
75 tristate "Winbond W83L51xD SD/MMC Card Interface support"
76 depends on MMC && ISA_DMA_API
77 help
78 This selects the Winbond(R) W83L51xD Secure digital and
79 Multimedia card Interface.
80 If you have a machine with a integrated W83L518D or W83L519D
81 SD/MMC card reader, say Y or M here.
82
83 If unsure, say N.
84
85config MMC_AU1X
86 tristate "Alchemy AU1XX0 MMC Card Interface support"
87 depends on MMC && SOC_AU1200
88 help
89 This selects the AMD Alchemy(R) Multimedia card interface.
90 If you have a Alchemy platform with a MMC slot, say Y or M here.
91
92 If unsure, say N.
93
94config MMC_AT91
95 tristate "AT91 SD/MMC Card Interface support"
96 depends on ARCH_AT91 && MMC
97 help
98 This selects the AT91 MCI controller.
99
100 If unsure, say N.
101
102config MMC_IMX
103 tristate "Motorola i.MX Multimedia Card Interface support"
104 depends on ARCH_IMX && MMC
105 help
106 This selects the Motorola i.MX Multimedia card Interface.
107 If you have a i.MX platform with a Multimedia Card slot,
108 say Y or M here.
109
110 If unsure, say N.
111
112config MMC_TIFM_SD
113 tristate "TI Flash Media MMC/SD Interface support (EXPERIMENTAL)"
114 depends on MMC && EXPERIMENTAL && PCI
115 select TIFM_CORE
116 help
117 Say Y here if you want to be able to access MMC/SD cards with
118 the Texas Instruments(R) Flash Media card reader, found in many
119 laptops.
120 This option 'selects' (turns on, enables) 'TIFM_CORE', but you
121 probably also need appropriate card reader host adapter, such as
122 'Misc devices: TI Flash Media PCI74xx/PCI76xx host adapter support
123 (TIFM_7XX1)'.
124 25
125 To compile this driver as a module, choose M here: the 26source "drivers/mmc/host/Kconfig"
126 module will be called tifm_sd.
127 27
128endmenu 28endmenu
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 83ffb9326a54..9979f5e9765b 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -2,32 +2,11 @@
2# Makefile for the kernel mmc device drivers. 2# Makefile for the kernel mmc device drivers.
3# 3#
4 4
5#
6# Core
7#
8obj-$(CONFIG_MMC) += mmc_core.o
9
10#
11# Media drivers
12#
13obj-$(CONFIG_MMC_BLOCK) += mmc_block.o
14
15#
16# Host drivers
17#
18obj-$(CONFIG_MMC_ARMMMCI) += mmci.o
19obj-$(CONFIG_MMC_PXA) += pxamci.o
20obj-$(CONFIG_MMC_IMX) += imxmmc.o
21obj-$(CONFIG_MMC_SDHCI) += sdhci.o
22obj-$(CONFIG_MMC_WBSD) += wbsd.o
23obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
24obj-$(CONFIG_MMC_OMAP) += omap.o
25obj-$(CONFIG_MMC_AT91) += at91_mci.o
26obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
27
28mmc_core-y := mmc.o mmc_sysfs.o
29mmc_core-$(CONFIG_BLOCK) += mmc_queue.o
30
31ifeq ($(CONFIG_MMC_DEBUG),y) 5ifeq ($(CONFIG_MMC_DEBUG),y)
32EXTRA_CFLAGS += -DDEBUG 6 EXTRA_CFLAGS += -DDEBUG
33endif 7endif
8
9obj-$(CONFIG_MMC) += core/
10obj-$(CONFIG_MMC) += card/
11obj-$(CONFIG_MMC) += host/
12
diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig
new file mode 100644
index 000000000000..01a9fd376a1f
--- /dev/null
+++ b/drivers/mmc/card/Kconfig
@@ -0,0 +1,17 @@
1#
2# MMC/SD card drivers
3#
4
5comment "MMC/SD Card Drivers"
6 depends MMC
7
8config MMC_BLOCK
9 tristate "MMC block device driver"
10 depends on MMC && BLOCK
11 default y
12 help
13 Say Y here to enable the MMC block device driver support.
14 This provides a block device driver, which you can use to
15 mount the filesystem. Almost everyone wishing MMC support
16 should say Y or M here.
17
diff --git a/drivers/mmc/card/Makefile b/drivers/mmc/card/Makefile
new file mode 100644
index 000000000000..cf8c939867f5
--- /dev/null
+++ b/drivers/mmc/card/Makefile
@@ -0,0 +1,11 @@
1#
2# Makefile for MMC/SD card drivers
3#
4
5ifeq ($(CONFIG_MMC_DEBUG),y)
6 EXTRA_CFLAGS += -DDEBUG
7endif
8
9obj-$(CONFIG_MMC_BLOCK) += mmc_block.o
10mmc_block-objs := block.o queue.o
11
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/card/block.c
index 86439a0bb271..d24ab234394c 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/card/block.c
@@ -2,6 +2,7 @@
2 * Block driver for media (i.e., flash cards) 2 * Block driver for media (i.e., flash cards)
3 * 3 *
4 * Copyright 2002 Hewlett-Packard Company 4 * Copyright 2002 Hewlett-Packard Company
5 * Copyright 2005-2007 Pierre Ossman
5 * 6 *
6 * Use consistent with the GNU GPL is permitted, 7 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is 8 * provided that this copyright notice is
@@ -31,13 +32,13 @@
31 32
32#include <linux/mmc/card.h> 33#include <linux/mmc/card.h>
33#include <linux/mmc/host.h> 34#include <linux/mmc/host.h>
34#include <linux/mmc/protocol.h> 35#include <linux/mmc/mmc.h>
35#include <linux/mmc/host.h> 36#include <linux/mmc/sd.h>
36 37
37#include <asm/system.h> 38#include <asm/system.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39 40
40#include "mmc_queue.h" 41#include "queue.h"
41 42
42/* 43/*
43 * max 8 partitions per card 44 * max 8 partitions per card
@@ -223,10 +224,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
223 struct mmc_blk_data *md = mq->data; 224 struct mmc_blk_data *md = mq->data;
224 struct mmc_card *card = md->queue.card; 225 struct mmc_card *card = md->queue.card;
225 struct mmc_blk_request brq; 226 struct mmc_blk_request brq;
226 int ret = 1; 227 int ret = 1, sg_pos, data_size;
227 228
228 if (mmc_card_claim_host(card)) 229 mmc_claim_host(card->host);
229 goto flush_queue;
230 230
231 do { 231 do {
232 struct mmc_command cmd; 232 struct mmc_command cmd;
@@ -283,6 +283,20 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
283 brq.data.sg = mq->sg; 283 brq.data.sg = mq->sg;
284 brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg); 284 brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg);
285 285
286 if (brq.data.blocks !=
287 (req->nr_sectors >> (md->block_bits - 9))) {
288 data_size = brq.data.blocks * brq.data.blksz;
289 for (sg_pos = 0; sg_pos < brq.data.sg_len; sg_pos++) {
290 data_size -= mq->sg[sg_pos].length;
291 if (data_size <= 0) {
292 mq->sg[sg_pos].length += data_size;
293 sg_pos++;
294 break;
295 }
296 }
297 brq.data.sg_len = sg_pos;
298 }
299
286 mmc_wait_for_req(card->host, &brq.mrq); 300 mmc_wait_for_req(card->host, &brq.mrq);
287 if (brq.cmd.error) { 301 if (brq.cmd.error) {
288 printk(KERN_ERR "%s: error %d sending read/write command\n", 302 printk(KERN_ERR "%s: error %d sending read/write command\n",
@@ -342,7 +356,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
342 spin_unlock_irq(&md->lock); 356 spin_unlock_irq(&md->lock);
343 } while (ret); 357 } while (ret);
344 358
345 mmc_card_release_host(card); 359 mmc_release_host(card->host);
346 360
347 return 1; 361 return 1;
348 362
@@ -378,9 +392,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
378 spin_unlock_irq(&md->lock); 392 spin_unlock_irq(&md->lock);
379 } 393 }
380 394
381flush_queue: 395 mmc_release_host(card->host);
382
383 mmc_card_release_host(card);
384 396
385 spin_lock_irq(&md->lock); 397 spin_lock_irq(&md->lock);
386 while (ret) { 398 while (ret) {
@@ -477,11 +489,20 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
477 489
478 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits); 490 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits);
479 491
480 /* 492 if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) {
481 * The CSD capacity field is in units of read_blkbits. 493 /*
482 * set_capacity takes units of 512 bytes. 494 * The EXT_CSD sector count is in number or 512 byte
483 */ 495 * sectors.
484 set_capacity(md->disk, card->csd.capacity << (card->csd.read_blkbits - 9)); 496 */
497 set_capacity(md->disk, card->ext_csd.sectors);
498 } else {
499 /*
500 * The CSD capacity field is in units of read_blkbits.
501 * set_capacity takes units of 512 bytes.
502 */
503 set_capacity(md->disk,
504 card->csd.capacity << (card->csd.read_blkbits - 9));
505 }
485 return md; 506 return md;
486 507
487 err_putdisk: 508 err_putdisk:
@@ -502,12 +523,12 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
502 if (mmc_card_blockaddr(card)) 523 if (mmc_card_blockaddr(card))
503 return 0; 524 return 0;
504 525
505 mmc_card_claim_host(card); 526 mmc_claim_host(card->host);
506 cmd.opcode = MMC_SET_BLOCKLEN; 527 cmd.opcode = MMC_SET_BLOCKLEN;
507 cmd.arg = 1 << md->block_bits; 528 cmd.arg = 1 << md->block_bits;
508 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; 529 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
509 err = mmc_wait_for_cmd(card->host, &cmd, 5); 530 err = mmc_wait_for_cmd(card->host, &cmd, 5);
510 mmc_card_release_host(card); 531 mmc_release_host(card->host);
511 532
512 if (err) { 533 if (err) {
513 printk(KERN_ERR "%s: unable to set block size to %d: %d\n", 534 printk(KERN_ERR "%s: unable to set block size to %d: %d\n",
diff --git a/drivers/mmc/mmc_queue.c b/drivers/mmc/card/queue.c
index c27e42645cdb..2e77963db334 100644
--- a/drivers/mmc/mmc_queue.c
+++ b/drivers/mmc/card/queue.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * linux/drivers/mmc/mmc_queue.c 2 * linux/drivers/mmc/queue.c
3 * 3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved. 4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * Copyright 2006-2007 Pierre Ossman
5 * 6 *
6 * 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
7 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -14,7 +15,7 @@
14 15
15#include <linux/mmc/card.h> 16#include <linux/mmc/card.h>
16#include <linux/mmc/host.h> 17#include <linux/mmc/host.h>
17#include "mmc_queue.h" 18#include "queue.h"
18 19
19#define MMC_QUEUE_SUSPENDED (1 << 0) 20#define MMC_QUEUE_SUSPENDED (1 << 0)
20 21
@@ -179,7 +180,6 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
179 blk_cleanup_queue(mq->queue); 180 blk_cleanup_queue(mq->queue);
180 return ret; 181 return ret;
181} 182}
182EXPORT_SYMBOL(mmc_init_queue);
183 183
184void mmc_cleanup_queue(struct mmc_queue *mq) 184void mmc_cleanup_queue(struct mmc_queue *mq)
185{ 185{
@@ -191,6 +191,9 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
191 q->queuedata = NULL; 191 q->queuedata = NULL;
192 spin_unlock_irqrestore(q->queue_lock, flags); 192 spin_unlock_irqrestore(q->queue_lock, flags);
193 193
194 /* Make sure the queue isn't suspended, as that will deadlock */
195 mmc_queue_resume(mq);
196
194 /* Then terminate our worker thread */ 197 /* Then terminate our worker thread */
195 kthread_stop(mq->thread); 198 kthread_stop(mq->thread);
196 199
@@ -226,7 +229,6 @@ void mmc_queue_suspend(struct mmc_queue *mq)
226 down(&mq->thread_sem); 229 down(&mq->thread_sem);
227 } 230 }
228} 231}
229EXPORT_SYMBOL(mmc_queue_suspend);
230 232
231/** 233/**
232 * mmc_queue_resume - resume a previously suspended MMC request queue 234 * mmc_queue_resume - resume a previously suspended MMC request queue
@@ -247,4 +249,4 @@ void mmc_queue_resume(struct mmc_queue *mq)
247 spin_unlock_irqrestore(q->queue_lock, flags); 249 spin_unlock_irqrestore(q->queue_lock, flags);
248 } 250 }
249} 251}
250EXPORT_SYMBOL(mmc_queue_resume); 252
diff --git a/drivers/mmc/mmc_queue.h b/drivers/mmc/card/queue.h
index c9f139e764f6..c9f139e764f6 100644
--- a/drivers/mmc/mmc_queue.h
+++ b/drivers/mmc/card/queue.h
diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig
new file mode 100644
index 000000000000..94222b9a15ea
--- /dev/null
+++ b/drivers/mmc/core/Kconfig
@@ -0,0 +1,17 @@
1#
2# MMC core configuration
3#
4
5config MMC_UNSAFE_RESUME
6 bool "Allow unsafe resume (DANGEROUS)"
7 depends on MMC != n
8 help
9 If you say Y here, the MMC layer will assume that all cards
10 stayed in their respective slots during the suspend. The
11 normal behaviour is to remove them at suspend and
12 redetecting them at resume. Breaking this assumption will
13 in most cases result in data corruption.
14
15 This option is usually just for embedded systems which use
16 a MMC/SD card for rootfs. Most people should say N here.
17
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
new file mode 100644
index 000000000000..1075b02ae754
--- /dev/null
+++ b/drivers/mmc/core/Makefile
@@ -0,0 +1,11 @@
1#
2# Makefile for the kernel mmc core.
3#
4
5ifeq ($(CONFIG_MMC_DEBUG),y)
6 EXTRA_CFLAGS += -DDEBUG
7endif
8
9obj-$(CONFIG_MMC) += mmc_core.o
10mmc_core-y := core.o sysfs.o mmc.o mmc_ops.o sd.o sd_ops.o
11
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
new file mode 100644
index 000000000000..72c7cf4a9f9d
--- /dev/null
+++ b/drivers/mmc/core/core.c
@@ -0,0 +1,727 @@
1/*
2 * linux/drivers/mmc/core/core.c
3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
6 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
7 * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
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#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/completion.h>
17#include <linux/device.h>
18#include <linux/delay.h>
19#include <linux/pagemap.h>
20#include <linux/err.h>
21#include <asm/scatterlist.h>
22#include <linux/scatterlist.h>
23
24#include <linux/mmc/card.h>
25#include <linux/mmc/host.h>
26#include <linux/mmc/mmc.h>
27#include <linux/mmc/sd.h>
28
29#include "core.h"
30#include "sysfs.h"
31
32#include "mmc_ops.h"
33#include "sd_ops.h"
34
35extern int mmc_attach_mmc(struct mmc_host *host, u32 ocr);
36extern int mmc_attach_sd(struct mmc_host *host, u32 ocr);
37
38/**
39 * mmc_request_done - finish processing an MMC request
40 * @host: MMC host which completed request
41 * @mrq: MMC request which request
42 *
43 * MMC drivers should call this function when they have completed
44 * their processing of a request.
45 */
46void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
47{
48 struct mmc_command *cmd = mrq->cmd;
49 int err = cmd->error;
50
51 pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n",
52 mmc_hostname(host), cmd->opcode, err,
53 mrq->data ? mrq->data->error : 0,
54 mrq->stop ? mrq->stop->error : 0,
55 cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
56
57 if (err && cmd->retries) {
58 cmd->retries--;
59 cmd->error = 0;
60 host->ops->request(host, mrq);
61 } else if (mrq->done) {
62 mrq->done(mrq);
63 }
64}
65
66EXPORT_SYMBOL(mmc_request_done);
67
68/**
69 * mmc_start_request - start a command on a host
70 * @host: MMC host to start command on
71 * @mrq: MMC request to start
72 *
73 * Queue a command on the specified host. We expect the
74 * caller to be holding the host lock with interrupts disabled.
75 */
76void
77mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
78{
79#ifdef CONFIG_MMC_DEBUG
80 unsigned int i, sz;
81#endif
82
83 pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
84 mmc_hostname(host), mrq->cmd->opcode,
85 mrq->cmd->arg, mrq->cmd->flags);
86
87 WARN_ON(!host->claimed);
88
89 mrq->cmd->error = 0;
90 mrq->cmd->mrq = mrq;
91 if (mrq->data) {
92 BUG_ON(mrq->data->blksz > host->max_blk_size);
93 BUG_ON(mrq->data->blocks > host->max_blk_count);
94 BUG_ON(mrq->data->blocks * mrq->data->blksz >
95 host->max_req_size);
96
97#ifdef CONFIG_MMC_DEBUG
98 sz = 0;
99 for (i = 0;i < mrq->data->sg_len;i++)
100 sz += mrq->data->sg[i].length;
101 BUG_ON(sz != mrq->data->blocks * mrq->data->blksz);
102#endif
103
104 mrq->cmd->data = mrq->data;
105 mrq->data->error = 0;
106 mrq->data->mrq = mrq;
107 if (mrq->stop) {
108 mrq->data->stop = mrq->stop;
109 mrq->stop->error = 0;
110 mrq->stop->mrq = mrq;
111 }
112 }
113 host->ops->request(host, mrq);
114}
115
116EXPORT_SYMBOL(mmc_start_request);
117
118static void mmc_wait_done(struct mmc_request *mrq)
119{
120 complete(mrq->done_data);
121}
122
123int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
124{
125 DECLARE_COMPLETION_ONSTACK(complete);
126
127 mrq->done_data = &complete;
128 mrq->done = mmc_wait_done;
129
130 mmc_start_request(host, mrq);
131
132 wait_for_completion(&complete);
133
134 return 0;
135}
136
137EXPORT_SYMBOL(mmc_wait_for_req);
138
139/**
140 * mmc_wait_for_cmd - start a command and wait for completion
141 * @host: MMC host to start command
142 * @cmd: MMC command to start
143 * @retries: maximum number of retries
144 *
145 * Start a new MMC command for a host, and wait for the command
146 * to complete. Return any error that occurred while the command
147 * was executing. Do not attempt to parse the response.
148 */
149int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries)
150{
151 struct mmc_request mrq;
152
153 BUG_ON(!host->claimed);
154
155 memset(&mrq, 0, sizeof(struct mmc_request));
156
157 memset(cmd->resp, 0, sizeof(cmd->resp));
158 cmd->retries = retries;
159
160 mrq.cmd = cmd;
161 cmd->data = NULL;
162
163 mmc_wait_for_req(host, &mrq);
164
165 return cmd->error;
166}
167
168EXPORT_SYMBOL(mmc_wait_for_cmd);
169
170/**
171 * mmc_set_data_timeout - set the timeout for a data command
172 * @data: data phase for command
173 * @card: the MMC card associated with the data transfer
174 * @write: flag to differentiate reads from writes
175 */
176void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card,
177 int write)
178{
179 unsigned int mult;
180
181 /*
182 * SD cards use a 100 multiplier rather than 10
183 */
184 mult = mmc_card_sd(card) ? 100 : 10;
185
186 /*
187 * Scale up the multiplier (and therefore the timeout) by
188 * the r2w factor for writes.
189 */
190 if (write)
191 mult <<= card->csd.r2w_factor;
192
193 data->timeout_ns = card->csd.tacc_ns * mult;
194 data->timeout_clks = card->csd.tacc_clks * mult;
195
196 /*
197 * SD cards also have an upper limit on the timeout.
198 */
199 if (mmc_card_sd(card)) {
200 unsigned int timeout_us, limit_us;
201
202 timeout_us = data->timeout_ns / 1000;
203 timeout_us += data->timeout_clks * 1000 /
204 (card->host->ios.clock / 1000);
205
206 if (write)
207 limit_us = 250000;
208 else
209 limit_us = 100000;
210
211 /*
212 * SDHC cards always use these fixed values.
213 */
214 if (timeout_us > limit_us || mmc_card_blockaddr(card)) {
215 data->timeout_ns = limit_us * 1000;
216 data->timeout_clks = 0;
217 }
218 }
219}
220EXPORT_SYMBOL(mmc_set_data_timeout);
221
222/**
223 * __mmc_claim_host - exclusively claim a host
224 * @host: mmc host to claim
225 * @card: mmc card to claim host for
226 *
227 * Claim a host for a set of operations. If a valid card
228 * is passed and this wasn't the last card selected, select
229 * the card before returning.
230 *
231 * Note: you should use mmc_card_claim_host or mmc_claim_host.
232 */
233void mmc_claim_host(struct mmc_host *host)
234{
235 DECLARE_WAITQUEUE(wait, current);
236 unsigned long flags;
237
238 add_wait_queue(&host->wq, &wait);
239 spin_lock_irqsave(&host->lock, flags);
240 while (1) {
241 set_current_state(TASK_UNINTERRUPTIBLE);
242 if (!host->claimed)
243 break;
244 spin_unlock_irqrestore(&host->lock, flags);
245 schedule();
246 spin_lock_irqsave(&host->lock, flags);
247 }
248 set_current_state(TASK_RUNNING);
249 host->claimed = 1;
250 spin_unlock_irqrestore(&host->lock, flags);
251 remove_wait_queue(&host->wq, &wait);
252}
253
254EXPORT_SYMBOL(mmc_claim_host);
255
256/**
257 * mmc_release_host - release a host
258 * @host: mmc host to release
259 *
260 * Release a MMC host, allowing others to claim the host
261 * for their operations.
262 */
263void mmc_release_host(struct mmc_host *host)
264{
265 unsigned long flags;
266
267 BUG_ON(!host->claimed);
268
269 spin_lock_irqsave(&host->lock, flags);
270 host->claimed = 0;
271 spin_unlock_irqrestore(&host->lock, flags);
272
273 wake_up(&host->wq);
274}
275
276EXPORT_SYMBOL(mmc_release_host);
277
278/*
279 * Internal function that does the actual ios call to the host driver,
280 * optionally printing some debug output.
281 */
282static inline void mmc_set_ios(struct mmc_host *host)
283{
284 struct mmc_ios *ios = &host->ios;
285
286 pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u "
287 "width %u timing %u\n",
288 mmc_hostname(host), ios->clock, ios->bus_mode,
289 ios->power_mode, ios->chip_select, ios->vdd,
290 ios->bus_width, ios->timing);
291
292 host->ops->set_ios(host, ios);
293}
294
295/*
296 * Control chip select pin on a host.
297 */
298void mmc_set_chip_select(struct mmc_host *host, int mode)
299{
300 host->ios.chip_select = mode;
301 mmc_set_ios(host);
302}
303
304/*
305 * Sets the host clock to the highest possible frequency that
306 * is below "hz".
307 */
308void mmc_set_clock(struct mmc_host *host, unsigned int hz)
309{
310 WARN_ON(hz < host->f_min);
311
312 if (hz > host->f_max)
313 hz = host->f_max;
314
315 host->ios.clock = hz;
316 mmc_set_ios(host);
317}
318
319/*
320 * Change the bus mode (open drain/push-pull) of a host.
321 */
322void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
323{
324 host->ios.bus_mode = mode;
325 mmc_set_ios(host);
326}
327
328/*
329 * Change data bus width of a host.
330 */
331void mmc_set_bus_width(struct mmc_host *host, unsigned int width)
332{
333 host->ios.bus_width = width;
334 mmc_set_ios(host);
335}
336
337/*
338 * Mask off any voltages we don't support and select
339 * the lowest voltage
340 */
341u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
342{
343 int bit;
344
345 ocr &= host->ocr_avail;
346
347 bit = ffs(ocr);
348 if (bit) {
349 bit -= 1;
350
351 ocr &= 3 << bit;
352
353 host->ios.vdd = bit;
354 mmc_set_ios(host);
355 } else {
356 ocr = 0;
357 }
358
359 return ocr;
360}
361
362/*
363 * Select timing parameters for host.
364 */
365void mmc_set_timing(struct mmc_host *host, unsigned int timing)
366{
367 host->ios.timing = timing;
368 mmc_set_ios(host);
369}
370
371/*
372 * Allocate a new MMC card
373 */
374struct mmc_card *mmc_alloc_card(struct mmc_host *host)
375{
376 struct mmc_card *card;
377
378 card = kmalloc(sizeof(struct mmc_card), GFP_KERNEL);
379 if (!card)
380 return ERR_PTR(-ENOMEM);
381
382 mmc_init_card(card, host);
383
384 return card;
385}
386
387/*
388 * Apply power to the MMC stack. This is a two-stage process.
389 * First, we enable power to the card without the clock running.
390 * We then wait a bit for the power to stabilise. Finally,
391 * enable the bus drivers and clock to the card.
392 *
393 * We must _NOT_ enable the clock prior to power stablising.
394 *
395 * If a host does all the power sequencing itself, ignore the
396 * initial MMC_POWER_UP stage.
397 */
398static void mmc_power_up(struct mmc_host *host)
399{
400 int bit = fls(host->ocr_avail) - 1;
401
402 host->ios.vdd = bit;
403 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
404 host->ios.chip_select = MMC_CS_DONTCARE;
405 host->ios.power_mode = MMC_POWER_UP;
406 host->ios.bus_width = MMC_BUS_WIDTH_1;
407 host->ios.timing = MMC_TIMING_LEGACY;
408 mmc_set_ios(host);
409
410 mmc_delay(1);
411
412 host->ios.clock = host->f_min;
413 host->ios.power_mode = MMC_POWER_ON;
414 mmc_set_ios(host);
415
416 mmc_delay(2);
417}
418
419static void mmc_power_off(struct mmc_host *host)
420{
421 host->ios.clock = 0;
422 host->ios.vdd = 0;
423 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
424 host->ios.chip_select = MMC_CS_DONTCARE;
425 host->ios.power_mode = MMC_POWER_OFF;
426 host->ios.bus_width = MMC_BUS_WIDTH_1;
427 host->ios.timing = MMC_TIMING_LEGACY;
428 mmc_set_ios(host);
429}
430
431/*
432 * Assign a mmc bus handler to a host. Only one bus handler may control a
433 * host at any given time.
434 */
435void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
436{
437 unsigned long flags;
438
439 BUG_ON(!host);
440 BUG_ON(!ops);
441
442 BUG_ON(!host->claimed);
443
444 spin_lock_irqsave(&host->lock, flags);
445
446 BUG_ON(host->bus_ops);
447 BUG_ON(host->bus_refs);
448
449 host->bus_ops = ops;
450 host->bus_refs = 1;
451 host->bus_dead = 0;
452
453 spin_unlock_irqrestore(&host->lock, flags);
454}
455
456/*
457 * Remove the current bus handler from a host. Assumes that there are
458 * no interesting cards left, so the bus is powered down.
459 */
460void mmc_detach_bus(struct mmc_host *host)
461{
462 unsigned long flags;
463
464 BUG_ON(!host);
465
466 BUG_ON(!host->claimed);
467 BUG_ON(!host->bus_ops);
468
469 spin_lock_irqsave(&host->lock, flags);
470
471 host->bus_dead = 1;
472
473 spin_unlock_irqrestore(&host->lock, flags);
474
475 mmc_power_off(host);
476
477 mmc_bus_put(host);
478}
479
480/*
481 * Cleanup when the last reference to the bus operator is dropped.
482 */
483void __mmc_release_bus(struct mmc_host *host)
484{
485 BUG_ON(!host);
486 BUG_ON(host->bus_refs);
487 BUG_ON(!host->bus_dead);
488
489 host->bus_ops = NULL;
490}
491
492/**
493 * mmc_detect_change - process change of state on a MMC socket
494 * @host: host which changed state.
495 * @delay: optional delay to wait before detection (jiffies)
496 *
497 * All we know is that card(s) have been inserted or removed
498 * from the socket(s). We don't know which socket or cards.
499 */
500void mmc_detect_change(struct mmc_host *host, unsigned long delay)
501{
502#ifdef CONFIG_MMC_DEBUG
503 mmc_claim_host(host);
504 BUG_ON(host->removed);
505 mmc_release_host(host);
506#endif
507
508 mmc_schedule_delayed_work(&host->detect, delay);
509}
510
511EXPORT_SYMBOL(mmc_detect_change);
512
513
514static void mmc_rescan(struct work_struct *work)
515{
516 struct mmc_host *host =
517 container_of(work, struct mmc_host, detect.work);
518 u32 ocr;
519 int err;
520
521 mmc_bus_get(host);
522
523 if (host->bus_ops == NULL) {
524 /*
525 * Only we can add a new handler, so it's safe to
526 * release the lock here.
527 */
528 mmc_bus_put(host);
529
530 mmc_claim_host(host);
531
532 mmc_power_up(host);
533 mmc_go_idle(host);
534
535 mmc_send_if_cond(host, host->ocr_avail);
536
537 err = mmc_send_app_op_cond(host, 0, &ocr);
538 if (err == MMC_ERR_NONE) {
539 if (mmc_attach_sd(host, ocr))
540 mmc_power_off(host);
541 } else {
542 /*
543 * If we fail to detect any SD cards then try
544 * searching for MMC cards.
545 */
546 err = mmc_send_op_cond(host, 0, &ocr);
547 if (err == MMC_ERR_NONE) {
548 if (mmc_attach_mmc(host, ocr))
549 mmc_power_off(host);
550 } else {
551 mmc_power_off(host);
552 mmc_release_host(host);
553 }
554 }
555 } else {
556 if (host->bus_ops->detect && !host->bus_dead)
557 host->bus_ops->detect(host);
558
559 mmc_bus_put(host);
560 }
561}
562
563
564/**
565 * mmc_alloc_host - initialise the per-host structure.
566 * @extra: sizeof private data structure
567 * @dev: pointer to host device model structure
568 *
569 * Initialise the per-host structure.
570 */
571struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
572{
573 struct mmc_host *host;
574
575 host = mmc_alloc_host_sysfs(extra, dev);
576 if (host) {
577 spin_lock_init(&host->lock);
578 init_waitqueue_head(&host->wq);
579 INIT_DELAYED_WORK(&host->detect, mmc_rescan);
580
581 /*
582 * By default, hosts do not support SGIO or large requests.
583 * They have to set these according to their abilities.
584 */
585 host->max_hw_segs = 1;
586 host->max_phys_segs = 1;
587 host->max_seg_size = PAGE_CACHE_SIZE;
588
589 host->max_req_size = PAGE_CACHE_SIZE;
590 host->max_blk_size = 512;
591 host->max_blk_count = PAGE_CACHE_SIZE / 512;
592 }
593
594 return host;
595}
596
597EXPORT_SYMBOL(mmc_alloc_host);
598
599/**
600 * mmc_add_host - initialise host hardware
601 * @host: mmc host
602 */
603int mmc_add_host(struct mmc_host *host)
604{
605 int ret;
606
607 ret = mmc_add_host_sysfs(host);
608 if (ret == 0) {
609 mmc_power_off(host);
610 mmc_detect_change(host, 0);
611 }
612
613 return ret;
614}
615
616EXPORT_SYMBOL(mmc_add_host);
617
618/**
619 * mmc_remove_host - remove host hardware
620 * @host: mmc host
621 *
622 * Unregister and remove all cards associated with this host,
623 * and power down the MMC bus.
624 */
625void mmc_remove_host(struct mmc_host *host)
626{
627#ifdef CONFIG_MMC_DEBUG
628 mmc_claim_host(host);
629 host->removed = 1;
630 mmc_release_host(host);
631#endif
632
633 mmc_flush_scheduled_work();
634
635 mmc_bus_get(host);
636 if (host->bus_ops && !host->bus_dead) {
637 if (host->bus_ops->remove)
638 host->bus_ops->remove(host);
639
640 mmc_claim_host(host);
641 mmc_detach_bus(host);
642 mmc_release_host(host);
643 }
644 mmc_bus_put(host);
645
646 BUG_ON(host->card);
647
648 mmc_power_off(host);
649 mmc_remove_host_sysfs(host);
650}
651
652EXPORT_SYMBOL(mmc_remove_host);
653
654/**
655 * mmc_free_host - free the host structure
656 * @host: mmc host
657 *
658 * Free the host once all references to it have been dropped.
659 */
660void mmc_free_host(struct mmc_host *host)
661{
662 mmc_free_host_sysfs(host);
663}
664
665EXPORT_SYMBOL(mmc_free_host);
666
667#ifdef CONFIG_PM
668
669/**
670 * mmc_suspend_host - suspend a host
671 * @host: mmc host
672 * @state: suspend mode (PM_SUSPEND_xxx)
673 */
674int mmc_suspend_host(struct mmc_host *host, pm_message_t state)
675{
676 mmc_flush_scheduled_work();
677
678 mmc_bus_get(host);
679 if (host->bus_ops && !host->bus_dead) {
680 if (host->bus_ops->suspend)
681 host->bus_ops->suspend(host);
682 if (!host->bus_ops->resume) {
683 if (host->bus_ops->remove)
684 host->bus_ops->remove(host);
685
686 mmc_claim_host(host);
687 mmc_detach_bus(host);
688 mmc_release_host(host);
689 }
690 }
691 mmc_bus_put(host);
692
693 mmc_power_off(host);
694
695 return 0;
696}
697
698EXPORT_SYMBOL(mmc_suspend_host);
699
700/**
701 * mmc_resume_host - resume a previously suspended host
702 * @host: mmc host
703 */
704int mmc_resume_host(struct mmc_host *host)
705{
706 mmc_bus_get(host);
707 if (host->bus_ops && !host->bus_dead) {
708 mmc_power_up(host);
709 BUG_ON(!host->bus_ops->resume);
710 host->bus_ops->resume(host);
711 }
712 mmc_bus_put(host);
713
714 /*
715 * We add a slight delay here so that resume can progress
716 * in parallel.
717 */
718 mmc_detect_change(host, 1);
719
720 return 0;
721}
722
723EXPORT_SYMBOL(mmc_resume_host);
724
725#endif
726
727MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
new file mode 100644
index 000000000000..177264d090ac
--- /dev/null
+++ b/drivers/mmc/core/core.h
@@ -0,0 +1,70 @@
1/*
2 * linux/drivers/mmc/core/core.h
3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * Copyright 2007 Pierre Ossman
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#ifndef _MMC_CORE_CORE_H
12#define _MMC_CORE_CORE_H
13
14#include <linux/delay.h>
15
16#define MMC_CMD_RETRIES 3
17
18struct mmc_bus_ops {
19 void (*remove)(struct mmc_host *);
20 void (*detect)(struct mmc_host *);
21 void (*suspend)(struct mmc_host *);
22 void (*resume)(struct mmc_host *);
23};
24
25void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
26void mmc_detach_bus(struct mmc_host *host);
27
28void __mmc_release_bus(struct mmc_host *host);
29
30static inline void mmc_bus_get(struct mmc_host *host)
31{
32 unsigned long flags;
33
34 spin_lock_irqsave(&host->lock, flags);
35 host->bus_refs++;
36 spin_unlock_irqrestore(&host->lock, flags);
37}
38
39static inline void mmc_bus_put(struct mmc_host *host)
40{
41 unsigned long flags;
42
43 spin_lock_irqsave(&host->lock, flags);
44 host->bus_refs--;
45 if ((host->bus_refs == 0) && host->bus_ops)
46 __mmc_release_bus(host);
47 spin_unlock_irqrestore(&host->lock, flags);
48}
49
50void mmc_set_chip_select(struct mmc_host *host, int mode);
51void mmc_set_clock(struct mmc_host *host, unsigned int hz);
52void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
53void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
54u32 mmc_select_voltage(struct mmc_host *host, u32 ocr);
55void mmc_set_timing(struct mmc_host *host, unsigned int timing);
56
57struct mmc_card *mmc_alloc_card(struct mmc_host *host);
58
59static inline void mmc_delay(unsigned int ms)
60{
61 if (ms < 1000 / HZ) {
62 cond_resched();
63 mdelay(ms);
64 } else {
65 msleep(ms);
66 }
67}
68
69#endif
70
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
new file mode 100644
index 000000000000..42cc2867ed7d
--- /dev/null
+++ b/drivers/mmc/core/mmc.c
@@ -0,0 +1,537 @@
1/*
2 * linux/drivers/mmc/mmc.c
3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
6 * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
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#include <linux/err.h>
14
15#include <linux/mmc/host.h>
16#include <linux/mmc/card.h>
17#include <linux/mmc/mmc.h>
18
19#include "core.h"
20#include "sysfs.h"
21#include "mmc_ops.h"
22
23static const unsigned int tran_exp[] = {
24 10000, 100000, 1000000, 10000000,
25 0, 0, 0, 0
26};
27
28static const unsigned char tran_mant[] = {
29 0, 10, 12, 13, 15, 20, 25, 30,
30 35, 40, 45, 50, 55, 60, 70, 80,
31};
32
33static const unsigned int tacc_exp[] = {
34 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000,
35};
36
37static const unsigned int tacc_mant[] = {
38 0, 10, 12, 13, 15, 20, 25, 30,
39 35, 40, 45, 50, 55, 60, 70, 80,
40};
41
42#define UNSTUFF_BITS(resp,start,size) \
43 ({ \
44 const int __size = size; \
45 const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \
46 const int __off = 3 - ((start) / 32); \
47 const int __shft = (start) & 31; \
48 u32 __res; \
49 \
50 __res = resp[__off] >> __shft; \
51 if (__size + __shft > 32) \
52 __res |= resp[__off-1] << ((32 - __shft) % 32); \
53 __res & __mask; \
54 })
55
56/*
57 * Given the decoded CSD structure, decode the raw CID to our CID structure.
58 */
59static int mmc_decode_cid(struct mmc_card *card)
60{
61 u32 *resp = card->raw_cid;
62
63 /*
64 * The selection of the format here is based upon published
65 * specs from sandisk and from what people have reported.
66 */
67 switch (card->csd.mmca_vsn) {
68 case 0: /* MMC v1.0 - v1.2 */
69 case 1: /* MMC v1.4 */
70 card->cid.manfid = UNSTUFF_BITS(resp, 104, 24);
71 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8);
72 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8);
73 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8);
74 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8);
75 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8);
76 card->cid.prod_name[5] = UNSTUFF_BITS(resp, 56, 8);
77 card->cid.prod_name[6] = UNSTUFF_BITS(resp, 48, 8);
78 card->cid.hwrev = UNSTUFF_BITS(resp, 44, 4);
79 card->cid.fwrev = UNSTUFF_BITS(resp, 40, 4);
80 card->cid.serial = UNSTUFF_BITS(resp, 16, 24);
81 card->cid.month = UNSTUFF_BITS(resp, 12, 4);
82 card->cid.year = UNSTUFF_BITS(resp, 8, 4) + 1997;
83 break;
84
85 case 2: /* MMC v2.0 - v2.2 */
86 case 3: /* MMC v3.1 - v3.3 */
87 case 4: /* MMC v4 */
88 card->cid.manfid = UNSTUFF_BITS(resp, 120, 8);
89 card->cid.oemid = UNSTUFF_BITS(resp, 104, 16);
90 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8);
91 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8);
92 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8);
93 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8);
94 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8);
95 card->cid.prod_name[5] = UNSTUFF_BITS(resp, 56, 8);
96 card->cid.serial = UNSTUFF_BITS(resp, 16, 32);
97 card->cid.month = UNSTUFF_BITS(resp, 12, 4);
98 card->cid.year = UNSTUFF_BITS(resp, 8, 4) + 1997;
99 break;
100
101 default:
102 printk("%s: card has unknown MMCA version %d\n",
103 mmc_hostname(card->host), card->csd.mmca_vsn);
104 return -EINVAL;
105 }
106
107 return 0;
108}
109
110/*
111 * Given a 128-bit response, decode to our card CSD structure.
112 */
113static int mmc_decode_csd(struct mmc_card *card)
114{
115 struct mmc_csd *csd = &card->csd;
116 unsigned int e, m, csd_struct;
117 u32 *resp = card->raw_csd;
118
119 /*
120 * We only understand CSD structure v1.1 and v1.2.
121 * v1.2 has extra information in bits 15, 11 and 10.
122 */
123 csd_struct = UNSTUFF_BITS(resp, 126, 2);
124 if (csd_struct != 1 && csd_struct != 2) {
125 printk("%s: unrecognised CSD structure version %d\n",
126 mmc_hostname(card->host), csd_struct);
127 return -EINVAL;
128 }
129
130 csd->mmca_vsn = UNSTUFF_BITS(resp, 122, 4);
131 m = UNSTUFF_BITS(resp, 115, 4);
132 e = UNSTUFF_BITS(resp, 112, 3);
133 csd->tacc_ns = (tacc_exp[e] * tacc_mant[m] + 9) / 10;
134 csd->tacc_clks = UNSTUFF_BITS(resp, 104, 8) * 100;
135
136 m = UNSTUFF_BITS(resp, 99, 4);
137 e = UNSTUFF_BITS(resp, 96, 3);
138 csd->max_dtr = tran_exp[e] * tran_mant[m];
139 csd->cmdclass = UNSTUFF_BITS(resp, 84, 12);
140
141 e = UNSTUFF_BITS(resp, 47, 3);
142 m = UNSTUFF_BITS(resp, 62, 12);
143 csd->capacity = (1 + m) << (e + 2);
144
145 csd->read_blkbits = UNSTUFF_BITS(resp, 80, 4);
146 csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
147 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
148 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
149 csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
150 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
151 csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
152
153 return 0;
154}
155
156/*
157 * Read and decode extended CSD.
158 */
159static int mmc_read_ext_csd(struct mmc_card *card)
160{
161 int err;
162 u8 *ext_csd;
163
164 BUG_ON(!card);
165
166 err = MMC_ERR_FAILED;
167
168 if (card->csd.mmca_vsn < CSD_SPEC_VER_4)
169 return MMC_ERR_NONE;
170
171 /*
172 * As the ext_csd is so large and mostly unused, we don't store the
173 * raw block in mmc_card.
174 */
175 ext_csd = kmalloc(512, GFP_KERNEL);
176 if (!ext_csd) {
177 printk(KERN_ERR "%s: could not allocate a buffer to "
178 "receive the ext_csd. mmc v4 cards will be "
179 "treated as v3.\n", mmc_hostname(card->host));
180 return MMC_ERR_FAILED;
181 }
182
183 err = mmc_send_ext_csd(card, ext_csd);
184 if (err != MMC_ERR_NONE) {
185 /*
186 * High capacity cards should have this "magic" size
187 * stored in their CSD.
188 */
189 if (card->csd.capacity == (4096 * 512)) {
190 printk(KERN_ERR "%s: unable to read EXT_CSD "
191 "on a possible high capacity card. "
192 "Card will be ignored.\n",
193 mmc_hostname(card->host));
194 } else {
195 printk(KERN_WARNING "%s: unable to read "
196 "EXT_CSD, performance might "
197 "suffer.\n",
198 mmc_hostname(card->host));
199 err = MMC_ERR_NONE;
200 }
201 goto out;
202 }
203
204 card->ext_csd.sectors =
205 ext_csd[EXT_CSD_SEC_CNT + 0] << 0 |
206 ext_csd[EXT_CSD_SEC_CNT + 1] << 8 |
207 ext_csd[EXT_CSD_SEC_CNT + 2] << 16 |
208 ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
209 if (card->ext_csd.sectors)
210 mmc_card_set_blockaddr(card);
211
212 switch (ext_csd[EXT_CSD_CARD_TYPE]) {
213 case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26:
214 card->ext_csd.hs_max_dtr = 52000000;
215 break;
216 case EXT_CSD_CARD_TYPE_26:
217 card->ext_csd.hs_max_dtr = 26000000;
218 break;
219 default:
220 /* MMC v4 spec says this cannot happen */
221 printk(KERN_WARNING "%s: card is mmc v4 but doesn't "
222 "support any high-speed modes.\n",
223 mmc_hostname(card->host));
224 goto out;
225 }
226
227out:
228 kfree(ext_csd);
229
230 return err;
231}
232
233/*
234 * Handle the detection and initialisation of a card.
235 *
236 * In the case of a resume, "curcard" will contain the card
237 * we're trying to reinitialise.
238 */
239static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
240 struct mmc_card *oldcard)
241{
242 struct mmc_card *card;
243 int err;
244 u32 cid[4];
245 unsigned int max_dtr;
246
247 BUG_ON(!host);
248 BUG_ON(!host->claimed);
249
250 /*
251 * Since we're changing the OCR value, we seem to
252 * need to tell some cards to go back to the idle
253 * state. We wait 1ms to give cards time to
254 * respond.
255 */
256 mmc_go_idle(host);
257
258 /* The extra bit indicates that we support high capacity */
259 err = mmc_send_op_cond(host, ocr | (1 << 30), NULL);
260 if (err != MMC_ERR_NONE)
261 goto err;
262
263 /*
264 * Fetch CID from card.
265 */
266 err = mmc_all_send_cid(host, cid);
267 if (err != MMC_ERR_NONE)
268 goto err;
269
270 if (oldcard) {
271 if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0)
272 goto err;
273
274 card = oldcard;
275 } else {
276 /*
277 * Allocate card structure.
278 */
279 card = mmc_alloc_card(host);
280 if (IS_ERR(card))
281 goto err;
282
283 card->type = MMC_TYPE_MMC;
284 card->rca = 1;
285 memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
286 }
287
288 /*
289 * Set card RCA.
290 */
291 err = mmc_set_relative_addr(card);
292 if (err != MMC_ERR_NONE)
293 goto free_card;
294
295 mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
296
297 if (!oldcard) {
298 /*
299 * Fetch CSD from card.
300 */
301 err = mmc_send_csd(card, card->raw_csd);
302 if (err != MMC_ERR_NONE)
303 goto free_card;
304
305 err = mmc_decode_csd(card);
306 if (err < 0)
307 goto free_card;
308 err = mmc_decode_cid(card);
309 if (err < 0)
310 goto free_card;
311 }
312
313 /*
314 * Select card, as all following commands rely on that.
315 */
316 err = mmc_select_card(card);
317 if (err != MMC_ERR_NONE)
318 goto free_card;
319
320 if (!oldcard) {
321 /*
322 * Fetch and process extened CSD.
323 */
324 err = mmc_read_ext_csd(card);
325 if (err != MMC_ERR_NONE)
326 goto free_card;
327 }
328
329 /*
330 * Activate high speed (if supported)
331 */
332 if ((card->ext_csd.hs_max_dtr != 0) &&
333 (host->caps & MMC_CAP_MMC_HIGHSPEED)) {
334 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
335 EXT_CSD_HS_TIMING, 1);
336 if (err != MMC_ERR_NONE)
337 goto free_card;
338
339 mmc_card_set_highspeed(card);
340
341 mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
342 }
343
344 /*
345 * Compute bus speed.
346 */
347 max_dtr = (unsigned int)-1;
348
349 if (mmc_card_highspeed(card)) {
350 if (max_dtr > card->ext_csd.hs_max_dtr)
351 max_dtr = card->ext_csd.hs_max_dtr;
352 } else if (max_dtr > card->csd.max_dtr) {
353 max_dtr = card->csd.max_dtr;
354 }
355
356 mmc_set_clock(host, max_dtr);
357
358 /*
359 * Activate wide bus (if supported).
360 */
361 if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) &&
362 (host->caps & MMC_CAP_4_BIT_DATA)) {
363 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
364 EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
365 if (err != MMC_ERR_NONE)
366 goto free_card;
367
368 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
369 }
370
371 if (!oldcard)
372 host->card = card;
373
374 return MMC_ERR_NONE;
375
376free_card:
377 if (!oldcard)
378 mmc_remove_card(card);
379err:
380
381 return MMC_ERR_FAILED;
382}
383
384/*
385 * Host is being removed. Free up the current card.
386 */
387static void mmc_remove(struct mmc_host *host)
388{
389 BUG_ON(!host);
390 BUG_ON(!host->card);
391
392 mmc_remove_card(host->card);
393 host->card = NULL;
394}
395
396/*
397 * Card detection callback from host.
398 */
399static void mmc_detect(struct mmc_host *host)
400{
401 int err;
402
403 BUG_ON(!host);
404 BUG_ON(!host->card);
405
406 mmc_claim_host(host);
407
408 /*
409 * Just check if our card has been removed.
410 */
411 err = mmc_send_status(host->card, NULL);
412
413 mmc_release_host(host);
414
415 if (err != MMC_ERR_NONE) {
416 mmc_remove_card(host->card);
417 host->card = NULL;
418
419 mmc_claim_host(host);
420 mmc_detach_bus(host);
421 mmc_release_host(host);
422 }
423}
424
425#ifdef CONFIG_MMC_UNSAFE_RESUME
426
427/*
428 * Suspend callback from host.
429 */
430static void mmc_suspend(struct mmc_host *host)
431{
432 BUG_ON(!host);
433 BUG_ON(!host->card);
434
435 mmc_claim_host(host);
436 mmc_deselect_cards(host);
437 host->card->state &= ~MMC_STATE_HIGHSPEED;
438 mmc_release_host(host);
439}
440
441/*
442 * Resume callback from host.
443 *
444 * This function tries to determine if the same card is still present
445 * and, if so, restore all state to it.
446 */
447static void mmc_resume(struct mmc_host *host)
448{
449 int err;
450
451 BUG_ON(!host);
452 BUG_ON(!host->card);
453
454 mmc_claim_host(host);
455
456 err = mmc_sd_init_card(host, host->ocr, host->card);
457 if (err != MMC_ERR_NONE) {
458 mmc_remove_card(host->card);
459 host->card = NULL;
460
461 mmc_detach_bus(host);
462 }
463
464 mmc_release_host(host);
465}
466
467#else
468
469#define mmc_suspend NULL
470#define mmc_resume NULL
471
472#endif
473
474static const struct mmc_bus_ops mmc_ops = {
475 .remove = mmc_remove,
476 .detect = mmc_detect,
477 .suspend = mmc_suspend,
478 .resume = mmc_resume,
479};
480
481/*
482 * Starting point for MMC card init.
483 */
484int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
485{
486 int err;
487
488 BUG_ON(!host);
489 BUG_ON(!host->claimed);
490
491 mmc_attach_bus(host, &mmc_ops);
492
493 /*
494 * Sanity check the voltages that the card claims to
495 * support.
496 */
497 if (ocr & 0x7F) {
498 printk(KERN_WARNING "%s: card claims to support voltages "
499 "below the defined range. These will be ignored.\n",
500 mmc_hostname(host));
501 ocr &= ~0x7F;
502 }
503
504 host->ocr = mmc_select_voltage(host, ocr);
505
506 /*
507 * Can we support the voltage of the card?
508 */
509 if (!host->ocr)
510 goto err;
511
512 /*
513 * Detect and init the card.
514 */
515 err = mmc_sd_init_card(host, host->ocr, NULL);
516 if (err != MMC_ERR_NONE)
517 goto err;
518
519 mmc_release_host(host);
520
521 err = mmc_register_card(host->card);
522 if (err)
523 goto reclaim_host;
524
525 return 0;
526
527reclaim_host:
528 mmc_claim_host(host);
529 mmc_remove_card(host->card);
530 host->card = NULL;
531err:
532 mmc_detach_bus(host);
533 mmc_release_host(host);
534
535 return 0;
536}
537
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
new file mode 100644
index 000000000000..7dd720fa5895
--- /dev/null
+++ b/drivers/mmc/core/mmc_ops.c
@@ -0,0 +1,276 @@
1/*
2 * linux/drivers/mmc/mmc_ops.h
3 *
4 * Copyright 2006-2007 Pierre Ossman
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 (at
9 * your option) any later version.
10 */
11
12#include <linux/types.h>
13#include <asm/scatterlist.h>
14#include <linux/scatterlist.h>
15
16#include <linux/mmc/host.h>
17#include <linux/mmc/card.h>
18#include <linux/mmc/mmc.h>
19
20#include "core.h"
21#include "mmc_ops.h"
22
23static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
24{
25 int err;
26 struct mmc_command cmd;
27
28 BUG_ON(!host);
29
30 memset(&cmd, 0, sizeof(struct mmc_command));
31
32 cmd.opcode = MMC_SELECT_CARD;
33
34 if (card) {
35 cmd.arg = card->rca << 16;
36 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
37 } else {
38 cmd.arg = 0;
39 cmd.flags = MMC_RSP_NONE | MMC_CMD_AC;
40 }
41
42 err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
43 if (err != MMC_ERR_NONE)
44 return err;
45
46 return MMC_ERR_NONE;
47}
48
49int mmc_select_card(struct mmc_card *card)
50{
51 BUG_ON(!card);
52
53 return _mmc_select_card(card->host, card);
54}
55
56int mmc_deselect_cards(struct mmc_host *host)
57{
58 return _mmc_select_card(host, NULL);
59}
60
61int mmc_go_idle(struct mmc_host *host)
62{
63 int err;
64 struct mmc_command cmd;
65
66 mmc_set_chip_select(host, MMC_CS_HIGH);
67
68 mmc_delay(1);
69
70 memset(&cmd, 0, sizeof(struct mmc_command));
71
72 cmd.opcode = MMC_GO_IDLE_STATE;
73 cmd.arg = 0;
74 cmd.flags = MMC_RSP_NONE | MMC_CMD_BC;
75
76 err = mmc_wait_for_cmd(host, &cmd, 0);
77
78 mmc_delay(1);
79
80 mmc_set_chip_select(host, MMC_CS_DONTCARE);
81
82 mmc_delay(1);
83
84 return err;
85}
86
87int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
88{
89 struct mmc_command cmd;
90 int i, err = 0;
91
92 BUG_ON(!host);
93
94 memset(&cmd, 0, sizeof(struct mmc_command));
95
96 cmd.opcode = MMC_SEND_OP_COND;
97 cmd.arg = ocr;
98 cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
99
100 for (i = 100; i; i--) {
101 err = mmc_wait_for_cmd(host, &cmd, 0);
102 if (err != MMC_ERR_NONE)
103 break;
104
105 if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0)
106 break;
107
108 err = MMC_ERR_TIMEOUT;
109
110 mmc_delay(10);
111 }
112
113 if (rocr)
114 *rocr = cmd.resp[0];
115
116 return err;
117}
118
119int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
120{
121 int err;
122 struct mmc_command cmd;
123
124 BUG_ON(!host);
125 BUG_ON(!cid);
126
127 memset(&cmd, 0, sizeof(struct mmc_command));
128
129 cmd.opcode = MMC_ALL_SEND_CID;
130 cmd.arg = 0;
131 cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
132
133 err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
134 if (err != MMC_ERR_NONE)
135 return err;
136
137 memcpy(cid, cmd.resp, sizeof(u32) * 4);
138
139 return MMC_ERR_NONE;
140}
141
142int mmc_set_relative_addr(struct mmc_card *card)
143{
144 int err;
145 struct mmc_command cmd;
146
147 BUG_ON(!card);
148 BUG_ON(!card->host);
149
150 memset(&cmd, 0, sizeof(struct mmc_command));
151
152 cmd.opcode = MMC_SET_RELATIVE_ADDR;
153 cmd.arg = card->rca << 16;
154 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
155
156 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
157 if (err != MMC_ERR_NONE)
158 return err;
159
160 return MMC_ERR_NONE;
161}
162
163int mmc_send_csd(struct mmc_card *card, u32 *csd)
164{
165 int err;
166 struct mmc_command cmd;
167
168 BUG_ON(!card);
169 BUG_ON(!card->host);
170 BUG_ON(!csd);
171
172 memset(&cmd, 0, sizeof(struct mmc_command));
173
174 cmd.opcode = MMC_SEND_CSD;
175 cmd.arg = card->rca << 16;
176 cmd.flags = MMC_RSP_R2 | MMC_CMD_AC;
177
178 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
179 if (err != MMC_ERR_NONE)
180 return err;
181
182 memcpy(csd, cmd.resp, sizeof(u32) * 4);
183
184 return MMC_ERR_NONE;
185}
186
187int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd)
188{
189 struct mmc_request mrq;
190 struct mmc_command cmd;
191 struct mmc_data data;
192 struct scatterlist sg;
193
194 BUG_ON(!card);
195 BUG_ON(!card->host);
196 BUG_ON(!ext_csd);
197
198 memset(&mrq, 0, sizeof(struct mmc_request));
199 memset(&cmd, 0, sizeof(struct mmc_command));
200 memset(&data, 0, sizeof(struct mmc_data));
201
202 mrq.cmd = &cmd;
203 mrq.data = &data;
204
205 cmd.opcode = MMC_SEND_EXT_CSD;
206 cmd.arg = 0;
207 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
208
209 data.blksz = 512;
210 data.blocks = 1;
211 data.flags = MMC_DATA_READ;
212 data.sg = &sg;
213 data.sg_len = 1;
214
215 sg_init_one(&sg, ext_csd, 512);
216
217 mmc_set_data_timeout(&data, card, 0);
218
219 mmc_wait_for_req(card->host, &mrq);
220
221 if (cmd.error != MMC_ERR_NONE)
222 return cmd.error;
223 if (data.error != MMC_ERR_NONE)
224 return data.error;
225
226 return MMC_ERR_NONE;
227}
228
229int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
230{
231 int err;
232 struct mmc_command cmd;
233
234 BUG_ON(!card);
235 BUG_ON(!card->host);
236
237 memset(&cmd, 0, sizeof(struct mmc_command));
238
239 cmd.opcode = MMC_SWITCH;
240 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
241 (index << 16) |
242 (value << 8) |
243 set;
244 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
245
246 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
247 if (err != MMC_ERR_NONE)
248 return err;
249
250 return MMC_ERR_NONE;
251}
252
253int mmc_send_status(struct mmc_card *card, u32 *status)
254{
255 int err;
256 struct mmc_command cmd;
257
258 BUG_ON(!card);
259 BUG_ON(!card->host);
260
261 memset(&cmd, 0, sizeof(struct mmc_command));
262
263 cmd.opcode = MMC_SEND_STATUS;
264 cmd.arg = card->rca << 16;
265 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
266
267 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
268 if (err != MMC_ERR_NONE)
269 return err;
270
271 if (status)
272 *status = cmd.resp[0];
273
274 return MMC_ERR_NONE;
275}
276
diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h
new file mode 100644
index 000000000000..7a481e8ca5ea
--- /dev/null
+++ b/drivers/mmc/core/mmc_ops.h
@@ -0,0 +1,27 @@
1/*
2 * linux/drivers/mmc/mmc_ops.h
3 *
4 * Copyright 2006-2007 Pierre Ossman
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 (at
9 * your option) any later version.
10 */
11
12#ifndef _MMC_MMC_OPS_H
13#define _MMC_MMC_OPS_H
14
15int mmc_select_card(struct mmc_card *card);
16int mmc_deselect_cards(struct mmc_host *host);
17int mmc_go_idle(struct mmc_host *host);
18int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
19int mmc_all_send_cid(struct mmc_host *host, u32 *cid);
20int mmc_set_relative_addr(struct mmc_card *card);
21int mmc_send_csd(struct mmc_card *card, u32 *csd);
22int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd);
23int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value);
24int mmc_send_status(struct mmc_card *card, u32 *status);
25
26#endif
27
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
new file mode 100644
index 000000000000..c1dfd03d559a
--- /dev/null
+++ b/drivers/mmc/core/sd.c
@@ -0,0 +1,587 @@
1/*
2 * linux/drivers/mmc/sd.c
3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
6 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
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#include <linux/err.h>
14
15#include <linux/mmc/host.h>
16#include <linux/mmc/card.h>
17#include <linux/mmc/mmc.h>
18
19#include "core.h"
20#include "sysfs.h"
21#include "mmc_ops.h"
22#include "sd_ops.h"
23
24#include "core.h"
25
26static const unsigned int tran_exp[] = {
27 10000, 100000, 1000000, 10000000,
28 0, 0, 0, 0
29};
30
31static const unsigned char tran_mant[] = {
32 0, 10, 12, 13, 15, 20, 25, 30,
33 35, 40, 45, 50, 55, 60, 70, 80,
34};
35
36static const unsigned int tacc_exp[] = {
37 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000,
38};
39
40static const unsigned int tacc_mant[] = {
41 0, 10, 12, 13, 15, 20, 25, 30,
42 35, 40, 45, 50, 55, 60, 70, 80,
43};
44
45#define UNSTUFF_BITS(resp,start,size) \
46 ({ \
47 const int __size = size; \
48 const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \
49 const int __off = 3 - ((start) / 32); \
50 const int __shft = (start) & 31; \
51 u32 __res; \
52 \
53 __res = resp[__off] >> __shft; \
54 if (__size + __shft > 32) \
55 __res |= resp[__off-1] << ((32 - __shft) % 32); \
56 __res & __mask; \
57 })
58
59/*
60 * Given the decoded CSD structure, decode the raw CID to our CID structure.
61 */
62static void mmc_decode_cid(struct mmc_card *card)
63{
64 u32 *resp = card->raw_cid;
65
66 memset(&card->cid, 0, sizeof(struct mmc_cid));
67
68 /*
69 * SD doesn't currently have a version field so we will
70 * have to assume we can parse this.
71 */
72 card->cid.manfid = UNSTUFF_BITS(resp, 120, 8);
73 card->cid.oemid = UNSTUFF_BITS(resp, 104, 16);
74 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8);
75 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8);
76 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8);
77 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8);
78 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8);
79 card->cid.hwrev = UNSTUFF_BITS(resp, 60, 4);
80 card->cid.fwrev = UNSTUFF_BITS(resp, 56, 4);
81 card->cid.serial = UNSTUFF_BITS(resp, 24, 32);
82 card->cid.year = UNSTUFF_BITS(resp, 12, 8);
83 card->cid.month = UNSTUFF_BITS(resp, 8, 4);
84
85 card->cid.year += 2000; /* SD cards year offset */
86}
87
88/*
89 * Given a 128-bit response, decode to our card CSD structure.
90 */
91static int mmc_decode_csd(struct mmc_card *card)
92{
93 struct mmc_csd *csd = &card->csd;
94 unsigned int e, m, csd_struct;
95 u32 *resp = card->raw_csd;
96
97 csd_struct = UNSTUFF_BITS(resp, 126, 2);
98
99 switch (csd_struct) {
100 case 0:
101 m = UNSTUFF_BITS(resp, 115, 4);
102 e = UNSTUFF_BITS(resp, 112, 3);
103 csd->tacc_ns = (tacc_exp[e] * tacc_mant[m] + 9) / 10;
104 csd->tacc_clks = UNSTUFF_BITS(resp, 104, 8) * 100;
105
106 m = UNSTUFF_BITS(resp, 99, 4);
107 e = UNSTUFF_BITS(resp, 96, 3);
108 csd->max_dtr = tran_exp[e] * tran_mant[m];
109 csd->cmdclass = UNSTUFF_BITS(resp, 84, 12);
110
111 e = UNSTUFF_BITS(resp, 47, 3);
112 m = UNSTUFF_BITS(resp, 62, 12);
113 csd->capacity = (1 + m) << (e + 2);
114
115 csd->read_blkbits = UNSTUFF_BITS(resp, 80, 4);
116 csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
117 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
118 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
119 csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
120 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
121 csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
122 break;
123 case 1:
124 /*
125 * This is a block-addressed SDHC card. Most
126 * interesting fields are unused and have fixed
127 * values. To avoid getting tripped by buggy cards,
128 * we assume those fixed values ourselves.
129 */
130 mmc_card_set_blockaddr(card);
131
132 csd->tacc_ns = 0; /* Unused */
133 csd->tacc_clks = 0; /* Unused */
134
135 m = UNSTUFF_BITS(resp, 99, 4);
136 e = UNSTUFF_BITS(resp, 96, 3);
137 csd->max_dtr = tran_exp[e] * tran_mant[m];
138 csd->cmdclass = UNSTUFF_BITS(resp, 84, 12);
139
140 m = UNSTUFF_BITS(resp, 48, 22);
141 csd->capacity = (1 + m) << 10;
142
143 csd->read_blkbits = 9;
144 csd->read_partial = 0;
145 csd->write_misalign = 0;
146 csd->read_misalign = 0;
147 csd->r2w_factor = 4; /* Unused */
148 csd->write_blkbits = 9;
149 csd->write_partial = 0;
150 break;
151 default:
152 printk("%s: unrecognised CSD structure version %d\n",
153 mmc_hostname(card->host), csd_struct);
154 return -EINVAL;
155 }
156
157 return 0;
158}
159
160/*
161 * Given a 64-bit response, decode to our card SCR structure.
162 */
163static int mmc_decode_scr(struct mmc_card *card)
164{
165 struct sd_scr *scr = &card->scr;
166 unsigned int scr_struct;
167 u32 resp[4];
168
169 BUG_ON(!mmc_card_sd(card));
170
171 resp[3] = card->raw_scr[1];
172 resp[2] = card->raw_scr[0];
173
174 scr_struct = UNSTUFF_BITS(resp, 60, 4);
175 if (scr_struct != 0) {
176 printk("%s: unrecognised SCR structure version %d\n",
177 mmc_hostname(card->host), scr_struct);
178 return -EINVAL;
179 }
180
181 scr->sda_vsn = UNSTUFF_BITS(resp, 56, 4);
182 scr->bus_widths = UNSTUFF_BITS(resp, 48, 4);
183
184 return 0;
185}
186
187/*
188 * Fetches and decodes switch information
189 */
190static int mmc_read_switch(struct mmc_card *card)
191{
192 int err;
193 u8 *status;
194
195 err = MMC_ERR_FAILED;
196
197 status = kmalloc(64, GFP_KERNEL);
198 if (!status) {
199 printk("%s: could not allocate a buffer for switch "
200 "capabilities.\n",
201 mmc_hostname(card->host));
202 return err;
203 }
204
205 err = mmc_sd_switch(card, 0, 0, 1, status);
206 if (err != MMC_ERR_NONE) {
207 /*
208 * Card not supporting high-speed will ignore the
209 * command.
210 */
211 err = MMC_ERR_NONE;
212 goto out;
213 }
214
215 if (status[13] & 0x02)
216 card->sw_caps.hs_max_dtr = 50000000;
217
218out:
219 kfree(status);
220
221 return err;
222}
223
224/*
225 * Test if the card supports high-speed mode and, if so, switch to it.
226 */
227static int mmc_switch_hs(struct mmc_card *card)
228{
229 int err;
230 u8 *status;
231
232 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
233 return MMC_ERR_NONE;
234
235 if (card->sw_caps.hs_max_dtr == 0)
236 return MMC_ERR_NONE;
237
238 err = MMC_ERR_FAILED;
239
240 status = kmalloc(64, GFP_KERNEL);
241 if (!status) {
242 printk("%s: could not allocate a buffer for switch "
243 "capabilities.\n",
244 mmc_hostname(card->host));
245 return err;
246 }
247
248 err = mmc_sd_switch(card, 1, 0, 1, status);
249 if (err != MMC_ERR_NONE)
250 goto out;
251
252 if ((status[16] & 0xF) != 1) {
253 printk(KERN_WARNING "%s: Problem switching card "
254 "into high-speed mode!\n",
255 mmc_hostname(card->host));
256 } else {
257 mmc_card_set_highspeed(card);
258 mmc_set_timing(card->host, MMC_TIMING_SD_HS);
259 }
260
261out:
262 kfree(status);
263
264 return err;
265}
266
267/*
268 * Handle the detection and initialisation of a card.
269 *
270 * In the case of a resume, "curcard" will contain the card
271 * we're trying to reinitialise.
272 */
273static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
274 struct mmc_card *oldcard)
275{
276 struct mmc_card *card;
277 int err;
278 u32 cid[4];
279 unsigned int max_dtr;
280
281 BUG_ON(!host);
282 BUG_ON(!host->claimed);
283
284 /*
285 * Since we're changing the OCR value, we seem to
286 * need to tell some cards to go back to the idle
287 * state. We wait 1ms to give cards time to
288 * respond.
289 */
290 mmc_go_idle(host);
291
292 /*
293 * If SD_SEND_IF_COND indicates an SD 2.0
294 * compliant card and we should set bit 30
295 * of the ocr to indicate that we can handle
296 * block-addressed SDHC cards.
297 */
298 err = mmc_send_if_cond(host, ocr);
299 if (err == MMC_ERR_NONE)
300 ocr |= 1 << 30;
301
302 err = mmc_send_app_op_cond(host, ocr, NULL);
303 if (err != MMC_ERR_NONE)
304 goto err;
305
306 /*
307 * Fetch CID from card.
308 */
309 err = mmc_all_send_cid(host, cid);
310 if (err != MMC_ERR_NONE)
311 goto err;
312
313 if (oldcard) {
314 if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0)
315 goto err;
316
317 card = oldcard;
318 } else {
319 /*
320 * Allocate card structure.
321 */
322 card = mmc_alloc_card(host);
323 if (IS_ERR(card))
324 goto err;
325
326 card->type = MMC_TYPE_SD;
327 memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
328 }
329
330 /*
331 * Set card RCA.
332 */
333 err = mmc_send_relative_addr(host, &card->rca);
334 if (err != MMC_ERR_NONE)
335 goto free_card;
336
337 mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
338
339 if (!oldcard) {
340 /*
341 * Fetch CSD from card.
342 */
343 err = mmc_send_csd(card, card->raw_csd);
344 if (err != MMC_ERR_NONE)
345 goto free_card;
346
347 err = mmc_decode_csd(card);
348 if (err < 0)
349 goto free_card;
350
351 mmc_decode_cid(card);
352 }
353
354 /*
355 * Select card, as all following commands rely on that.
356 */
357 err = mmc_select_card(card);
358 if (err != MMC_ERR_NONE)
359 goto free_card;
360
361 if (!oldcard) {
362 /*
363 * Fetch SCR from card.
364 */
365 err = mmc_app_send_scr(card, card->raw_scr);
366 if (err != MMC_ERR_NONE)
367 goto free_card;
368
369 err = mmc_decode_scr(card);
370 if (err < 0)
371 goto free_card;
372
373 /*
374 * Fetch switch information from card.
375 */
376 err = mmc_read_switch(card);
377 if (err != MMC_ERR_NONE)
378 goto free_card;
379 }
380
381 /*
382 * Attempt to change to high-speed (if supported)
383 */
384 err = mmc_switch_hs(card);
385 if (err != MMC_ERR_NONE)
386 goto free_card;
387
388 /*
389 * Compute bus speed.
390 */
391 max_dtr = (unsigned int)-1;
392
393 if (mmc_card_highspeed(card)) {
394 if (max_dtr > card->sw_caps.hs_max_dtr)
395 max_dtr = card->sw_caps.hs_max_dtr;
396 } else if (max_dtr > card->csd.max_dtr) {
397 max_dtr = card->csd.max_dtr;
398 }
399
400 mmc_set_clock(host, max_dtr);
401
402 /*
403 * Switch to wider bus (if supported).
404 */
405 if ((host->caps && MMC_CAP_4_BIT_DATA) &&
406 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
407 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4);
408 if (err != MMC_ERR_NONE)
409 goto free_card;
410
411 mmc_set_bus_width(host, MMC_BUS_WIDTH_4);
412 }
413
414 if (!oldcard)
415 host->card = card;
416
417 return MMC_ERR_NONE;
418
419free_card:
420 if (!oldcard)
421 mmc_remove_card(card);
422err:
423
424 return MMC_ERR_FAILED;
425}
426
427/*
428 * Host is being removed. Free up the current card.
429 */
430static void mmc_sd_remove(struct mmc_host *host)
431{
432 BUG_ON(!host);
433 BUG_ON(!host->card);
434
435 mmc_remove_card(host->card);
436 host->card = NULL;
437}
438
439/*
440 * Card detection callback from host.
441 */
442static void mmc_sd_detect(struct mmc_host *host)
443{
444 int err;
445
446 BUG_ON(!host);
447 BUG_ON(!host->card);
448
449 mmc_claim_host(host);
450
451 /*
452 * Just check if our card has been removed.
453 */
454 err = mmc_send_status(host->card, NULL);
455
456 mmc_release_host(host);
457
458 if (err != MMC_ERR_NONE) {
459 mmc_remove_card(host->card);
460 host->card = NULL;
461
462 mmc_claim_host(host);
463 mmc_detach_bus(host);
464 mmc_release_host(host);
465 }
466}
467
468#ifdef CONFIG_MMC_UNSAFE_RESUME
469
470/*
471 * Suspend callback from host.
472 */
473static void mmc_sd_suspend(struct mmc_host *host)
474{
475 BUG_ON(!host);
476 BUG_ON(!host->card);
477
478 mmc_claim_host(host);
479 mmc_deselect_cards(host);
480 host->card->state &= ~MMC_STATE_HIGHSPEED;
481 mmc_release_host(host);
482}
483
484/*
485 * Resume callback from host.
486 *
487 * This function tries to determine if the same card is still present
488 * and, if so, restore all state to it.
489 */
490static void mmc_sd_resume(struct mmc_host *host)
491{
492 int err;
493
494 BUG_ON(!host);
495 BUG_ON(!host->card);
496
497 mmc_claim_host(host);
498
499 err = mmc_sd_init_card(host, host->ocr, host->card);
500 if (err != MMC_ERR_NONE) {
501 mmc_remove_card(host->card);
502 host->card = NULL;
503
504 mmc_detach_bus(host);
505 }
506
507 mmc_release_host(host);
508}
509
510#else
511
512#define mmc_sd_suspend NULL
513#define mmc_sd_resume NULL
514
515#endif
516
517static const struct mmc_bus_ops mmc_sd_ops = {
518 .remove = mmc_sd_remove,
519 .detect = mmc_sd_detect,
520 .suspend = mmc_sd_suspend,
521 .resume = mmc_sd_resume,
522};
523
524/*
525 * Starting point for SD card init.
526 */
527int mmc_attach_sd(struct mmc_host *host, u32 ocr)
528{
529 int err;
530
531 BUG_ON(!host);
532 BUG_ON(!host->claimed);
533
534 mmc_attach_bus(host, &mmc_sd_ops);
535
536 /*
537 * Sanity check the voltages that the card claims to
538 * support.
539 */
540 if (ocr & 0x7F) {
541 printk(KERN_WARNING "%s: card claims to support voltages "
542 "below the defined range. These will be ignored.\n",
543 mmc_hostname(host));
544 ocr &= ~0x7F;
545 }
546
547 if (ocr & MMC_VDD_165_195) {
548 printk(KERN_WARNING "%s: SD card claims to support the "
549 "incompletely defined 'low voltage range'. This "
550 "will be ignored.\n", mmc_hostname(host));
551 ocr &= ~MMC_VDD_165_195;
552 }
553
554 host->ocr = mmc_select_voltage(host, ocr);
555
556 /*
557 * Can we support the voltage(s) of the card(s)?
558 */
559 if (!host->ocr)
560 goto err;
561
562 /*
563 * Detect and init the card.
564 */
565 err = mmc_sd_init_card(host, host->ocr, NULL);
566 if (err != MMC_ERR_NONE)
567 goto err;
568
569 mmc_release_host(host);
570
571 err = mmc_register_card(host->card);
572 if (err)
573 goto reclaim_host;
574
575 return 0;
576
577reclaim_host:
578 mmc_claim_host(host);
579 mmc_remove_card(host->card);
580 host->card = NULL;
581err:
582 mmc_detach_bus(host);
583 mmc_release_host(host);
584
585 return 0;
586}
587
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
new file mode 100644
index 000000000000..9697ce581101
--- /dev/null
+++ b/drivers/mmc/core/sd_ops.c
@@ -0,0 +1,316 @@
1/*
2 * linux/drivers/mmc/sd_ops.h
3 *
4 * Copyright 2006-2007 Pierre Ossman
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 (at
9 * your option) any later version.
10 */
11
12#include <linux/types.h>
13#include <asm/scatterlist.h>
14#include <linux/scatterlist.h>
15
16#include <linux/mmc/host.h>
17#include <linux/mmc/card.h>
18#include <linux/mmc/mmc.h>
19#include <linux/mmc/sd.h>
20
21#include "core.h"
22#include "sd_ops.h"
23
24/**
25 * mmc_wait_for_app_cmd - start an application command and wait for
26 completion
27 * @host: MMC host to start command
28 * @rca: RCA to send MMC_APP_CMD to
29 * @cmd: MMC command to start
30 * @retries: maximum number of retries
31 *
32 * Sends a MMC_APP_CMD, checks the card response, sends the command
33 * in the parameter and waits for it to complete. Return any error
34 * that occurred while the command was executing. Do not attempt to
35 * parse the response.
36 */
37int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card,
38 struct mmc_command *cmd, int retries)
39{
40 struct mmc_request mrq;
41
42 int i, err;
43
44 BUG_ON(!cmd);
45 BUG_ON(retries < 0);
46
47 err = MMC_ERR_INVALID;
48
49 /*
50 * We have to resend MMC_APP_CMD for each attempt so
51 * we cannot use the retries field in mmc_command.
52 */
53 for (i = 0;i <= retries;i++) {
54 memset(&mrq, 0, sizeof(struct mmc_request));
55
56 err = mmc_app_cmd(host, card);
57 if (err != MMC_ERR_NONE)
58 continue;
59
60 memset(&mrq, 0, sizeof(struct mmc_request));
61
62 memset(cmd->resp, 0, sizeof(cmd->resp));
63 cmd->retries = 0;
64
65 mrq.cmd = cmd;
66 cmd->data = NULL;
67
68 mmc_wait_for_req(host, &mrq);
69
70 err = cmd->error;
71 if (cmd->error == MMC_ERR_NONE)
72 break;
73 }
74
75 return err;
76}
77
78EXPORT_SYMBOL(mmc_wait_for_app_cmd);
79
80int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
81{
82 int err;
83 struct mmc_command cmd;
84
85 BUG_ON(!host);
86 BUG_ON(card && (card->host != host));
87
88 cmd.opcode = MMC_APP_CMD;
89
90 if (card) {
91 cmd.arg = card->rca << 16;
92 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
93 } else {
94 cmd.arg = 0;
95 cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR;
96 }
97
98 err = mmc_wait_for_cmd(host, &cmd, 0);
99 if (err != MMC_ERR_NONE)
100 return err;
101
102 /* Check that card supported application commands */
103 if (!(cmd.resp[0] & R1_APP_CMD))
104 return MMC_ERR_FAILED;
105
106 return MMC_ERR_NONE;
107}
108
109int mmc_app_set_bus_width(struct mmc_card *card, int width)
110{
111 int err;
112 struct mmc_command cmd;
113
114 BUG_ON(!card);
115 BUG_ON(!card->host);
116
117 memset(&cmd, 0, sizeof(struct mmc_command));
118
119 cmd.opcode = SD_APP_SET_BUS_WIDTH;
120 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
121
122 switch (width) {
123 case MMC_BUS_WIDTH_1:
124 cmd.arg = SD_BUS_WIDTH_1;
125 break;
126 case MMC_BUS_WIDTH_4:
127 cmd.arg = SD_BUS_WIDTH_4;
128 break;
129 default:
130 return MMC_ERR_INVALID;
131 }
132
133 err = mmc_wait_for_app_cmd(card->host, card, &cmd, MMC_CMD_RETRIES);
134 if (err != MMC_ERR_NONE)
135 return err;
136
137 return MMC_ERR_NONE;
138}
139
140int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
141{
142 struct mmc_command cmd;
143 int i, err = 0;
144
145 BUG_ON(!host);
146
147 memset(&cmd, 0, sizeof(struct mmc_command));
148
149 cmd.opcode = SD_APP_OP_COND;
150 cmd.arg = ocr;
151 cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
152
153 for (i = 100; i; i--) {
154 err = mmc_wait_for_app_cmd(host, NULL, &cmd, MMC_CMD_RETRIES);
155 if (err != MMC_ERR_NONE)
156 break;
157
158 if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0)
159 break;
160
161 err = MMC_ERR_TIMEOUT;
162
163 mmc_delay(10);
164 }
165
166 if (rocr)
167 *rocr = cmd.resp[0];
168
169 return err;
170}
171
172int mmc_send_if_cond(struct mmc_host *host, u32 ocr)
173{
174 struct mmc_command cmd;
175 int err;
176 static const u8 test_pattern = 0xAA;
177
178 /*
179 * To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND
180 * before SD_APP_OP_COND. This command will harmlessly fail for
181 * SD 1.0 cards.
182 */
183 cmd.opcode = SD_SEND_IF_COND;
184 cmd.arg = ((ocr & 0xFF8000) != 0) << 8 | test_pattern;
185 cmd.flags = MMC_RSP_R7 | MMC_CMD_BCR;
186
187 err = mmc_wait_for_cmd(host, &cmd, 0);
188 if (err != MMC_ERR_NONE)
189 return err;
190
191 if ((cmd.resp[0] & 0xFF) != test_pattern)
192 return MMC_ERR_FAILED;
193
194 return MMC_ERR_NONE;
195}
196
197int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca)
198{
199 int err;
200 struct mmc_command cmd;
201
202 BUG_ON(!host);
203 BUG_ON(!rca);
204
205 memset(&cmd, 0, sizeof(struct mmc_command));
206
207 cmd.opcode = SD_SEND_RELATIVE_ADDR;
208 cmd.arg = 0;
209 cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
210
211 err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
212 if (err != MMC_ERR_NONE)
213 return err;
214
215 *rca = cmd.resp[0] >> 16;
216
217 return MMC_ERR_NONE;
218}
219
220int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
221{
222 int err;
223 struct mmc_request mrq;
224 struct mmc_command cmd;
225 struct mmc_data data;
226 struct scatterlist sg;
227
228 BUG_ON(!card);
229 BUG_ON(!card->host);
230 BUG_ON(!scr);
231
232 err = mmc_app_cmd(card->host, card);
233 if (err != MMC_ERR_NONE)
234 return err;
235
236 memset(&mrq, 0, sizeof(struct mmc_request));
237 memset(&cmd, 0, sizeof(struct mmc_command));
238 memset(&data, 0, sizeof(struct mmc_data));
239
240 mrq.cmd = &cmd;
241 mrq.data = &data;
242
243 cmd.opcode = SD_APP_SEND_SCR;
244 cmd.arg = 0;
245 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
246
247 data.blksz = 8;
248 data.blocks = 1;
249 data.flags = MMC_DATA_READ;
250 data.sg = &sg;
251 data.sg_len = 1;
252
253 sg_init_one(&sg, scr, 8);
254
255 mmc_set_data_timeout(&data, card, 0);
256
257 mmc_wait_for_req(card->host, &mrq);
258
259 if (cmd.error != MMC_ERR_NONE)
260 return cmd.error;
261 if (data.error != MMC_ERR_NONE)
262 return data.error;
263
264 scr[0] = ntohl(scr[0]);
265 scr[1] = ntohl(scr[1]);
266
267 return MMC_ERR_NONE;
268}
269
270int mmc_sd_switch(struct mmc_card *card, int mode, int group,
271 u8 value, u8 *resp)
272{
273 struct mmc_request mrq;
274 struct mmc_command cmd;
275 struct mmc_data data;
276 struct scatterlist sg;
277
278 BUG_ON(!card);
279 BUG_ON(!card->host);
280
281 mode = !!mode;
282 value &= 0xF;
283
284 memset(&mrq, 0, sizeof(struct mmc_request));
285 memset(&cmd, 0, sizeof(struct mmc_command));
286 memset(&data, 0, sizeof(struct mmc_data));
287
288 mrq.cmd = &cmd;
289 mrq.data = &data;
290
291 cmd.opcode = SD_SWITCH;
292 cmd.arg = mode << 31 | 0x00FFFFFF;
293 cmd.arg &= ~(0xF << (group * 4));
294 cmd.arg |= value << (group * 4);
295 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
296
297 data.blksz = 64;
298 data.blocks = 1;
299 data.flags = MMC_DATA_READ;
300 data.sg = &sg;
301 data.sg_len = 1;
302
303 sg_init_one(&sg, resp, 64);
304
305 mmc_set_data_timeout(&data, card, 0);
306
307 mmc_wait_for_req(card->host, &mrq);
308
309 if (cmd.error != MMC_ERR_NONE)
310 return cmd.error;
311 if (data.error != MMC_ERR_NONE)
312 return data.error;
313
314 return MMC_ERR_NONE;
315}
316
diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h
new file mode 100644
index 000000000000..1240fddba5e3
--- /dev/null
+++ b/drivers/mmc/core/sd_ops.h
@@ -0,0 +1,25 @@
1/*
2 * linux/drivers/mmc/sd_ops.h
3 *
4 * Copyright 2006-2007 Pierre Ossman
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 (at
9 * your option) any later version.
10 */
11
12#ifndef _MMC_SD_OPS_H
13#define _MMC_SD_OPS_H
14
15int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card);
16int mmc_app_set_bus_width(struct mmc_card *card, int width);
17int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
18int mmc_send_if_cond(struct mmc_host *host, u32 ocr);
19int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca);
20int mmc_app_send_scr(struct mmc_card *card, u32 *scr);
21int mmc_sd_switch(struct mmc_card *card, int mode, int group,
22 u8 value, u8 *resp);
23
24#endif
25
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/core/sysfs.c
index e0e82d849d5f..843b1fbba557 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/core/sysfs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/mmc_sysfs.c 2 * linux/drivers/mmc/core/sysfs.c
3 * 3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved. 4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * 5 *
@@ -18,7 +18,7 @@
18#include <linux/mmc/card.h> 18#include <linux/mmc/card.h>
19#include <linux/mmc/host.h> 19#include <linux/mmc/host.h>
20 20
21#include "mmc.h" 21#include "sysfs.h"
22 22
23#define dev_to_mmc_card(d) container_of(d, struct mmc_card, dev) 23#define dev_to_mmc_card(d) container_of(d, struct mmc_card, dev)
24#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) 24#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv)
@@ -72,12 +72,11 @@ static void mmc_release_card(struct device *dev)
72/* 72/*
73 * This currently matches any MMC driver to any MMC card - drivers 73 * This currently matches any MMC driver to any MMC card - drivers
74 * themselves make the decision whether to drive this card in their 74 * themselves make the decision whether to drive this card in their
75 * probe method. However, we force "bad" cards to fail. 75 * probe method.
76 */ 76 */
77static int mmc_bus_match(struct device *dev, struct device_driver *drv) 77static int mmc_bus_match(struct device *dev, struct device_driver *drv)
78{ 78{
79 struct mmc_card *card = dev_to_mmc_card(dev); 79 return 1;
80 return !mmc_card_bad(card);
81} 80}
82 81
83static int 82static int
@@ -217,6 +216,8 @@ int mmc_register_card(struct mmc_card *card)
217 device_del(&card->dev); 216 device_del(&card->dev);
218 } 217 }
219 } 218 }
219 if (ret == 0)
220 mmc_card_set_present(card);
220 return ret; 221 return ret;
221} 222}
222 223
diff --git a/drivers/mmc/mmc.h b/drivers/mmc/core/sysfs.h
index 149affe0b686..80e29b358282 100644
--- a/drivers/mmc/mmc.h
+++ b/drivers/mmc/core/sysfs.h
@@ -1,15 +1,16 @@
1/* 1/*
2 * linux/drivers/mmc/mmc.h 2 * linux/drivers/mmc/core/sysfs.h
3 * 3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved. 4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * Copyright 2007 Pierre Ossman
5 * 6 *
6 * 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
7 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
9 */ 10 */
10#ifndef _MMC_H 11#ifndef _MMC_CORE_SYSFS_H
11#define _MMC_H 12#define _MMC_CORE_SYSFS_H
12/* core-internal functions */ 13
13void mmc_init_card(struct mmc_card *card, struct mmc_host *host); 14void mmc_init_card(struct mmc_card *card, struct mmc_host *host);
14int mmc_register_card(struct mmc_card *card); 15int mmc_register_card(struct mmc_card *card);
15void mmc_remove_card(struct mmc_card *card); 16void mmc_remove_card(struct mmc_card *card);
@@ -22,4 +23,5 @@ void mmc_free_host_sysfs(struct mmc_host *host);
22int mmc_schedule_work(struct work_struct *work); 23int mmc_schedule_work(struct work_struct *work);
23int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay); 24int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay);
24void mmc_flush_scheduled_work(void); 25void mmc_flush_scheduled_work(void);
26
25#endif 27#endif
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
new file mode 100644
index 000000000000..ed4deab2203d
--- /dev/null
+++ b/drivers/mmc/host/Kconfig
@@ -0,0 +1,103 @@
1#
2# MMC/SD host controller drivers
3#
4
5comment "MMC/SD Host Controller Drivers"
6 depends on MMC
7
8config MMC_ARMMMCI
9 tristate "ARM AMBA Multimedia Card Interface support"
10 depends on ARM_AMBA && MMC
11 help
12 This selects the ARM(R) AMBA(R) PrimeCell Multimedia Card
13 Interface (PL180 and PL181) support. If you have an ARM(R)
14 platform with a Multimedia Card slot, say Y or M here.
15
16 If unsure, say N.
17
18config MMC_PXA
19 tristate "Intel PXA25x/26x/27x Multimedia Card Interface support"
20 depends on ARCH_PXA && MMC
21 help
22 This selects the Intel(R) PXA(R) Multimedia card Interface.
23 If you have a PXA(R) platform with a Multimedia Card slot,
24 say Y or M here.
25
26 If unsure, say N.
27
28config MMC_SDHCI
29 tristate "Secure Digital Host Controller Interface support (EXPERIMENTAL)"
30 depends on PCI && MMC && EXPERIMENTAL
31 help
32 This select the generic Secure Digital Host Controller Interface.
33 It is used by manufacturers such as Texas Instruments(R), Ricoh(R)
34 and Toshiba(R). Most controllers found in laptops are of this type.
35 If you have a controller with this interface, say Y or M here.
36
37 If unsure, say N.
38
39config MMC_OMAP
40 tristate "TI OMAP Multimedia Card Interface support"
41 depends on ARCH_OMAP && MMC
42 select TPS65010 if MACH_OMAP_H2
43 help
44 This selects the TI OMAP Multimedia card Interface.
45 If you have an OMAP board with a Multimedia Card slot,
46 say Y or M here.
47
48 If unsure, say N.
49
50config MMC_WBSD
51 tristate "Winbond W83L51xD SD/MMC Card Interface support"
52 depends on MMC && ISA_DMA_API
53 help
54 This selects the Winbond(R) W83L51xD Secure digital and
55 Multimedia card Interface.
56 If you have a machine with a integrated W83L518D or W83L519D
57 SD/MMC card reader, say Y or M here.
58
59 If unsure, say N.
60
61config MMC_AU1X
62 tristate "Alchemy AU1XX0 MMC Card Interface support"
63 depends on MMC && SOC_AU1200
64 help
65 This selects the AMD Alchemy(R) Multimedia card interface.
66 If you have a Alchemy platform with a MMC slot, say Y or M here.
67
68 If unsure, say N.
69
70config MMC_AT91
71 tristate "AT91 SD/MMC Card Interface support"
72 depends on ARCH_AT91 && MMC
73 help
74 This selects the AT91 MCI controller.
75
76 If unsure, say N.
77
78config MMC_IMX
79 tristate "Motorola i.MX Multimedia Card Interface support"
80 depends on ARCH_IMX && MMC
81 help
82 This selects the Motorola i.MX Multimedia card Interface.
83 If you have a i.MX platform with a Multimedia Card slot,
84 say Y or M here.
85
86 If unsure, say N.
87
88config MMC_TIFM_SD
89 tristate "TI Flash Media MMC/SD Interface support (EXPERIMENTAL)"
90 depends on MMC && EXPERIMENTAL && PCI
91 select TIFM_CORE
92 help
93 Say Y here if you want to be able to access MMC/SD cards with
94 the Texas Instruments(R) Flash Media card reader, found in many
95 laptops.
96 This option 'selects' (turns on, enables) 'TIFM_CORE', but you
97 probably also need appropriate card reader host adapter, such as
98 'Misc devices: TI Flash Media PCI74xx/PCI76xx host adapter support
99 (TIFM_7XX1)'.
100
101 To compile this driver as a module, choose M here: the
102 module will be called tifm_sd.
103
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
new file mode 100644
index 000000000000..6685f64345b4
--- /dev/null
+++ b/drivers/mmc/host/Makefile
@@ -0,0 +1,18 @@
1#
2# Makefile for MMC/SD host controller drivers
3#
4
5ifeq ($(CONFIG_MMC_DEBUG),y)
6 EXTRA_CFLAGS += -DDEBUG
7endif
8
9obj-$(CONFIG_MMC_ARMMMCI) += mmci.o
10obj-$(CONFIG_MMC_PXA) += pxamci.o
11obj-$(CONFIG_MMC_IMX) += imxmmc.o
12obj-$(CONFIG_MMC_SDHCI) += sdhci.o
13obj-$(CONFIG_MMC_WBSD) += wbsd.o
14obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
15obj-$(CONFIG_MMC_OMAP) += omap.o
16obj-$(CONFIG_MMC_AT91) += at91_mci.o
17obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
18
diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/host/at91_mci.c
index 459f4b4feded..e37943c314cb 100644
--- a/drivers/mmc/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -67,7 +67,6 @@
67#include <linux/atmel_pdc.h> 67#include <linux/atmel_pdc.h>
68 68
69#include <linux/mmc/host.h> 69#include <linux/mmc/host.h>
70#include <linux/mmc/protocol.h>
71 70
72#include <asm/io.h> 71#include <asm/io.h>
73#include <asm/irq.h> 72#include <asm/irq.h>
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index b834be261ab7..b7156a4555b5 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -42,7 +42,6 @@
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43 43
44#include <linux/mmc/host.h> 44#include <linux/mmc/host.h>
45#include <linux/mmc/protocol.h>
46#include <asm/io.h> 45#include <asm/io.h>
47#include <asm/mach-au1x00/au1000.h> 46#include <asm/mach-au1x00/au1000.h>
48#include <asm/mach-au1x00/au1xxx_dbdma.h> 47#include <asm/mach-au1x00/au1xxx_dbdma.h>
diff --git a/drivers/mmc/au1xmmc.h b/drivers/mmc/host/au1xmmc.h
index 341cbdf0baca..341cbdf0baca 100644
--- a/drivers/mmc/au1xmmc.h
+++ b/drivers/mmc/host/au1xmmc.h
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/host/imxmmc.c
index 0de5c9e94e74..7ee2045acbef 100644
--- a/drivers/mmc/imxmmc.c
+++ b/drivers/mmc/host/imxmmc.c
@@ -41,7 +41,6 @@
41#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
42#include <linux/mmc/host.h> 42#include <linux/mmc/host.h>
43#include <linux/mmc/card.h> 43#include <linux/mmc/card.h>
44#include <linux/mmc/protocol.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
46 45
47#include <asm/dma.h> 46#include <asm/dma.h>
diff --git a/drivers/mmc/imxmmc.h b/drivers/mmc/host/imxmmc.h
index e5339e334dbb..e5339e334dbb 100644
--- a/drivers/mmc/imxmmc.h
+++ b/drivers/mmc/host/imxmmc.h
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/host/mmci.c
index 5941dd951e82..d11c2d23ceea 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -17,7 +17,6 @@
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19#include <linux/mmc/host.h> 19#include <linux/mmc/host.h>
20#include <linux/mmc/protocol.h>
21#include <linux/amba/bus.h> 20#include <linux/amba/bus.h>
22#include <linux/clk.h> 21#include <linux/clk.h>
23 22
diff --git a/drivers/mmc/mmci.h b/drivers/mmc/host/mmci.h
index 6d7eadc9a678..6d7eadc9a678 100644
--- a/drivers/mmc/mmci.h
+++ b/drivers/mmc/host/mmci.h
diff --git a/drivers/mmc/omap.c b/drivers/mmc/host/omap.c
index 1e96a2f65022..1914e65d4db1 100644
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -22,7 +22,6 @@
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/timer.h> 23#include <linux/timer.h>
24#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
25#include <linux/mmc/protocol.h>
26#include <linux/mmc/card.h> 25#include <linux/mmc/card.h>
27#include <linux/clk.h> 26#include <linux/clk.h>
28 27
@@ -605,7 +604,7 @@ static void mmc_omap_switch_handler(struct work_struct *work)
605 } 604 }
606 if (mmc_omap_cover_is_open(host)) { 605 if (mmc_omap_cover_is_open(host)) {
607 if (!complained) { 606 if (!complained) {
608 dev_info(mmc_dev(host->mmc), "cover is open"); 607 dev_info(mmc_dev(host->mmc), "cover is open\n");
609 complained = 1; 608 complained = 1;
610 } 609 }
611 if (mmc_omap_enable_poll) 610 if (mmc_omap_enable_poll)
@@ -937,48 +936,55 @@ static void mmc_omap_power(struct mmc_omap_host *host, int on)
937 } 936 }
938} 937}
939 938
940static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 939static int mmc_omap_calc_divisor(struct mmc_host *mmc, struct mmc_ios *ios)
941{ 940{
942 struct mmc_omap_host *host = mmc_priv(mmc); 941 struct mmc_omap_host *host = mmc_priv(mmc);
942 int func_clk_rate = clk_get_rate(host->fclk);
943 int dsor; 943 int dsor;
944 int realclock, i;
945
946 realclock = ios->clock;
947 944
948 if (ios->clock == 0) 945 if (ios->clock == 0)
949 dsor = 0; 946 return 0;
950 else {
951 int func_clk_rate = clk_get_rate(host->fclk);
952
953 dsor = func_clk_rate / realclock;
954 if (dsor < 1)
955 dsor = 1;
956 947
957 if (func_clk_rate / dsor > realclock) 948 dsor = func_clk_rate / ios->clock;
958 dsor++; 949 if (dsor < 1)
950 dsor = 1;
959 951
960 if (dsor > 250) 952 if (func_clk_rate / dsor > ios->clock)
961 dsor = 250;
962 dsor++; 953 dsor++;
963 954
964 if (ios->bus_width == MMC_BUS_WIDTH_4) 955 if (dsor > 250)
965 dsor |= 1 << 15; 956 dsor = 250;
966 } 957 dsor++;
958
959 if (ios->bus_width == MMC_BUS_WIDTH_4)
960 dsor |= 1 << 15;
961
962 return dsor;
963}
964
965static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
966{
967 struct mmc_omap_host *host = mmc_priv(mmc);
968 int dsor;
969 int i;
970
971 dsor = mmc_omap_calc_divisor(mmc, ios);
972 host->bus_mode = ios->bus_mode;
973 host->hw_bus_mode = host->bus_mode;
967 974
968 switch (ios->power_mode) { 975 switch (ios->power_mode) {
969 case MMC_POWER_OFF: 976 case MMC_POWER_OFF:
970 mmc_omap_power(host, 0); 977 mmc_omap_power(host, 0);
971 break; 978 break;
972 case MMC_POWER_UP: 979 case MMC_POWER_UP:
973 case MMC_POWER_ON: 980 /* Cannot touch dsor yet, just power up MMC */
974 mmc_omap_power(host, 1); 981 mmc_omap_power(host, 1);
982 return;
983 case MMC_POWER_ON:
975 dsor |= 1 << 11; 984 dsor |= 1 << 11;
976 break; 985 break;
977 } 986 }
978 987
979 host->bus_mode = ios->bus_mode;
980 host->hw_bus_mode = host->bus_mode;
981
982 clk_enable(host->fclk); 988 clk_enable(host->fclk);
983 989
984 /* On insanely high arm_per frequencies something sometimes 990 /* On insanely high arm_per frequencies something sometimes
@@ -987,7 +993,7 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
987 * Writing to the CON register twice seems to do the trick. */ 993 * Writing to the CON register twice seems to do the trick. */
988 for (i = 0; i < 2; i++) 994 for (i = 0; i < 2; i++)
989 OMAP_MMC_WRITE(host, CON, dsor); 995 OMAP_MMC_WRITE(host, CON, dsor);
990 if (ios->power_mode == MMC_POWER_UP) { 996 if (ios->power_mode == MMC_POWER_ON) {
991 /* Send clock cycles, poll completion */ 997 /* Send clock cycles, poll completion */
992 OMAP_MMC_WRITE(host, IE, 0); 998 OMAP_MMC_WRITE(host, IE, 0);
993 OMAP_MMC_WRITE(host, STAT, 0xffff); 999 OMAP_MMC_WRITE(host, STAT, 0xffff);
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/host/pxamci.c
index 9774fc68b61a..a98ff98fa567 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -24,7 +24,6 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/mmc/host.h> 26#include <linux/mmc/host.h>
27#include <linux/mmc/protocol.h>
28 27
29#include <asm/dma.h> 28#include <asm/dma.h>
30#include <asm/io.h> 29#include <asm/io.h>
diff --git a/drivers/mmc/pxamci.h b/drivers/mmc/host/pxamci.h
index 1b163220df2b..1b163220df2b 100644
--- a/drivers/mmc/pxamci.h
+++ b/drivers/mmc/host/pxamci.h
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/host/sdhci.c
index d749f08601b8..ff5bf73cdd25 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/drivers/mmc/sdhci.c - Secure Digital Host Controller Interface driver 2 * linux/drivers/mmc/sdhci.c - Secure Digital Host Controller Interface driver
3 * 3 *
4 * Copyright (C) 2005-2006 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -15,7 +15,6 @@
15#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
16 16
17#include <linux/mmc/host.h> 17#include <linux/mmc/host.h>
18#include <linux/mmc/protocol.h>
19 18
20#include <asm/scatterlist.h> 19#include <asm/scatterlist.h>
21 20
@@ -247,14 +246,13 @@ static void sdhci_read_block_pio(struct sdhci_host *host)
247 chunk_remain = min(blksize, 4); 246 chunk_remain = min(blksize, 4);
248 } 247 }
249 248
250 size = min(host->size, host->remain); 249 size = min(host->remain, chunk_remain);
251 size = min(size, chunk_remain);
252 250
253 chunk_remain -= size; 251 chunk_remain -= size;
254 blksize -= size; 252 blksize -= size;
255 host->offset += size; 253 host->offset += size;
256 host->remain -= size; 254 host->remain -= size;
257 host->size -= size; 255
258 while (size) { 256 while (size) {
259 *buffer = data & 0xFF; 257 *buffer = data & 0xFF;
260 buffer++; 258 buffer++;
@@ -289,14 +287,13 @@ static void sdhci_write_block_pio(struct sdhci_host *host)
289 buffer = sdhci_sg_to_buffer(host) + host->offset; 287 buffer = sdhci_sg_to_buffer(host) + host->offset;
290 288
291 while (blksize) { 289 while (blksize) {
292 size = min(host->size, host->remain); 290 size = min(host->remain, chunk_remain);
293 size = min(size, chunk_remain);
294 291
295 chunk_remain -= size; 292 chunk_remain -= size;
296 blksize -= size; 293 blksize -= size;
297 host->offset += size; 294 host->offset += size;
298 host->remain -= size; 295 host->remain -= size;
299 host->size -= size; 296
300 while (size) { 297 while (size) {
301 data >>= 8; 298 data >>= 8;
302 data |= (u32)*buffer << 24; 299 data |= (u32)*buffer << 24;
@@ -325,7 +322,7 @@ static void sdhci_transfer_pio(struct sdhci_host *host)
325 322
326 BUG_ON(!host->data); 323 BUG_ON(!host->data);
327 324
328 if (host->size == 0) 325 if (host->num_sg == 0)
329 return; 326 return;
330 327
331 if (host->data->flags & MMC_DATA_READ) 328 if (host->data->flags & MMC_DATA_READ)
@@ -339,10 +336,8 @@ static void sdhci_transfer_pio(struct sdhci_host *host)
339 else 336 else
340 sdhci_write_block_pio(host); 337 sdhci_write_block_pio(host);
341 338
342 if (host->size == 0) 339 if (host->num_sg == 0)
343 break; 340 break;
344
345 BUG_ON(host->num_sg == 0);
346 } 341 }
347 342
348 DBG("PIO transfer complete.\n"); 343 DBG("PIO transfer complete.\n");
@@ -408,8 +403,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
408 403
409 writel(sg_dma_address(data->sg), host->ioaddr + SDHCI_DMA_ADDRESS); 404 writel(sg_dma_address(data->sg), host->ioaddr + SDHCI_DMA_ADDRESS);
410 } else { 405 } else {
411 host->size = data->blksz * data->blocks;
412
413 host->cur_sg = data->sg; 406 host->cur_sg = data->sg;
414 host->num_sg = data->sg_len; 407 host->num_sg = data->sg_len;
415 408
@@ -473,10 +466,6 @@ static void sdhci_finish_data(struct sdhci_host *host)
473 "though there were blocks left.\n", 466 "though there were blocks left.\n",
474 mmc_hostname(host->mmc)); 467 mmc_hostname(host->mmc));
475 data->error = MMC_ERR_FAILED; 468 data->error = MMC_ERR_FAILED;
476 } else if (host->size != 0) {
477 printk(KERN_ERR "%s: %d bytes were left untransferred.\n",
478 mmc_hostname(host->mmc), host->size);
479 data->error = MMC_ERR_FAILED;
480 } 469 }
481 470
482 DBG("Ending data transfer (%d bytes)\n", data->bytes_xfered); 471 DBG("Ending data transfer (%d bytes)\n", data->bytes_xfered);
@@ -669,20 +658,16 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
669 658
670 pwr = SDHCI_POWER_ON; 659 pwr = SDHCI_POWER_ON;
671 660
672 switch (power) { 661 switch (1 << power) {
673 case MMC_VDD_170: 662 case MMC_VDD_165_195:
674 case MMC_VDD_180:
675 case MMC_VDD_190:
676 pwr |= SDHCI_POWER_180; 663 pwr |= SDHCI_POWER_180;
677 break; 664 break;
678 case MMC_VDD_290: 665 case MMC_VDD_29_30:
679 case MMC_VDD_300: 666 case MMC_VDD_30_31:
680 case MMC_VDD_310:
681 pwr |= SDHCI_POWER_300; 667 pwr |= SDHCI_POWER_300;
682 break; 668 break;
683 case MMC_VDD_320: 669 case MMC_VDD_32_33:
684 case MMC_VDD_330: 670 case MMC_VDD_33_34:
685 case MMC_VDD_340:
686 pwr |= SDHCI_POWER_330; 671 pwr |= SDHCI_POWER_330;
687 break; 672 break;
688 default: 673 default:
@@ -1294,7 +1279,7 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1294 if (caps & SDHCI_CAN_VDD_300) 1279 if (caps & SDHCI_CAN_VDD_300)
1295 mmc->ocr_avail |= MMC_VDD_29_30|MMC_VDD_30_31; 1280 mmc->ocr_avail |= MMC_VDD_29_30|MMC_VDD_30_31;
1296 if (caps & SDHCI_CAN_VDD_180) 1281 if (caps & SDHCI_CAN_VDD_180)
1297 mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19; 1282 mmc->ocr_avail |= MMC_VDD_165_195;
1298 1283
1299 if (mmc->ocr_avail == 0) { 1284 if (mmc->ocr_avail == 0) {
1300 printk(KERN_ERR "%s: Hardware doesn't report any " 1285 printk(KERN_ERR "%s: Hardware doesn't report any "
diff --git a/drivers/mmc/sdhci.h b/drivers/mmc/host/sdhci.h
index e324f0a623dc..7400f4bc114f 100644
--- a/drivers/mmc/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/drivers/mmc/sdhci.h - Secure Digital Host Controller Interface driver 2 * linux/drivers/mmc/sdhci.h - Secure Digital Host Controller Interface driver
3 * 3 *
4 * Copyright (C) 2005 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -187,8 +187,6 @@ struct sdhci_host {
187 int offset; /* Offset into current sg */ 187 int offset; /* Offset into current sg */
188 int remain; /* Bytes left in current */ 188 int remain; /* Bytes left in current */
189 189
190 int size; /* Remaining bytes in transfer */
191
192 char slot_descr[20]; /* Name for reservations */ 190 char slot_descr[20]; /* Name for reservations */
193 191
194 int irq; /* Device IRQ */ 192 int irq; /* Device IRQ */
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
new file mode 100644
index 000000000000..7511f961c67b
--- /dev/null
+++ b/drivers/mmc/host/tifm_sd.c
@@ -0,0 +1,1102 @@
1/*
2 * tifm_sd.c - TI FlashMedia driver
3 *
4 * Copyright (C) 2006 Alex Dubov <oakad@yahoo.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Special thanks to Brad Campbell for extensive testing of this driver.
11 *
12 */
13
14
15#include <linux/tifm.h>
16#include <linux/mmc/host.h>
17#include <linux/highmem.h>
18#include <linux/scatterlist.h>
19#include <asm/io.h>
20
21#define DRIVER_NAME "tifm_sd"
22#define DRIVER_VERSION "0.8"
23
24static int no_dma = 0;
25static int fixed_timeout = 0;
26module_param(no_dma, bool, 0644);
27module_param(fixed_timeout, bool, 0644);
28
29/* Constants here are mostly from OMAP5912 datasheet */
30#define TIFM_MMCSD_RESET 0x0002
31#define TIFM_MMCSD_CLKMASK 0x03ff
32#define TIFM_MMCSD_POWER 0x0800
33#define TIFM_MMCSD_4BBUS 0x8000
34#define TIFM_MMCSD_RXDE 0x8000 /* rx dma enable */
35#define TIFM_MMCSD_TXDE 0x0080 /* tx dma enable */
36#define TIFM_MMCSD_BUFINT 0x0c00 /* set bits: AE, AF */
37#define TIFM_MMCSD_DPE 0x0020 /* data timeout counted in kilocycles */
38#define TIFM_MMCSD_INAB 0x0080 /* abort / initialize command */
39#define TIFM_MMCSD_READ 0x8000
40
41#define TIFM_MMCSD_ERRMASK 0x01e0 /* set bits: CCRC, CTO, DCRC, DTO */
42#define TIFM_MMCSD_EOC 0x0001 /* end of command phase */
43#define TIFM_MMCSD_CD 0x0002 /* card detect */
44#define TIFM_MMCSD_CB 0x0004 /* card enter busy state */
45#define TIFM_MMCSD_BRS 0x0008 /* block received/sent */
46#define TIFM_MMCSD_EOFB 0x0010 /* card exit busy state */
47#define TIFM_MMCSD_DTO 0x0020 /* data time-out */
48#define TIFM_MMCSD_DCRC 0x0040 /* data crc error */
49#define TIFM_MMCSD_CTO 0x0080 /* command time-out */
50#define TIFM_MMCSD_CCRC 0x0100 /* command crc error */
51#define TIFM_MMCSD_AF 0x0400 /* fifo almost full */
52#define TIFM_MMCSD_AE 0x0800 /* fifo almost empty */
53#define TIFM_MMCSD_OCRB 0x1000 /* OCR busy */
54#define TIFM_MMCSD_CIRQ 0x2000 /* card irq (cmd40/sdio) */
55#define TIFM_MMCSD_CERR 0x4000 /* card status error */
56
57#define TIFM_MMCSD_ODTO 0x0040 /* open drain / extended timeout */
58#define TIFM_MMCSD_CARD_RO 0x0200 /* card is read-only */
59
60#define TIFM_MMCSD_FIFO_SIZE 0x0020
61
62#define TIFM_MMCSD_RSP_R0 0x0000
63#define TIFM_MMCSD_RSP_R1 0x0100
64#define TIFM_MMCSD_RSP_R2 0x0200
65#define TIFM_MMCSD_RSP_R3 0x0300
66#define TIFM_MMCSD_RSP_R4 0x0400
67#define TIFM_MMCSD_RSP_R5 0x0500
68#define TIFM_MMCSD_RSP_R6 0x0600
69
70#define TIFM_MMCSD_RSP_BUSY 0x0800
71
72#define TIFM_MMCSD_CMD_BC 0x0000
73#define TIFM_MMCSD_CMD_BCR 0x1000
74#define TIFM_MMCSD_CMD_AC 0x2000
75#define TIFM_MMCSD_CMD_ADTC 0x3000
76
77#define TIFM_MMCSD_MAX_BLOCK_SIZE 0x0800UL
78
79enum {
80 CMD_READY = 0x0001,
81 FIFO_READY = 0x0002,
82 BRS_READY = 0x0004,
83 SCMD_ACTIVE = 0x0008,
84 SCMD_READY = 0x0010,
85 CARD_BUSY = 0x0020,
86 DATA_CARRY = 0x0040
87};
88
89struct tifm_sd {
90 struct tifm_dev *dev;
91
92 unsigned short eject:1,
93 open_drain:1,
94 no_dma:1;
95 unsigned short cmd_flags;
96
97 unsigned int clk_freq;
98 unsigned int clk_div;
99 unsigned long timeout_jiffies;
100
101 struct tasklet_struct finish_tasklet;
102 struct timer_list timer;
103 struct mmc_request *req;
104
105 int sg_len;
106 int sg_pos;
107 unsigned int block_pos;
108 struct scatterlist bounce_buf;
109 unsigned char bounce_buf_data[TIFM_MMCSD_MAX_BLOCK_SIZE];
110};
111
112/* for some reason, host won't respond correctly to readw/writew */
113static void tifm_sd_read_fifo(struct tifm_sd *host, struct page *pg,
114 unsigned int off, unsigned int cnt)
115{
116 struct tifm_dev *sock = host->dev;
117 unsigned char *buf;
118 unsigned int pos = 0, val;
119
120 buf = kmap_atomic(pg, KM_BIO_DST_IRQ) + off;
121 if (host->cmd_flags & DATA_CARRY) {
122 buf[pos++] = host->bounce_buf_data[0];
123 host->cmd_flags &= ~DATA_CARRY;
124 }
125
126 while (pos < cnt) {
127 val = readl(sock->addr + SOCK_MMCSD_DATA);
128 buf[pos++] = val & 0xff;
129 if (pos == cnt) {
130 host->bounce_buf_data[0] = (val >> 8) & 0xff;
131 host->cmd_flags |= DATA_CARRY;
132 break;
133 }
134 buf[pos++] = (val >> 8) & 0xff;
135 }
136 kunmap_atomic(buf - off, KM_BIO_DST_IRQ);
137}
138
139static void tifm_sd_write_fifo(struct tifm_sd *host, struct page *pg,
140 unsigned int off, unsigned int cnt)
141{
142 struct tifm_dev *sock = host->dev;
143 unsigned char *buf;
144 unsigned int pos = 0, val;
145
146 buf = kmap_atomic(pg, KM_BIO_SRC_IRQ) + off;
147 if (host->cmd_flags & DATA_CARRY) {
148 val = host->bounce_buf_data[0] | ((buf[pos++] << 8) & 0xff00);
149 writel(val, sock->addr + SOCK_MMCSD_DATA);
150 host->cmd_flags &= ~DATA_CARRY;
151 }
152
153 while (pos < cnt) {
154 val = buf[pos++];
155 if (pos == cnt) {
156 host->bounce_buf_data[0] = val & 0xff;
157 host->cmd_flags |= DATA_CARRY;
158 break;
159 }
160 val |= (buf[pos++] << 8) & 0xff00;
161 writel(val, sock->addr + SOCK_MMCSD_DATA);
162 }
163 kunmap_atomic(buf - off, KM_BIO_SRC_IRQ);
164}
165
166static void tifm_sd_transfer_data(struct tifm_sd *host)
167{
168 struct mmc_data *r_data = host->req->cmd->data;
169 struct scatterlist *sg = r_data->sg;
170 unsigned int off, cnt, t_size = TIFM_MMCSD_FIFO_SIZE * 2;
171 unsigned int p_off, p_cnt;
172 struct page *pg;
173
174 if (host->sg_pos == host->sg_len)
175 return;
176 while (t_size) {
177 cnt = sg[host->sg_pos].length - host->block_pos;
178 if (!cnt) {
179 host->block_pos = 0;
180 host->sg_pos++;
181 if (host->sg_pos == host->sg_len) {
182 if ((r_data->flags & MMC_DATA_WRITE)
183 && DATA_CARRY)
184 writel(host->bounce_buf_data[0],
185 host->dev->addr
186 + SOCK_MMCSD_DATA);
187
188 return;
189 }
190 cnt = sg[host->sg_pos].length;
191 }
192 off = sg[host->sg_pos].offset + host->block_pos;
193
194 pg = nth_page(sg[host->sg_pos].page, off >> PAGE_SHIFT);
195 p_off = offset_in_page(off);
196 p_cnt = PAGE_SIZE - p_off;
197 p_cnt = min(p_cnt, cnt);
198 p_cnt = min(p_cnt, t_size);
199
200 if (r_data->flags & MMC_DATA_READ)
201 tifm_sd_read_fifo(host, pg, p_off, p_cnt);
202 else if (r_data->flags & MMC_DATA_WRITE)
203 tifm_sd_write_fifo(host, pg, p_off, p_cnt);
204
205 t_size -= p_cnt;
206 host->block_pos += p_cnt;
207 }
208}
209
210static void tifm_sd_copy_page(struct page *dst, unsigned int dst_off,
211 struct page *src, unsigned int src_off,
212 unsigned int count)
213{
214 unsigned char *src_buf = kmap_atomic(src, KM_BIO_SRC_IRQ) + src_off;
215 unsigned char *dst_buf = kmap_atomic(dst, KM_BIO_DST_IRQ) + dst_off;
216
217 memcpy(dst_buf, src_buf, count);
218
219 kunmap_atomic(dst_buf - dst_off, KM_BIO_DST_IRQ);
220 kunmap_atomic(src_buf - src_off, KM_BIO_SRC_IRQ);
221}
222
223static void tifm_sd_bounce_block(struct tifm_sd *host, struct mmc_data *r_data)
224{
225 struct scatterlist *sg = r_data->sg;
226 unsigned int t_size = r_data->blksz;
227 unsigned int off, cnt;
228 unsigned int p_off, p_cnt;
229 struct page *pg;
230
231 dev_dbg(&host->dev->dev, "bouncing block\n");
232 while (t_size) {
233 cnt = sg[host->sg_pos].length - host->block_pos;
234 if (!cnt) {
235 host->block_pos = 0;
236 host->sg_pos++;
237 if (host->sg_pos == host->sg_len)
238 return;
239 cnt = sg[host->sg_pos].length;
240 }
241 off = sg[host->sg_pos].offset + host->block_pos;
242
243 pg = nth_page(sg[host->sg_pos].page, off >> PAGE_SHIFT);
244 p_off = offset_in_page(off);
245 p_cnt = PAGE_SIZE - p_off;
246 p_cnt = min(p_cnt, cnt);
247 p_cnt = min(p_cnt, t_size);
248
249 if (r_data->flags & MMC_DATA_WRITE)
250 tifm_sd_copy_page(host->bounce_buf.page,
251 r_data->blksz - t_size,
252 pg, p_off, p_cnt);
253 else if (r_data->flags & MMC_DATA_READ)
254 tifm_sd_copy_page(pg, p_off, host->bounce_buf.page,
255 r_data->blksz - t_size, p_cnt);
256
257 t_size -= p_cnt;
258 host->block_pos += p_cnt;
259 }
260}
261
262static int tifm_sd_set_dma_data(struct tifm_sd *host, struct mmc_data *r_data)
263{
264 struct tifm_dev *sock = host->dev;
265 unsigned int t_size = TIFM_DMA_TSIZE * r_data->blksz;
266 unsigned int dma_len, dma_blk_cnt, dma_off;
267 struct scatterlist *sg = NULL;
268 unsigned long flags;
269
270 if (host->sg_pos == host->sg_len)
271 return 1;
272
273 if (host->cmd_flags & DATA_CARRY) {
274 host->cmd_flags &= ~DATA_CARRY;
275 local_irq_save(flags);
276 tifm_sd_bounce_block(host, r_data);
277 local_irq_restore(flags);
278 if (host->sg_pos == host->sg_len)
279 return 1;
280 }
281
282 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]) - host->block_pos;
283 if (!dma_len) {
284 host->block_pos = 0;
285 host->sg_pos++;
286 if (host->sg_pos == host->sg_len)
287 return 1;
288 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]);
289 }
290
291 if (dma_len < t_size) {
292 dma_blk_cnt = dma_len / r_data->blksz;
293 dma_off = host->block_pos;
294 host->block_pos += dma_blk_cnt * r_data->blksz;
295 } else {
296 dma_blk_cnt = TIFM_DMA_TSIZE;
297 dma_off = host->block_pos;
298 host->block_pos += t_size;
299 }
300
301 if (dma_blk_cnt)
302 sg = &r_data->sg[host->sg_pos];
303 else if (dma_len) {
304 if (r_data->flags & MMC_DATA_WRITE) {
305 local_irq_save(flags);
306 tifm_sd_bounce_block(host, r_data);
307 local_irq_restore(flags);
308 } else
309 host->cmd_flags |= DATA_CARRY;
310
311 sg = &host->bounce_buf;
312 dma_off = 0;
313 dma_blk_cnt = 1;
314 } else
315 return 1;
316
317 dev_dbg(&sock->dev, "setting dma for %d blocks\n", dma_blk_cnt);
318 writel(sg_dma_address(sg) + dma_off, sock->addr + SOCK_DMA_ADDRESS);
319 if (r_data->flags & MMC_DATA_WRITE)
320 writel((dma_blk_cnt << 8) | TIFM_DMA_TX | TIFM_DMA_EN,
321 sock->addr + SOCK_DMA_CONTROL);
322 else
323 writel((dma_blk_cnt << 8) | TIFM_DMA_EN,
324 sock->addr + SOCK_DMA_CONTROL);
325
326 return 0;
327}
328
329static unsigned int tifm_sd_op_flags(struct mmc_command *cmd)
330{
331 unsigned int rc = 0;
332
333 switch (mmc_resp_type(cmd)) {
334 case MMC_RSP_NONE:
335 rc |= TIFM_MMCSD_RSP_R0;
336 break;
337 case MMC_RSP_R1B:
338 rc |= TIFM_MMCSD_RSP_BUSY; // deliberate fall-through
339 case MMC_RSP_R1:
340 rc |= TIFM_MMCSD_RSP_R1;
341 break;
342 case MMC_RSP_R2:
343 rc |= TIFM_MMCSD_RSP_R2;
344 break;
345 case MMC_RSP_R3:
346 rc |= TIFM_MMCSD_RSP_R3;
347 break;
348 default:
349 BUG();
350 }
351
352 switch (mmc_cmd_type(cmd)) {
353 case MMC_CMD_BC:
354 rc |= TIFM_MMCSD_CMD_BC;
355 break;
356 case MMC_CMD_BCR:
357 rc |= TIFM_MMCSD_CMD_BCR;
358 break;
359 case MMC_CMD_AC:
360 rc |= TIFM_MMCSD_CMD_AC;
361 break;
362 case MMC_CMD_ADTC:
363 rc |= TIFM_MMCSD_CMD_ADTC;
364 break;
365 default:
366 BUG();
367 }
368 return rc;
369}
370
371static void tifm_sd_exec(struct tifm_sd *host, struct mmc_command *cmd)
372{
373 struct tifm_dev *sock = host->dev;
374 unsigned int cmd_mask = tifm_sd_op_flags(cmd);
375
376 if (host->open_drain)
377 cmd_mask |= TIFM_MMCSD_ODTO;
378
379 if (cmd->data && (cmd->data->flags & MMC_DATA_READ))
380 cmd_mask |= TIFM_MMCSD_READ;
381
382 dev_dbg(&sock->dev, "executing opcode 0x%x, arg: 0x%x, mask: 0x%x\n",
383 cmd->opcode, cmd->arg, cmd_mask);
384
385 writel((cmd->arg >> 16) & 0xffff, sock->addr + SOCK_MMCSD_ARG_HIGH);
386 writel(cmd->arg & 0xffff, sock->addr + SOCK_MMCSD_ARG_LOW);
387 writel(cmd->opcode | cmd_mask, sock->addr + SOCK_MMCSD_COMMAND);
388}
389
390static void tifm_sd_fetch_resp(struct mmc_command *cmd, struct tifm_dev *sock)
391{
392 cmd->resp[0] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x1c) << 16)
393 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x18);
394 cmd->resp[1] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x14) << 16)
395 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x10);
396 cmd->resp[2] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x0c) << 16)
397 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x08);
398 cmd->resp[3] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x04) << 16)
399 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x00);
400}
401
402static void tifm_sd_check_status(struct tifm_sd *host)
403{
404 struct tifm_dev *sock = host->dev;
405 struct mmc_command *cmd = host->req->cmd;
406
407 if (cmd->error != MMC_ERR_NONE)
408 goto finish_request;
409
410 if (!(host->cmd_flags & CMD_READY))
411 return;
412
413 if (cmd->data) {
414 if (cmd->data->error != MMC_ERR_NONE) {
415 if ((host->cmd_flags & SCMD_ACTIVE)
416 && !(host->cmd_flags & SCMD_READY))
417 return;
418
419 goto finish_request;
420 }
421
422 if (!(host->cmd_flags & BRS_READY))
423 return;
424
425 if (!(host->no_dma || (host->cmd_flags & FIFO_READY)))
426 return;
427
428 if (cmd->data->flags & MMC_DATA_WRITE) {
429 if (host->req->stop) {
430 if (!(host->cmd_flags & SCMD_ACTIVE)) {
431 host->cmd_flags |= SCMD_ACTIVE;
432 writel(TIFM_MMCSD_EOFB
433 | readl(sock->addr
434 + SOCK_MMCSD_INT_ENABLE),
435 sock->addr
436 + SOCK_MMCSD_INT_ENABLE);
437 tifm_sd_exec(host, host->req->stop);
438 return;
439 } else {
440 if (!(host->cmd_flags & SCMD_READY)
441 || (host->cmd_flags & CARD_BUSY))
442 return;
443 writel((~TIFM_MMCSD_EOFB)
444 & readl(sock->addr
445 + SOCK_MMCSD_INT_ENABLE),
446 sock->addr
447 + SOCK_MMCSD_INT_ENABLE);
448 }
449 } else {
450 if (host->cmd_flags & CARD_BUSY)
451 return;
452 writel((~TIFM_MMCSD_EOFB)
453 & readl(sock->addr
454 + SOCK_MMCSD_INT_ENABLE),
455 sock->addr + SOCK_MMCSD_INT_ENABLE);
456 }
457 } else {
458 if (host->req->stop) {
459 if (!(host->cmd_flags & SCMD_ACTIVE)) {
460 host->cmd_flags |= SCMD_ACTIVE;
461 tifm_sd_exec(host, host->req->stop);
462 return;
463 } else {
464 if (!(host->cmd_flags & SCMD_READY))
465 return;
466 }
467 }
468 }
469 }
470finish_request:
471 tasklet_schedule(&host->finish_tasklet);
472}
473
474/* Called from interrupt handler */
475static void tifm_sd_data_event(struct tifm_dev *sock)
476{
477 struct tifm_sd *host;
478 unsigned int fifo_status = 0;
479 struct mmc_data *r_data = NULL;
480
481 spin_lock(&sock->lock);
482 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
483 fifo_status = readl(sock->addr + SOCK_DMA_FIFO_STATUS);
484 dev_dbg(&sock->dev, "data event: fifo_status %x, flags %x\n",
485 fifo_status, host->cmd_flags);
486
487 if (host->req) {
488 r_data = host->req->cmd->data;
489
490 if (r_data && (fifo_status & TIFM_FIFO_READY)) {
491 if (tifm_sd_set_dma_data(host, r_data)) {
492 host->cmd_flags |= FIFO_READY;
493 tifm_sd_check_status(host);
494 }
495 }
496 }
497
498 writel(fifo_status, sock->addr + SOCK_DMA_FIFO_STATUS);
499 spin_unlock(&sock->lock);
500}
501
502/* Called from interrupt handler */
503static void tifm_sd_card_event(struct tifm_dev *sock)
504{
505 struct tifm_sd *host;
506 unsigned int host_status = 0;
507 int cmd_error = MMC_ERR_NONE;
508 struct mmc_command *cmd = NULL;
509 unsigned long flags;
510
511 spin_lock(&sock->lock);
512 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
513 host_status = readl(sock->addr + SOCK_MMCSD_STATUS);
514 dev_dbg(&sock->dev, "host event: host_status %x, flags %x\n",
515 host_status, host->cmd_flags);
516
517 if (host->req) {
518 cmd = host->req->cmd;
519
520 if (host_status & TIFM_MMCSD_ERRMASK) {
521 writel(host_status & TIFM_MMCSD_ERRMASK,
522 sock->addr + SOCK_MMCSD_STATUS);
523 if (host_status & TIFM_MMCSD_CTO)
524 cmd_error = MMC_ERR_TIMEOUT;
525 else if (host_status & TIFM_MMCSD_CCRC)
526 cmd_error = MMC_ERR_BADCRC;
527
528 if (cmd->data) {
529 if (host_status & TIFM_MMCSD_DTO)
530 cmd->data->error = MMC_ERR_TIMEOUT;
531 else if (host_status & TIFM_MMCSD_DCRC)
532 cmd->data->error = MMC_ERR_BADCRC;
533 }
534
535 writel(TIFM_FIFO_INT_SETALL,
536 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
537 writel(TIFM_DMA_RESET, sock->addr + SOCK_DMA_CONTROL);
538
539 if (host->req->stop) {
540 if (host->cmd_flags & SCMD_ACTIVE) {
541 host->req->stop->error = cmd_error;
542 host->cmd_flags |= SCMD_READY;
543 } else {
544 cmd->error = cmd_error;
545 host->cmd_flags |= SCMD_ACTIVE;
546 tifm_sd_exec(host, host->req->stop);
547 goto done;
548 }
549 } else
550 cmd->error = cmd_error;
551 } else {
552 if (host_status & (TIFM_MMCSD_EOC | TIFM_MMCSD_CERR)) {
553 if (!(host->cmd_flags & CMD_READY)) {
554 host->cmd_flags |= CMD_READY;
555 tifm_sd_fetch_resp(cmd, sock);
556 } else if (host->cmd_flags & SCMD_ACTIVE) {
557 host->cmd_flags |= SCMD_READY;
558 tifm_sd_fetch_resp(host->req->stop,
559 sock);
560 }
561 }
562 if (host_status & TIFM_MMCSD_BRS)
563 host->cmd_flags |= BRS_READY;
564 }
565
566 if (host->no_dma && cmd->data) {
567 if (host_status & TIFM_MMCSD_AE)
568 writel(host_status & TIFM_MMCSD_AE,
569 sock->addr + SOCK_MMCSD_STATUS);
570
571 if (host_status & (TIFM_MMCSD_AE | TIFM_MMCSD_AF
572 | TIFM_MMCSD_BRS)) {
573 local_irq_save(flags);
574 tifm_sd_transfer_data(host);
575 local_irq_restore(flags);
576 host_status &= ~TIFM_MMCSD_AE;
577 }
578 }
579
580 if (host_status & TIFM_MMCSD_EOFB)
581 host->cmd_flags &= ~CARD_BUSY;
582 else if (host_status & TIFM_MMCSD_CB)
583 host->cmd_flags |= CARD_BUSY;
584
585 tifm_sd_check_status(host);
586 }
587done:
588 writel(host_status, sock->addr + SOCK_MMCSD_STATUS);
589 spin_unlock(&sock->lock);
590}
591
592static void tifm_sd_set_data_timeout(struct tifm_sd *host,
593 struct mmc_data *data)
594{
595 struct tifm_dev *sock = host->dev;
596 unsigned int data_timeout = data->timeout_clks;
597
598 if (fixed_timeout)
599 return;
600
601 data_timeout += data->timeout_ns /
602 ((1000000000UL / host->clk_freq) * host->clk_div);
603
604 if (data_timeout < 0xffff) {
605 writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
606 writel((~TIFM_MMCSD_DPE)
607 & readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
608 sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
609 } else {
610 data_timeout = (data_timeout >> 10) + 1;
611 if (data_timeout > 0xffff)
612 data_timeout = 0; /* set to unlimited */
613 writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
614 writel(TIFM_MMCSD_DPE
615 | readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
616 sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
617 }
618}
619
620static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
621{
622 struct tifm_sd *host = mmc_priv(mmc);
623 struct tifm_dev *sock = host->dev;
624 unsigned long flags;
625 struct mmc_data *r_data = mrq->cmd->data;
626
627 spin_lock_irqsave(&sock->lock, flags);
628 if (host->eject) {
629 spin_unlock_irqrestore(&sock->lock, flags);
630 goto err_out;
631 }
632
633 if (host->req) {
634 printk(KERN_ERR "%s : unfinished request detected\n",
635 sock->dev.bus_id);
636 spin_unlock_irqrestore(&sock->lock, flags);
637 goto err_out;
638 }
639
640 host->cmd_flags = 0;
641 host->block_pos = 0;
642 host->sg_pos = 0;
643
644 if (r_data) {
645 tifm_sd_set_data_timeout(host, r_data);
646
647 if ((r_data->flags & MMC_DATA_WRITE) && !mrq->stop)
648 writel(TIFM_MMCSD_EOFB
649 | readl(sock->addr + SOCK_MMCSD_INT_ENABLE),
650 sock->addr + SOCK_MMCSD_INT_ENABLE);
651
652 if (host->no_dma) {
653 writel(TIFM_MMCSD_BUFINT
654 | readl(sock->addr + SOCK_MMCSD_INT_ENABLE),
655 sock->addr + SOCK_MMCSD_INT_ENABLE);
656 writel(((TIFM_MMCSD_FIFO_SIZE - 1) << 8)
657 | (TIFM_MMCSD_FIFO_SIZE - 1),
658 sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
659
660 host->sg_len = r_data->sg_len;
661 } else {
662 sg_init_one(&host->bounce_buf, host->bounce_buf_data,
663 r_data->blksz);
664
665 if(1 != tifm_map_sg(sock, &host->bounce_buf, 1,
666 r_data->flags & MMC_DATA_WRITE
667 ? PCI_DMA_TODEVICE
668 : PCI_DMA_FROMDEVICE)) {
669 printk(KERN_ERR "%s : scatterlist map failed\n",
670 sock->dev.bus_id);
671 spin_unlock_irqrestore(&sock->lock, flags);
672 goto err_out;
673 }
674 host->sg_len = tifm_map_sg(sock, r_data->sg,
675 r_data->sg_len,
676 r_data->flags
677 & MMC_DATA_WRITE
678 ? PCI_DMA_TODEVICE
679 : PCI_DMA_FROMDEVICE);
680 if (host->sg_len < 1) {
681 printk(KERN_ERR "%s : scatterlist map failed\n",
682 sock->dev.bus_id);
683 tifm_unmap_sg(sock, &host->bounce_buf, 1,
684 r_data->flags & MMC_DATA_WRITE
685 ? PCI_DMA_TODEVICE
686 : PCI_DMA_FROMDEVICE);
687 spin_unlock_irqrestore(&sock->lock, flags);
688 goto err_out;
689 }
690
691 writel(TIFM_FIFO_INT_SETALL,
692 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
693 writel(ilog2(r_data->blksz) - 2,
694 sock->addr + SOCK_FIFO_PAGE_SIZE);
695 writel(TIFM_FIFO_ENABLE,
696 sock->addr + SOCK_FIFO_CONTROL);
697 writel(TIFM_FIFO_INTMASK,
698 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
699
700 if (r_data->flags & MMC_DATA_WRITE)
701 writel(TIFM_MMCSD_TXDE,
702 sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
703 else
704 writel(TIFM_MMCSD_RXDE,
705 sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
706
707 tifm_sd_set_dma_data(host, r_data);
708 }
709
710 writel(r_data->blocks - 1,
711 sock->addr + SOCK_MMCSD_NUM_BLOCKS);
712 writel(r_data->blksz - 1,
713 sock->addr + SOCK_MMCSD_BLOCK_LEN);
714 }
715
716 host->req = mrq;
717 mod_timer(&host->timer, jiffies + host->timeout_jiffies);
718 writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL),
719 sock->addr + SOCK_CONTROL);
720 tifm_sd_exec(host, mrq->cmd);
721 spin_unlock_irqrestore(&sock->lock, flags);
722 return;
723
724err_out:
725 mrq->cmd->error = MMC_ERR_TIMEOUT;
726 mmc_request_done(mmc, mrq);
727}
728
729static void tifm_sd_end_cmd(unsigned long data)
730{
731 struct tifm_sd *host = (struct tifm_sd*)data;
732 struct tifm_dev *sock = host->dev;
733 struct mmc_host *mmc = tifm_get_drvdata(sock);
734 struct mmc_request *mrq;
735 struct mmc_data *r_data = NULL;
736 unsigned long flags;
737
738 spin_lock_irqsave(&sock->lock, flags);
739
740 del_timer(&host->timer);
741 mrq = host->req;
742 host->req = NULL;
743
744 if (!mrq) {
745 printk(KERN_ERR " %s : no request to complete?\n",
746 sock->dev.bus_id);
747 spin_unlock_irqrestore(&sock->lock, flags);
748 return;
749 }
750
751 r_data = mrq->cmd->data;
752 if (r_data) {
753 if (host->no_dma) {
754 writel((~TIFM_MMCSD_BUFINT)
755 & readl(sock->addr + SOCK_MMCSD_INT_ENABLE),
756 sock->addr + SOCK_MMCSD_INT_ENABLE);
757 } else {
758 tifm_unmap_sg(sock, &host->bounce_buf, 1,
759 (r_data->flags & MMC_DATA_WRITE)
760 ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
761 tifm_unmap_sg(sock, r_data->sg, r_data->sg_len,
762 (r_data->flags & MMC_DATA_WRITE)
763 ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
764 }
765
766 r_data->bytes_xfered = r_data->blocks
767 - readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1;
768 r_data->bytes_xfered *= r_data->blksz;
769 r_data->bytes_xfered += r_data->blksz
770 - readl(sock->addr + SOCK_MMCSD_BLOCK_LEN) + 1;
771 }
772
773 writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
774 sock->addr + SOCK_CONTROL);
775
776 spin_unlock_irqrestore(&sock->lock, flags);
777 mmc_request_done(mmc, mrq);
778}
779
780static void tifm_sd_abort(unsigned long data)
781{
782 struct tifm_sd *host = (struct tifm_sd*)data;
783
784 printk(KERN_ERR
785 "%s : card failed to respond for a long period of time "
786 "(%x, %x)\n",
787 host->dev->dev.bus_id, host->req->cmd->opcode, host->cmd_flags);
788
789 tifm_eject(host->dev);
790}
791
792static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
793{
794 struct tifm_sd *host = mmc_priv(mmc);
795 struct tifm_dev *sock = host->dev;
796 unsigned int clk_div1, clk_div2;
797 unsigned long flags;
798
799 spin_lock_irqsave(&sock->lock, flags);
800
801 dev_dbg(&sock->dev, "ios: clock = %u, vdd = %x, bus_mode = %x, "
802 "chip_select = %x, power_mode = %x, bus_width = %x\n",
803 ios->clock, ios->vdd, ios->bus_mode, ios->chip_select,
804 ios->power_mode, ios->bus_width);
805
806 if (ios->bus_width == MMC_BUS_WIDTH_4) {
807 writel(TIFM_MMCSD_4BBUS | readl(sock->addr + SOCK_MMCSD_CONFIG),
808 sock->addr + SOCK_MMCSD_CONFIG);
809 } else {
810 writel((~TIFM_MMCSD_4BBUS)
811 & readl(sock->addr + SOCK_MMCSD_CONFIG),
812 sock->addr + SOCK_MMCSD_CONFIG);
813 }
814
815 if (ios->clock) {
816 clk_div1 = 20000000 / ios->clock;
817 if (!clk_div1)
818 clk_div1 = 1;
819
820 clk_div2 = 24000000 / ios->clock;
821 if (!clk_div2)
822 clk_div2 = 1;
823
824 if ((20000000 / clk_div1) > ios->clock)
825 clk_div1++;
826 if ((24000000 / clk_div2) > ios->clock)
827 clk_div2++;
828 if ((20000000 / clk_div1) > (24000000 / clk_div2)) {
829 host->clk_freq = 20000000;
830 host->clk_div = clk_div1;
831 writel((~TIFM_CTRL_FAST_CLK)
832 & readl(sock->addr + SOCK_CONTROL),
833 sock->addr + SOCK_CONTROL);
834 } else {
835 host->clk_freq = 24000000;
836 host->clk_div = clk_div2;
837 writel(TIFM_CTRL_FAST_CLK
838 | readl(sock->addr + SOCK_CONTROL),
839 sock->addr + SOCK_CONTROL);
840 }
841 } else {
842 host->clk_div = 0;
843 }
844 host->clk_div &= TIFM_MMCSD_CLKMASK;
845 writel(host->clk_div
846 | ((~TIFM_MMCSD_CLKMASK)
847 & readl(sock->addr + SOCK_MMCSD_CONFIG)),
848 sock->addr + SOCK_MMCSD_CONFIG);
849
850 host->open_drain = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN);
851
852 /* chip_select : maybe later */
853 //vdd
854 //power is set before probe / after remove
855
856 spin_unlock_irqrestore(&sock->lock, flags);
857}
858
859static int tifm_sd_ro(struct mmc_host *mmc)
860{
861 int rc = 0;
862 struct tifm_sd *host = mmc_priv(mmc);
863 struct tifm_dev *sock = host->dev;
864 unsigned long flags;
865
866 spin_lock_irqsave(&sock->lock, flags);
867 if (TIFM_MMCSD_CARD_RO & readl(sock->addr + SOCK_PRESENT_STATE))
868 rc = 1;
869 spin_unlock_irqrestore(&sock->lock, flags);
870 return rc;
871}
872
873static const struct mmc_host_ops tifm_sd_ops = {
874 .request = tifm_sd_request,
875 .set_ios = tifm_sd_ios,
876 .get_ro = tifm_sd_ro
877};
878
879static int tifm_sd_initialize_host(struct tifm_sd *host)
880{
881 int rc;
882 unsigned int host_status = 0;
883 struct tifm_dev *sock = host->dev;
884
885 writel(0, sock->addr + SOCK_MMCSD_INT_ENABLE);
886 mmiowb();
887 host->clk_div = 61;
888 host->clk_freq = 20000000;
889 writel(TIFM_MMCSD_RESET, sock->addr + SOCK_MMCSD_SYSTEM_CONTROL);
890 writel(host->clk_div | TIFM_MMCSD_POWER,
891 sock->addr + SOCK_MMCSD_CONFIG);
892
893 /* wait up to 0.51 sec for reset */
894 for (rc = 32; rc <= 256; rc <<= 1) {
895 if (1 & readl(sock->addr + SOCK_MMCSD_SYSTEM_STATUS)) {
896 rc = 0;
897 break;
898 }
899 msleep(rc);
900 }
901
902 if (rc) {
903 printk(KERN_ERR "%s : controller failed to reset\n",
904 sock->dev.bus_id);
905 return -ENODEV;
906 }
907
908 writel(0, sock->addr + SOCK_MMCSD_NUM_BLOCKS);
909 writel(host->clk_div | TIFM_MMCSD_POWER,
910 sock->addr + SOCK_MMCSD_CONFIG);
911 writel(TIFM_MMCSD_RXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
912
913 // command timeout fixed to 64 clocks for now
914 writel(64, sock->addr + SOCK_MMCSD_COMMAND_TO);
915 writel(TIFM_MMCSD_INAB, sock->addr + SOCK_MMCSD_COMMAND);
916
917 for (rc = 16; rc <= 64; rc <<= 1) {
918 host_status = readl(sock->addr + SOCK_MMCSD_STATUS);
919 writel(host_status, sock->addr + SOCK_MMCSD_STATUS);
920 if (!(host_status & TIFM_MMCSD_ERRMASK)
921 && (host_status & TIFM_MMCSD_EOC)) {
922 rc = 0;
923 break;
924 }
925 msleep(rc);
926 }
927
928 if (rc) {
929 printk(KERN_ERR
930 "%s : card not ready - probe failed on initialization\n",
931 sock->dev.bus_id);
932 return -ENODEV;
933 }
934
935 writel(TIFM_MMCSD_CERR | TIFM_MMCSD_BRS | TIFM_MMCSD_EOC
936 | TIFM_MMCSD_ERRMASK,
937 sock->addr + SOCK_MMCSD_INT_ENABLE);
938 mmiowb();
939
940 return 0;
941}
942
943static int tifm_sd_probe(struct tifm_dev *sock)
944{
945 struct mmc_host *mmc;
946 struct tifm_sd *host;
947 int rc = -EIO;
948
949 if (!(TIFM_SOCK_STATE_OCCUPIED
950 & readl(sock->addr + SOCK_PRESENT_STATE))) {
951 printk(KERN_WARNING "%s : card gone, unexpectedly\n",
952 sock->dev.bus_id);
953 return rc;
954 }
955
956 mmc = mmc_alloc_host(sizeof(struct tifm_sd), &sock->dev);
957 if (!mmc)
958 return -ENOMEM;
959
960 host = mmc_priv(mmc);
961 host->no_dma = no_dma;
962 tifm_set_drvdata(sock, mmc);
963 host->dev = sock;
964 host->timeout_jiffies = msecs_to_jiffies(1000);
965
966 tasklet_init(&host->finish_tasklet, tifm_sd_end_cmd,
967 (unsigned long)host);
968 setup_timer(&host->timer, tifm_sd_abort, (unsigned long)host);
969
970 mmc->ops = &tifm_sd_ops;
971 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
972 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE;
973 mmc->f_min = 20000000 / 60;
974 mmc->f_max = 24000000;
975
976 mmc->max_blk_count = 2048;
977 mmc->max_hw_segs = mmc->max_blk_count;
978 mmc->max_blk_size = min(TIFM_MMCSD_MAX_BLOCK_SIZE, PAGE_SIZE);
979 mmc->max_seg_size = mmc->max_blk_count * mmc->max_blk_size;
980 mmc->max_req_size = mmc->max_seg_size;
981 mmc->max_phys_segs = mmc->max_hw_segs;
982
983 sock->card_event = tifm_sd_card_event;
984 sock->data_event = tifm_sd_data_event;
985 rc = tifm_sd_initialize_host(host);
986
987 if (!rc)
988 rc = mmc_add_host(mmc);
989 if (!rc)
990 return 0;
991
992 mmc_free_host(mmc);
993 return rc;
994}
995
996static void tifm_sd_remove(struct tifm_dev *sock)
997{
998 struct mmc_host *mmc = tifm_get_drvdata(sock);
999 struct tifm_sd *host = mmc_priv(mmc);
1000 unsigned long flags;
1001
1002 spin_lock_irqsave(&sock->lock, flags);
1003 host->eject = 1;
1004 writel(0, sock->addr + SOCK_MMCSD_INT_ENABLE);
1005 mmiowb();
1006 spin_unlock_irqrestore(&sock->lock, flags);
1007
1008 tasklet_kill(&host->finish_tasklet);
1009
1010 spin_lock_irqsave(&sock->lock, flags);
1011 if (host->req) {
1012 writel(TIFM_FIFO_INT_SETALL,
1013 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
1014 writel(0, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
1015 host->req->cmd->error = MMC_ERR_TIMEOUT;
1016 if (host->req->stop)
1017 host->req->stop->error = MMC_ERR_TIMEOUT;
1018 tasklet_schedule(&host->finish_tasklet);
1019 }
1020 spin_unlock_irqrestore(&sock->lock, flags);
1021 mmc_remove_host(mmc);
1022 dev_dbg(&sock->dev, "after remove\n");
1023
1024 /* The meaning of the bit majority in this constant is unknown. */
1025 writel(0xfff8 & readl(sock->addr + SOCK_CONTROL),
1026 sock->addr + SOCK_CONTROL);
1027
1028 mmc_free_host(mmc);
1029}
1030
1031#ifdef CONFIG_PM
1032
1033static int tifm_sd_suspend(struct tifm_dev *sock, pm_message_t state)
1034{
1035 struct mmc_host *mmc = tifm_get_drvdata(sock);
1036 int rc;
1037
1038 rc = mmc_suspend_host(mmc, state);
1039 /* The meaning of the bit majority in this constant is unknown. */
1040 writel(0xfff8 & readl(sock->addr + SOCK_CONTROL),
1041 sock->addr + SOCK_CONTROL);
1042 return rc;
1043}
1044
1045static int tifm_sd_resume(struct tifm_dev *sock)
1046{
1047 struct mmc_host *mmc = tifm_get_drvdata(sock);
1048 struct tifm_sd *host = mmc_priv(mmc);
1049 int rc;
1050
1051 rc = tifm_sd_initialize_host(host);
1052 dev_dbg(&sock->dev, "resume initialize %d\n", rc);
1053
1054 if (rc)
1055 host->eject = 1;
1056 else
1057 rc = mmc_resume_host(mmc);
1058
1059 return rc;
1060}
1061
1062#else
1063
1064#define tifm_sd_suspend NULL
1065#define tifm_sd_resume NULL
1066
1067#endif /* CONFIG_PM */
1068
1069static struct tifm_device_id tifm_sd_id_tbl[] = {
1070 { TIFM_TYPE_SD }, { }
1071};
1072
1073static struct tifm_driver tifm_sd_driver = {
1074 .driver = {
1075 .name = DRIVER_NAME,
1076 .owner = THIS_MODULE
1077 },
1078 .id_table = tifm_sd_id_tbl,
1079 .probe = tifm_sd_probe,
1080 .remove = tifm_sd_remove,
1081 .suspend = tifm_sd_suspend,
1082 .resume = tifm_sd_resume
1083};
1084
1085static int __init tifm_sd_init(void)
1086{
1087 return tifm_register_driver(&tifm_sd_driver);
1088}
1089
1090static void __exit tifm_sd_exit(void)
1091{
1092 tifm_unregister_driver(&tifm_sd_driver);
1093}
1094
1095MODULE_AUTHOR("Alex Dubov");
1096MODULE_DESCRIPTION("TI FlashMedia SD driver");
1097MODULE_LICENSE("GPL");
1098MODULE_DEVICE_TABLE(tifm, tifm_sd_id_tbl);
1099MODULE_VERSION(DRIVER_VERSION);
1100
1101module_init(tifm_sd_init);
1102module_exit(tifm_sd_exit);
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/host/wbsd.c
index 05ccfc43168f..867ca6a69298 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/drivers/mmc/wbsd.c - Winbond W83L51xD SD/MMC driver 2 * linux/drivers/mmc/wbsd.c - Winbond W83L51xD SD/MMC driver
3 * 3 *
4 * Copyright (C) 2004-2006 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -33,7 +33,6 @@
33#include <linux/pnp.h> 33#include <linux/pnp.h>
34#include <linux/highmem.h> 34#include <linux/highmem.h>
35#include <linux/mmc/host.h> 35#include <linux/mmc/host.h>
36#include <linux/mmc/protocol.h>
37 36
38#include <asm/io.h> 37#include <asm/io.h>
39#include <asm/dma.h> 38#include <asm/dma.h>
@@ -178,9 +177,8 @@ static void wbsd_init_device(struct wbsd_host *host)
178 ier = 0; 177 ier = 0;
179 ier |= WBSD_EINT_CARD; 178 ier |= WBSD_EINT_CARD;
180 ier |= WBSD_EINT_FIFO_THRE; 179 ier |= WBSD_EINT_FIFO_THRE;
181 ier |= WBSD_EINT_CCRC;
182 ier |= WBSD_EINT_TIMEOUT;
183 ier |= WBSD_EINT_CRC; 180 ier |= WBSD_EINT_CRC;
181 ier |= WBSD_EINT_TIMEOUT;
184 ier |= WBSD_EINT_TC; 182 ier |= WBSD_EINT_TC;
185 183
186 outb(ier, host->base + WBSD_EIR); 184 outb(ier, host->base + WBSD_EIR);
@@ -278,90 +276,36 @@ static inline char *wbsd_sg_to_buffer(struct wbsd_host *host)
278 276
279static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data) 277static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data)
280{ 278{
281 unsigned int len, i, size; 279 unsigned int len, i;
282 struct scatterlist *sg; 280 struct scatterlist *sg;
283 char *dmabuf = host->dma_buffer; 281 char *dmabuf = host->dma_buffer;
284 char *sgbuf; 282 char *sgbuf;
285 283
286 size = host->size;
287
288 sg = data->sg; 284 sg = data->sg;
289 len = data->sg_len; 285 len = data->sg_len;
290 286
291 /*
292 * Just loop through all entries. Size might not
293 * be the entire list though so make sure that
294 * we do not transfer too much.
295 */
296 for (i = 0; i < len; i++) { 287 for (i = 0; i < len; i++) {
297 sgbuf = page_address(sg[i].page) + sg[i].offset; 288 sgbuf = page_address(sg[i].page) + sg[i].offset;
298 if (size < sg[i].length) 289 memcpy(dmabuf, sgbuf, sg[i].length);
299 memcpy(dmabuf, sgbuf, size);
300 else
301 memcpy(dmabuf, sgbuf, sg[i].length);
302 dmabuf += sg[i].length; 290 dmabuf += sg[i].length;
303
304 if (size < sg[i].length)
305 size = 0;
306 else
307 size -= sg[i].length;
308
309 if (size == 0)
310 break;
311 } 291 }
312
313 /*
314 * Check that we didn't get a request to transfer
315 * more data than can fit into the SG list.
316 */
317
318 BUG_ON(size != 0);
319
320 host->size -= size;
321} 292}
322 293
323static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data) 294static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data)
324{ 295{
325 unsigned int len, i, size; 296 unsigned int len, i;
326 struct scatterlist *sg; 297 struct scatterlist *sg;
327 char *dmabuf = host->dma_buffer; 298 char *dmabuf = host->dma_buffer;
328 char *sgbuf; 299 char *sgbuf;
329 300
330 size = host->size;
331
332 sg = data->sg; 301 sg = data->sg;
333 len = data->sg_len; 302 len = data->sg_len;
334 303
335 /*
336 * Just loop through all entries. Size might not
337 * be the entire list though so make sure that
338 * we do not transfer too much.
339 */
340 for (i = 0; i < len; i++) { 304 for (i = 0; i < len; i++) {
341 sgbuf = page_address(sg[i].page) + sg[i].offset; 305 sgbuf = page_address(sg[i].page) + sg[i].offset;
342 if (size < sg[i].length) 306 memcpy(sgbuf, dmabuf, sg[i].length);
343 memcpy(sgbuf, dmabuf, size);
344 else
345 memcpy(sgbuf, dmabuf, sg[i].length);
346 dmabuf += sg[i].length; 307 dmabuf += sg[i].length;
347
348 if (size < sg[i].length)
349 size = 0;
350 else
351 size -= sg[i].length;
352
353 if (size == 0)
354 break;
355 } 308 }
356
357 /*
358 * Check that we didn't get a request to transfer
359 * more data than can fit into the SG list.
360 */
361
362 BUG_ON(size != 0);
363
364 host->size -= size;
365} 309}
366 310
367/* 311/*
@@ -484,7 +428,7 @@ static void wbsd_empty_fifo(struct wbsd_host *host)
484 /* 428 /*
485 * Handle excessive data. 429 * Handle excessive data.
486 */ 430 */
487 if (data->bytes_xfered == host->size) 431 if (host->num_sg == 0)
488 return; 432 return;
489 433
490 buffer = wbsd_sg_to_buffer(host) + host->offset; 434 buffer = wbsd_sg_to_buffer(host) + host->offset;
@@ -514,31 +458,14 @@ static void wbsd_empty_fifo(struct wbsd_host *host)
514 data->bytes_xfered++; 458 data->bytes_xfered++;
515 459
516 /* 460 /*
517 * Transfer done?
518 */
519 if (data->bytes_xfered == host->size)
520 return;
521
522 /*
523 * End of scatter list entry? 461 * End of scatter list entry?
524 */ 462 */
525 if (host->remain == 0) { 463 if (host->remain == 0) {
526 /* 464 /*
527 * Get next entry. Check if last. 465 * Get next entry. Check if last.
528 */ 466 */
529 if (!wbsd_next_sg(host)) { 467 if (!wbsd_next_sg(host))
530 /*
531 * We should never reach this point.
532 * It means that we're trying to
533 * transfer more blocks than can fit
534 * into the scatter list.
535 */
536 BUG_ON(1);
537
538 host->size = data->bytes_xfered;
539
540 return; 468 return;
541 }
542 469
543 buffer = wbsd_sg_to_buffer(host); 470 buffer = wbsd_sg_to_buffer(host);
544 } 471 }
@@ -550,7 +477,7 @@ static void wbsd_empty_fifo(struct wbsd_host *host)
550 * hardware problem. The chip doesn't trigger 477 * hardware problem. The chip doesn't trigger
551 * FIFO threshold interrupts properly. 478 * FIFO threshold interrupts properly.
552 */ 479 */
553 if ((host->size - data->bytes_xfered) < 16) 480 if ((data->blocks * data->blksz - data->bytes_xfered) < 16)
554 tasklet_schedule(&host->fifo_tasklet); 481 tasklet_schedule(&host->fifo_tasklet);
555} 482}
556 483
@@ -564,7 +491,7 @@ static void wbsd_fill_fifo(struct wbsd_host *host)
564 * Check that we aren't being called after the 491 * Check that we aren't being called after the
565 * entire buffer has been transfered. 492 * entire buffer has been transfered.
566 */ 493 */
567 if (data->bytes_xfered == host->size) 494 if (host->num_sg == 0)
568 return; 495 return;
569 496
570 buffer = wbsd_sg_to_buffer(host) + host->offset; 497 buffer = wbsd_sg_to_buffer(host) + host->offset;
@@ -594,31 +521,14 @@ static void wbsd_fill_fifo(struct wbsd_host *host)
594 data->bytes_xfered++; 521 data->bytes_xfered++;
595 522
596 /* 523 /*
597 * Transfer done?
598 */
599 if (data->bytes_xfered == host->size)
600 return;
601
602 /*
603 * End of scatter list entry? 524 * End of scatter list entry?
604 */ 525 */
605 if (host->remain == 0) { 526 if (host->remain == 0) {
606 /* 527 /*
607 * Get next entry. Check if last. 528 * Get next entry. Check if last.
608 */ 529 */
609 if (!wbsd_next_sg(host)) { 530 if (!wbsd_next_sg(host))
610 /*
611 * We should never reach this point.
612 * It means that we're trying to
613 * transfer more blocks than can fit
614 * into the scatter list.
615 */
616 BUG_ON(1);
617
618 host->size = data->bytes_xfered;
619
620 return; 531 return;
621 }
622 532
623 buffer = wbsd_sg_to_buffer(host); 533 buffer = wbsd_sg_to_buffer(host);
624 } 534 }
@@ -638,6 +548,7 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
638 u16 blksize; 548 u16 blksize;
639 u8 setup; 549 u8 setup;
640 unsigned long dmaflags; 550 unsigned long dmaflags;
551 unsigned int size;
641 552
642 DBGF("blksz %04x blks %04x flags %08x\n", 553 DBGF("blksz %04x blks %04x flags %08x\n",
643 data->blksz, data->blocks, data->flags); 554 data->blksz, data->blocks, data->flags);
@@ -647,7 +558,7 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
647 /* 558 /*
648 * Calculate size. 559 * Calculate size.
649 */ 560 */
650 host->size = data->blocks * data->blksz; 561 size = data->blocks * data->blksz;
651 562
652 /* 563 /*
653 * Check timeout values for overflow. 564 * Check timeout values for overflow.
@@ -705,8 +616,8 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
705 /* 616 /*
706 * The buffer for DMA is only 64 kB. 617 * The buffer for DMA is only 64 kB.
707 */ 618 */
708 BUG_ON(host->size > 0x10000); 619 BUG_ON(size > 0x10000);
709 if (host->size > 0x10000) { 620 if (size > 0x10000) {
710 data->error = MMC_ERR_INVALID; 621 data->error = MMC_ERR_INVALID;
711 return; 622 return;
712 } 623 }
@@ -729,7 +640,7 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
729 else 640 else
730 set_dma_mode(host->dma, DMA_MODE_WRITE & ~0x40); 641 set_dma_mode(host->dma, DMA_MODE_WRITE & ~0x40);
731 set_dma_addr(host->dma, host->dma_addr); 642 set_dma_addr(host->dma, host->dma_addr);
732 set_dma_count(host->dma, host->size); 643 set_dma_count(host->dma, size);
733 644
734 enable_dma(host->dma); 645 enable_dma(host->dma);
735 release_dma_lock(dmaflags); 646 release_dma_lock(dmaflags);
@@ -812,6 +723,10 @@ static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data)
812 count = get_dma_residue(host->dma); 723 count = get_dma_residue(host->dma);
813 release_dma_lock(dmaflags); 724 release_dma_lock(dmaflags);
814 725
726 data->bytes_xfered = host->mrq->data->blocks *
727 host->mrq->data->blksz - count;
728 data->bytes_xfered -= data->bytes_xfered % data->blksz;
729
815 /* 730 /*
816 * Any leftover data? 731 * Any leftover data?
817 */ 732 */
@@ -820,7 +735,8 @@ static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data)
820 "%d bytes left.\n", 735 "%d bytes left.\n",
821 mmc_hostname(host->mmc), count); 736 mmc_hostname(host->mmc), count);
822 737
823 data->error = MMC_ERR_FAILED; 738 if (data->error == MMC_ERR_NONE)
739 data->error = MMC_ERR_FAILED;
824 } else { 740 } else {
825 /* 741 /*
826 * Transfer data from DMA buffer to 742 * Transfer data from DMA buffer to
@@ -828,8 +744,11 @@ static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data)
828 */ 744 */
829 if (data->flags & MMC_DATA_READ) 745 if (data->flags & MMC_DATA_READ)
830 wbsd_dma_to_sg(host, data); 746 wbsd_dma_to_sg(host, data);
747 }
831 748
832 data->bytes_xfered = host->size; 749 if (data->error != MMC_ERR_NONE) {
750 if (data->bytes_xfered)
751 data->bytes_xfered -= data->blksz;
833 } 752 }
834 } 753 }
835 754
@@ -869,24 +788,7 @@ static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)
869 goto done; 788 goto done;
870 } 789 }
871 790
872 /*
873 * Does the request include data?
874 */
875 if (cmd->data) { 791 if (cmd->data) {
876 wbsd_prepare_data(host, cmd->data);
877
878 if (cmd->data->error != MMC_ERR_NONE)
879 goto done;
880 }
881
882 wbsd_send_command(host, cmd);
883
884 /*
885 * If this is a data transfer the request
886 * will be finished after the data has
887 * transfered.
888 */
889 if (cmd->data && (cmd->error == MMC_ERR_NONE)) {
890 /* 792 /*
891 * The hardware is so delightfully stupid that it has a list 793 * The hardware is so delightfully stupid that it has a list
892 * of "data" commands. If a command isn't on this list, it'll 794 * of "data" commands. If a command isn't on this list, it'll
@@ -918,14 +820,30 @@ static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)
918 "supported by this controller.\n", 820 "supported by this controller.\n",
919 mmc_hostname(host->mmc), cmd->opcode); 821 mmc_hostname(host->mmc), cmd->opcode);
920#endif 822#endif
921 cmd->data->error = MMC_ERR_INVALID; 823 cmd->error = MMC_ERR_INVALID;
922
923 if (cmd->data->stop)
924 wbsd_send_command(host, cmd->data->stop);
925 824
926 goto done; 825 goto done;
927 }; 826 };
827 }
828
829 /*
830 * Does the request include data?
831 */
832 if (cmd->data) {
833 wbsd_prepare_data(host, cmd->data);
834
835 if (cmd->data->error != MMC_ERR_NONE)
836 goto done;
837 }
838
839 wbsd_send_command(host, cmd);
928 840
841 /*
842 * If this is a data transfer the request
843 * will be finished after the data has
844 * transfered.
845 */
846 if (cmd->data && (cmd->error == MMC_ERR_NONE)) {
929 /* 847 /*
930 * Dirty fix for hardware bug. 848 * Dirty fix for hardware bug.
931 */ 849 */
@@ -1167,7 +1085,7 @@ static void wbsd_tasklet_fifo(unsigned long param)
1167 /* 1085 /*
1168 * Done? 1086 * Done?
1169 */ 1087 */
1170 if (host->size == data->bytes_xfered) { 1088 if (host->num_sg == 0) {
1171 wbsd_write_index(host, WBSD_IDX_FIFOEN, 0); 1089 wbsd_write_index(host, WBSD_IDX_FIFOEN, 0);
1172 tasklet_schedule(&host->finish_tasklet); 1090 tasklet_schedule(&host->finish_tasklet);
1173 } 1091 }
@@ -1245,30 +1163,6 @@ end:
1245 spin_unlock(&host->lock); 1163 spin_unlock(&host->lock);
1246} 1164}
1247 1165
1248static void wbsd_tasklet_block(unsigned long param)
1249{
1250 struct wbsd_host *host = (struct wbsd_host *)param;
1251 struct mmc_data *data;
1252
1253 spin_lock(&host->lock);
1254
1255 if ((wbsd_read_index(host, WBSD_IDX_CRCSTATUS) & WBSD_CRC_MASK) !=
1256 WBSD_CRC_OK) {
1257 data = wbsd_get_data(host);
1258 if (!data)
1259 goto end;
1260
1261 DBGF("CRC error\n");
1262
1263 data->error = MMC_ERR_BADCRC;
1264
1265 tasklet_schedule(&host->finish_tasklet);
1266 }
1267
1268end:
1269 spin_unlock(&host->lock);
1270}
1271
1272/* 1166/*
1273 * Interrupt handling 1167 * Interrupt handling
1274 */ 1168 */
@@ -1299,8 +1193,6 @@ static irqreturn_t wbsd_irq(int irq, void *dev_id)
1299 tasklet_hi_schedule(&host->crc_tasklet); 1193 tasklet_hi_schedule(&host->crc_tasklet);
1300 if (isr & WBSD_INT_TIMEOUT) 1194 if (isr & WBSD_INT_TIMEOUT)
1301 tasklet_hi_schedule(&host->timeout_tasklet); 1195 tasklet_hi_schedule(&host->timeout_tasklet);
1302 if (isr & WBSD_INT_BUSYEND)
1303 tasklet_hi_schedule(&host->block_tasklet);
1304 if (isr & WBSD_INT_TC) 1196 if (isr & WBSD_INT_TC)
1305 tasklet_schedule(&host->finish_tasklet); 1197 tasklet_schedule(&host->finish_tasklet);
1306 1198
@@ -1601,8 +1493,6 @@ static int __devinit wbsd_request_irq(struct wbsd_host *host, int irq)
1601 (unsigned long)host); 1493 (unsigned long)host);
1602 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, 1494 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish,
1603 (unsigned long)host); 1495 (unsigned long)host);
1604 tasklet_init(&host->block_tasklet, wbsd_tasklet_block,
1605 (unsigned long)host);
1606 1496
1607 return 0; 1497 return 0;
1608} 1498}
@@ -1621,7 +1511,6 @@ static void __devexit wbsd_release_irq(struct wbsd_host *host)
1621 tasklet_kill(&host->crc_tasklet); 1511 tasklet_kill(&host->crc_tasklet);
1622 tasklet_kill(&host->timeout_tasklet); 1512 tasklet_kill(&host->timeout_tasklet);
1623 tasklet_kill(&host->finish_tasklet); 1513 tasklet_kill(&host->finish_tasklet);
1624 tasklet_kill(&host->block_tasklet);
1625} 1514}
1626 1515
1627/* 1516/*
diff --git a/drivers/mmc/wbsd.h b/drivers/mmc/host/wbsd.h
index d06718b0e2ab..873bda1e59b4 100644
--- a/drivers/mmc/wbsd.h
+++ b/drivers/mmc/host/wbsd.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/drivers/mmc/wbsd.h - Winbond W83L51xD SD/MMC driver 2 * linux/drivers/mmc/wbsd.h - Winbond W83L51xD SD/MMC driver
3 * 3 *
4 * Copyright (C) 2004-2005 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -46,10 +46,10 @@
46 46
47#define WBSD_EINT_CARD 0x40 47#define WBSD_EINT_CARD 0x40
48#define WBSD_EINT_FIFO_THRE 0x20 48#define WBSD_EINT_FIFO_THRE 0x20
49#define WBSD_EINT_CCRC 0x10 49#define WBSD_EINT_CRC 0x10
50#define WBSD_EINT_TIMEOUT 0x08 50#define WBSD_EINT_TIMEOUT 0x08
51#define WBSD_EINT_PROGEND 0x04 51#define WBSD_EINT_PROGEND 0x04
52#define WBSD_EINT_CRC 0x02 52#define WBSD_EINT_BUSYEND 0x02
53#define WBSD_EINT_TC 0x01 53#define WBSD_EINT_TC 0x01
54 54
55#define WBSD_INT_PENDING 0x80 55#define WBSD_INT_PENDING 0x80
@@ -158,8 +158,6 @@ struct wbsd_host
158 unsigned int offset; /* Offset into current entry */ 158 unsigned int offset; /* Offset into current entry */
159 unsigned int remain; /* Data left in curren entry */ 159 unsigned int remain; /* Data left in curren entry */
160 160
161 int size; /* Total size of transfer */
162
163 char* dma_buffer; /* ISA DMA buffer */ 161 char* dma_buffer; /* ISA DMA buffer */
164 dma_addr_t dma_addr; /* Physical address for same */ 162 dma_addr_t dma_addr; /* Physical address for same */
165 163
@@ -182,7 +180,6 @@ struct wbsd_host
182 struct tasklet_struct crc_tasklet; 180 struct tasklet_struct crc_tasklet;
183 struct tasklet_struct timeout_tasklet; 181 struct tasklet_struct timeout_tasklet;
184 struct tasklet_struct finish_tasklet; 182 struct tasklet_struct finish_tasklet;
185 struct tasklet_struct block_tasklet;
186 183
187 struct timer_list ignore_timer; /* Ignore detection timer */ 184 struct timer_list ignore_timer; /* Ignore detection timer */
188}; 185};
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
deleted file mode 100644
index 4a73e8b2428d..000000000000
--- a/drivers/mmc/mmc.c
+++ /dev/null
@@ -1,1724 +0,0 @@
1/*
2 * linux/drivers/mmc/mmc.c
3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
6 * SD support Copyright (C) 2005 Pierre Ossman, All Rights Reserved.
7 * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
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#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/completion.h>
17#include <linux/device.h>
18#include <linux/delay.h>
19#include <linux/pagemap.h>
20#include <linux/err.h>
21#include <asm/scatterlist.h>
22#include <linux/scatterlist.h>
23
24#include <linux/mmc/card.h>
25#include <linux/mmc/host.h>
26#include <linux/mmc/protocol.h>
27
28#include "mmc.h"
29
30#define CMD_RETRIES 3
31
32/*
33 * OCR Bit positions to 10s of Vdd mV.
34 */
35static const unsigned short mmc_ocr_bit_to_vdd[] = {
36 150, 155, 160, 165, 170, 180, 190, 200,
37 210, 220, 230, 240, 250, 260, 270, 280,
38 290, 300, 310, 320, 330, 340, 350, 360
39};
40
41static const unsigned int tran_exp[] = {
42 10000, 100000, 1000000, 10000000,
43 0, 0, 0, 0
44};
45
46static const unsigned char tran_mant[] = {
47 0, 10, 12, 13, 15, 20, 25, 30,
48 35, 40, 45, 50, 55, 60, 70, 80,
49};
50
51static const unsigned int tacc_exp[] = {
52 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000,
53};
54
55static const unsigned int tacc_mant[] = {
56 0, 10, 12, 13, 15, 20, 25, 30,
57 35, 40, 45, 50, 55, 60, 70, 80,
58};
59
60
61/**
62 * mmc_request_done - finish processing an MMC request
63 * @host: MMC host which completed request
64 * @mrq: MMC request which request
65 *
66 * MMC drivers should call this function when they have completed
67 * their processing of a request.
68 */
69void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
70{
71 struct mmc_command *cmd = mrq->cmd;
72 int err = cmd->error;
73
74 pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n",
75 mmc_hostname(host), cmd->opcode, err,
76 mrq->data ? mrq->data->error : 0,
77 mrq->stop ? mrq->stop->error : 0,
78 cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
79
80 if (err && cmd->retries) {
81 cmd->retries--;
82 cmd->error = 0;
83 host->ops->request(host, mrq);
84 } else if (mrq->done) {
85 mrq->done(mrq);
86 }
87}
88
89EXPORT_SYMBOL(mmc_request_done);
90
91/**
92 * mmc_start_request - start a command on a host
93 * @host: MMC host to start command on
94 * @mrq: MMC request to start
95 *
96 * Queue a command on the specified host. We expect the
97 * caller to be holding the host lock with interrupts disabled.
98 */
99void
100mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
101{
102 pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
103 mmc_hostname(host), mrq->cmd->opcode,
104 mrq->cmd->arg, mrq->cmd->flags);
105
106 WARN_ON(!host->claimed);
107
108 mrq->cmd->error = 0;
109 mrq->cmd->mrq = mrq;
110 if (mrq->data) {
111 BUG_ON(mrq->data->blksz > host->max_blk_size);
112 BUG_ON(mrq->data->blocks > host->max_blk_count);
113 BUG_ON(mrq->data->blocks * mrq->data->blksz >
114 host->max_req_size);
115
116 mrq->cmd->data = mrq->data;
117 mrq->data->error = 0;
118 mrq->data->mrq = mrq;
119 if (mrq->stop) {
120 mrq->data->stop = mrq->stop;
121 mrq->stop->error = 0;
122 mrq->stop->mrq = mrq;
123 }
124 }
125 host->ops->request(host, mrq);
126}
127
128EXPORT_SYMBOL(mmc_start_request);
129
130static void mmc_wait_done(struct mmc_request *mrq)
131{
132 complete(mrq->done_data);
133}
134
135int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
136{
137 DECLARE_COMPLETION_ONSTACK(complete);
138
139 mrq->done_data = &complete;
140 mrq->done = mmc_wait_done;
141
142 mmc_start_request(host, mrq);
143
144 wait_for_completion(&complete);
145
146 return 0;
147}
148
149EXPORT_SYMBOL(mmc_wait_for_req);
150
151/**
152 * mmc_wait_for_cmd - start a command and wait for completion
153 * @host: MMC host to start command
154 * @cmd: MMC command to start
155 * @retries: maximum number of retries
156 *
157 * Start a new MMC command for a host, and wait for the command
158 * to complete. Return any error that occurred while the command
159 * was executing. Do not attempt to parse the response.
160 */
161int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries)
162{
163 struct mmc_request mrq;
164
165 BUG_ON(!host->claimed);
166
167 memset(&mrq, 0, sizeof(struct mmc_request));
168
169 memset(cmd->resp, 0, sizeof(cmd->resp));
170 cmd->retries = retries;
171
172 mrq.cmd = cmd;
173 cmd->data = NULL;
174
175 mmc_wait_for_req(host, &mrq);
176
177 return cmd->error;
178}
179
180EXPORT_SYMBOL(mmc_wait_for_cmd);
181
182/**
183 * mmc_wait_for_app_cmd - start an application command and wait for
184 completion
185 * @host: MMC host to start command
186 * @rca: RCA to send MMC_APP_CMD to
187 * @cmd: MMC command to start
188 * @retries: maximum number of retries
189 *
190 * Sends a MMC_APP_CMD, checks the card response, sends the command
191 * in the parameter and waits for it to complete. Return any error
192 * that occurred while the command was executing. Do not attempt to
193 * parse the response.
194 */
195int mmc_wait_for_app_cmd(struct mmc_host *host, unsigned int rca,
196 struct mmc_command *cmd, int retries)
197{
198 struct mmc_request mrq;
199 struct mmc_command appcmd;
200
201 int i, err;
202
203 BUG_ON(!host->claimed);
204 BUG_ON(retries < 0);
205
206 err = MMC_ERR_INVALID;
207
208 /*
209 * We have to resend MMC_APP_CMD for each attempt so
210 * we cannot use the retries field in mmc_command.
211 */
212 for (i = 0;i <= retries;i++) {
213 memset(&mrq, 0, sizeof(struct mmc_request));
214
215 appcmd.opcode = MMC_APP_CMD;
216 appcmd.arg = rca << 16;
217 appcmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
218 appcmd.retries = 0;
219 memset(appcmd.resp, 0, sizeof(appcmd.resp));
220 appcmd.data = NULL;
221
222 mrq.cmd = &appcmd;
223 appcmd.data = NULL;
224
225 mmc_wait_for_req(host, &mrq);
226
227 if (appcmd.error) {
228 err = appcmd.error;
229 continue;
230 }
231
232 /* Check that card supported application commands */
233 if (!(appcmd.resp[0] & R1_APP_CMD))
234 return MMC_ERR_FAILED;
235
236 memset(&mrq, 0, sizeof(struct mmc_request));
237
238 memset(cmd->resp, 0, sizeof(cmd->resp));
239 cmd->retries = 0;
240
241 mrq.cmd = cmd;
242 cmd->data = NULL;
243
244 mmc_wait_for_req(host, &mrq);
245
246 err = cmd->error;
247 if (cmd->error == MMC_ERR_NONE)
248 break;
249 }
250
251 return err;
252}
253
254EXPORT_SYMBOL(mmc_wait_for_app_cmd);
255
256/**
257 * mmc_set_data_timeout - set the timeout for a data command
258 * @data: data phase for command
259 * @card: the MMC card associated with the data transfer
260 * @write: flag to differentiate reads from writes
261 */
262void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card,
263 int write)
264{
265 unsigned int mult;
266
267 /*
268 * SD cards use a 100 multiplier rather than 10
269 */
270 mult = mmc_card_sd(card) ? 100 : 10;
271
272 /*
273 * Scale up the multiplier (and therefore the timeout) by
274 * the r2w factor for writes.
275 */
276 if (write)
277 mult <<= card->csd.r2w_factor;
278
279 data->timeout_ns = card->csd.tacc_ns * mult;
280 data->timeout_clks = card->csd.tacc_clks * mult;
281
282 /*
283 * SD cards also have an upper limit on the timeout.
284 */
285 if (mmc_card_sd(card)) {
286 unsigned int timeout_us, limit_us;
287
288 timeout_us = data->timeout_ns / 1000;
289 timeout_us += data->timeout_clks * 1000 /
290 (card->host->ios.clock / 1000);
291
292 if (write)
293 limit_us = 250000;
294 else
295 limit_us = 100000;
296
297 /*
298 * SDHC cards always use these fixed values.
299 */
300 if (timeout_us > limit_us || mmc_card_blockaddr(card)) {
301 data->timeout_ns = limit_us * 1000;
302 data->timeout_clks = 0;
303 }
304 }
305}
306EXPORT_SYMBOL(mmc_set_data_timeout);
307
308static int mmc_select_card(struct mmc_host *host, struct mmc_card *card);
309
310/**
311 * __mmc_claim_host - exclusively claim a host
312 * @host: mmc host to claim
313 * @card: mmc card to claim host for
314 *
315 * Claim a host for a set of operations. If a valid card
316 * is passed and this wasn't the last card selected, select
317 * the card before returning.
318 *
319 * Note: you should use mmc_card_claim_host or mmc_claim_host.
320 */
321int __mmc_claim_host(struct mmc_host *host, struct mmc_card *card)
322{
323 DECLARE_WAITQUEUE(wait, current);
324 unsigned long flags;
325 int err = 0;
326
327 add_wait_queue(&host->wq, &wait);
328 spin_lock_irqsave(&host->lock, flags);
329 while (1) {
330 set_current_state(TASK_UNINTERRUPTIBLE);
331 if (!host->claimed)
332 break;
333 spin_unlock_irqrestore(&host->lock, flags);
334 schedule();
335 spin_lock_irqsave(&host->lock, flags);
336 }
337 set_current_state(TASK_RUNNING);
338 host->claimed = 1;
339 spin_unlock_irqrestore(&host->lock, flags);
340 remove_wait_queue(&host->wq, &wait);
341
342 if (card != (void *)-1) {
343 err = mmc_select_card(host, card);
344 if (err != MMC_ERR_NONE)
345 return err;
346 }
347
348 return err;
349}
350
351EXPORT_SYMBOL(__mmc_claim_host);
352
353/**
354 * mmc_release_host - release a host
355 * @host: mmc host to release
356 *
357 * Release a MMC host, allowing others to claim the host
358 * for their operations.
359 */
360void mmc_release_host(struct mmc_host *host)
361{
362 unsigned long flags;
363
364 BUG_ON(!host->claimed);
365
366 spin_lock_irqsave(&host->lock, flags);
367 host->claimed = 0;
368 spin_unlock_irqrestore(&host->lock, flags);
369
370 wake_up(&host->wq);
371}
372
373EXPORT_SYMBOL(mmc_release_host);
374
375static inline void mmc_set_ios(struct mmc_host *host)
376{
377 struct mmc_ios *ios = &host->ios;
378
379 pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u "
380 "width %u timing %u\n",
381 mmc_hostname(host), ios->clock, ios->bus_mode,
382 ios->power_mode, ios->chip_select, ios->vdd,
383 ios->bus_width, ios->timing);
384
385 host->ops->set_ios(host, ios);
386}
387
388static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
389{
390 int err;
391 struct mmc_command cmd;
392
393 BUG_ON(!host->claimed);
394
395 if (host->card_selected == card)
396 return MMC_ERR_NONE;
397
398 host->card_selected = card;
399
400 cmd.opcode = MMC_SELECT_CARD;
401 cmd.arg = card->rca << 16;
402 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
403
404 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
405 if (err != MMC_ERR_NONE)
406 return err;
407
408 /*
409 * We can only change the bus width of SD cards when
410 * they are selected so we have to put the handling
411 * here.
412 *
413 * The card is in 1 bit mode by default so
414 * we only need to change if it supports the
415 * wider version.
416 */
417 if (mmc_card_sd(card) &&
418 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
419
420 /*
421 * Default bus width is 1 bit.
422 */
423 host->ios.bus_width = MMC_BUS_WIDTH_1;
424
425 if (host->caps & MMC_CAP_4_BIT_DATA) {
426 struct mmc_command cmd;
427 cmd.opcode = SD_APP_SET_BUS_WIDTH;
428 cmd.arg = SD_BUS_WIDTH_4;
429 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
430
431 err = mmc_wait_for_app_cmd(host, card->rca, &cmd,
432 CMD_RETRIES);
433 if (err != MMC_ERR_NONE)
434 return err;
435
436 host->ios.bus_width = MMC_BUS_WIDTH_4;
437 }
438 }
439
440 mmc_set_ios(host);
441
442 return MMC_ERR_NONE;
443}
444
445/*
446 * Ensure that no card is selected.
447 */
448static void mmc_deselect_cards(struct mmc_host *host)
449{
450 struct mmc_command cmd;
451
452 if (host->card_selected) {
453 host->card_selected = NULL;
454
455 cmd.opcode = MMC_SELECT_CARD;
456 cmd.arg = 0;
457 cmd.flags = MMC_RSP_NONE | MMC_CMD_AC;
458
459 mmc_wait_for_cmd(host, &cmd, 0);
460 }
461}
462
463
464static inline void mmc_delay(unsigned int ms)
465{
466 if (ms < 1000 / HZ) {
467 cond_resched();
468 mdelay(ms);
469 } else {
470 msleep(ms);
471 }
472}
473
474/*
475 * Mask off any voltages we don't support and select
476 * the lowest voltage
477 */
478static u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
479{
480 int bit;
481
482 ocr &= host->ocr_avail;
483
484 bit = ffs(ocr);
485 if (bit) {
486 bit -= 1;
487
488 ocr &= 3 << bit;
489
490 host->ios.vdd = bit;
491 mmc_set_ios(host);
492 } else {
493 ocr = 0;
494 }
495
496 return ocr;
497}
498
499#define UNSTUFF_BITS(resp,start,size) \
500 ({ \
501 const int __size = size; \
502 const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \
503 const int __off = 3 - ((start) / 32); \
504 const int __shft = (start) & 31; \
505 u32 __res; \
506 \
507 __res = resp[__off] >> __shft; \
508 if (__size + __shft > 32) \
509 __res |= resp[__off-1] << ((32 - __shft) % 32); \
510 __res & __mask; \
511 })
512
513/*
514 * Given the decoded CSD structure, decode the raw CID to our CID structure.
515 */
516static void mmc_decode_cid(struct mmc_card *card)
517{
518 u32 *resp = card->raw_cid;
519
520 memset(&card->cid, 0, sizeof(struct mmc_cid));
521
522 if (mmc_card_sd(card)) {
523 /*
524 * SD doesn't currently have a version field so we will
525 * have to assume we can parse this.
526 */
527 card->cid.manfid = UNSTUFF_BITS(resp, 120, 8);
528 card->cid.oemid = UNSTUFF_BITS(resp, 104, 16);
529 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8);
530 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8);
531 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8);
532 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8);
533 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8);
534 card->cid.hwrev = UNSTUFF_BITS(resp, 60, 4);
535 card->cid.fwrev = UNSTUFF_BITS(resp, 56, 4);
536 card->cid.serial = UNSTUFF_BITS(resp, 24, 32);
537 card->cid.year = UNSTUFF_BITS(resp, 12, 8);
538 card->cid.month = UNSTUFF_BITS(resp, 8, 4);
539
540 card->cid.year += 2000; /* SD cards year offset */
541 } else {
542 /*
543 * The selection of the format here is based upon published
544 * specs from sandisk and from what people have reported.
545 */
546 switch (card->csd.mmca_vsn) {
547 case 0: /* MMC v1.0 - v1.2 */
548 case 1: /* MMC v1.4 */
549 card->cid.manfid = UNSTUFF_BITS(resp, 104, 24);
550 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8);
551 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8);
552 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8);
553 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8);
554 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8);
555 card->cid.prod_name[5] = UNSTUFF_BITS(resp, 56, 8);
556 card->cid.prod_name[6] = UNSTUFF_BITS(resp, 48, 8);
557 card->cid.hwrev = UNSTUFF_BITS(resp, 44, 4);
558 card->cid.fwrev = UNSTUFF_BITS(resp, 40, 4);
559 card->cid.serial = UNSTUFF_BITS(resp, 16, 24);
560 card->cid.month = UNSTUFF_BITS(resp, 12, 4);
561 card->cid.year = UNSTUFF_BITS(resp, 8, 4) + 1997;
562 break;
563
564 case 2: /* MMC v2.0 - v2.2 */
565 case 3: /* MMC v3.1 - v3.3 */
566 case 4: /* MMC v4 */
567 card->cid.manfid = UNSTUFF_BITS(resp, 120, 8);
568 card->cid.oemid = UNSTUFF_BITS(resp, 104, 16);
569 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8);
570 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8);
571 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8);
572 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8);
573 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8);
574 card->cid.prod_name[5] = UNSTUFF_BITS(resp, 56, 8);
575 card->cid.serial = UNSTUFF_BITS(resp, 16, 32);
576 card->cid.month = UNSTUFF_BITS(resp, 12, 4);
577 card->cid.year = UNSTUFF_BITS(resp, 8, 4) + 1997;
578 break;
579
580 default:
581 printk("%s: card has unknown MMCA version %d\n",
582 mmc_hostname(card->host), card->csd.mmca_vsn);
583 mmc_card_set_bad(card);
584 break;
585 }
586 }
587}
588
589/*
590 * Given a 128-bit response, decode to our card CSD structure.
591 */
592static void mmc_decode_csd(struct mmc_card *card)
593{
594 struct mmc_csd *csd = &card->csd;
595 unsigned int e, m, csd_struct;
596 u32 *resp = card->raw_csd;
597
598 if (mmc_card_sd(card)) {
599 csd_struct = UNSTUFF_BITS(resp, 126, 2);
600
601 switch (csd_struct) {
602 case 0:
603 m = UNSTUFF_BITS(resp, 115, 4);
604 e = UNSTUFF_BITS(resp, 112, 3);
605 csd->tacc_ns = (tacc_exp[e] * tacc_mant[m] + 9) / 10;
606 csd->tacc_clks = UNSTUFF_BITS(resp, 104, 8) * 100;
607
608 m = UNSTUFF_BITS(resp, 99, 4);
609 e = UNSTUFF_BITS(resp, 96, 3);
610 csd->max_dtr = tran_exp[e] * tran_mant[m];
611 csd->cmdclass = UNSTUFF_BITS(resp, 84, 12);
612
613 e = UNSTUFF_BITS(resp, 47, 3);
614 m = UNSTUFF_BITS(resp, 62, 12);
615 csd->capacity = (1 + m) << (e + 2);
616
617 csd->read_blkbits = UNSTUFF_BITS(resp, 80, 4);
618 csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
619 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
620 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
621 csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
622 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
623 csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
624 break;
625 case 1:
626 /*
627 * This is a block-addressed SDHC card. Most
628 * interesting fields are unused and have fixed
629 * values. To avoid getting tripped by buggy cards,
630 * we assume those fixed values ourselves.
631 */
632 mmc_card_set_blockaddr(card);
633
634 csd->tacc_ns = 0; /* Unused */
635 csd->tacc_clks = 0; /* Unused */
636
637 m = UNSTUFF_BITS(resp, 99, 4);
638 e = UNSTUFF_BITS(resp, 96, 3);
639 csd->max_dtr = tran_exp[e] * tran_mant[m];
640 csd->cmdclass = UNSTUFF_BITS(resp, 84, 12);
641
642 m = UNSTUFF_BITS(resp, 48, 22);
643 csd->capacity = (1 + m) << 10;
644
645 csd->read_blkbits = 9;
646 csd->read_partial = 0;
647 csd->write_misalign = 0;
648 csd->read_misalign = 0;
649 csd->r2w_factor = 4; /* Unused */
650 csd->write_blkbits = 9;
651 csd->write_partial = 0;
652 break;
653 default:
654 printk("%s: unrecognised CSD structure version %d\n",
655 mmc_hostname(card->host), csd_struct);
656 mmc_card_set_bad(card);
657 return;
658 }
659 } else {
660 /*
661 * We only understand CSD structure v1.1 and v1.2.
662 * v1.2 has extra information in bits 15, 11 and 10.
663 */
664 csd_struct = UNSTUFF_BITS(resp, 126, 2);
665 if (csd_struct != 1 && csd_struct != 2) {
666 printk("%s: unrecognised CSD structure version %d\n",
667 mmc_hostname(card->host), csd_struct);
668 mmc_card_set_bad(card);
669 return;
670 }
671
672 csd->mmca_vsn = UNSTUFF_BITS(resp, 122, 4);
673 m = UNSTUFF_BITS(resp, 115, 4);
674 e = UNSTUFF_BITS(resp, 112, 3);
675 csd->tacc_ns = (tacc_exp[e] * tacc_mant[m] + 9) / 10;
676 csd->tacc_clks = UNSTUFF_BITS(resp, 104, 8) * 100;
677
678 m = UNSTUFF_BITS(resp, 99, 4);
679 e = UNSTUFF_BITS(resp, 96, 3);
680 csd->max_dtr = tran_exp[e] * tran_mant[m];
681 csd->cmdclass = UNSTUFF_BITS(resp, 84, 12);
682
683 e = UNSTUFF_BITS(resp, 47, 3);
684 m = UNSTUFF_BITS(resp, 62, 12);
685 csd->capacity = (1 + m) << (e + 2);
686
687 csd->read_blkbits = UNSTUFF_BITS(resp, 80, 4);
688 csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
689 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
690 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
691 csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
692 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
693 csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
694 }
695}
696
697/*
698 * Given a 64-bit response, decode to our card SCR structure.
699 */
700static void mmc_decode_scr(struct mmc_card *card)
701{
702 struct sd_scr *scr = &card->scr;
703 unsigned int scr_struct;
704 u32 resp[4];
705
706 BUG_ON(!mmc_card_sd(card));
707
708 resp[3] = card->raw_scr[1];
709 resp[2] = card->raw_scr[0];
710
711 scr_struct = UNSTUFF_BITS(resp, 60, 4);
712 if (scr_struct != 0) {
713 printk("%s: unrecognised SCR structure version %d\n",
714 mmc_hostname(card->host), scr_struct);
715 mmc_card_set_bad(card);
716 return;
717 }
718
719 scr->sda_vsn = UNSTUFF_BITS(resp, 56, 4);
720 scr->bus_widths = UNSTUFF_BITS(resp, 48, 4);
721}
722
723/*
724 * Locate a MMC card on this MMC host given a raw CID.
725 */
726static struct mmc_card *mmc_find_card(struct mmc_host *host, u32 *raw_cid)
727{
728 struct mmc_card *card;
729
730 list_for_each_entry(card, &host->cards, node) {
731 if (memcmp(card->raw_cid, raw_cid, sizeof(card->raw_cid)) == 0)
732 return card;
733 }
734 return NULL;
735}
736
737/*
738 * Allocate a new MMC card, and assign a unique RCA.
739 */
740static struct mmc_card *
741mmc_alloc_card(struct mmc_host *host, u32 *raw_cid, unsigned int *frca)
742{
743 struct mmc_card *card, *c;
744 unsigned int rca = *frca;
745
746 card = kmalloc(sizeof(struct mmc_card), GFP_KERNEL);
747 if (!card)
748 return ERR_PTR(-ENOMEM);
749
750 mmc_init_card(card, host);
751 memcpy(card->raw_cid, raw_cid, sizeof(card->raw_cid));
752
753 again:
754 list_for_each_entry(c, &host->cards, node)
755 if (c->rca == rca) {
756 rca++;
757 goto again;
758 }
759
760 card->rca = rca;
761
762 *frca = rca;
763
764 return card;
765}
766
767/*
768 * Tell attached cards to go to IDLE state
769 */
770static void mmc_idle_cards(struct mmc_host *host)
771{
772 struct mmc_command cmd;
773
774 host->ios.chip_select = MMC_CS_HIGH;
775 mmc_set_ios(host);
776
777 mmc_delay(1);
778
779 cmd.opcode = MMC_GO_IDLE_STATE;
780 cmd.arg = 0;
781 cmd.flags = MMC_RSP_NONE | MMC_CMD_BC;
782
783 mmc_wait_for_cmd(host, &cmd, 0);
784
785 mmc_delay(1);
786
787 host->ios.chip_select = MMC_CS_DONTCARE;
788 mmc_set_ios(host);
789
790 mmc_delay(1);
791}
792
793/*
794 * Apply power to the MMC stack. This is a two-stage process.
795 * First, we enable power to the card without the clock running.
796 * We then wait a bit for the power to stabilise. Finally,
797 * enable the bus drivers and clock to the card.
798 *
799 * We must _NOT_ enable the clock prior to power stablising.
800 *
801 * If a host does all the power sequencing itself, ignore the
802 * initial MMC_POWER_UP stage.
803 */
804static void mmc_power_up(struct mmc_host *host)
805{
806 int bit = fls(host->ocr_avail) - 1;
807
808 host->ios.vdd = bit;
809 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
810 host->ios.chip_select = MMC_CS_DONTCARE;
811 host->ios.power_mode = MMC_POWER_UP;
812 host->ios.bus_width = MMC_BUS_WIDTH_1;
813 host->ios.timing = MMC_TIMING_LEGACY;
814 mmc_set_ios(host);
815
816 mmc_delay(1);
817
818 host->ios.clock = host->f_min;
819 host->ios.power_mode = MMC_POWER_ON;
820 mmc_set_ios(host);
821
822 mmc_delay(2);
823}
824
825static void mmc_power_off(struct mmc_host *host)
826{
827 host->ios.clock = 0;
828 host->ios.vdd = 0;
829 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
830 host->ios.chip_select = MMC_CS_DONTCARE;
831 host->ios.power_mode = MMC_POWER_OFF;
832 host->ios.bus_width = MMC_BUS_WIDTH_1;
833 host->ios.timing = MMC_TIMING_LEGACY;
834 mmc_set_ios(host);
835}
836
837static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
838{
839 struct mmc_command cmd;
840 int i, err = 0;
841
842 cmd.opcode = MMC_SEND_OP_COND;
843 cmd.arg = ocr;
844 cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
845
846 for (i = 100; i; i--) {
847 err = mmc_wait_for_cmd(host, &cmd, 0);
848 if (err != MMC_ERR_NONE)
849 break;
850
851 if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0)
852 break;
853
854 err = MMC_ERR_TIMEOUT;
855
856 mmc_delay(10);
857 }
858
859 if (rocr)
860 *rocr = cmd.resp[0];
861
862 return err;
863}
864
865static int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
866{
867 struct mmc_command cmd;
868 int i, err = 0;
869
870 cmd.opcode = SD_APP_OP_COND;
871 cmd.arg = ocr;
872 cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
873
874 for (i = 100; i; i--) {
875 err = mmc_wait_for_app_cmd(host, 0, &cmd, CMD_RETRIES);
876 if (err != MMC_ERR_NONE)
877 break;
878
879 if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0)
880 break;
881
882 err = MMC_ERR_TIMEOUT;
883
884 mmc_delay(10);
885 }
886
887 if (rocr)
888 *rocr = cmd.resp[0];
889
890 return err;
891}
892
893static int mmc_send_if_cond(struct mmc_host *host, u32 ocr, int *rsd2)
894{
895 struct mmc_command cmd;
896 int err, sd2;
897 static const u8 test_pattern = 0xAA;
898
899 /*
900 * To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND
901 * before SD_APP_OP_COND. This command will harmlessly fail for
902 * SD 1.0 cards.
903 */
904 cmd.opcode = SD_SEND_IF_COND;
905 cmd.arg = ((ocr & 0xFF8000) != 0) << 8 | test_pattern;
906 cmd.flags = MMC_RSP_R7 | MMC_CMD_BCR;
907
908 err = mmc_wait_for_cmd(host, &cmd, 0);
909 if (err == MMC_ERR_NONE) {
910 if ((cmd.resp[0] & 0xFF) == test_pattern) {
911 sd2 = 1;
912 } else {
913 sd2 = 0;
914 err = MMC_ERR_FAILED;
915 }
916 } else {
917 /*
918 * Treat errors as SD 1.0 card.
919 */
920 sd2 = 0;
921 err = MMC_ERR_NONE;
922 }
923 if (rsd2)
924 *rsd2 = sd2;
925 return err;
926}
927
928/*
929 * Discover cards by requesting their CID. If this command
930 * times out, it is not an error; there are no further cards
931 * to be discovered. Add new cards to the list.
932 *
933 * Create a mmc_card entry for each discovered card, assigning
934 * it an RCA, and save the raw CID for decoding later.
935 */
936static void mmc_discover_cards(struct mmc_host *host)
937{
938 struct mmc_card *card;
939 unsigned int first_rca = 1, err;
940
941 while (1) {
942 struct mmc_command cmd;
943
944 cmd.opcode = MMC_ALL_SEND_CID;
945 cmd.arg = 0;
946 cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
947
948 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
949 if (err == MMC_ERR_TIMEOUT) {
950 err = MMC_ERR_NONE;
951 break;
952 }
953 if (err != MMC_ERR_NONE) {
954 printk(KERN_ERR "%s: error requesting CID: %d\n",
955 mmc_hostname(host), err);
956 break;
957 }
958
959 card = mmc_find_card(host, cmd.resp);
960 if (!card) {
961 card = mmc_alloc_card(host, cmd.resp, &first_rca);
962 if (IS_ERR(card)) {
963 err = PTR_ERR(card);
964 break;
965 }
966 list_add(&card->node, &host->cards);
967 }
968
969 card->state &= ~MMC_STATE_DEAD;
970
971 if (host->mode == MMC_MODE_SD) {
972 mmc_card_set_sd(card);
973
974 cmd.opcode = SD_SEND_RELATIVE_ADDR;
975 cmd.arg = 0;
976 cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
977
978 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
979 if (err != MMC_ERR_NONE)
980 mmc_card_set_dead(card);
981 else {
982 card->rca = cmd.resp[0] >> 16;
983
984 if (!host->ops->get_ro) {
985 printk(KERN_WARNING "%s: host does not "
986 "support reading read-only "
987 "switch. assuming write-enable.\n",
988 mmc_hostname(host));
989 } else {
990 if (host->ops->get_ro(host))
991 mmc_card_set_readonly(card);
992 }
993 }
994 } else {
995 cmd.opcode = MMC_SET_RELATIVE_ADDR;
996 cmd.arg = card->rca << 16;
997 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
998
999 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1000 if (err != MMC_ERR_NONE)
1001 mmc_card_set_dead(card);
1002 }
1003 }
1004}
1005
1006static void mmc_read_csds(struct mmc_host *host)
1007{
1008 struct mmc_card *card;
1009
1010 list_for_each_entry(card, &host->cards, node) {
1011 struct mmc_command cmd;
1012 int err;
1013
1014 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
1015 continue;
1016
1017 cmd.opcode = MMC_SEND_CSD;
1018 cmd.arg = card->rca << 16;
1019 cmd.flags = MMC_RSP_R2 | MMC_CMD_AC;
1020
1021 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1022 if (err != MMC_ERR_NONE) {
1023 mmc_card_set_dead(card);
1024 continue;
1025 }
1026
1027 memcpy(card->raw_csd, cmd.resp, sizeof(card->raw_csd));
1028
1029 mmc_decode_csd(card);
1030 mmc_decode_cid(card);
1031 }
1032}
1033
1034static void mmc_process_ext_csds(struct mmc_host *host)
1035{
1036 int err;
1037 struct mmc_card *card;
1038
1039 struct mmc_request mrq;
1040 struct mmc_command cmd;
1041 struct mmc_data data;
1042
1043 struct scatterlist sg;
1044
1045 /*
1046 * As the ext_csd is so large and mostly unused, we don't store the
1047 * raw block in mmc_card.
1048 */
1049 u8 *ext_csd;
1050 ext_csd = kmalloc(512, GFP_KERNEL);
1051 if (!ext_csd) {
1052 printk("%s: could not allocate a buffer to receive the ext_csd."
1053 "mmc v4 cards will be treated as v3.\n",
1054 mmc_hostname(host));
1055 return;
1056 }
1057
1058 list_for_each_entry(card, &host->cards, node) {
1059 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
1060 continue;
1061 if (mmc_card_sd(card))
1062 continue;
1063 if (card->csd.mmca_vsn < CSD_SPEC_VER_4)
1064 continue;
1065
1066 err = mmc_select_card(host, card);
1067 if (err != MMC_ERR_NONE) {
1068 mmc_card_set_dead(card);
1069 continue;
1070 }
1071
1072 memset(&cmd, 0, sizeof(struct mmc_command));
1073
1074 cmd.opcode = MMC_SEND_EXT_CSD;
1075 cmd.arg = 0;
1076 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1077
1078 memset(&data, 0, sizeof(struct mmc_data));
1079
1080 mmc_set_data_timeout(&data, card, 0);
1081
1082 data.blksz = 512;
1083 data.blocks = 1;
1084 data.flags = MMC_DATA_READ;
1085 data.sg = &sg;
1086 data.sg_len = 1;
1087
1088 memset(&mrq, 0, sizeof(struct mmc_request));
1089
1090 mrq.cmd = &cmd;
1091 mrq.data = &data;
1092
1093 sg_init_one(&sg, ext_csd, 512);
1094
1095 mmc_wait_for_req(host, &mrq);
1096
1097 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1098 printk("%s: unable to read EXT_CSD, performance "
1099 "might suffer.\n", mmc_hostname(card->host));
1100 continue;
1101 }
1102
1103 switch (ext_csd[EXT_CSD_CARD_TYPE]) {
1104 case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26:
1105 card->ext_csd.hs_max_dtr = 52000000;
1106 break;
1107 case EXT_CSD_CARD_TYPE_26:
1108 card->ext_csd.hs_max_dtr = 26000000;
1109 break;
1110 default:
1111 /* MMC v4 spec says this cannot happen */
1112 printk("%s: card is mmc v4 but doesn't support "
1113 "any high-speed modes.\n",
1114 mmc_hostname(card->host));
1115 continue;
1116 }
1117
1118 if (host->caps & MMC_CAP_MMC_HIGHSPEED) {
1119 /* Activate highspeed support. */
1120 cmd.opcode = MMC_SWITCH;
1121 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1122 (EXT_CSD_HS_TIMING << 16) |
1123 (1 << 8) |
1124 EXT_CSD_CMD_SET_NORMAL;
1125 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1126
1127 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1128 if (err != MMC_ERR_NONE) {
1129 printk("%s: failed to switch card to mmc v4 "
1130 "high-speed mode.\n",
1131 mmc_hostname(card->host));
1132 continue;
1133 }
1134
1135 mmc_card_set_highspeed(card);
1136
1137 host->ios.timing = MMC_TIMING_SD_HS;
1138 mmc_set_ios(host);
1139 }
1140
1141 /* Check for host support for wide-bus modes. */
1142 if (host->caps & MMC_CAP_4_BIT_DATA) {
1143 /* Activate 4-bit support. */
1144 cmd.opcode = MMC_SWITCH;
1145 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1146 (EXT_CSD_BUS_WIDTH << 16) |
1147 (EXT_CSD_BUS_WIDTH_4 << 8) |
1148 EXT_CSD_CMD_SET_NORMAL;
1149 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1150
1151 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1152 if (err != MMC_ERR_NONE) {
1153 printk("%s: failed to switch card to "
1154 "mmc v4 4-bit bus mode.\n",
1155 mmc_hostname(card->host));
1156 continue;
1157 }
1158
1159 host->ios.bus_width = MMC_BUS_WIDTH_4;
1160 mmc_set_ios(host);
1161 }
1162 }
1163
1164 kfree(ext_csd);
1165
1166 mmc_deselect_cards(host);
1167}
1168
1169static void mmc_read_scrs(struct mmc_host *host)
1170{
1171 int err;
1172 struct mmc_card *card;
1173 struct mmc_request mrq;
1174 struct mmc_command cmd;
1175 struct mmc_data data;
1176 struct scatterlist sg;
1177
1178 list_for_each_entry(card, &host->cards, node) {
1179 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
1180 continue;
1181 if (!mmc_card_sd(card))
1182 continue;
1183
1184 err = mmc_select_card(host, card);
1185 if (err != MMC_ERR_NONE) {
1186 mmc_card_set_dead(card);
1187 continue;
1188 }
1189
1190 memset(&cmd, 0, sizeof(struct mmc_command));
1191
1192 cmd.opcode = MMC_APP_CMD;
1193 cmd.arg = card->rca << 16;
1194 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
1195
1196 err = mmc_wait_for_cmd(host, &cmd, 0);
1197 if ((err != MMC_ERR_NONE) || !(cmd.resp[0] & R1_APP_CMD)) {
1198 mmc_card_set_dead(card);
1199 continue;
1200 }
1201
1202 memset(&cmd, 0, sizeof(struct mmc_command));
1203
1204 cmd.opcode = SD_APP_SEND_SCR;
1205 cmd.arg = 0;
1206 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1207
1208 memset(&data, 0, sizeof(struct mmc_data));
1209
1210 mmc_set_data_timeout(&data, card, 0);
1211
1212 data.blksz = 1 << 3;
1213 data.blocks = 1;
1214 data.flags = MMC_DATA_READ;
1215 data.sg = &sg;
1216 data.sg_len = 1;
1217
1218 memset(&mrq, 0, sizeof(struct mmc_request));
1219
1220 mrq.cmd = &cmd;
1221 mrq.data = &data;
1222
1223 sg_init_one(&sg, (u8*)card->raw_scr, 8);
1224
1225 mmc_wait_for_req(host, &mrq);
1226
1227 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1228 mmc_card_set_dead(card);
1229 continue;
1230 }
1231
1232 card->raw_scr[0] = ntohl(card->raw_scr[0]);
1233 card->raw_scr[1] = ntohl(card->raw_scr[1]);
1234
1235 mmc_decode_scr(card);
1236 }
1237
1238 mmc_deselect_cards(host);
1239}
1240
1241static void mmc_read_switch_caps(struct mmc_host *host)
1242{
1243 int err;
1244 struct mmc_card *card;
1245 struct mmc_request mrq;
1246 struct mmc_command cmd;
1247 struct mmc_data data;
1248 unsigned char *status;
1249 struct scatterlist sg;
1250
1251 if (!(host->caps & MMC_CAP_SD_HIGHSPEED))
1252 return;
1253
1254 status = kmalloc(64, GFP_KERNEL);
1255 if (!status) {
1256 printk(KERN_WARNING "%s: Unable to allocate buffer for "
1257 "reading switch capabilities.\n",
1258 mmc_hostname(host));
1259 return;
1260 }
1261
1262 list_for_each_entry(card, &host->cards, node) {
1263 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
1264 continue;
1265 if (!mmc_card_sd(card))
1266 continue;
1267 if (card->scr.sda_vsn < SCR_SPEC_VER_1)
1268 continue;
1269
1270 err = mmc_select_card(host, card);
1271 if (err != MMC_ERR_NONE) {
1272 mmc_card_set_dead(card);
1273 continue;
1274 }
1275
1276 memset(&cmd, 0, sizeof(struct mmc_command));
1277
1278 cmd.opcode = SD_SWITCH;
1279 cmd.arg = 0x00FFFFF1;
1280 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1281
1282 memset(&data, 0, sizeof(struct mmc_data));
1283
1284 mmc_set_data_timeout(&data, card, 0);
1285
1286 data.blksz = 64;
1287 data.blocks = 1;
1288 data.flags = MMC_DATA_READ;
1289 data.sg = &sg;
1290 data.sg_len = 1;
1291
1292 memset(&mrq, 0, sizeof(struct mmc_request));
1293
1294 mrq.cmd = &cmd;
1295 mrq.data = &data;
1296
1297 sg_init_one(&sg, status, 64);
1298
1299 mmc_wait_for_req(host, &mrq);
1300
1301 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1302 printk("%s: unable to read switch capabilities, "
1303 "performance might suffer.\n",
1304 mmc_hostname(card->host));
1305 continue;
1306 }
1307
1308 if (status[13] & 0x02)
1309 card->sw_caps.hs_max_dtr = 50000000;
1310
1311 memset(&cmd, 0, sizeof(struct mmc_command));
1312
1313 cmd.opcode = SD_SWITCH;
1314 cmd.arg = 0x80FFFFF1;
1315 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1316
1317 memset(&data, 0, sizeof(struct mmc_data));
1318
1319 mmc_set_data_timeout(&data, card, 0);
1320
1321 data.blksz = 64;
1322 data.blocks = 1;
1323 data.flags = MMC_DATA_READ;
1324 data.sg = &sg;
1325 data.sg_len = 1;
1326
1327 memset(&mrq, 0, sizeof(struct mmc_request));
1328
1329 mrq.cmd = &cmd;
1330 mrq.data = &data;
1331
1332 sg_init_one(&sg, status, 64);
1333
1334 mmc_wait_for_req(host, &mrq);
1335
1336 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE ||
1337 (status[16] & 0xF) != 1) {
1338 printk(KERN_WARNING "%s: Problem switching card "
1339 "into high-speed mode!\n",
1340 mmc_hostname(host));
1341 continue;
1342 }
1343
1344 mmc_card_set_highspeed(card);
1345
1346 host->ios.timing = MMC_TIMING_SD_HS;
1347 mmc_set_ios(host);
1348 }
1349
1350 kfree(status);
1351
1352 mmc_deselect_cards(host);
1353}
1354
1355static unsigned int mmc_calculate_clock(struct mmc_host *host)
1356{
1357 struct mmc_card *card;
1358 unsigned int max_dtr = host->f_max;
1359
1360 list_for_each_entry(card, &host->cards, node)
1361 if (!mmc_card_dead(card)) {
1362 if (mmc_card_highspeed(card) && mmc_card_sd(card)) {
1363 if (max_dtr > card->sw_caps.hs_max_dtr)
1364 max_dtr = card->sw_caps.hs_max_dtr;
1365 } else if (mmc_card_highspeed(card) && !mmc_card_sd(card)) {
1366 if (max_dtr > card->ext_csd.hs_max_dtr)
1367 max_dtr = card->ext_csd.hs_max_dtr;
1368 } else if (max_dtr > card->csd.max_dtr) {
1369 max_dtr = card->csd.max_dtr;
1370 }
1371 }
1372
1373 pr_debug("%s: selected %d.%03dMHz transfer rate\n",
1374 mmc_hostname(host),
1375 max_dtr / 1000000, (max_dtr / 1000) % 1000);
1376
1377 return max_dtr;
1378}
1379
1380/*
1381 * Check whether cards we already know about are still present.
1382 * We do this by requesting status, and checking whether a card
1383 * responds.
1384 *
1385 * A request for status does not cause a state change in data
1386 * transfer mode.
1387 */
1388static void mmc_check_cards(struct mmc_host *host)
1389{
1390 struct list_head *l, *n;
1391
1392 mmc_deselect_cards(host);
1393
1394 list_for_each_safe(l, n, &host->cards) {
1395 struct mmc_card *card = mmc_list_to_card(l);
1396 struct mmc_command cmd;
1397 int err;
1398
1399 cmd.opcode = MMC_SEND_STATUS;
1400 cmd.arg = card->rca << 16;
1401 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
1402
1403 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1404 if (err == MMC_ERR_NONE)
1405 continue;
1406
1407 mmc_card_set_dead(card);
1408 }
1409}
1410
1411static void mmc_setup(struct mmc_host *host)
1412{
1413 if (host->ios.power_mode != MMC_POWER_ON) {
1414 int err;
1415 u32 ocr;
1416
1417 host->mode = MMC_MODE_SD;
1418
1419 mmc_power_up(host);
1420 mmc_idle_cards(host);
1421
1422 err = mmc_send_if_cond(host, host->ocr_avail, NULL);
1423 if (err != MMC_ERR_NONE) {
1424 return;
1425 }
1426 err = mmc_send_app_op_cond(host, 0, &ocr);
1427
1428 /*
1429 * If we fail to detect any SD cards then try
1430 * searching for MMC cards.
1431 */
1432 if (err != MMC_ERR_NONE) {
1433 host->mode = MMC_MODE_MMC;
1434
1435 err = mmc_send_op_cond(host, 0, &ocr);
1436 if (err != MMC_ERR_NONE)
1437 return;
1438 }
1439
1440 host->ocr = mmc_select_voltage(host, ocr);
1441
1442 /*
1443 * Since we're changing the OCR value, we seem to
1444 * need to tell some cards to go back to the idle
1445 * state. We wait 1ms to give cards time to
1446 * respond.
1447 */
1448 if (host->ocr)
1449 mmc_idle_cards(host);
1450 } else {
1451 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
1452 host->ios.clock = host->f_min;
1453 mmc_set_ios(host);
1454
1455 /*
1456 * We should remember the OCR mask from the existing
1457 * cards, and detect the new cards OCR mask, combine
1458 * the two and re-select the VDD. However, if we do
1459 * change VDD, we should do an idle, and then do a
1460 * full re-initialisation. We would need to notify
1461 * drivers so that they can re-setup the cards as
1462 * well, while keeping their queues at bay.
1463 *
1464 * For the moment, we take the easy way out - if the
1465 * new cards don't like our currently selected VDD,
1466 * they drop off the bus.
1467 */
1468 }
1469
1470 if (host->ocr == 0)
1471 return;
1472
1473 /*
1474 * Send the selected OCR multiple times... until the cards
1475 * all get the idea that they should be ready for CMD2.
1476 * (My SanDisk card seems to need this.)
1477 */
1478 if (host->mode == MMC_MODE_SD) {
1479 int err, sd2;
1480 err = mmc_send_if_cond(host, host->ocr, &sd2);
1481 if (err == MMC_ERR_NONE) {
1482 /*
1483 * If SD_SEND_IF_COND indicates an SD 2.0
1484 * compliant card and we should set bit 30
1485 * of the ocr to indicate that we can handle
1486 * block-addressed SDHC cards.
1487 */
1488 mmc_send_app_op_cond(host, host->ocr | (sd2 << 30), NULL);
1489 }
1490 } else {
1491 mmc_send_op_cond(host, host->ocr, NULL);
1492 }
1493
1494 mmc_discover_cards(host);
1495
1496 /*
1497 * Ok, now switch to push-pull mode.
1498 */
1499 host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
1500 mmc_set_ios(host);
1501
1502 mmc_read_csds(host);
1503
1504 if (host->mode == MMC_MODE_SD) {
1505 mmc_read_scrs(host);
1506 mmc_read_switch_caps(host);
1507 } else
1508 mmc_process_ext_csds(host);
1509}
1510
1511
1512/**
1513 * mmc_detect_change - process change of state on a MMC socket
1514 * @host: host which changed state.
1515 * @delay: optional delay to wait before detection (jiffies)
1516 *
1517 * All we know is that card(s) have been inserted or removed
1518 * from the socket(s). We don't know which socket or cards.
1519 */
1520void mmc_detect_change(struct mmc_host *host, unsigned long delay)
1521{
1522 mmc_schedule_delayed_work(&host->detect, delay);
1523}
1524
1525EXPORT_SYMBOL(mmc_detect_change);
1526
1527
1528static void mmc_rescan(struct work_struct *work)
1529{
1530 struct mmc_host *host =
1531 container_of(work, struct mmc_host, detect.work);
1532 struct list_head *l, *n;
1533 unsigned char power_mode;
1534
1535 mmc_claim_host(host);
1536
1537 /*
1538 * Check for removed cards and newly inserted ones. We check for
1539 * removed cards first so we can intelligently re-select the VDD.
1540 */
1541 power_mode = host->ios.power_mode;
1542 if (power_mode == MMC_POWER_ON)
1543 mmc_check_cards(host);
1544
1545 mmc_setup(host);
1546
1547 /*
1548 * Some broken cards process CMD1 even in stand-by state. There is
1549 * no reply, but an ILLEGAL_COMMAND error is cached and returned
1550 * after next command. We poll for card status here to clear any
1551 * possibly pending error.
1552 */
1553 if (power_mode == MMC_POWER_ON)
1554 mmc_check_cards(host);
1555
1556 if (!list_empty(&host->cards)) {
1557 /*
1558 * (Re-)calculate the fastest clock rate which the
1559 * attached cards and the host support.
1560 */
1561 host->ios.clock = mmc_calculate_clock(host);
1562 mmc_set_ios(host);
1563 }
1564
1565 mmc_release_host(host);
1566
1567 list_for_each_safe(l, n, &host->cards) {
1568 struct mmc_card *card = mmc_list_to_card(l);
1569
1570 /*
1571 * If this is a new and good card, register it.
1572 */
1573 if (!mmc_card_present(card) && !mmc_card_dead(card)) {
1574 if (mmc_register_card(card))
1575 mmc_card_set_dead(card);
1576 else
1577 mmc_card_set_present(card);
1578 }
1579
1580 /*
1581 * If this card is dead, destroy it.
1582 */
1583 if (mmc_card_dead(card)) {
1584 list_del(&card->node);
1585 mmc_remove_card(card);
1586 }
1587 }
1588
1589 /*
1590 * If we discover that there are no cards on the
1591 * bus, turn off the clock and power down.
1592 */
1593 if (list_empty(&host->cards))
1594 mmc_power_off(host);
1595}
1596
1597
1598/**
1599 * mmc_alloc_host - initialise the per-host structure.
1600 * @extra: sizeof private data structure
1601 * @dev: pointer to host device model structure
1602 *
1603 * Initialise the per-host structure.
1604 */
1605struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
1606{
1607 struct mmc_host *host;
1608
1609 host = mmc_alloc_host_sysfs(extra, dev);
1610 if (host) {
1611 spin_lock_init(&host->lock);
1612 init_waitqueue_head(&host->wq);
1613 INIT_LIST_HEAD(&host->cards);
1614 INIT_DELAYED_WORK(&host->detect, mmc_rescan);
1615
1616 /*
1617 * By default, hosts do not support SGIO or large requests.
1618 * They have to set these according to their abilities.
1619 */
1620 host->max_hw_segs = 1;
1621 host->max_phys_segs = 1;
1622 host->max_seg_size = PAGE_CACHE_SIZE;
1623
1624 host->max_req_size = PAGE_CACHE_SIZE;
1625 host->max_blk_size = 512;
1626 host->max_blk_count = PAGE_CACHE_SIZE / 512;
1627 }
1628
1629 return host;
1630}
1631
1632EXPORT_SYMBOL(mmc_alloc_host);
1633
1634/**
1635 * mmc_add_host - initialise host hardware
1636 * @host: mmc host
1637 */
1638int mmc_add_host(struct mmc_host *host)
1639{
1640 int ret;
1641
1642 ret = mmc_add_host_sysfs(host);
1643 if (ret == 0) {
1644 mmc_power_off(host);
1645 mmc_detect_change(host, 0);
1646 }
1647
1648 return ret;
1649}
1650
1651EXPORT_SYMBOL(mmc_add_host);
1652
1653/**
1654 * mmc_remove_host - remove host hardware
1655 * @host: mmc host
1656 *
1657 * Unregister and remove all cards associated with this host,
1658 * and power down the MMC bus.
1659 */
1660void mmc_remove_host(struct mmc_host *host)
1661{
1662 struct list_head *l, *n;
1663
1664 list_for_each_safe(l, n, &host->cards) {
1665 struct mmc_card *card = mmc_list_to_card(l);
1666
1667 mmc_remove_card(card);
1668 }
1669
1670 mmc_power_off(host);
1671 mmc_remove_host_sysfs(host);
1672}
1673
1674EXPORT_SYMBOL(mmc_remove_host);
1675
1676/**
1677 * mmc_free_host - free the host structure
1678 * @host: mmc host
1679 *
1680 * Free the host once all references to it have been dropped.
1681 */
1682void mmc_free_host(struct mmc_host *host)
1683{
1684 mmc_flush_scheduled_work();
1685 mmc_free_host_sysfs(host);
1686}
1687
1688EXPORT_SYMBOL(mmc_free_host);
1689
1690#ifdef CONFIG_PM
1691
1692/**
1693 * mmc_suspend_host - suspend a host
1694 * @host: mmc host
1695 * @state: suspend mode (PM_SUSPEND_xxx)
1696 */
1697int mmc_suspend_host(struct mmc_host *host, pm_message_t state)
1698{
1699 mmc_claim_host(host);
1700 mmc_deselect_cards(host);
1701 mmc_power_off(host);
1702 mmc_release_host(host);
1703
1704 return 0;
1705}
1706
1707EXPORT_SYMBOL(mmc_suspend_host);
1708
1709/**
1710 * mmc_resume_host - resume a previously suspended host
1711 * @host: mmc host
1712 */
1713int mmc_resume_host(struct mmc_host *host)
1714{
1715 mmc_rescan(&host->detect.work);
1716
1717 return 0;
1718}
1719
1720EXPORT_SYMBOL(mmc_resume_host);
1721
1722#endif
1723
1724MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
deleted file mode 100644
index 0581d09c58fc..000000000000
--- a/drivers/mmc/tifm_sd.c
+++ /dev/null
@@ -1,987 +0,0 @@
1/*
2 * tifm_sd.c - TI FlashMedia driver
3 *
4 * Copyright (C) 2006 Alex Dubov <oakad@yahoo.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12
13#include <linux/tifm.h>
14#include <linux/mmc/protocol.h>
15#include <linux/mmc/host.h>
16#include <linux/highmem.h>
17#include <asm/io.h>
18
19#define DRIVER_NAME "tifm_sd"
20#define DRIVER_VERSION "0.7"
21
22static int no_dma = 0;
23static int fixed_timeout = 0;
24module_param(no_dma, bool, 0644);
25module_param(fixed_timeout, bool, 0644);
26
27/* Constants here are mostly from OMAP5912 datasheet */
28#define TIFM_MMCSD_RESET 0x0002
29#define TIFM_MMCSD_CLKMASK 0x03ff
30#define TIFM_MMCSD_POWER 0x0800
31#define TIFM_MMCSD_4BBUS 0x8000
32#define TIFM_MMCSD_RXDE 0x8000 /* rx dma enable */
33#define TIFM_MMCSD_TXDE 0x0080 /* tx dma enable */
34#define TIFM_MMCSD_BUFINT 0x0c00 /* set bits: AE, AF */
35#define TIFM_MMCSD_DPE 0x0020 /* data timeout counted in kilocycles */
36#define TIFM_MMCSD_INAB 0x0080 /* abort / initialize command */
37#define TIFM_MMCSD_READ 0x8000
38
39#define TIFM_MMCSD_DATAMASK 0x401d /* set bits: CERR, EOFB, BRS, CB, EOC */
40#define TIFM_MMCSD_ERRMASK 0x01e0 /* set bits: CCRC, CTO, DCRC, DTO */
41#define TIFM_MMCSD_EOC 0x0001 /* end of command phase */
42#define TIFM_MMCSD_CB 0x0004 /* card enter busy state */
43#define TIFM_MMCSD_BRS 0x0008 /* block received/sent */
44#define TIFM_MMCSD_EOFB 0x0010 /* card exit busy state */
45#define TIFM_MMCSD_DTO 0x0020 /* data time-out */
46#define TIFM_MMCSD_DCRC 0x0040 /* data crc error */
47#define TIFM_MMCSD_CTO 0x0080 /* command time-out */
48#define TIFM_MMCSD_CCRC 0x0100 /* command crc error */
49#define TIFM_MMCSD_AF 0x0400 /* fifo almost full */
50#define TIFM_MMCSD_AE 0x0800 /* fifo almost empty */
51#define TIFM_MMCSD_CERR 0x4000 /* card status error */
52
53#define TIFM_MMCSD_FIFO_SIZE 0x0020
54
55#define TIFM_MMCSD_RSP_R0 0x0000
56#define TIFM_MMCSD_RSP_R1 0x0100
57#define TIFM_MMCSD_RSP_R2 0x0200
58#define TIFM_MMCSD_RSP_R3 0x0300
59#define TIFM_MMCSD_RSP_R4 0x0400
60#define TIFM_MMCSD_RSP_R5 0x0500
61#define TIFM_MMCSD_RSP_R6 0x0600
62
63#define TIFM_MMCSD_RSP_BUSY 0x0800
64
65#define TIFM_MMCSD_CMD_BC 0x0000
66#define TIFM_MMCSD_CMD_BCR 0x1000
67#define TIFM_MMCSD_CMD_AC 0x2000
68#define TIFM_MMCSD_CMD_ADTC 0x3000
69
70typedef enum {
71 IDLE = 0,
72 CMD, /* main command ended */
73 BRS, /* block transfer finished */
74 SCMD, /* stop command ended */
75 CARD, /* card left busy state */
76 FIFO, /* FIFO operation completed (uncertain) */
77 READY
78} card_state_t;
79
80enum {
81 FIFO_RDY = 0x0001, /* hardware dependent value */
82 EJECT = 0x0004,
83 EJECT_DONE = 0x0008,
84 CARD_BUSY = 0x0010,
85 OPENDRAIN = 0x0040, /* hardware dependent value */
86 CARD_EVENT = 0x0100, /* hardware dependent value */
87 CARD_RO = 0x0200, /* hardware dependent value */
88 FIFO_EVENT = 0x10000 }; /* hardware dependent value */
89
90struct tifm_sd {
91 struct tifm_dev *dev;
92
93 unsigned int flags;
94 card_state_t state;
95 unsigned int clk_freq;
96 unsigned int clk_div;
97 unsigned long timeout_jiffies;
98
99 struct tasklet_struct finish_tasklet;
100 struct timer_list timer;
101 struct mmc_request *req;
102 wait_queue_head_t notify;
103
104 size_t written_blocks;
105 size_t buffer_size;
106 size_t buffer_pos;
107
108};
109
110static char* tifm_sd_data_buffer(struct mmc_data *data)
111{
112 return page_address(data->sg->page) + data->sg->offset;
113}
114
115static int tifm_sd_transfer_data(struct tifm_dev *sock, struct tifm_sd *host,
116 unsigned int host_status)
117{
118 struct mmc_command *cmd = host->req->cmd;
119 unsigned int t_val = 0, cnt = 0;
120 char *buffer;
121
122 if (host_status & TIFM_MMCSD_BRS) {
123 /* in non-dma rx mode BRS fires when fifo is still not empty */
124 if (no_dma && (cmd->data->flags & MMC_DATA_READ)) {
125 buffer = tifm_sd_data_buffer(host->req->data);
126 while (host->buffer_size > host->buffer_pos) {
127 t_val = readl(sock->addr + SOCK_MMCSD_DATA);
128 buffer[host->buffer_pos++] = t_val & 0xff;
129 buffer[host->buffer_pos++] =
130 (t_val >> 8) & 0xff;
131 }
132 }
133 return 1;
134 } else if (no_dma) {
135 buffer = tifm_sd_data_buffer(host->req->data);
136 if ((cmd->data->flags & MMC_DATA_READ) &&
137 (host_status & TIFM_MMCSD_AF)) {
138 for (cnt = 0; cnt < TIFM_MMCSD_FIFO_SIZE; cnt++) {
139 t_val = readl(sock->addr + SOCK_MMCSD_DATA);
140 if (host->buffer_size > host->buffer_pos) {
141 buffer[host->buffer_pos++] =
142 t_val & 0xff;
143 buffer[host->buffer_pos++] =
144 (t_val >> 8) & 0xff;
145 }
146 }
147 } else if ((cmd->data->flags & MMC_DATA_WRITE)
148 && (host_status & TIFM_MMCSD_AE)) {
149 for (cnt = 0; cnt < TIFM_MMCSD_FIFO_SIZE; cnt++) {
150 if (host->buffer_size > host->buffer_pos) {
151 t_val = buffer[host->buffer_pos++]
152 & 0x00ff;
153 t_val |= ((buffer[host->buffer_pos++])
154 << 8) & 0xff00;
155 writel(t_val,
156 sock->addr + SOCK_MMCSD_DATA);
157 }
158 }
159 }
160 }
161 return 0;
162}
163
164static unsigned int tifm_sd_op_flags(struct mmc_command *cmd)
165{
166 unsigned int rc = 0;
167
168 switch (mmc_resp_type(cmd)) {
169 case MMC_RSP_NONE:
170 rc |= TIFM_MMCSD_RSP_R0;
171 break;
172 case MMC_RSP_R1B:
173 rc |= TIFM_MMCSD_RSP_BUSY; // deliberate fall-through
174 case MMC_RSP_R1:
175 rc |= TIFM_MMCSD_RSP_R1;
176 break;
177 case MMC_RSP_R2:
178 rc |= TIFM_MMCSD_RSP_R2;
179 break;
180 case MMC_RSP_R3:
181 rc |= TIFM_MMCSD_RSP_R3;
182 break;
183 default:
184 BUG();
185 }
186
187 switch (mmc_cmd_type(cmd)) {
188 case MMC_CMD_BC:
189 rc |= TIFM_MMCSD_CMD_BC;
190 break;
191 case MMC_CMD_BCR:
192 rc |= TIFM_MMCSD_CMD_BCR;
193 break;
194 case MMC_CMD_AC:
195 rc |= TIFM_MMCSD_CMD_AC;
196 break;
197 case MMC_CMD_ADTC:
198 rc |= TIFM_MMCSD_CMD_ADTC;
199 break;
200 default:
201 BUG();
202 }
203 return rc;
204}
205
206static void tifm_sd_exec(struct tifm_sd *host, struct mmc_command *cmd)
207{
208 struct tifm_dev *sock = host->dev;
209 unsigned int cmd_mask = tifm_sd_op_flags(cmd) |
210 (host->flags & OPENDRAIN);
211
212 if (cmd->data && (cmd->data->flags & MMC_DATA_READ))
213 cmd_mask |= TIFM_MMCSD_READ;
214
215 dev_dbg(&sock->dev, "executing opcode 0x%x, arg: 0x%x, mask: 0x%x\n",
216 cmd->opcode, cmd->arg, cmd_mask);
217
218 writel((cmd->arg >> 16) & 0xffff, sock->addr + SOCK_MMCSD_ARG_HIGH);
219 writel(cmd->arg & 0xffff, sock->addr + SOCK_MMCSD_ARG_LOW);
220 writel(cmd->opcode | cmd_mask, sock->addr + SOCK_MMCSD_COMMAND);
221}
222
223static void tifm_sd_fetch_resp(struct mmc_command *cmd, struct tifm_dev *sock)
224{
225 cmd->resp[0] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x1c) << 16)
226 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x18);
227 cmd->resp[1] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x14) << 16)
228 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x10);
229 cmd->resp[2] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x0c) << 16)
230 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x08);
231 cmd->resp[3] = (readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x04) << 16)
232 | readl(sock->addr + SOCK_MMCSD_RESPONSE + 0x00);
233}
234
235static void tifm_sd_process_cmd(struct tifm_dev *sock, struct tifm_sd *host,
236 unsigned int host_status)
237{
238 struct mmc_command *cmd = host->req->cmd;
239
240change_state:
241 switch (host->state) {
242 case IDLE:
243 return;
244 case CMD:
245 if (host_status & (TIFM_MMCSD_EOC | TIFM_MMCSD_CERR)) {
246 tifm_sd_fetch_resp(cmd, sock);
247 if (cmd->data) {
248 host->state = BRS;
249 } else {
250 host->state = READY;
251 }
252 goto change_state;
253 }
254 break;
255 case BRS:
256 if (tifm_sd_transfer_data(sock, host, host_status)) {
257 if (cmd->data->flags & MMC_DATA_WRITE) {
258 host->state = CARD;
259 } else {
260 if (no_dma) {
261 if (host->req->stop) {
262 tifm_sd_exec(host, host->req->stop);
263 host->state = SCMD;
264 } else {
265 host->state = READY;
266 }
267 } else {
268 host->state = FIFO;
269 }
270 }
271 goto change_state;
272 }
273 break;
274 case SCMD:
275 if (host_status & TIFM_MMCSD_EOC) {
276 tifm_sd_fetch_resp(host->req->stop, sock);
277 host->state = READY;
278 goto change_state;
279 }
280 break;
281 case CARD:
282 dev_dbg(&sock->dev, "waiting for CARD, have %zd blocks\n",
283 host->written_blocks);
284 if (!(host->flags & CARD_BUSY)
285 && (host->written_blocks == cmd->data->blocks)) {
286 if (no_dma) {
287 if (host->req->stop) {
288 tifm_sd_exec(host, host->req->stop);
289 host->state = SCMD;
290 } else {
291 host->state = READY;
292 }
293 } else {
294 host->state = FIFO;
295 }
296 goto change_state;
297 }
298 break;
299 case FIFO:
300 if (host->flags & FIFO_RDY) {
301 host->flags &= ~FIFO_RDY;
302 if (host->req->stop) {
303 tifm_sd_exec(host, host->req->stop);
304 host->state = SCMD;
305 } else {
306 host->state = READY;
307 }
308 goto change_state;
309 }
310 break;
311 case READY:
312 tasklet_schedule(&host->finish_tasklet);
313 return;
314 }
315
316}
317
318/* Called from interrupt handler */
319static void tifm_sd_signal_irq(struct tifm_dev *sock,
320 unsigned int sock_irq_status)
321{
322 struct tifm_sd *host;
323 unsigned int host_status = 0, fifo_status = 0;
324 int error_code = 0;
325
326 spin_lock(&sock->lock);
327 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
328
329 if (sock_irq_status & FIFO_EVENT) {
330 fifo_status = readl(sock->addr + SOCK_DMA_FIFO_STATUS);
331 writel(fifo_status, sock->addr + SOCK_DMA_FIFO_STATUS);
332
333 host->flags |= fifo_status & FIFO_RDY;
334 }
335
336 if (sock_irq_status & CARD_EVENT) {
337 host_status = readl(sock->addr + SOCK_MMCSD_STATUS);
338 writel(host_status, sock->addr + SOCK_MMCSD_STATUS);
339
340 if (!host->req)
341 goto done;
342
343 if (host_status & TIFM_MMCSD_ERRMASK) {
344 if (host_status & (TIFM_MMCSD_CTO | TIFM_MMCSD_DTO))
345 error_code = MMC_ERR_TIMEOUT;
346 else if (host_status
347 & (TIFM_MMCSD_CCRC | TIFM_MMCSD_DCRC))
348 error_code = MMC_ERR_BADCRC;
349
350 writel(TIFM_FIFO_INT_SETALL,
351 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
352 writel(TIFM_DMA_RESET, sock->addr + SOCK_DMA_CONTROL);
353
354 if (host->req->stop) {
355 if (host->state == SCMD) {
356 host->req->stop->error = error_code;
357 } else if (host->state == BRS
358 || host->state == CARD
359 || host->state == FIFO) {
360 host->req->cmd->error = error_code;
361 tifm_sd_exec(host, host->req->stop);
362 host->state = SCMD;
363 goto done;
364 } else {
365 host->req->cmd->error = error_code;
366 }
367 } else {
368 host->req->cmd->error = error_code;
369 }
370 host->state = READY;
371 }
372
373 if (host_status & TIFM_MMCSD_CB)
374 host->flags |= CARD_BUSY;
375 if ((host_status & TIFM_MMCSD_EOFB)
376 && (host->flags & CARD_BUSY)) {
377 host->written_blocks++;
378 host->flags &= ~CARD_BUSY;
379 }
380 }
381
382 if (host->req)
383 tifm_sd_process_cmd(sock, host, host_status);
384done:
385 dev_dbg(&sock->dev, "host_status %x, fifo_status %x\n",
386 host_status, fifo_status);
387 spin_unlock(&sock->lock);
388}
389
390static void tifm_sd_prepare_data(struct tifm_sd *host, struct mmc_command *cmd)
391{
392 struct tifm_dev *sock = host->dev;
393 unsigned int dest_cnt;
394
395 /* DMA style IO */
396 dev_dbg(&sock->dev, "setting dma for %d blocks\n",
397 cmd->data->blocks);
398 writel(TIFM_FIFO_INT_SETALL,
399 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
400 writel(ilog2(cmd->data->blksz) - 2,
401 sock->addr + SOCK_FIFO_PAGE_SIZE);
402 writel(TIFM_FIFO_ENABLE, sock->addr + SOCK_FIFO_CONTROL);
403 writel(TIFM_FIFO_INTMASK, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
404
405 dest_cnt = (cmd->data->blocks) << 8;
406
407 writel(sg_dma_address(cmd->data->sg), sock->addr + SOCK_DMA_ADDRESS);
408
409 writel(cmd->data->blocks - 1, sock->addr + SOCK_MMCSD_NUM_BLOCKS);
410 writel(cmd->data->blksz - 1, sock->addr + SOCK_MMCSD_BLOCK_LEN);
411
412 if (cmd->data->flags & MMC_DATA_WRITE) {
413 writel(TIFM_MMCSD_TXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
414 writel(dest_cnt | TIFM_DMA_TX | TIFM_DMA_EN,
415 sock->addr + SOCK_DMA_CONTROL);
416 } else {
417 writel(TIFM_MMCSD_RXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
418 writel(dest_cnt | TIFM_DMA_EN, sock->addr + SOCK_DMA_CONTROL);
419 }
420}
421
422static void tifm_sd_set_data_timeout(struct tifm_sd *host,
423 struct mmc_data *data)
424{
425 struct tifm_dev *sock = host->dev;
426 unsigned int data_timeout = data->timeout_clks;
427
428 if (fixed_timeout)
429 return;
430
431 data_timeout += data->timeout_ns /
432 ((1000000000UL / host->clk_freq) * host->clk_div);
433
434 if (data_timeout < 0xffff) {
435 writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
436 writel((~TIFM_MMCSD_DPE)
437 & readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
438 sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
439 } else {
440 data_timeout = (data_timeout >> 10) + 1;
441 if (data_timeout > 0xffff)
442 data_timeout = 0; /* set to unlimited */
443 writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
444 writel(TIFM_MMCSD_DPE
445 | readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
446 sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
447 }
448}
449
450static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
451{
452 struct tifm_sd *host = mmc_priv(mmc);
453 struct tifm_dev *sock = host->dev;
454 unsigned long flags;
455 int sg_count = 0;
456 struct mmc_data *r_data = mrq->cmd->data;
457
458 spin_lock_irqsave(&sock->lock, flags);
459 if (host->flags & EJECT) {
460 spin_unlock_irqrestore(&sock->lock, flags);
461 goto err_out;
462 }
463
464 if (host->req) {
465 printk(KERN_ERR DRIVER_NAME ": unfinished request detected\n");
466 spin_unlock_irqrestore(&sock->lock, flags);
467 goto err_out;
468 }
469
470 if (r_data) {
471 tifm_sd_set_data_timeout(host, r_data);
472
473 sg_count = tifm_map_sg(sock, r_data->sg, r_data->sg_len,
474 mrq->cmd->flags & MMC_DATA_WRITE
475 ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
476 if (sg_count != 1) {
477 printk(KERN_ERR DRIVER_NAME
478 ": scatterlist map failed\n");
479 spin_unlock_irqrestore(&sock->lock, flags);
480 goto err_out;
481 }
482
483 host->written_blocks = 0;
484 host->flags &= ~CARD_BUSY;
485 tifm_sd_prepare_data(host, mrq->cmd);
486 }
487
488 host->req = mrq;
489 mod_timer(&host->timer, jiffies + host->timeout_jiffies);
490 host->state = CMD;
491 writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL),
492 sock->addr + SOCK_CONTROL);
493 tifm_sd_exec(host, mrq->cmd);
494 spin_unlock_irqrestore(&sock->lock, flags);
495 return;
496
497err_out:
498 if (sg_count > 0)
499 tifm_unmap_sg(sock, r_data->sg, r_data->sg_len,
500 (r_data->flags & MMC_DATA_WRITE)
501 ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
502
503 mrq->cmd->error = MMC_ERR_TIMEOUT;
504 mmc_request_done(mmc, mrq);
505}
506
507static void tifm_sd_end_cmd(unsigned long data)
508{
509 struct tifm_sd *host = (struct tifm_sd*)data;
510 struct tifm_dev *sock = host->dev;
511 struct mmc_host *mmc = tifm_get_drvdata(sock);
512 struct mmc_request *mrq;
513 struct mmc_data *r_data = NULL;
514 unsigned long flags;
515
516 spin_lock_irqsave(&sock->lock, flags);
517
518 del_timer(&host->timer);
519 mrq = host->req;
520 host->req = NULL;
521 host->state = IDLE;
522
523 if (!mrq) {
524 printk(KERN_ERR DRIVER_NAME ": no request to complete?\n");
525 spin_unlock_irqrestore(&sock->lock, flags);
526 return;
527 }
528
529 r_data = mrq->cmd->data;
530 if (r_data) {
531 if (r_data->flags & MMC_DATA_WRITE) {
532 r_data->bytes_xfered = host->written_blocks
533 * r_data->blksz;
534 } else {
535 r_data->bytes_xfered = r_data->blocks -
536 readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1;
537 r_data->bytes_xfered *= r_data->blksz;
538 r_data->bytes_xfered += r_data->blksz -
539 readl(sock->addr + SOCK_MMCSD_BLOCK_LEN) + 1;
540 }
541 tifm_unmap_sg(sock, r_data->sg, r_data->sg_len,
542 (r_data->flags & MMC_DATA_WRITE)
543 ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
544 }
545
546 writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
547 sock->addr + SOCK_CONTROL);
548
549 spin_unlock_irqrestore(&sock->lock, flags);
550 mmc_request_done(mmc, mrq);
551}
552
553static void tifm_sd_request_nodma(struct mmc_host *mmc, struct mmc_request *mrq)
554{
555 struct tifm_sd *host = mmc_priv(mmc);
556 struct tifm_dev *sock = host->dev;
557 unsigned long flags;
558 struct mmc_data *r_data = mrq->cmd->data;
559
560 spin_lock_irqsave(&sock->lock, flags);
561 if (host->flags & EJECT) {
562 spin_unlock_irqrestore(&sock->lock, flags);
563 goto err_out;
564 }
565
566 if (host->req) {
567 printk(KERN_ERR DRIVER_NAME ": unfinished request detected\n");
568 spin_unlock_irqrestore(&sock->lock, flags);
569 goto err_out;
570 }
571
572 if (r_data) {
573 tifm_sd_set_data_timeout(host, r_data);
574
575 host->buffer_size = mrq->cmd->data->blocks
576 * mrq->cmd->data->blksz;
577
578 writel(TIFM_MMCSD_BUFINT
579 | readl(sock->addr + SOCK_MMCSD_INT_ENABLE),
580 sock->addr + SOCK_MMCSD_INT_ENABLE);
581 writel(((TIFM_MMCSD_FIFO_SIZE - 1) << 8)
582 | (TIFM_MMCSD_FIFO_SIZE - 1),
583 sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
584
585 host->written_blocks = 0;
586 host->flags &= ~CARD_BUSY;
587 host->buffer_pos = 0;
588 writel(r_data->blocks - 1, sock->addr + SOCK_MMCSD_NUM_BLOCKS);
589 writel(r_data->blksz - 1, sock->addr + SOCK_MMCSD_BLOCK_LEN);
590 }
591
592 host->req = mrq;
593 mod_timer(&host->timer, jiffies + host->timeout_jiffies);
594 host->state = CMD;
595 writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL),
596 sock->addr + SOCK_CONTROL);
597 tifm_sd_exec(host, mrq->cmd);
598 spin_unlock_irqrestore(&sock->lock, flags);
599 return;
600
601err_out:
602 mrq->cmd->error = MMC_ERR_TIMEOUT;
603 mmc_request_done(mmc, mrq);
604}
605
606static void tifm_sd_end_cmd_nodma(unsigned long data)
607{
608 struct tifm_sd *host = (struct tifm_sd*)data;
609 struct tifm_dev *sock = host->dev;
610 struct mmc_host *mmc = tifm_get_drvdata(sock);
611 struct mmc_request *mrq;
612 struct mmc_data *r_data = NULL;
613 unsigned long flags;
614
615 spin_lock_irqsave(&sock->lock, flags);
616
617 del_timer(&host->timer);
618 mrq = host->req;
619 host->req = NULL;
620 host->state = IDLE;
621
622 if (!mrq) {
623 printk(KERN_ERR DRIVER_NAME ": no request to complete?\n");
624 spin_unlock_irqrestore(&sock->lock, flags);
625 return;
626 }
627
628 r_data = mrq->cmd->data;
629 if (r_data) {
630 writel((~TIFM_MMCSD_BUFINT) &
631 readl(sock->addr + SOCK_MMCSD_INT_ENABLE),
632 sock->addr + SOCK_MMCSD_INT_ENABLE);
633
634 if (r_data->flags & MMC_DATA_WRITE) {
635 r_data->bytes_xfered = host->written_blocks
636 * r_data->blksz;
637 } else {
638 r_data->bytes_xfered = r_data->blocks -
639 readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1;
640 r_data->bytes_xfered *= r_data->blksz;
641 r_data->bytes_xfered += r_data->blksz -
642 readl(sock->addr + SOCK_MMCSD_BLOCK_LEN) + 1;
643 }
644 host->buffer_pos = 0;
645 host->buffer_size = 0;
646 }
647
648 writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
649 sock->addr + SOCK_CONTROL);
650
651 spin_unlock_irqrestore(&sock->lock, flags);
652
653 mmc_request_done(mmc, mrq);
654}
655
656static void tifm_sd_terminate(struct tifm_sd *host)
657{
658 struct tifm_dev *sock = host->dev;
659 unsigned long flags;
660
661 writel(0, sock->addr + SOCK_MMCSD_INT_ENABLE);
662 mmiowb();
663 spin_lock_irqsave(&sock->lock, flags);
664 host->flags |= EJECT;
665 if (host->req) {
666 writel(TIFM_FIFO_INT_SETALL,
667 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
668 writel(0, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
669 tasklet_schedule(&host->finish_tasklet);
670 }
671 spin_unlock_irqrestore(&sock->lock, flags);
672}
673
674static void tifm_sd_abort(unsigned long data)
675{
676 struct tifm_sd *host = (struct tifm_sd*)data;
677
678 printk(KERN_ERR DRIVER_NAME
679 ": card failed to respond for a long period of time");
680
681 tifm_sd_terminate(host);
682 tifm_eject(host->dev);
683}
684
685static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
686{
687 struct tifm_sd *host = mmc_priv(mmc);
688 struct tifm_dev *sock = host->dev;
689 unsigned int clk_div1, clk_div2;
690 unsigned long flags;
691
692 spin_lock_irqsave(&sock->lock, flags);
693
694 dev_dbg(&sock->dev, "Setting bus width %d, power %d\n", ios->bus_width,
695 ios->power_mode);
696 if (ios->bus_width == MMC_BUS_WIDTH_4) {
697 writel(TIFM_MMCSD_4BBUS | readl(sock->addr + SOCK_MMCSD_CONFIG),
698 sock->addr + SOCK_MMCSD_CONFIG);
699 } else {
700 writel((~TIFM_MMCSD_4BBUS)
701 & readl(sock->addr + SOCK_MMCSD_CONFIG),
702 sock->addr + SOCK_MMCSD_CONFIG);
703 }
704
705 if (ios->clock) {
706 clk_div1 = 20000000 / ios->clock;
707 if (!clk_div1)
708 clk_div1 = 1;
709
710 clk_div2 = 24000000 / ios->clock;
711 if (!clk_div2)
712 clk_div2 = 1;
713
714 if ((20000000 / clk_div1) > ios->clock)
715 clk_div1++;
716 if ((24000000 / clk_div2) > ios->clock)
717 clk_div2++;
718 if ((20000000 / clk_div1) > (24000000 / clk_div2)) {
719 host->clk_freq = 20000000;
720 host->clk_div = clk_div1;
721 writel((~TIFM_CTRL_FAST_CLK)
722 & readl(sock->addr + SOCK_CONTROL),
723 sock->addr + SOCK_CONTROL);
724 } else {
725 host->clk_freq = 24000000;
726 host->clk_div = clk_div2;
727 writel(TIFM_CTRL_FAST_CLK
728 | readl(sock->addr + SOCK_CONTROL),
729 sock->addr + SOCK_CONTROL);
730 }
731 } else {
732 host->clk_div = 0;
733 }
734 host->clk_div &= TIFM_MMCSD_CLKMASK;
735 writel(host->clk_div
736 | ((~TIFM_MMCSD_CLKMASK)
737 & readl(sock->addr + SOCK_MMCSD_CONFIG)),
738 sock->addr + SOCK_MMCSD_CONFIG);
739
740 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
741 host->flags |= OPENDRAIN;
742 else
743 host->flags &= ~OPENDRAIN;
744
745 /* chip_select : maybe later */
746 //vdd
747 //power is set before probe / after remove
748 //I believe, power_off when already marked for eject is sufficient to
749 // allow removal.
750 if ((host->flags & EJECT) && ios->power_mode == MMC_POWER_OFF) {
751 host->flags |= EJECT_DONE;
752 wake_up_all(&host->notify);
753 }
754
755 spin_unlock_irqrestore(&sock->lock, flags);
756}
757
758static int tifm_sd_ro(struct mmc_host *mmc)
759{
760 int rc;
761 struct tifm_sd *host = mmc_priv(mmc);
762 struct tifm_dev *sock = host->dev;
763 unsigned long flags;
764
765 spin_lock_irqsave(&sock->lock, flags);
766
767 host->flags |= (CARD_RO & readl(sock->addr + SOCK_PRESENT_STATE));
768 rc = (host->flags & CARD_RO) ? 1 : 0;
769
770 spin_unlock_irqrestore(&sock->lock, flags);
771 return rc;
772}
773
774static struct mmc_host_ops tifm_sd_ops = {
775 .request = tifm_sd_request,
776 .set_ios = tifm_sd_ios,
777 .get_ro = tifm_sd_ro
778};
779
780static int tifm_sd_initialize_host(struct tifm_sd *host)
781{
782 int rc;
783 unsigned int host_status = 0;
784 struct tifm_dev *sock = host->dev;
785
786 writel(0, sock->addr + SOCK_MMCSD_INT_ENABLE);
787 mmiowb();
788 host->clk_div = 61;
789 host->clk_freq = 20000000;
790 writel(TIFM_MMCSD_RESET, sock->addr + SOCK_MMCSD_SYSTEM_CONTROL);
791 writel(host->clk_div | TIFM_MMCSD_POWER,
792 sock->addr + SOCK_MMCSD_CONFIG);
793
794 /* wait up to 0.51 sec for reset */
795 for (rc = 2; rc <= 256; rc <<= 1) {
796 if (1 & readl(sock->addr + SOCK_MMCSD_SYSTEM_STATUS)) {
797 rc = 0;
798 break;
799 }
800 msleep(rc);
801 }
802
803 if (rc) {
804 printk(KERN_ERR DRIVER_NAME
805 ": controller failed to reset\n");
806 return -ENODEV;
807 }
808
809 writel(0, sock->addr + SOCK_MMCSD_NUM_BLOCKS);
810 writel(host->clk_div | TIFM_MMCSD_POWER,
811 sock->addr + SOCK_MMCSD_CONFIG);
812 writel(TIFM_MMCSD_RXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
813
814 // command timeout fixed to 64 clocks for now
815 writel(64, sock->addr + SOCK_MMCSD_COMMAND_TO);
816 writel(TIFM_MMCSD_INAB, sock->addr + SOCK_MMCSD_COMMAND);
817
818 /* INAB should take much less than reset */
819 for (rc = 1; rc <= 16; rc <<= 1) {
820 host_status = readl(sock->addr + SOCK_MMCSD_STATUS);
821 writel(host_status, sock->addr + SOCK_MMCSD_STATUS);
822 if (!(host_status & TIFM_MMCSD_ERRMASK)
823 && (host_status & TIFM_MMCSD_EOC)) {
824 rc = 0;
825 break;
826 }
827 msleep(rc);
828 }
829
830 if (rc) {
831 printk(KERN_ERR DRIVER_NAME
832 ": card not ready - probe failed on initialization\n");
833 return -ENODEV;
834 }
835
836 writel(TIFM_MMCSD_DATAMASK | TIFM_MMCSD_ERRMASK,
837 sock->addr + SOCK_MMCSD_INT_ENABLE);
838 mmiowb();
839
840 return 0;
841}
842
843static int tifm_sd_probe(struct tifm_dev *sock)
844{
845 struct mmc_host *mmc;
846 struct tifm_sd *host;
847 int rc = -EIO;
848
849 if (!(TIFM_SOCK_STATE_OCCUPIED
850 & readl(sock->addr + SOCK_PRESENT_STATE))) {
851 printk(KERN_WARNING DRIVER_NAME ": card gone, unexpectedly\n");
852 return rc;
853 }
854
855 mmc = mmc_alloc_host(sizeof(struct tifm_sd), &sock->dev);
856 if (!mmc)
857 return -ENOMEM;
858
859 host = mmc_priv(mmc);
860 tifm_set_drvdata(sock, mmc);
861 host->dev = sock;
862 host->timeout_jiffies = msecs_to_jiffies(1000);
863
864 init_waitqueue_head(&host->notify);
865 tasklet_init(&host->finish_tasklet,
866 no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd,
867 (unsigned long)host);
868 setup_timer(&host->timer, tifm_sd_abort, (unsigned long)host);
869
870 tifm_sd_ops.request = no_dma ? tifm_sd_request_nodma : tifm_sd_request;
871 mmc->ops = &tifm_sd_ops;
872 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
873 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE;
874 mmc->f_min = 20000000 / 60;
875 mmc->f_max = 24000000;
876 mmc->max_hw_segs = 1;
877 mmc->max_phys_segs = 1;
878 // limited by DMA counter - it's safer to stick with
879 // block counter has 11 bits though
880 mmc->max_blk_count = 256;
881 // 2k maximum hw block length
882 mmc->max_blk_size = 2048;
883 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
884 mmc->max_seg_size = mmc->max_req_size;
885 sock->signal_irq = tifm_sd_signal_irq;
886 rc = tifm_sd_initialize_host(host);
887
888 if (!rc)
889 rc = mmc_add_host(mmc);
890 if (rc)
891 goto out_free_mmc;
892
893 return 0;
894out_free_mmc:
895 mmc_free_host(mmc);
896 return rc;
897}
898
899static void tifm_sd_remove(struct tifm_dev *sock)
900{
901 struct mmc_host *mmc = tifm_get_drvdata(sock);
902 struct tifm_sd *host = mmc_priv(mmc);
903
904 del_timer_sync(&host->timer);
905 tifm_sd_terminate(host);
906 wait_event_timeout(host->notify, host->flags & EJECT_DONE,
907 host->timeout_jiffies);
908 tasklet_kill(&host->finish_tasklet);
909 mmc_remove_host(mmc);
910
911 /* The meaning of the bit majority in this constant is unknown. */
912 writel(0xfff8 & readl(sock->addr + SOCK_CONTROL),
913 sock->addr + SOCK_CONTROL);
914
915 tifm_set_drvdata(sock, NULL);
916 mmc_free_host(mmc);
917}
918
919#ifdef CONFIG_PM
920
921static int tifm_sd_suspend(struct tifm_dev *sock, pm_message_t state)
922{
923 struct mmc_host *mmc = tifm_get_drvdata(sock);
924 int rc;
925
926 rc = mmc_suspend_host(mmc, state);
927 /* The meaning of the bit majority in this constant is unknown. */
928 writel(0xfff8 & readl(sock->addr + SOCK_CONTROL),
929 sock->addr + SOCK_CONTROL);
930 return rc;
931}
932
933static int tifm_sd_resume(struct tifm_dev *sock)
934{
935 struct mmc_host *mmc = tifm_get_drvdata(sock);
936 struct tifm_sd *host = mmc_priv(mmc);
937
938 if (sock->media_id != FM_SD
939 || tifm_sd_initialize_host(host)) {
940 tifm_eject(sock);
941 return 0;
942 } else {
943 return mmc_resume_host(mmc);
944 }
945}
946
947#else
948
949#define tifm_sd_suspend NULL
950#define tifm_sd_resume NULL
951
952#endif /* CONFIG_PM */
953
954static tifm_media_id tifm_sd_id_tbl[] = {
955 FM_SD, 0
956};
957
958static struct tifm_driver tifm_sd_driver = {
959 .driver = {
960 .name = DRIVER_NAME,
961 .owner = THIS_MODULE
962 },
963 .id_table = tifm_sd_id_tbl,
964 .probe = tifm_sd_probe,
965 .remove = tifm_sd_remove,
966 .suspend = tifm_sd_suspend,
967 .resume = tifm_sd_resume
968};
969
970static int __init tifm_sd_init(void)
971{
972 return tifm_register_driver(&tifm_sd_driver);
973}
974
975static void __exit tifm_sd_exit(void)
976{
977 tifm_unregister_driver(&tifm_sd_driver);
978}
979
980MODULE_AUTHOR("Alex Dubov");
981MODULE_DESCRIPTION("TI FlashMedia SD driver");
982MODULE_LICENSE("GPL");
983MODULE_DEVICE_TABLE(tifm, tifm_sd_id_tbl);
984MODULE_VERSION(DRIVER_VERSION);
985
986module_init(tifm_sd_init);
987module_exit(tifm_sd_exit);
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
index 8a0c4dec6351..c73e96bfafc6 100644
--- a/drivers/mtd/devices/doc2000.c
+++ b/drivers/mtd/devices/doc2000.c
@@ -13,7 +13,6 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <linux/miscdevice.h> 15#include <linux/miscdevice.h>
16#include <linux/pci.h>
17#include <linux/delay.h> 16#include <linux/delay.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include <linux/sched.h> 18#include <linux/sched.h>
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 6f368aec5d5d..6413efc045e0 100644
--- a/drivers/mtd/devices/doc2001.c
+++ b/drivers/mtd/devices/doc2001.c
@@ -13,7 +13,6 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <linux/miscdevice.h> 15#include <linux/miscdevice.h>
16#include <linux/pci.h>
17#include <linux/delay.h> 16#include <linux/delay.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include <linux/init.h> 18#include <linux/init.h>
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
index 88ba82df0fbb..2b30b587c6e8 100644
--- a/drivers/mtd/devices/doc2001plus.c
+++ b/drivers/mtd/devices/doc2001plus.c
@@ -17,7 +17,6 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/pci.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/init.h> 22#include <linux/init.h>
diff --git a/drivers/mtd/devices/docecc.c b/drivers/mtd/devices/docecc.c
index 52b5d638077f..fd8a8daba3a8 100644
--- a/drivers/mtd/devices/docecc.c
+++ b/drivers/mtd/devices/docecc.c
@@ -29,7 +29,6 @@
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/uaccess.h> 30#include <asm/uaccess.h>
31#include <linux/miscdevice.h> 31#include <linux/miscdevice.h>
32#include <linux/pci.h>
33#include <linux/delay.h> 32#include <linux/delay.h>
34#include <linux/slab.h> 33#include <linux/slab.h>
35#include <linux/init.h> 34#include <linux/init.h>
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index acf3ba223298..ecac0e438f49 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -31,7 +31,6 @@
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
34#include <linux/pci.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/init.h> 36#include <linux/init.h>
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
index 8296305c8297..89deff007116 100644
--- a/drivers/mtd/nand/cs553x_nand.c
+++ b/drivers/mtd/nand/cs553x_nand.c
@@ -20,7 +20,6 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/pci.h>
24#include <linux/mtd/mtd.h> 23#include <linux/mtd/mtd.h>
25#include <linux/mtd/nand.h> 24#include <linux/mtd/nand.h>
26#include <linux/mtd/nand_ecc.h> 25#include <linux/mtd/nand_ecc.h>
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index e6ef7d7f9f14..0c9ce19ea27a 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -17,7 +17,6 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/pci.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/init.h> 22#include <linux/init.h>
diff --git a/drivers/net/7990.c b/drivers/net/7990.c
index d396f996af57..0877fc372f4b 100644
--- a/drivers/net/7990.c
+++ b/drivers/net/7990.c
@@ -565,9 +565,9 @@ int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
565 ib->btx_ring [entry].length = (-len) | 0xf000; 565 ib->btx_ring [entry].length = (-len) | 0xf000;
566 ib->btx_ring [entry].misc = 0; 566 ib->btx_ring [entry].misc = 0;
567 567
568 if (skb->len < ETH_ZLEN) 568 if (skb->len < ETH_ZLEN)
569 memset((char *)&ib->tx_buf[entry][0], 0, ETH_ZLEN); 569 memset((void *)&ib->tx_buf[entry][0], 0, ETH_ZLEN);
570 skb_copy_from_linear_data(skb, &ib->tx_buf[entry][0], skblen); 570 skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen);
571 571
572 /* Now, give the packet to the lance */ 572 /* Now, give the packet to the lance */
573 ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN); 573 ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index dcdad217df51..69dba62e0bad 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -311,7 +311,7 @@ config MAC8390
311 311
312config MAC89x0 312config MAC89x0
313 tristate "Macintosh CS89x0 based ethernet cards" 313 tristate "Macintosh CS89x0 based ethernet cards"
314 depends on NET_ETHERNET && MAC && BROKEN 314 depends on NET_ETHERNET && MAC
315 ---help--- 315 ---help---
316 Support for CS89x0 chipset based Ethernet cards. If you have a 316 Support for CS89x0 chipset based Ethernet cards. If you have a
317 Nubus or LC-PDS network (Ethernet) card of this type, say Y and 317 Nubus or LC-PDS network (Ethernet) card of this type, say Y and
@@ -337,8 +337,8 @@ config MACSONIC
337 be called macsonic. 337 be called macsonic.
338 338
339config MACMACE 339config MACMACE
340 bool "Macintosh (AV) onboard MACE ethernet (EXPERIMENTAL)" 340 bool "Macintosh (AV) onboard MACE ethernet"
341 depends on NET_ETHERNET && MAC && EXPERIMENTAL 341 depends on NET_ETHERNET && MAC
342 select CRC32 342 select CRC32
343 help 343 help
344 Support for the onboard AMD 79C940 MACE Ethernet controller used in 344 Support for the onboard AMD 79C940 MACE Ethernet controller used in
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index dd8ed456c8b2..1c3e293fbaf7 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -83,7 +83,6 @@ extern struct net_device *bagetlance_probe(int unit);
83extern struct net_device *mvme147lance_probe(int unit); 83extern struct net_device *mvme147lance_probe(int unit);
84extern struct net_device *tc515_probe(int unit); 84extern struct net_device *tc515_probe(int unit);
85extern struct net_device *lance_probe(int unit); 85extern struct net_device *lance_probe(int unit);
86extern struct net_device *mace_probe(int unit);
87extern struct net_device *mac8390_probe(int unit); 86extern struct net_device *mac8390_probe(int unit);
88extern struct net_device *mac89x0_probe(int unit); 87extern struct net_device *mac89x0_probe(int unit);
89extern struct net_device *mc32_probe(int unit); 88extern struct net_device *mc32_probe(int unit);
@@ -274,9 +273,6 @@ static struct devprobe2 m68k_probes[] __initdata = {
274#ifdef CONFIG_MVME147_NET /* MVME147 internal Ethernet */ 273#ifdef CONFIG_MVME147_NET /* MVME147 internal Ethernet */
275 {mvme147lance_probe, 0}, 274 {mvme147lance_probe, 0},
276#endif 275#endif
277#ifdef CONFIG_MACMACE /* Mac 68k Quadra AV builtin Ethernet */
278 {mace_probe, 0},
279#endif
280#ifdef CONFIG_MAC8390 /* NuBus NS8390-based cards */ 276#ifdef CONFIG_MAC8390 /* NuBus NS8390-based cards */
281 {mac8390_probe, 0}, 277 {mac8390_probe, 0},
282#endif 278#endif
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index 1226cbba0450..81d5a374042a 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -562,7 +562,6 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
562 volatile struct lance_init_block *ib = lp->init_block; 562 volatile struct lance_init_block *ib = lp->init_block;
563 int entry, skblen, len; 563 int entry, skblen, len;
564 int status = 0; 564 int status = 0;
565 static int outs;
566 unsigned long flags; 565 unsigned long flags;
567 566
568 skblen = skb->len; 567 skblen = skb->len;
@@ -598,17 +597,16 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
598 ib->btx_ring [entry].length = (-len) | 0xf000; 597 ib->btx_ring [entry].length = (-len) | 0xf000;
599 ib->btx_ring [entry].misc = 0; 598 ib->btx_ring [entry].misc = 0;
600 599
601 skb_copy_from_linear_data(skb, &ib->tx_buf [entry][0], skblen); 600 skb_copy_from_linear_data(skb, (void *)&ib->tx_buf [entry][0], skblen);
602 601
603 /* Clear the slack of the packet, do I need this? */ 602 /* Clear the slack of the packet, do I need this? */
604 if (len != skblen) 603 if (len != skblen)
605 memset ((char *) &ib->tx_buf [entry][skblen], 0, len - skblen); 604 memset ((void *) &ib->tx_buf [entry][skblen], 0, len - skblen);
606 605
607 /* Now, give the packet to the lance */ 606 /* Now, give the packet to the lance */
608 ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN); 607 ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN);
609 lp->tx_new = (lp->tx_new+1) & lp->tx_ring_mod_mask; 608 lp->tx_new = (lp->tx_new+1) & lp->tx_ring_mod_mask;
610 609 lp->stats.tx_bytes += skblen;
611 outs++;
612 610
613 if (TX_BUFFS_AVAIL <= 0) 611 if (TX_BUFFS_AVAIL <= 0)
614 netif_stop_queue(dev); 612 netif_stop_queue(dev);
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c
index a0e68e718531..a241ae7855a3 100644
--- a/drivers/net/ariadne.c
+++ b/drivers/net/ariadne.c
@@ -677,6 +677,7 @@ static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev)
677 priv->cur_tx -= TX_RING_SIZE; 677 priv->cur_tx -= TX_RING_SIZE;
678 priv->dirty_tx -= TX_RING_SIZE; 678 priv->dirty_tx -= TX_RING_SIZE;
679 } 679 }
680 priv->stats.tx_bytes += len;
680 681
681 /* Trigger an immediate send poll. */ 682 /* Trigger an immediate send poll. */
682 lance->RAP = CSR0; /* PCnet-ISA Controller Status */ 683 lance->RAP = CSR0; /* PCnet-ISA Controller Status */
diff --git a/drivers/net/atl1/atl1_param.c b/drivers/net/atl1/atl1_param.c
index c407214339f6..bcd0bd891722 100644
--- a/drivers/net/atl1/atl1_param.c
+++ b/drivers/net/atl1/atl1_param.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/pci.h>
26#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
27#include "atl1.h" 26#include "atl1.h"
28 27
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index d10fb80e9a63..c39ab803c5d8 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -45,7 +45,6 @@
45#include <linux/bitops.h> 45#include <linux/bitops.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/interrupt.h> 47#include <linux/interrupt.h>
48#include <linux/pci.h>
49#include <linux/init.h> 48#include <linux/init.h>
50#include <linux/netdevice.h> 49#include <linux/netdevice.h>
51#include <linux/etherdevice.h> 50#include <linux/etherdevice.h>
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index f98a2205a090..88b33c6ddda8 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -1,6 +1,6 @@
1/* bnx2.c: Broadcom NX2 network driver. 1/* bnx2.c: Broadcom NX2 network driver.
2 * 2 *
3 * Copyright (c) 2004, 2005, 2006 Broadcom Corporation 3 * Copyright (c) 2004-2007 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -54,8 +54,8 @@
54 54
55#define DRV_MODULE_NAME "bnx2" 55#define DRV_MODULE_NAME "bnx2"
56#define PFX DRV_MODULE_NAME ": " 56#define PFX DRV_MODULE_NAME ": "
57#define DRV_MODULE_VERSION "1.5.8" 57#define DRV_MODULE_VERSION "1.5.10"
58#define DRV_MODULE_RELDATE "April 24, 2007" 58#define DRV_MODULE_RELDATE "May 1, 2007"
59 59
60#define RUN_AT(x) (jiffies + (x)) 60#define RUN_AT(x) (jiffies + (x))
61 61
@@ -84,6 +84,7 @@ typedef enum {
84 BCM5708, 84 BCM5708,
85 BCM5708S, 85 BCM5708S,
86 BCM5709, 86 BCM5709,
87 BCM5709S,
87} board_t; 88} board_t;
88 89
89/* indexed by board_t, above */ 90/* indexed by board_t, above */
@@ -98,6 +99,7 @@ static const struct {
98 { "Broadcom NetXtreme II BCM5708 1000Base-T" }, 99 { "Broadcom NetXtreme II BCM5708 1000Base-T" },
99 { "Broadcom NetXtreme II BCM5708 1000Base-SX" }, 100 { "Broadcom NetXtreme II BCM5708 1000Base-SX" },
100 { "Broadcom NetXtreme II BCM5709 1000Base-T" }, 101 { "Broadcom NetXtreme II BCM5709 1000Base-T" },
102 { "Broadcom NetXtreme II BCM5709 1000Base-SX" },
101 }; 103 };
102 104
103static struct pci_device_id bnx2_pci_tbl[] = { 105static struct pci_device_id bnx2_pci_tbl[] = {
@@ -117,6 +119,8 @@ static struct pci_device_id bnx2_pci_tbl[] = {
117 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S }, 119 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S },
118 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5709, 120 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5709,
119 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709 }, 121 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709 },
122 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5709S,
123 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709S },
120 { 0, } 124 { 0, }
121}; 125};
122 126
@@ -230,21 +234,29 @@ static inline u32 bnx2_tx_avail(struct bnx2 *bp)
230static u32 234static u32
231bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset) 235bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset)
232{ 236{
237 u32 val;
238
239 spin_lock_bh(&bp->indirect_lock);
233 REG_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset); 240 REG_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
234 return (REG_RD(bp, BNX2_PCICFG_REG_WINDOW)); 241 val = REG_RD(bp, BNX2_PCICFG_REG_WINDOW);
242 spin_unlock_bh(&bp->indirect_lock);
243 return val;
235} 244}
236 245
237static void 246static void
238bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val) 247bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val)
239{ 248{
249 spin_lock_bh(&bp->indirect_lock);
240 REG_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset); 250 REG_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
241 REG_WR(bp, BNX2_PCICFG_REG_WINDOW, val); 251 REG_WR(bp, BNX2_PCICFG_REG_WINDOW, val);
252 spin_unlock_bh(&bp->indirect_lock);
242} 253}
243 254
244static void 255static void
245bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val) 256bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
246{ 257{
247 offset += cid_addr; 258 offset += cid_addr;
259 spin_lock_bh(&bp->indirect_lock);
248 if (CHIP_NUM(bp) == CHIP_NUM_5709) { 260 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
249 int i; 261 int i;
250 262
@@ -262,6 +274,7 @@ bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
262 REG_WR(bp, BNX2_CTX_DATA_ADR, offset); 274 REG_WR(bp, BNX2_CTX_DATA_ADR, offset);
263 REG_WR(bp, BNX2_CTX_DATA, val); 275 REG_WR(bp, BNX2_CTX_DATA, val);
264 } 276 }
277 spin_unlock_bh(&bp->indirect_lock);
265} 278}
266 279
267static int 280static int
@@ -572,8 +585,8 @@ bnx2_report_fw_link(struct bnx2 *bp)
572 if (bp->autoneg) { 585 if (bp->autoneg) {
573 fw_link_status |= BNX2_LINK_STATUS_AN_ENABLED; 586 fw_link_status |= BNX2_LINK_STATUS_AN_ENABLED;
574 587
575 bnx2_read_phy(bp, MII_BMSR, &bmsr); 588 bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
576 bnx2_read_phy(bp, MII_BMSR, &bmsr); 589 bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
577 590
578 if (!(bmsr & BMSR_ANEGCOMPLETE) || 591 if (!(bmsr & BMSR_ANEGCOMPLETE) ||
579 bp->phy_flags & PHY_PARALLEL_DETECT_FLAG) 592 bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)
@@ -654,8 +667,8 @@ bnx2_resolve_flow_ctrl(struct bnx2 *bp)
654 return; 667 return;
655 } 668 }
656 669
657 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv); 670 bnx2_read_phy(bp, bp->mii_adv, &local_adv);
658 bnx2_read_phy(bp, MII_LPA, &remote_adv); 671 bnx2_read_phy(bp, bp->mii_lpa, &remote_adv);
659 672
660 if (bp->phy_flags & PHY_SERDES_FLAG) { 673 if (bp->phy_flags & PHY_SERDES_FLAG) {
661 u32 new_local_adv = 0; 674 u32 new_local_adv = 0;
@@ -700,6 +713,45 @@ bnx2_resolve_flow_ctrl(struct bnx2 *bp)
700} 713}
701 714
702static int 715static int
716bnx2_5709s_linkup(struct bnx2 *bp)
717{
718 u32 val, speed;
719
720 bp->link_up = 1;
721
722 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_GP_STATUS);
723 bnx2_read_phy(bp, MII_BNX2_GP_TOP_AN_STATUS1, &val);
724 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
725
726 if ((bp->autoneg & AUTONEG_SPEED) == 0) {
727 bp->line_speed = bp->req_line_speed;
728 bp->duplex = bp->req_duplex;
729 return 0;
730 }
731 speed = val & MII_BNX2_GP_TOP_AN_SPEED_MSK;
732 switch (speed) {
733 case MII_BNX2_GP_TOP_AN_SPEED_10:
734 bp->line_speed = SPEED_10;
735 break;
736 case MII_BNX2_GP_TOP_AN_SPEED_100:
737 bp->line_speed = SPEED_100;
738 break;
739 case MII_BNX2_GP_TOP_AN_SPEED_1G:
740 case MII_BNX2_GP_TOP_AN_SPEED_1GKV:
741 bp->line_speed = SPEED_1000;
742 break;
743 case MII_BNX2_GP_TOP_AN_SPEED_2_5G:
744 bp->line_speed = SPEED_2500;
745 break;
746 }
747 if (val & MII_BNX2_GP_TOP_AN_FD)
748 bp->duplex = DUPLEX_FULL;
749 else
750 bp->duplex = DUPLEX_HALF;
751 return 0;
752}
753
754static int
703bnx2_5708s_linkup(struct bnx2 *bp) 755bnx2_5708s_linkup(struct bnx2 *bp)
704{ 756{
705 u32 val; 757 u32 val;
@@ -736,7 +788,7 @@ bnx2_5706s_linkup(struct bnx2 *bp)
736 bp->link_up = 1; 788 bp->link_up = 1;
737 bp->line_speed = SPEED_1000; 789 bp->line_speed = SPEED_1000;
738 790
739 bnx2_read_phy(bp, MII_BMCR, &bmcr); 791 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
740 if (bmcr & BMCR_FULLDPLX) { 792 if (bmcr & BMCR_FULLDPLX) {
741 bp->duplex = DUPLEX_FULL; 793 bp->duplex = DUPLEX_FULL;
742 } 794 }
@@ -748,8 +800,8 @@ bnx2_5706s_linkup(struct bnx2 *bp)
748 return 0; 800 return 0;
749 } 801 }
750 802
751 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv); 803 bnx2_read_phy(bp, bp->mii_adv, &local_adv);
752 bnx2_read_phy(bp, MII_LPA, &remote_adv); 804 bnx2_read_phy(bp, bp->mii_lpa, &remote_adv);
753 805
754 common = local_adv & remote_adv; 806 common = local_adv & remote_adv;
755 if (common & (ADVERTISE_1000XHALF | ADVERTISE_1000XFULL)) { 807 if (common & (ADVERTISE_1000XHALF | ADVERTISE_1000XFULL)) {
@@ -770,7 +822,7 @@ bnx2_copper_linkup(struct bnx2 *bp)
770{ 822{
771 u32 bmcr; 823 u32 bmcr;
772 824
773 bnx2_read_phy(bp, MII_BMCR, &bmcr); 825 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
774 if (bmcr & BMCR_ANENABLE) { 826 if (bmcr & BMCR_ANENABLE) {
775 u32 local_adv, remote_adv, common; 827 u32 local_adv, remote_adv, common;
776 828
@@ -787,8 +839,8 @@ bnx2_copper_linkup(struct bnx2 *bp)
787 bp->duplex = DUPLEX_HALF; 839 bp->duplex = DUPLEX_HALF;
788 } 840 }
789 else { 841 else {
790 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv); 842 bnx2_read_phy(bp, bp->mii_adv, &local_adv);
791 bnx2_read_phy(bp, MII_LPA, &remote_adv); 843 bnx2_read_phy(bp, bp->mii_lpa, &remote_adv);
792 844
793 common = local_adv & remote_adv; 845 common = local_adv & remote_adv;
794 if (common & ADVERTISE_100FULL) { 846 if (common & ADVERTISE_100FULL) {
@@ -898,6 +950,145 @@ bnx2_set_mac_link(struct bnx2 *bp)
898 return 0; 950 return 0;
899} 951}
900 952
953static void
954bnx2_enable_bmsr1(struct bnx2 *bp)
955{
956 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
957 (CHIP_NUM(bp) == CHIP_NUM_5709))
958 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
959 MII_BNX2_BLK_ADDR_GP_STATUS);
960}
961
962static void
963bnx2_disable_bmsr1(struct bnx2 *bp)
964{
965 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
966 (CHIP_NUM(bp) == CHIP_NUM_5709))
967 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
968 MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
969}
970
971static int
972bnx2_test_and_enable_2g5(struct bnx2 *bp)
973{
974 u32 up1;
975 int ret = 1;
976
977 if (!(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
978 return 0;
979
980 if (bp->autoneg & AUTONEG_SPEED)
981 bp->advertising |= ADVERTISED_2500baseX_Full;
982
983 if (CHIP_NUM(bp) == CHIP_NUM_5709)
984 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_OVER1G);
985
986 bnx2_read_phy(bp, bp->mii_up1, &up1);
987 if (!(up1 & BCM5708S_UP1_2G5)) {
988 up1 |= BCM5708S_UP1_2G5;
989 bnx2_write_phy(bp, bp->mii_up1, up1);
990 ret = 0;
991 }
992
993 if (CHIP_NUM(bp) == CHIP_NUM_5709)
994 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
995 MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
996
997 return ret;
998}
999
1000static int
1001bnx2_test_and_disable_2g5(struct bnx2 *bp)
1002{
1003 u32 up1;
1004 int ret = 0;
1005
1006 if (!(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
1007 return 0;
1008
1009 if (CHIP_NUM(bp) == CHIP_NUM_5709)
1010 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_OVER1G);
1011
1012 bnx2_read_phy(bp, bp->mii_up1, &up1);
1013 if (up1 & BCM5708S_UP1_2G5) {
1014 up1 &= ~BCM5708S_UP1_2G5;
1015 bnx2_write_phy(bp, bp->mii_up1, up1);
1016 ret = 1;
1017 }
1018
1019 if (CHIP_NUM(bp) == CHIP_NUM_5709)
1020 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
1021 MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
1022
1023 return ret;
1024}
1025
1026static void
1027bnx2_enable_forced_2g5(struct bnx2 *bp)
1028{
1029 u32 bmcr;
1030
1031 if (!(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
1032 return;
1033
1034 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
1035 u32 val;
1036
1037 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
1038 MII_BNX2_BLK_ADDR_SERDES_DIG);
1039 bnx2_read_phy(bp, MII_BNX2_SERDES_DIG_MISC1, &val);
1040 val &= ~MII_BNX2_SD_MISC1_FORCE_MSK;
1041 val |= MII_BNX2_SD_MISC1_FORCE | MII_BNX2_SD_MISC1_FORCE_2_5G;
1042 bnx2_write_phy(bp, MII_BNX2_SERDES_DIG_MISC1, val);
1043
1044 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
1045 MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
1046 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
1047
1048 } else if (CHIP_NUM(bp) == CHIP_NUM_5708) {
1049 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
1050 bmcr |= BCM5708S_BMCR_FORCE_2500;
1051 }
1052
1053 if (bp->autoneg & AUTONEG_SPEED) {
1054 bmcr &= ~BMCR_ANENABLE;
1055 if (bp->req_duplex == DUPLEX_FULL)
1056 bmcr |= BMCR_FULLDPLX;
1057 }
1058 bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
1059}
1060
1061static void
1062bnx2_disable_forced_2g5(struct bnx2 *bp)
1063{
1064 u32 bmcr;
1065
1066 if (!(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
1067 return;
1068
1069 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
1070 u32 val;
1071
1072 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
1073 MII_BNX2_BLK_ADDR_SERDES_DIG);
1074 bnx2_read_phy(bp, MII_BNX2_SERDES_DIG_MISC1, &val);
1075 val &= ~MII_BNX2_SD_MISC1_FORCE;
1076 bnx2_write_phy(bp, MII_BNX2_SERDES_DIG_MISC1, val);
1077
1078 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR,
1079 MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
1080 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
1081
1082 } else if (CHIP_NUM(bp) == CHIP_NUM_5708) {
1083 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
1084 bmcr &= ~BCM5708S_BMCR_FORCE_2500;
1085 }
1086
1087 if (bp->autoneg & AUTONEG_SPEED)
1088 bmcr |= BMCR_SPEED1000 | BMCR_ANENABLE | BMCR_ANRESTART;
1089 bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
1090}
1091
901static int 1092static int
902bnx2_set_link(struct bnx2 *bp) 1093bnx2_set_link(struct bnx2 *bp)
903{ 1094{
@@ -911,8 +1102,10 @@ bnx2_set_link(struct bnx2 *bp)
911 1102
912 link_up = bp->link_up; 1103 link_up = bp->link_up;
913 1104
914 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1105 bnx2_enable_bmsr1(bp);
915 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1106 bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
1107 bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
1108 bnx2_disable_bmsr1(bp);
916 1109
917 if ((bp->phy_flags & PHY_SERDES_FLAG) && 1110 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
918 (CHIP_NUM(bp) == CHIP_NUM_5706)) { 1111 (CHIP_NUM(bp) == CHIP_NUM_5706)) {
@@ -933,6 +1126,8 @@ bnx2_set_link(struct bnx2 *bp)
933 bnx2_5706s_linkup(bp); 1126 bnx2_5706s_linkup(bp);
934 else if (CHIP_NUM(bp) == CHIP_NUM_5708) 1127 else if (CHIP_NUM(bp) == CHIP_NUM_5708)
935 bnx2_5708s_linkup(bp); 1128 bnx2_5708s_linkup(bp);
1129 else if (CHIP_NUM(bp) == CHIP_NUM_5709)
1130 bnx2_5709s_linkup(bp);
936 } 1131 }
937 else { 1132 else {
938 bnx2_copper_linkup(bp); 1133 bnx2_copper_linkup(bp);
@@ -941,17 +1136,9 @@ bnx2_set_link(struct bnx2 *bp)
941 } 1136 }
942 else { 1137 else {
943 if ((bp->phy_flags & PHY_SERDES_FLAG) && 1138 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
944 (bp->autoneg & AUTONEG_SPEED)) { 1139 (bp->autoneg & AUTONEG_SPEED))
1140 bnx2_disable_forced_2g5(bp);
945 1141
946 u32 bmcr;
947
948 bnx2_read_phy(bp, MII_BMCR, &bmcr);
949 bmcr &= ~BCM5708S_BMCR_FORCE_2500;
950 if (!(bmcr & BMCR_ANENABLE)) {
951 bnx2_write_phy(bp, MII_BMCR, bmcr |
952 BMCR_ANENABLE);
953 }
954 }
955 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 1142 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
956 bp->link_up = 0; 1143 bp->link_up = 0;
957 } 1144 }
@@ -971,13 +1158,13 @@ bnx2_reset_phy(struct bnx2 *bp)
971 int i; 1158 int i;
972 u32 reg; 1159 u32 reg;
973 1160
974 bnx2_write_phy(bp, MII_BMCR, BMCR_RESET); 1161 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_RESET);
975 1162
976#define PHY_RESET_MAX_WAIT 100 1163#define PHY_RESET_MAX_WAIT 100
977 for (i = 0; i < PHY_RESET_MAX_WAIT; i++) { 1164 for (i = 0; i < PHY_RESET_MAX_WAIT; i++) {
978 udelay(10); 1165 udelay(10);
979 1166
980 bnx2_read_phy(bp, MII_BMCR, &reg); 1167 bnx2_read_phy(bp, bp->mii_bmcr, &reg);
981 if (!(reg & BMCR_RESET)) { 1168 if (!(reg & BMCR_RESET)) {
982 udelay(20); 1169 udelay(20);
983 break; 1170 break;
@@ -1026,34 +1213,40 @@ bnx2_phy_get_pause_adv(struct bnx2 *bp)
1026static int 1213static int
1027bnx2_setup_serdes_phy(struct bnx2 *bp) 1214bnx2_setup_serdes_phy(struct bnx2 *bp)
1028{ 1215{
1029 u32 adv, bmcr, up1; 1216 u32 adv, bmcr;
1030 u32 new_adv = 0; 1217 u32 new_adv = 0;
1031 1218
1032 if (!(bp->autoneg & AUTONEG_SPEED)) { 1219 if (!(bp->autoneg & AUTONEG_SPEED)) {
1033 u32 new_bmcr; 1220 u32 new_bmcr;
1034 int force_link_down = 0; 1221 int force_link_down = 0;
1035 1222
1036 bnx2_read_phy(bp, MII_ADVERTISE, &adv); 1223 if (bp->req_line_speed == SPEED_2500) {
1224 if (!bnx2_test_and_enable_2g5(bp))
1225 force_link_down = 1;
1226 } else if (bp->req_line_speed == SPEED_1000) {
1227 if (bnx2_test_and_disable_2g5(bp))
1228 force_link_down = 1;
1229 }
1230 bnx2_read_phy(bp, bp->mii_adv, &adv);
1037 adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF); 1231 adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
1038 1232
1039 bnx2_read_phy(bp, MII_BMCR, &bmcr); 1233 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
1040 new_bmcr = bmcr & ~(BMCR_ANENABLE | BCM5708S_BMCR_FORCE_2500); 1234 new_bmcr = bmcr & ~BMCR_ANENABLE;
1041 new_bmcr |= BMCR_SPEED1000; 1235 new_bmcr |= BMCR_SPEED1000;
1042 if (bp->req_line_speed == SPEED_2500) { 1236
1043 new_bmcr |= BCM5708S_BMCR_FORCE_2500; 1237 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
1044 bnx2_read_phy(bp, BCM5708S_UP1, &up1); 1238 if (bp->req_line_speed == SPEED_2500)
1045 if (!(up1 & BCM5708S_UP1_2G5)) { 1239 bnx2_enable_forced_2g5(bp);
1046 up1 |= BCM5708S_UP1_2G5; 1240 else if (bp->req_line_speed == SPEED_1000) {
1047 bnx2_write_phy(bp, BCM5708S_UP1, up1); 1241 bnx2_disable_forced_2g5(bp);
1048 force_link_down = 1; 1242 new_bmcr &= ~0x2000;
1049 } 1243 }
1244
1050 } else if (CHIP_NUM(bp) == CHIP_NUM_5708) { 1245 } else if (CHIP_NUM(bp) == CHIP_NUM_5708) {
1051 bnx2_read_phy(bp, BCM5708S_UP1, &up1); 1246 if (bp->req_line_speed == SPEED_2500)
1052 if (up1 & BCM5708S_UP1_2G5) { 1247 new_bmcr |= BCM5708S_BMCR_FORCE_2500;
1053 up1 &= ~BCM5708S_UP1_2G5; 1248 else
1054 bnx2_write_phy(bp, BCM5708S_UP1, up1); 1249 new_bmcr = bmcr & ~BCM5708S_BMCR_FORCE_2500;
1055 force_link_down = 1;
1056 }
1057 } 1250 }
1058 1251
1059 if (bp->req_duplex == DUPLEX_FULL) { 1252 if (bp->req_duplex == DUPLEX_FULL) {
@@ -1067,49 +1260,48 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
1067 if ((new_bmcr != bmcr) || (force_link_down)) { 1260 if ((new_bmcr != bmcr) || (force_link_down)) {
1068 /* Force a link down visible on the other side */ 1261 /* Force a link down visible on the other side */
1069 if (bp->link_up) { 1262 if (bp->link_up) {
1070 bnx2_write_phy(bp, MII_ADVERTISE, adv & 1263 bnx2_write_phy(bp, bp->mii_adv, adv &
1071 ~(ADVERTISE_1000XFULL | 1264 ~(ADVERTISE_1000XFULL |
1072 ADVERTISE_1000XHALF)); 1265 ADVERTISE_1000XHALF));
1073 bnx2_write_phy(bp, MII_BMCR, bmcr | 1266 bnx2_write_phy(bp, bp->mii_bmcr, bmcr |
1074 BMCR_ANRESTART | BMCR_ANENABLE); 1267 BMCR_ANRESTART | BMCR_ANENABLE);
1075 1268
1076 bp->link_up = 0; 1269 bp->link_up = 0;
1077 netif_carrier_off(bp->dev); 1270 netif_carrier_off(bp->dev);
1078 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1271 bnx2_write_phy(bp, bp->mii_bmcr, new_bmcr);
1079 bnx2_report_link(bp); 1272 bnx2_report_link(bp);
1080 } 1273 }
1081 bnx2_write_phy(bp, MII_ADVERTISE, adv); 1274 bnx2_write_phy(bp, bp->mii_adv, adv);
1082 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1275 bnx2_write_phy(bp, bp->mii_bmcr, new_bmcr);
1276 } else {
1277 bnx2_resolve_flow_ctrl(bp);
1278 bnx2_set_mac_link(bp);
1083 } 1279 }
1084 return 0; 1280 return 0;
1085 } 1281 }
1086 1282
1087 if (bp->phy_flags & PHY_2_5G_CAPABLE_FLAG) { 1283 bnx2_test_and_enable_2g5(bp);
1088 bnx2_read_phy(bp, BCM5708S_UP1, &up1);
1089 up1 |= BCM5708S_UP1_2G5;
1090 bnx2_write_phy(bp, BCM5708S_UP1, up1);
1091 }
1092 1284
1093 if (bp->advertising & ADVERTISED_1000baseT_Full) 1285 if (bp->advertising & ADVERTISED_1000baseT_Full)
1094 new_adv |= ADVERTISE_1000XFULL; 1286 new_adv |= ADVERTISE_1000XFULL;
1095 1287
1096 new_adv |= bnx2_phy_get_pause_adv(bp); 1288 new_adv |= bnx2_phy_get_pause_adv(bp);
1097 1289
1098 bnx2_read_phy(bp, MII_ADVERTISE, &adv); 1290 bnx2_read_phy(bp, bp->mii_adv, &adv);
1099 bnx2_read_phy(bp, MII_BMCR, &bmcr); 1291 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
1100 1292
1101 bp->serdes_an_pending = 0; 1293 bp->serdes_an_pending = 0;
1102 if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) { 1294 if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
1103 /* Force a link down visible on the other side */ 1295 /* Force a link down visible on the other side */
1104 if (bp->link_up) { 1296 if (bp->link_up) {
1105 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK); 1297 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK);
1106 spin_unlock_bh(&bp->phy_lock); 1298 spin_unlock_bh(&bp->phy_lock);
1107 msleep(20); 1299 msleep(20);
1108 spin_lock_bh(&bp->phy_lock); 1300 spin_lock_bh(&bp->phy_lock);
1109 } 1301 }
1110 1302
1111 bnx2_write_phy(bp, MII_ADVERTISE, new_adv); 1303 bnx2_write_phy(bp, bp->mii_adv, new_adv);
1112 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART | 1304 bnx2_write_phy(bp, bp->mii_bmcr, bmcr | BMCR_ANRESTART |
1113 BMCR_ANENABLE); 1305 BMCR_ANENABLE);
1114 /* Speed up link-up time when the link partner 1306 /* Speed up link-up time when the link partner
1115 * does not autonegotiate which is very common 1307 * does not autonegotiate which is very common
@@ -1122,6 +1314,9 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
1122 bp->current_interval = SERDES_AN_TIMEOUT; 1314 bp->current_interval = SERDES_AN_TIMEOUT;
1123 bp->serdes_an_pending = 1; 1315 bp->serdes_an_pending = 1;
1124 mod_timer(&bp->timer, jiffies + bp->current_interval); 1316 mod_timer(&bp->timer, jiffies + bp->current_interval);
1317 } else {
1318 bnx2_resolve_flow_ctrl(bp);
1319 bnx2_set_mac_link(bp);
1125 } 1320 }
1126 1321
1127 return 0; 1322 return 0;
@@ -1146,14 +1341,14 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1146 u32 bmcr; 1341 u32 bmcr;
1147 u32 new_bmcr; 1342 u32 new_bmcr;
1148 1343
1149 bnx2_read_phy(bp, MII_BMCR, &bmcr); 1344 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
1150 1345
1151 if (bp->autoneg & AUTONEG_SPEED) { 1346 if (bp->autoneg & AUTONEG_SPEED) {
1152 u32 adv_reg, adv1000_reg; 1347 u32 adv_reg, adv1000_reg;
1153 u32 new_adv_reg = 0; 1348 u32 new_adv_reg = 0;
1154 u32 new_adv1000_reg = 0; 1349 u32 new_adv1000_reg = 0;
1155 1350
1156 bnx2_read_phy(bp, MII_ADVERTISE, &adv_reg); 1351 bnx2_read_phy(bp, bp->mii_adv, &adv_reg);
1157 adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP | 1352 adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP |
1158 ADVERTISE_PAUSE_ASYM); 1353 ADVERTISE_PAUSE_ASYM);
1159 1354
@@ -1179,9 +1374,9 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1179 (adv_reg != new_adv_reg) || 1374 (adv_reg != new_adv_reg) ||
1180 ((bmcr & BMCR_ANENABLE) == 0)) { 1375 ((bmcr & BMCR_ANENABLE) == 0)) {
1181 1376
1182 bnx2_write_phy(bp, MII_ADVERTISE, new_adv_reg); 1377 bnx2_write_phy(bp, bp->mii_adv, new_adv_reg);
1183 bnx2_write_phy(bp, MII_CTRL1000, new_adv1000_reg); 1378 bnx2_write_phy(bp, MII_CTRL1000, new_adv1000_reg);
1184 bnx2_write_phy(bp, MII_BMCR, BMCR_ANRESTART | 1379 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_ANRESTART |
1185 BMCR_ANENABLE); 1380 BMCR_ANENABLE);
1186 } 1381 }
1187 else if (bp->link_up) { 1382 else if (bp->link_up) {
@@ -1204,21 +1399,21 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1204 if (new_bmcr != bmcr) { 1399 if (new_bmcr != bmcr) {
1205 u32 bmsr; 1400 u32 bmsr;
1206 1401
1207 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1402 bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
1208 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1403 bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
1209 1404
1210 if (bmsr & BMSR_LSTATUS) { 1405 if (bmsr & BMSR_LSTATUS) {
1211 /* Force link down */ 1406 /* Force link down */
1212 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK); 1407 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK);
1213 spin_unlock_bh(&bp->phy_lock); 1408 spin_unlock_bh(&bp->phy_lock);
1214 msleep(50); 1409 msleep(50);
1215 spin_lock_bh(&bp->phy_lock); 1410 spin_lock_bh(&bp->phy_lock);
1216 1411
1217 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1412 bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
1218 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1413 bnx2_read_phy(bp, bp->mii_bmsr, &bmsr);
1219 } 1414 }
1220 1415
1221 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1416 bnx2_write_phy(bp, bp->mii_bmcr, new_bmcr);
1222 1417
1223 /* Normally, the new speed is setup after the link has 1418 /* Normally, the new speed is setup after the link has
1224 * gone down and up again. In some cases, link will not go 1419 * gone down and up again. In some cases, link will not go
@@ -1230,6 +1425,9 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1230 bnx2_resolve_flow_ctrl(bp); 1425 bnx2_resolve_flow_ctrl(bp);
1231 bnx2_set_mac_link(bp); 1426 bnx2_set_mac_link(bp);
1232 } 1427 }
1428 } else {
1429 bnx2_resolve_flow_ctrl(bp);
1430 bnx2_set_mac_link(bp);
1233 } 1431 }
1234 return 0; 1432 return 0;
1235} 1433}
@@ -1249,10 +1447,63 @@ bnx2_setup_phy(struct bnx2 *bp)
1249} 1447}
1250 1448
1251static int 1449static int
1450bnx2_init_5709s_phy(struct bnx2 *bp)
1451{
1452 u32 val;
1453
1454 bp->mii_bmcr = MII_BMCR + 0x10;
1455 bp->mii_bmsr = MII_BMSR + 0x10;
1456 bp->mii_bmsr1 = MII_BNX2_GP_TOP_AN_STATUS1;
1457 bp->mii_adv = MII_ADVERTISE + 0x10;
1458 bp->mii_lpa = MII_LPA + 0x10;
1459 bp->mii_up1 = MII_BNX2_OVER1G_UP1;
1460
1461 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_AER);
1462 bnx2_write_phy(bp, MII_BNX2_AER_AER, MII_BNX2_AER_AER_AN_MMD);
1463
1464 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
1465 bnx2_reset_phy(bp);
1466
1467 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_SERDES_DIG);
1468
1469 bnx2_read_phy(bp, MII_BNX2_SERDES_DIG_1000XCTL1, &val);
1470 val &= ~MII_BNX2_SD_1000XCTL1_AUTODET;
1471 val |= MII_BNX2_SD_1000XCTL1_FIBER;
1472 bnx2_write_phy(bp, MII_BNX2_SERDES_DIG_1000XCTL1, val);
1473
1474 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_OVER1G);
1475 bnx2_read_phy(bp, MII_BNX2_OVER1G_UP1, &val);
1476 if (bp->phy_flags & PHY_2_5G_CAPABLE_FLAG)
1477 val |= BCM5708S_UP1_2G5;
1478 else
1479 val &= ~BCM5708S_UP1_2G5;
1480 bnx2_write_phy(bp, MII_BNX2_OVER1G_UP1, val);
1481
1482 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_BAM_NXTPG);
1483 bnx2_read_phy(bp, MII_BNX2_BAM_NXTPG_CTL, &val);
1484 val |= MII_BNX2_NXTPG_CTL_T2 | MII_BNX2_NXTPG_CTL_BAM;
1485 bnx2_write_phy(bp, MII_BNX2_BAM_NXTPG_CTL, val);
1486
1487 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_CL73_USERB0);
1488
1489 val = MII_BNX2_CL73_BAM_EN | MII_BNX2_CL73_BAM_STA_MGR_EN |
1490 MII_BNX2_CL73_BAM_NP_AFT_BP_EN;
1491 bnx2_write_phy(bp, MII_BNX2_CL73_BAM_CTL1, val);
1492
1493 bnx2_write_phy(bp, MII_BNX2_BLK_ADDR, MII_BNX2_BLK_ADDR_COMBO_IEEEB0);
1494
1495 return 0;
1496}
1497
1498static int
1252bnx2_init_5708s_phy(struct bnx2 *bp) 1499bnx2_init_5708s_phy(struct bnx2 *bp)
1253{ 1500{
1254 u32 val; 1501 u32 val;
1255 1502
1503 bnx2_reset_phy(bp);
1504
1505 bp->mii_up1 = BCM5708S_UP1;
1506
1256 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG3); 1507 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG3);
1257 bnx2_write_phy(bp, BCM5708S_DIG_3_0, BCM5708S_DIG_3_0_USE_IEEE); 1508 bnx2_write_phy(bp, BCM5708S_DIG_3_0, BCM5708S_DIG_3_0_USE_IEEE);
1258 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG); 1509 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG);
@@ -1305,6 +1556,8 @@ bnx2_init_5708s_phy(struct bnx2 *bp)
1305static int 1556static int
1306bnx2_init_5706s_phy(struct bnx2 *bp) 1557bnx2_init_5706s_phy(struct bnx2 *bp)
1307{ 1558{
1559 bnx2_reset_phy(bp);
1560
1308 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 1561 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
1309 1562
1310 if (CHIP_NUM(bp) == CHIP_NUM_5706) 1563 if (CHIP_NUM(bp) == CHIP_NUM_5706)
@@ -1342,6 +1595,8 @@ bnx2_init_copper_phy(struct bnx2 *bp)
1342{ 1595{
1343 u32 val; 1596 u32 val;
1344 1597
1598 bnx2_reset_phy(bp);
1599
1345 if (bp->phy_flags & PHY_CRC_FIX_FLAG) { 1600 if (bp->phy_flags & PHY_CRC_FIX_FLAG) {
1346 bnx2_write_phy(bp, 0x18, 0x0c00); 1601 bnx2_write_phy(bp, 0x18, 0x0c00);
1347 bnx2_write_phy(bp, 0x17, 0x000a); 1602 bnx2_write_phy(bp, 0x17, 0x000a);
@@ -1396,9 +1651,13 @@ bnx2_init_phy(struct bnx2 *bp)
1396 bp->phy_flags &= ~PHY_INT_MODE_MASK_FLAG; 1651 bp->phy_flags &= ~PHY_INT_MODE_MASK_FLAG;
1397 bp->phy_flags |= PHY_INT_MODE_LINK_READY_FLAG; 1652 bp->phy_flags |= PHY_INT_MODE_LINK_READY_FLAG;
1398 1653
1399 REG_WR(bp, BNX2_EMAC_ATTENTION_ENA, BNX2_EMAC_ATTENTION_ENA_LINK); 1654 bp->mii_bmcr = MII_BMCR;
1655 bp->mii_bmsr = MII_BMSR;
1656 bp->mii_bmsr1 = MII_BMSR;
1657 bp->mii_adv = MII_ADVERTISE;
1658 bp->mii_lpa = MII_LPA;
1400 1659
1401 bnx2_reset_phy(bp); 1660 REG_WR(bp, BNX2_EMAC_ATTENTION_ENA, BNX2_EMAC_ATTENTION_ENA_LINK);
1402 1661
1403 bnx2_read_phy(bp, MII_PHYSID1, &val); 1662 bnx2_read_phy(bp, MII_PHYSID1, &val);
1404 bp->phy_id = val << 16; 1663 bp->phy_id = val << 16;
@@ -1410,6 +1669,8 @@ bnx2_init_phy(struct bnx2 *bp)
1410 rc = bnx2_init_5706s_phy(bp); 1669 rc = bnx2_init_5706s_phy(bp);
1411 else if (CHIP_NUM(bp) == CHIP_NUM_5708) 1670 else if (CHIP_NUM(bp) == CHIP_NUM_5708)
1412 rc = bnx2_init_5708s_phy(bp); 1671 rc = bnx2_init_5708s_phy(bp);
1672 else if (CHIP_NUM(bp) == CHIP_NUM_5709)
1673 rc = bnx2_init_5709s_phy(bp);
1413 } 1674 }
1414 else { 1675 else {
1415 rc = bnx2_init_copper_phy(bp); 1676 rc = bnx2_init_copper_phy(bp);
@@ -1442,7 +1703,7 @@ bnx2_set_phy_loopback(struct bnx2 *bp)
1442 int rc, i; 1703 int rc, i;
1443 1704
1444 spin_lock_bh(&bp->phy_lock); 1705 spin_lock_bh(&bp->phy_lock);
1445 rc = bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK | BMCR_FULLDPLX | 1706 rc = bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK | BMCR_FULLDPLX |
1446 BMCR_SPEED1000); 1707 BMCR_SPEED1000);
1447 spin_unlock_bh(&bp->phy_lock); 1708 spin_unlock_bh(&bp->phy_lock);
1448 if (rc) 1709 if (rc)
@@ -1681,25 +1942,33 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, u16 index)
1681 return 0; 1942 return 0;
1682} 1943}
1683 1944
1684static void 1945static int
1685bnx2_phy_int(struct bnx2 *bp) 1946bnx2_phy_event_is_set(struct bnx2 *bp, u32 event)
1686{ 1947{
1948 struct status_block *sblk = bp->status_blk;
1687 u32 new_link_state, old_link_state; 1949 u32 new_link_state, old_link_state;
1950 int is_set = 1;
1688 1951
1689 new_link_state = bp->status_blk->status_attn_bits & 1952 new_link_state = sblk->status_attn_bits & event;
1690 STATUS_ATTN_BITS_LINK_STATE; 1953 old_link_state = sblk->status_attn_bits_ack & event;
1691 old_link_state = bp->status_blk->status_attn_bits_ack &
1692 STATUS_ATTN_BITS_LINK_STATE;
1693 if (new_link_state != old_link_state) { 1954 if (new_link_state != old_link_state) {
1694 if (new_link_state) { 1955 if (new_link_state)
1695 REG_WR(bp, BNX2_PCICFG_STATUS_BIT_SET_CMD, 1956 REG_WR(bp, BNX2_PCICFG_STATUS_BIT_SET_CMD, event);
1696 STATUS_ATTN_BITS_LINK_STATE); 1957 else
1697 } 1958 REG_WR(bp, BNX2_PCICFG_STATUS_BIT_CLEAR_CMD, event);
1698 else { 1959 } else
1699 REG_WR(bp, BNX2_PCICFG_STATUS_BIT_CLEAR_CMD, 1960 is_set = 0;
1700 STATUS_ATTN_BITS_LINK_STATE); 1961
1701 } 1962 return is_set;
1963}
1964
1965static void
1966bnx2_phy_int(struct bnx2 *bp)
1967{
1968 if (bnx2_phy_event_is_set(bp, STATUS_ATTN_BITS_LINK_STATE)) {
1969 spin_lock(&bp->phy_lock);
1702 bnx2_set_link(bp); 1970 bnx2_set_link(bp);
1971 spin_unlock(&bp->phy_lock);
1703 } 1972 }
1704} 1973}
1705 1974
@@ -1993,6 +2262,23 @@ bnx2_msi(int irq, void *dev_instance)
1993} 2262}
1994 2263
1995static irqreturn_t 2264static irqreturn_t
2265bnx2_msi_1shot(int irq, void *dev_instance)
2266{
2267 struct net_device *dev = dev_instance;
2268 struct bnx2 *bp = netdev_priv(dev);
2269
2270 prefetch(bp->status_blk);
2271
2272 /* Return here if interrupt is disabled. */
2273 if (unlikely(atomic_read(&bp->intr_sem) != 0))
2274 return IRQ_HANDLED;
2275
2276 netif_rx_schedule(dev);
2277
2278 return IRQ_HANDLED;
2279}
2280
2281static irqreturn_t
1996bnx2_interrupt(int irq, void *dev_instance) 2282bnx2_interrupt(int irq, void *dev_instance)
1997{ 2283{
1998 struct net_device *dev = dev_instance; 2284 struct net_device *dev = dev_instance;
@@ -2022,6 +2308,8 @@ bnx2_interrupt(int irq, void *dev_instance)
2022 return IRQ_HANDLED; 2308 return IRQ_HANDLED;
2023} 2309}
2024 2310
2311#define STATUS_ATTN_EVENTS STATUS_ATTN_BITS_LINK_STATE
2312
2025static inline int 2313static inline int
2026bnx2_has_work(struct bnx2 *bp) 2314bnx2_has_work(struct bnx2 *bp)
2027{ 2315{
@@ -2031,8 +2319,8 @@ bnx2_has_work(struct bnx2 *bp)
2031 (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)) 2319 (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons))
2032 return 1; 2320 return 1;
2033 2321
2034 if ((sblk->status_attn_bits & STATUS_ATTN_BITS_LINK_STATE) != 2322 if ((sblk->status_attn_bits & STATUS_ATTN_EVENTS) !=
2035 (sblk->status_attn_bits_ack & STATUS_ATTN_BITS_LINK_STATE)) 2323 (sblk->status_attn_bits_ack & STATUS_ATTN_EVENTS))
2036 return 1; 2324 return 1;
2037 2325
2038 return 0; 2326 return 0;
@@ -2042,15 +2330,14 @@ static int
2042bnx2_poll(struct net_device *dev, int *budget) 2330bnx2_poll(struct net_device *dev, int *budget)
2043{ 2331{
2044 struct bnx2 *bp = netdev_priv(dev); 2332 struct bnx2 *bp = netdev_priv(dev);
2333 struct status_block *sblk = bp->status_blk;
2334 u32 status_attn_bits = sblk->status_attn_bits;
2335 u32 status_attn_bits_ack = sblk->status_attn_bits_ack;
2045 2336
2046 if ((bp->status_blk->status_attn_bits & 2337 if ((status_attn_bits & STATUS_ATTN_EVENTS) !=
2047 STATUS_ATTN_BITS_LINK_STATE) != 2338 (status_attn_bits_ack & STATUS_ATTN_EVENTS)) {
2048 (bp->status_blk->status_attn_bits_ack &
2049 STATUS_ATTN_BITS_LINK_STATE)) {
2050 2339
2051 spin_lock(&bp->phy_lock);
2052 bnx2_phy_int(bp); 2340 bnx2_phy_int(bp);
2053 spin_unlock(&bp->phy_lock);
2054 2341
2055 /* This is needed to take care of transient status 2342 /* This is needed to take care of transient status
2056 * during link changes. 2343 * during link changes.
@@ -3489,17 +3776,21 @@ bnx2_init_chip(struct bnx2 *bp)
3489 REG_WR(bp, BNX2_HC_STAT_COLLECT_TICKS, 0xbb8); /* 3ms */ 3776 REG_WR(bp, BNX2_HC_STAT_COLLECT_TICKS, 0xbb8); /* 3ms */
3490 3777
3491 if (CHIP_ID(bp) == CHIP_ID_5706_A1) 3778 if (CHIP_ID(bp) == CHIP_ID_5706_A1)
3492 REG_WR(bp, BNX2_HC_CONFIG, BNX2_HC_CONFIG_COLLECT_STATS); 3779 val = BNX2_HC_CONFIG_COLLECT_STATS;
3493 else { 3780 else {
3494 REG_WR(bp, BNX2_HC_CONFIG, BNX2_HC_CONFIG_RX_TMR_MODE | 3781 val = BNX2_HC_CONFIG_RX_TMR_MODE | BNX2_HC_CONFIG_TX_TMR_MODE |
3495 BNX2_HC_CONFIG_TX_TMR_MODE | 3782 BNX2_HC_CONFIG_COLLECT_STATS;
3496 BNX2_HC_CONFIG_COLLECT_STATS);
3497 } 3783 }
3498 3784
3785 if (bp->flags & ONE_SHOT_MSI_FLAG)
3786 val |= BNX2_HC_CONFIG_ONE_SHOT;
3787
3788 REG_WR(bp, BNX2_HC_CONFIG, val);
3789
3499 /* Clear internal stats counters. */ 3790 /* Clear internal stats counters. */
3500 REG_WR(bp, BNX2_HC_COMMAND, BNX2_HC_COMMAND_CLR_STAT_NOW); 3791 REG_WR(bp, BNX2_HC_COMMAND, BNX2_HC_COMMAND_CLR_STAT_NOW);
3501 3792
3502 REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_BITS_LINK_STATE); 3793 REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_EVENTS);
3503 3794
3504 if (REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_FEATURE) & 3795 if (REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_FEATURE) &
3505 BNX2_PORT_FEATURE_ASF_ENABLED) 3796 BNX2_PORT_FEATURE_ASF_ENABLED)
@@ -3763,10 +4054,11 @@ static int
3763bnx2_test_registers(struct bnx2 *bp) 4054bnx2_test_registers(struct bnx2 *bp)
3764{ 4055{
3765 int ret; 4056 int ret;
3766 int i; 4057 int i, is_5709;
3767 static const struct { 4058 static const struct {
3768 u16 offset; 4059 u16 offset;
3769 u16 flags; 4060 u16 flags;
4061#define BNX2_FL_NOT_5709 1
3770 u32 rw_mask; 4062 u32 rw_mask;
3771 u32 ro_mask; 4063 u32 ro_mask;
3772 } reg_tbl[] = { 4064 } reg_tbl[] = {
@@ -3774,26 +4066,26 @@ bnx2_test_registers(struct bnx2 *bp)
3774 { 0x0090, 0, 0xffffffff, 0x00000000 }, 4066 { 0x0090, 0, 0xffffffff, 0x00000000 },
3775 { 0x0094, 0, 0x00000000, 0x00000000 }, 4067 { 0x0094, 0, 0x00000000, 0x00000000 },
3776 4068
3777 { 0x0404, 0, 0x00003f00, 0x00000000 }, 4069 { 0x0404, BNX2_FL_NOT_5709, 0x00003f00, 0x00000000 },
3778 { 0x0418, 0, 0x00000000, 0xffffffff }, 4070 { 0x0418, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
3779 { 0x041c, 0, 0x00000000, 0xffffffff }, 4071 { 0x041c, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
3780 { 0x0420, 0, 0x00000000, 0x80ffffff }, 4072 { 0x0420, BNX2_FL_NOT_5709, 0x00000000, 0x80ffffff },
3781 { 0x0424, 0, 0x00000000, 0x00000000 }, 4073 { 0x0424, BNX2_FL_NOT_5709, 0x00000000, 0x00000000 },
3782 { 0x0428, 0, 0x00000000, 0x00000001 }, 4074 { 0x0428, BNX2_FL_NOT_5709, 0x00000000, 0x00000001 },
3783 { 0x0450, 0, 0x00000000, 0x0000ffff }, 4075 { 0x0450, BNX2_FL_NOT_5709, 0x00000000, 0x0000ffff },
3784 { 0x0454, 0, 0x00000000, 0xffffffff }, 4076 { 0x0454, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
3785 { 0x0458, 0, 0x00000000, 0xffffffff }, 4077 { 0x0458, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
3786 4078
3787 { 0x0808, 0, 0x00000000, 0xffffffff }, 4079 { 0x0808, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
3788 { 0x0854, 0, 0x00000000, 0xffffffff }, 4080 { 0x0854, BNX2_FL_NOT_5709, 0x00000000, 0xffffffff },
3789 { 0x0868, 0, 0x00000000, 0x77777777 }, 4081 { 0x0868, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
3790 { 0x086c, 0, 0x00000000, 0x77777777 }, 4082 { 0x086c, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
3791 { 0x0870, 0, 0x00000000, 0x77777777 }, 4083 { 0x0870, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
3792 { 0x0874, 0, 0x00000000, 0x77777777 }, 4084 { 0x0874, BNX2_FL_NOT_5709, 0x00000000, 0x77777777 },
3793 4085
3794 { 0x0c00, 0, 0x00000000, 0x00000001 }, 4086 { 0x0c00, BNX2_FL_NOT_5709, 0x00000000, 0x00000001 },
3795 { 0x0c04, 0, 0x00000000, 0x03ff0001 }, 4087 { 0x0c04, BNX2_FL_NOT_5709, 0x00000000, 0x03ff0001 },
3796 { 0x0c08, 0, 0x0f0ff073, 0x00000000 }, 4088 { 0x0c08, BNX2_FL_NOT_5709, 0x0f0ff073, 0x00000000 },
3797 4089
3798 { 0x1000, 0, 0x00000000, 0x00000001 }, 4090 { 0x1000, 0, 0x00000000, 0x00000001 },
3799 { 0x1004, 0, 0x00000000, 0x000f0001 }, 4091 { 0x1004, 0, 0x00000000, 0x000f0001 },
@@ -3840,7 +4132,6 @@ bnx2_test_registers(struct bnx2 *bp)
3840 4132
3841 { 0x5004, 0, 0x00000000, 0x0000007f }, 4133 { 0x5004, 0, 0x00000000, 0x0000007f },
3842 { 0x5008, 0, 0x0f0007ff, 0x00000000 }, 4134 { 0x5008, 0, 0x0f0007ff, 0x00000000 },
3843 { 0x500c, 0, 0xf800f800, 0x07ff07ff },
3844 4135
3845 { 0x5c00, 0, 0x00000000, 0x00000001 }, 4136 { 0x5c00, 0, 0x00000000, 0x00000001 },
3846 { 0x5c04, 0, 0x00000000, 0x0003000f }, 4137 { 0x5c04, 0, 0x00000000, 0x0003000f },
@@ -3880,8 +4171,16 @@ bnx2_test_registers(struct bnx2 *bp)
3880 }; 4171 };
3881 4172
3882 ret = 0; 4173 ret = 0;
4174 is_5709 = 0;
4175 if (CHIP_NUM(bp) == CHIP_NUM_5709)
4176 is_5709 = 1;
4177
3883 for (i = 0; reg_tbl[i].offset != 0xffff; i++) { 4178 for (i = 0; reg_tbl[i].offset != 0xffff; i++) {
3884 u32 offset, rw_mask, ro_mask, save_val, val; 4179 u32 offset, rw_mask, ro_mask, save_val, val;
4180 u16 flags = reg_tbl[i].flags;
4181
4182 if (is_5709 && (flags & BNX2_FL_NOT_5709))
4183 continue;
3885 4184
3886 offset = (u32) reg_tbl[i].offset; 4185 offset = (u32) reg_tbl[i].offset;
3887 rw_mask = reg_tbl[i].rw_mask; 4186 rw_mask = reg_tbl[i].rw_mask;
@@ -3950,10 +4249,10 @@ bnx2_test_memory(struct bnx2 *bp)
3950{ 4249{
3951 int ret = 0; 4250 int ret = 0;
3952 int i; 4251 int i;
3953 static const struct { 4252 static struct mem_entry {
3954 u32 offset; 4253 u32 offset;
3955 u32 len; 4254 u32 len;
3956 } mem_tbl[] = { 4255 } mem_tbl_5706[] = {
3957 { 0x60000, 0x4000 }, 4256 { 0x60000, 0x4000 },
3958 { 0xa0000, 0x3000 }, 4257 { 0xa0000, 0x3000 },
3959 { 0xe0000, 0x4000 }, 4258 { 0xe0000, 0x4000 },
@@ -3961,7 +4260,21 @@ bnx2_test_memory(struct bnx2 *bp)
3961 { 0x1a0000, 0x4000 }, 4260 { 0x1a0000, 0x4000 },
3962 { 0x160000, 0x4000 }, 4261 { 0x160000, 0x4000 },
3963 { 0xffffffff, 0 }, 4262 { 0xffffffff, 0 },
4263 },
4264 mem_tbl_5709[] = {
4265 { 0x60000, 0x4000 },
4266 { 0xa0000, 0x3000 },
4267 { 0xe0000, 0x4000 },
4268 { 0x120000, 0x4000 },
4269 { 0x1a0000, 0x4000 },
4270 { 0xffffffff, 0 },
3964 }; 4271 };
4272 struct mem_entry *mem_tbl;
4273
4274 if (CHIP_NUM(bp) == CHIP_NUM_5709)
4275 mem_tbl = mem_tbl_5709;
4276 else
4277 mem_tbl = mem_tbl_5706;
3965 4278
3966 for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) { 4279 for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) {
3967 if ((ret = bnx2_do_mem_test(bp, mem_tbl[i].offset, 4280 if ((ret = bnx2_do_mem_test(bp, mem_tbl[i].offset,
@@ -4163,8 +4476,10 @@ bnx2_test_link(struct bnx2 *bp)
4163 u32 bmsr; 4476 u32 bmsr;
4164 4477
4165 spin_lock_bh(&bp->phy_lock); 4478 spin_lock_bh(&bp->phy_lock);
4166 bnx2_read_phy(bp, MII_BMSR, &bmsr); 4479 bnx2_enable_bmsr1(bp);
4167 bnx2_read_phy(bp, MII_BMSR, &bmsr); 4480 bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
4481 bnx2_read_phy(bp, bp->mii_bmsr1, &bmsr);
4482 bnx2_disable_bmsr1(bp);
4168 spin_unlock_bh(&bp->phy_lock); 4483 spin_unlock_bh(&bp->phy_lock);
4169 4484
4170 if (bmsr & BMSR_LSTATUS) { 4485 if (bmsr & BMSR_LSTATUS) {
@@ -4214,7 +4529,7 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
4214 4529
4215 bp->current_interval = bp->timer_interval; 4530 bp->current_interval = bp->timer_interval;
4216 4531
4217 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4532 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
4218 4533
4219 if (bmcr & BMCR_ANENABLE) { 4534 if (bmcr & BMCR_ANENABLE) {
4220 u32 phy1, phy2; 4535 u32 phy1, phy2;
@@ -4232,7 +4547,7 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
4232 4547
4233 bmcr &= ~BMCR_ANENABLE; 4548 bmcr &= ~BMCR_ANENABLE;
4234 bmcr |= BMCR_SPEED1000 | BMCR_FULLDPLX; 4549 bmcr |= BMCR_SPEED1000 | BMCR_FULLDPLX;
4235 bnx2_write_phy(bp, MII_BMCR, bmcr); 4550 bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
4236 bp->phy_flags |= PHY_PARALLEL_DETECT_FLAG; 4551 bp->phy_flags |= PHY_PARALLEL_DETECT_FLAG;
4237 } 4552 }
4238 } 4553 }
@@ -4246,9 +4561,9 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
4246 if (phy2 & 0x20) { 4561 if (phy2 & 0x20) {
4247 u32 bmcr; 4562 u32 bmcr;
4248 4563
4249 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4564 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
4250 bmcr |= BMCR_ANENABLE; 4565 bmcr |= BMCR_ANENABLE;
4251 bnx2_write_phy(bp, MII_BMCR, bmcr); 4566 bnx2_write_phy(bp, bp->mii_bmcr, bmcr);
4252 4567
4253 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 4568 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
4254 } 4569 }
@@ -4272,17 +4587,12 @@ bnx2_5708_serdes_timer(struct bnx2 *bp)
4272 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) { 4587 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
4273 u32 bmcr; 4588 u32 bmcr;
4274 4589
4275 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4590 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
4276
4277 if (bmcr & BMCR_ANENABLE) { 4591 if (bmcr & BMCR_ANENABLE) {
4278 bmcr &= ~BMCR_ANENABLE; 4592 bnx2_enable_forced_2g5(bp);
4279 bmcr |= BMCR_FULLDPLX | BCM5708S_BMCR_FORCE_2500;
4280 bnx2_write_phy(bp, MII_BMCR, bmcr);
4281 bp->current_interval = SERDES_FORCED_TIMEOUT; 4593 bp->current_interval = SERDES_FORCED_TIMEOUT;
4282 } else { 4594 } else {
4283 bmcr &= ~(BMCR_FULLDPLX | BCM5708S_BMCR_FORCE_2500); 4595 bnx2_disable_forced_2g5(bp);
4284 bmcr |= BMCR_ANENABLE;
4285 bnx2_write_phy(bp, MII_BMCR, bmcr);
4286 bp->serdes_an_pending = 2; 4596 bp->serdes_an_pending = 2;
4287 bp->current_interval = bp->timer_interval; 4597 bp->current_interval = bp->timer_interval;
4288 } 4598 }
@@ -4313,7 +4623,7 @@ bnx2_timer(unsigned long data)
4313 if (bp->phy_flags & PHY_SERDES_FLAG) { 4623 if (bp->phy_flags & PHY_SERDES_FLAG) {
4314 if (CHIP_NUM(bp) == CHIP_NUM_5706) 4624 if (CHIP_NUM(bp) == CHIP_NUM_5706)
4315 bnx2_5706_serdes_timer(bp); 4625 bnx2_5706_serdes_timer(bp);
4316 else if (CHIP_NUM(bp) == CHIP_NUM_5708) 4626 else
4317 bnx2_5708_serdes_timer(bp); 4627 bnx2_5708_serdes_timer(bp);
4318 } 4628 }
4319 4629
@@ -4321,6 +4631,38 @@ bnx2_restart_timer:
4321 mod_timer(&bp->timer, jiffies + bp->current_interval); 4631 mod_timer(&bp->timer, jiffies + bp->current_interval);
4322} 4632}
4323 4633
4634static int
4635bnx2_request_irq(struct bnx2 *bp)
4636{
4637 struct net_device *dev = bp->dev;
4638 int rc = 0;
4639
4640 if (bp->flags & USING_MSI_FLAG) {
4641 irq_handler_t fn = bnx2_msi;
4642
4643 if (bp->flags & ONE_SHOT_MSI_FLAG)
4644 fn = bnx2_msi_1shot;
4645
4646 rc = request_irq(bp->pdev->irq, fn, 0, dev->name, dev);
4647 } else
4648 rc = request_irq(bp->pdev->irq, bnx2_interrupt,
4649 IRQF_SHARED, dev->name, dev);
4650 return rc;
4651}
4652
4653static void
4654bnx2_free_irq(struct bnx2 *bp)
4655{
4656 struct net_device *dev = bp->dev;
4657
4658 if (bp->flags & USING_MSI_FLAG) {
4659 free_irq(bp->pdev->irq, dev);
4660 pci_disable_msi(bp->pdev);
4661 bp->flags &= ~(USING_MSI_FLAG | ONE_SHOT_MSI_FLAG);
4662 } else
4663 free_irq(bp->pdev->irq, dev);
4664}
4665
4324/* Called with rtnl_lock */ 4666/* Called with rtnl_lock */
4325static int 4667static int
4326bnx2_open(struct net_device *dev) 4668bnx2_open(struct net_device *dev)
@@ -4328,6 +4670,8 @@ bnx2_open(struct net_device *dev)
4328 struct bnx2 *bp = netdev_priv(dev); 4670 struct bnx2 *bp = netdev_priv(dev);
4329 int rc; 4671 int rc;
4330 4672
4673 netif_carrier_off(dev);
4674
4331 bnx2_set_power_state(bp, PCI_D0); 4675 bnx2_set_power_state(bp, PCI_D0);
4332 bnx2_disable_int(bp); 4676 bnx2_disable_int(bp);
4333 4677
@@ -4335,24 +4679,15 @@ bnx2_open(struct net_device *dev)
4335 if (rc) 4679 if (rc)
4336 return rc; 4680 return rc;
4337 4681
4338 if ((CHIP_ID(bp) != CHIP_ID_5706_A0) && 4682 if ((bp->flags & MSI_CAP_FLAG) && !disable_msi) {
4339 (CHIP_ID(bp) != CHIP_ID_5706_A1) &&
4340 !disable_msi) {
4341
4342 if (pci_enable_msi(bp->pdev) == 0) { 4683 if (pci_enable_msi(bp->pdev) == 0) {
4343 bp->flags |= USING_MSI_FLAG; 4684 bp->flags |= USING_MSI_FLAG;
4344 rc = request_irq(bp->pdev->irq, bnx2_msi, 0, dev->name, 4685 if (CHIP_NUM(bp) == CHIP_NUM_5709)
4345 dev); 4686 bp->flags |= ONE_SHOT_MSI_FLAG;
4346 }
4347 else {
4348 rc = request_irq(bp->pdev->irq, bnx2_interrupt,
4349 IRQF_SHARED, dev->name, dev);
4350 } 4687 }
4351 } 4688 }
4352 else { 4689 rc = bnx2_request_irq(bp);
4353 rc = request_irq(bp->pdev->irq, bnx2_interrupt, IRQF_SHARED, 4690
4354 dev->name, dev);
4355 }
4356 if (rc) { 4691 if (rc) {
4357 bnx2_free_mem(bp); 4692 bnx2_free_mem(bp);
4358 return rc; 4693 return rc;
@@ -4361,11 +4696,7 @@ bnx2_open(struct net_device *dev)
4361 rc = bnx2_init_nic(bp); 4696 rc = bnx2_init_nic(bp);
4362 4697
4363 if (rc) { 4698 if (rc) {
4364 free_irq(bp->pdev->irq, dev); 4699 bnx2_free_irq(bp);
4365 if (bp->flags & USING_MSI_FLAG) {
4366 pci_disable_msi(bp->pdev);
4367 bp->flags &= ~USING_MSI_FLAG;
4368 }
4369 bnx2_free_skbs(bp); 4700 bnx2_free_skbs(bp);
4370 bnx2_free_mem(bp); 4701 bnx2_free_mem(bp);
4371 return rc; 4702 return rc;
@@ -4389,16 +4720,13 @@ bnx2_open(struct net_device *dev)
4389 bp->dev->name); 4720 bp->dev->name);
4390 4721
4391 bnx2_disable_int(bp); 4722 bnx2_disable_int(bp);
4392 free_irq(bp->pdev->irq, dev); 4723 bnx2_free_irq(bp);
4393 pci_disable_msi(bp->pdev);
4394 bp->flags &= ~USING_MSI_FLAG;
4395 4724
4396 rc = bnx2_init_nic(bp); 4725 rc = bnx2_init_nic(bp);
4397 4726
4398 if (!rc) { 4727 if (!rc)
4399 rc = request_irq(bp->pdev->irq, bnx2_interrupt, 4728 rc = bnx2_request_irq(bp);
4400 IRQF_SHARED, dev->name, dev); 4729
4401 }
4402 if (rc) { 4730 if (rc) {
4403 bnx2_free_skbs(bp); 4731 bnx2_free_skbs(bp);
4404 bnx2_free_mem(bp); 4732 bnx2_free_mem(bp);
@@ -4508,40 +4836,53 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4508 vlan_tag_flags |= 4836 vlan_tag_flags |=
4509 (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16)); 4837 (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
4510 } 4838 }
4511 if ((mss = skb_shinfo(skb)->gso_size) && 4839 if ((mss = skb_shinfo(skb)->gso_size)) {
4512 (skb->len > (bp->dev->mtu + ETH_HLEN))) {
4513 u32 tcp_opt_len, ip_tcp_len; 4840 u32 tcp_opt_len, ip_tcp_len;
4514 struct iphdr *iph; 4841 struct iphdr *iph;
4515 4842
4516 if (skb_header_cloned(skb) &&
4517 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
4518 dev_kfree_skb(skb);
4519 return NETDEV_TX_OK;
4520 }
4521
4522 vlan_tag_flags |= TX_BD_FLAGS_SW_LSO; 4843 vlan_tag_flags |= TX_BD_FLAGS_SW_LSO;
4523 4844
4524 tcp_opt_len = 0; 4845 tcp_opt_len = tcp_optlen(skb);
4525 if (tcp_hdr(skb)->doff > 5) 4846
4526 tcp_opt_len = tcp_optlen(skb); 4847 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) {
4848 u32 tcp_off = skb_transport_offset(skb) -
4849 sizeof(struct ipv6hdr) - ETH_HLEN;
4527 4850
4528 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr); 4851 vlan_tag_flags |= ((tcp_opt_len >> 2) << 8) |
4852 TX_BD_FLAGS_SW_FLAGS;
4853 if (likely(tcp_off == 0))
4854 vlan_tag_flags &= ~TX_BD_FLAGS_TCP6_OFF0_MSK;
4855 else {
4856 tcp_off >>= 3;
4857 vlan_tag_flags |= ((tcp_off & 0x3) <<
4858 TX_BD_FLAGS_TCP6_OFF0_SHL) |
4859 ((tcp_off & 0x10) <<
4860 TX_BD_FLAGS_TCP6_OFF4_SHL);
4861 mss |= (tcp_off & 0xc) << TX_BD_TCP6_OFF2_SHL;
4862 }
4863 } else {
4864 if (skb_header_cloned(skb) &&
4865 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
4866 dev_kfree_skb(skb);
4867 return NETDEV_TX_OK;
4868 }
4529 4869
4530 iph = ip_hdr(skb); 4870 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
4531 iph->check = 0; 4871
4532 iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); 4872 iph = ip_hdr(skb);
4533 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, 4873 iph->check = 0;
4534 iph->daddr, 0, 4874 iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
4535 IPPROTO_TCP, 0); 4875 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
4536 if (tcp_opt_len || (iph->ihl > 5)) { 4876 iph->daddr, 0,
4537 vlan_tag_flags |= ((iph->ihl - 5) + 4877 IPPROTO_TCP,
4538 (tcp_opt_len >> 2)) << 8; 4878 0);
4879 if (tcp_opt_len || (iph->ihl > 5)) {
4880 vlan_tag_flags |= ((iph->ihl - 5) +
4881 (tcp_opt_len >> 2)) << 8;
4882 }
4539 } 4883 }
4540 } 4884 } else
4541 else
4542 {
4543 mss = 0; 4885 mss = 0;
4544 }
4545 4886
4546 mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE); 4887 mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE);
4547 4888
@@ -4622,11 +4963,7 @@ bnx2_close(struct net_device *dev)
4622 else 4963 else
4623 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL; 4964 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
4624 bnx2_reset_chip(bp, reset_code); 4965 bnx2_reset_chip(bp, reset_code);
4625 free_irq(bp->pdev->irq, dev); 4966 bnx2_free_irq(bp);
4626 if (bp->flags & USING_MSI_FLAG) {
4627 pci_disable_msi(bp->pdev);
4628 bp->flags &= ~USING_MSI_FLAG;
4629 }
4630 bnx2_free_skbs(bp); 4967 bnx2_free_skbs(bp);
4631 bnx2_free_mem(bp); 4968 bnx2_free_mem(bp);
4632 bp->link_up = 0; 4969 bp->link_up = 0;
@@ -4735,6 +5072,8 @@ bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4735 if (bp->phy_flags & PHY_SERDES_FLAG) { 5072 if (bp->phy_flags & PHY_SERDES_FLAG) {
4736 cmd->supported |= SUPPORTED_1000baseT_Full | 5073 cmd->supported |= SUPPORTED_1000baseT_Full |
4737 SUPPORTED_FIBRE; 5074 SUPPORTED_FIBRE;
5075 if (bp->phy_flags & PHY_2_5G_CAPABLE_FLAG)
5076 cmd->supported |= SUPPORTED_2500baseX_Full;
4738 5077
4739 cmd->port = PORT_FIBRE; 5078 cmd->port = PORT_FIBRE;
4740 } 5079 }
@@ -4798,8 +5137,10 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4798 5137
4799 advertising = cmd->advertising; 5138 advertising = cmd->advertising;
4800 5139
4801 } 5140 } else if (cmd->advertising == ADVERTISED_2500baseX_Full) {
4802 else if (cmd->advertising == ADVERTISED_1000baseT_Full) { 5141 if (!(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
5142 return -EINVAL;
5143 } else if (cmd->advertising == ADVERTISED_1000baseT_Full) {
4803 advertising = cmd->advertising; 5144 advertising = cmd->advertising;
4804 } 5145 }
4805 else if (cmd->advertising == ADVERTISED_1000baseT_Half) { 5146 else if (cmd->advertising == ADVERTISED_1000baseT_Half) {
@@ -4975,7 +5316,7 @@ bnx2_nway_reset(struct net_device *dev)
4975 5316
4976 /* Force a link down visible on the other side */ 5317 /* Force a link down visible on the other side */
4977 if (bp->phy_flags & PHY_SERDES_FLAG) { 5318 if (bp->phy_flags & PHY_SERDES_FLAG) {
4978 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK); 5319 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_LOOPBACK);
4979 spin_unlock_bh(&bp->phy_lock); 5320 spin_unlock_bh(&bp->phy_lock);
4980 5321
4981 msleep(20); 5322 msleep(20);
@@ -4987,9 +5328,9 @@ bnx2_nway_reset(struct net_device *dev)
4987 mod_timer(&bp->timer, jiffies + bp->current_interval); 5328 mod_timer(&bp->timer, jiffies + bp->current_interval);
4988 } 5329 }
4989 5330
4990 bnx2_read_phy(bp, MII_BMCR, &bmcr); 5331 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
4991 bmcr &= ~BMCR_LOOPBACK; 5332 bmcr &= ~BMCR_LOOPBACK;
4992 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART | BMCR_ANENABLE); 5333 bnx2_write_phy(bp, bp->mii_bmcr, bmcr | BMCR_ANRESTART | BMCR_ANENABLE);
4993 5334
4994 spin_unlock_bh(&bp->phy_lock); 5335 spin_unlock_bh(&bp->phy_lock);
4995 5336
@@ -5209,10 +5550,15 @@ bnx2_set_rx_csum(struct net_device *dev, u32 data)
5209static int 5550static int
5210bnx2_set_tso(struct net_device *dev, u32 data) 5551bnx2_set_tso(struct net_device *dev, u32 data)
5211{ 5552{
5212 if (data) 5553 struct bnx2 *bp = netdev_priv(dev);
5554
5555 if (data) {
5213 dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; 5556 dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
5214 else 5557 if (CHIP_NUM(bp) == CHIP_NUM_5709)
5215 dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO_ECN); 5558 dev->features |= NETIF_F_TSO6;
5559 } else
5560 dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6 |
5561 NETIF_F_TSO_ECN);
5216 return 0; 5562 return 0;
5217} 5563}
5218 5564
@@ -5510,6 +5856,17 @@ bnx2_phys_id(struct net_device *dev, u32 data)
5510 return 0; 5856 return 0;
5511} 5857}
5512 5858
5859static int
5860bnx2_set_tx_csum(struct net_device *dev, u32 data)
5861{
5862 struct bnx2 *bp = netdev_priv(dev);
5863
5864 if (CHIP_NUM(bp) == CHIP_NUM_5709)
5865 return (ethtool_op_set_tx_hw_csum(dev, data));
5866 else
5867 return (ethtool_op_set_tx_csum(dev, data));
5868}
5869
5513static const struct ethtool_ops bnx2_ethtool_ops = { 5870static const struct ethtool_ops bnx2_ethtool_ops = {
5514 .get_settings = bnx2_get_settings, 5871 .get_settings = bnx2_get_settings,
5515 .set_settings = bnx2_set_settings, 5872 .set_settings = bnx2_set_settings,
@@ -5532,7 +5889,7 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
5532 .get_rx_csum = bnx2_get_rx_csum, 5889 .get_rx_csum = bnx2_get_rx_csum,
5533 .set_rx_csum = bnx2_set_rx_csum, 5890 .set_rx_csum = bnx2_set_rx_csum,
5534 .get_tx_csum = ethtool_op_get_tx_csum, 5891 .get_tx_csum = ethtool_op_get_tx_csum,
5535 .set_tx_csum = ethtool_op_set_tx_csum, 5892 .set_tx_csum = bnx2_set_tx_csum,
5536 .get_sg = ethtool_op_get_sg, 5893 .get_sg = ethtool_op_get_sg,
5537 .set_sg = ethtool_op_set_sg, 5894 .set_sg = ethtool_op_set_sg,
5538 .get_tso = ethtool_op_get_tso, 5895 .get_tso = ethtool_op_get_tso,
@@ -5562,6 +5919,9 @@ bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
5562 case SIOCGMIIREG: { 5919 case SIOCGMIIREG: {
5563 u32 mii_regval; 5920 u32 mii_regval;
5564 5921
5922 if (!netif_running(dev))
5923 return -EAGAIN;
5924
5565 spin_lock_bh(&bp->phy_lock); 5925 spin_lock_bh(&bp->phy_lock);
5566 err = bnx2_read_phy(bp, data->reg_num & 0x1f, &mii_regval); 5926 err = bnx2_read_phy(bp, data->reg_num & 0x1f, &mii_regval);
5567 spin_unlock_bh(&bp->phy_lock); 5927 spin_unlock_bh(&bp->phy_lock);
@@ -5575,6 +5935,9 @@ bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
5575 if (!capable(CAP_NET_ADMIN)) 5935 if (!capable(CAP_NET_ADMIN))
5576 return -EPERM; 5936 return -EPERM;
5577 5937
5938 if (!netif_running(dev))
5939 return -EAGAIN;
5940
5578 spin_lock_bh(&bp->phy_lock); 5941 spin_lock_bh(&bp->phy_lock);
5579 err = bnx2_write_phy(bp, data->reg_num & 0x1f, data->val_in); 5942 err = bnx2_write_phy(bp, data->reg_num & 0x1f, data->val_in);
5580 spin_unlock_bh(&bp->phy_lock); 5943 spin_unlock_bh(&bp->phy_lock);
@@ -5676,6 +6039,58 @@ bnx2_get_5709_media(struct bnx2 *bp)
5676 } 6039 }
5677} 6040}
5678 6041
6042static void __devinit
6043bnx2_get_pci_speed(struct bnx2 *bp)
6044{
6045 u32 reg;
6046
6047 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS);
6048 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) {
6049 u32 clkreg;
6050
6051 bp->flags |= PCIX_FLAG;
6052
6053 clkreg = REG_RD(bp, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS);
6054
6055 clkreg &= BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET;
6056 switch (clkreg) {
6057 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_133MHZ:
6058 bp->bus_speed_mhz = 133;
6059 break;
6060
6061 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_95MHZ:
6062 bp->bus_speed_mhz = 100;
6063 break;
6064
6065 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_66MHZ:
6066 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_80MHZ:
6067 bp->bus_speed_mhz = 66;
6068 break;
6069
6070 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_48MHZ:
6071 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_55MHZ:
6072 bp->bus_speed_mhz = 50;
6073 break;
6074
6075 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_LOW:
6076 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_32MHZ:
6077 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_38MHZ:
6078 bp->bus_speed_mhz = 33;
6079 break;
6080 }
6081 }
6082 else {
6083 if (reg & BNX2_PCICFG_MISC_STATUS_M66EN)
6084 bp->bus_speed_mhz = 66;
6085 else
6086 bp->bus_speed_mhz = 33;
6087 }
6088
6089 if (reg & BNX2_PCICFG_MISC_STATUS_32BIT_DET)
6090 bp->flags |= PCI_32BIT_FLAG;
6091
6092}
6093
5679static int __devinit 6094static int __devinit
5680bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) 6095bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5681{ 6096{
@@ -5683,6 +6098,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5683 unsigned long mem_len; 6098 unsigned long mem_len;
5684 int rc; 6099 int rc;
5685 u32 reg; 6100 u32 reg;
6101 u64 dma_mask, persist_dma_mask;
5686 6102
5687 SET_MODULE_OWNER(dev); 6103 SET_MODULE_OWNER(dev);
5688 SET_NETDEV_DEV(dev, &pdev->dev); 6104 SET_NETDEV_DEV(dev, &pdev->dev);
@@ -5721,25 +6137,11 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5721 goto err_out_release; 6137 goto err_out_release;
5722 } 6138 }
5723 6139
5724 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
5725 bp->flags |= USING_DAC_FLAG;
5726 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
5727 dev_err(&pdev->dev,
5728 "pci_set_consistent_dma_mask failed, aborting.\n");
5729 rc = -EIO;
5730 goto err_out_release;
5731 }
5732 }
5733 else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) {
5734 dev_err(&pdev->dev, "System does not support DMA, aborting.\n");
5735 rc = -EIO;
5736 goto err_out_release;
5737 }
5738
5739 bp->dev = dev; 6140 bp->dev = dev;
5740 bp->pdev = pdev; 6141 bp->pdev = pdev;
5741 6142
5742 spin_lock_init(&bp->phy_lock); 6143 spin_lock_init(&bp->phy_lock);
6144 spin_lock_init(&bp->indirect_lock);
5743 INIT_WORK(&bp->reset_task, bnx2_reset_task); 6145 INIT_WORK(&bp->reset_task, bnx2_reset_task);
5744 6146
5745 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); 6147 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
@@ -5767,7 +6169,15 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5767 6169
5768 bp->chip_id = REG_RD(bp, BNX2_MISC_ID); 6170 bp->chip_id = REG_RD(bp, BNX2_MISC_ID);
5769 6171
5770 if (CHIP_NUM(bp) != CHIP_NUM_5709) { 6172 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
6173 if (pci_find_capability(pdev, PCI_CAP_ID_EXP) == 0) {
6174 dev_err(&pdev->dev,
6175 "Cannot find PCIE capability, aborting.\n");
6176 rc = -EIO;
6177 goto err_out_unmap;
6178 }
6179 bp->flags |= PCIE_FLAG;
6180 } else {
5771 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX); 6181 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
5772 if (bp->pcix_cap == 0) { 6182 if (bp->pcix_cap == 0) {
5773 dev_err(&pdev->dev, 6183 dev_err(&pdev->dev,
@@ -5777,51 +6187,33 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5777 } 6187 }
5778 } 6188 }
5779 6189
5780 /* Get bus information. */ 6190 if (CHIP_ID(bp) != CHIP_ID_5706_A0 && CHIP_ID(bp) != CHIP_ID_5706_A1) {
5781 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS); 6191 if (pci_find_capability(pdev, PCI_CAP_ID_MSI))
5782 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) { 6192 bp->flags |= MSI_CAP_FLAG;
5783 u32 clkreg; 6193 }
5784
5785 bp->flags |= PCIX_FLAG;
5786
5787 clkreg = REG_RD(bp, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS);
5788
5789 clkreg &= BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET;
5790 switch (clkreg) {
5791 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_133MHZ:
5792 bp->bus_speed_mhz = 133;
5793 break;
5794
5795 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_95MHZ:
5796 bp->bus_speed_mhz = 100;
5797 break;
5798
5799 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_66MHZ:
5800 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_80MHZ:
5801 bp->bus_speed_mhz = 66;
5802 break;
5803 6194
5804 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_48MHZ: 6195 /* 5708 cannot support DMA addresses > 40-bit. */
5805 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_55MHZ: 6196 if (CHIP_NUM(bp) == CHIP_NUM_5708)
5806 bp->bus_speed_mhz = 50; 6197 persist_dma_mask = dma_mask = DMA_40BIT_MASK;
5807 break; 6198 else
6199 persist_dma_mask = dma_mask = DMA_64BIT_MASK;
5808 6200
5809 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_LOW: 6201 /* Configure DMA attributes. */
5810 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_32MHZ: 6202 if (pci_set_dma_mask(pdev, dma_mask) == 0) {
5811 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_38MHZ: 6203 dev->features |= NETIF_F_HIGHDMA;
5812 bp->bus_speed_mhz = 33; 6204 rc = pci_set_consistent_dma_mask(pdev, persist_dma_mask);
5813 break; 6205 if (rc) {
6206 dev_err(&pdev->dev,
6207 "pci_set_consistent_dma_mask failed, aborting.\n");
6208 goto err_out_unmap;
5814 } 6209 }
5815 } 6210 } else if ((rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) != 0) {
5816 else { 6211 dev_err(&pdev->dev, "System does not support DMA, aborting.\n");
5817 if (reg & BNX2_PCICFG_MISC_STATUS_M66EN) 6212 goto err_out_unmap;
5818 bp->bus_speed_mhz = 66;
5819 else
5820 bp->bus_speed_mhz = 33;
5821 } 6213 }
5822 6214
5823 if (reg & BNX2_PCICFG_MISC_STATUS_32BIT_DET) 6215 if (!(bp->flags & PCIE_FLAG))
5824 bp->flags |= PCI_32BIT_FLAG; 6216 bnx2_get_pci_speed(bp);
5825 6217
5826 /* 5706A0 may falsely detect SERR and PERR. */ 6218 /* 5706A0 may falsely detect SERR and PERR. */
5827 if (CHIP_ID(bp) == CHIP_ID_5706_A0) { 6219 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
@@ -6005,6 +6397,26 @@ err_out:
6005 return rc; 6397 return rc;
6006} 6398}
6007 6399
6400static char * __devinit
6401bnx2_bus_string(struct bnx2 *bp, char *str)
6402{
6403 char *s = str;
6404
6405 if (bp->flags & PCIE_FLAG) {
6406 s += sprintf(s, "PCI Express");
6407 } else {
6408 s += sprintf(s, "PCI");
6409 if (bp->flags & PCIX_FLAG)
6410 s += sprintf(s, "-X");
6411 if (bp->flags & PCI_32BIT_FLAG)
6412 s += sprintf(s, " 32-bit");
6413 else
6414 s += sprintf(s, " 64-bit");
6415 s += sprintf(s, " %dMHz", bp->bus_speed_mhz);
6416 }
6417 return str;
6418}
6419
6008static int __devinit 6420static int __devinit
6009bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 6421bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6010{ 6422{
@@ -6012,6 +6424,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6012 struct net_device *dev = NULL; 6424 struct net_device *dev = NULL;
6013 struct bnx2 *bp; 6425 struct bnx2 *bp;
6014 int rc, i; 6426 int rc, i;
6427 char str[40];
6015 6428
6016 if (version_printed++ == 0) 6429 if (version_printed++ == 0)
6017 printk(KERN_INFO "%s", version); 6430 printk(KERN_INFO "%s", version);
@@ -6052,6 +6465,23 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6052 dev->poll_controller = poll_bnx2; 6465 dev->poll_controller = poll_bnx2;
6053#endif 6466#endif
6054 6467
6468 pci_set_drvdata(pdev, dev);
6469
6470 memcpy(dev->dev_addr, bp->mac_addr, 6);
6471 memcpy(dev->perm_addr, bp->mac_addr, 6);
6472 bp->name = board_info[ent->driver_data].name;
6473
6474 if (CHIP_NUM(bp) == CHIP_NUM_5709)
6475 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
6476 else
6477 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
6478#ifdef BCM_VLAN
6479 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
6480#endif
6481 dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
6482 if (CHIP_NUM(bp) == CHIP_NUM_5709)
6483 dev->features |= NETIF_F_TSO6;
6484
6055 if ((rc = register_netdev(dev))) { 6485 if ((rc = register_netdev(dev))) {
6056 dev_err(&pdev->dev, "Cannot register net device\n"); 6486 dev_err(&pdev->dev, "Cannot register net device\n");
6057 if (bp->regview) 6487 if (bp->regview)
@@ -6063,20 +6493,13 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6063 return rc; 6493 return rc;
6064 } 6494 }
6065 6495
6066 pci_set_drvdata(pdev, dev); 6496 printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, "
6067
6068 memcpy(dev->dev_addr, bp->mac_addr, 6);
6069 memcpy(dev->perm_addr, bp->mac_addr, 6);
6070 bp->name = board_info[ent->driver_data].name,
6071 printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz found at mem %lx, "
6072 "IRQ %d, ", 6497 "IRQ %d, ",
6073 dev->name, 6498 dev->name,
6074 bp->name, 6499 bp->name,
6075 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A', 6500 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
6076 ((CHIP_ID(bp) & 0x0ff0) >> 4), 6501 ((CHIP_ID(bp) & 0x0ff0) >> 4),
6077 ((bp->flags & PCIX_FLAG) ? "-X" : ""), 6502 bnx2_bus_string(bp, str),
6078 ((bp->flags & PCI_32BIT_FLAG) ? "32-bit" : "64-bit"),
6079 bp->bus_speed_mhz,
6080 dev->base_addr, 6503 dev->base_addr,
6081 bp->pdev->irq); 6504 bp->pdev->irq);
6082 6505
@@ -6085,17 +6508,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6085 printk("%2.2x", dev->dev_addr[i]); 6508 printk("%2.2x", dev->dev_addr[i]);
6086 printk("\n"); 6509 printk("\n");
6087 6510
6088 dev->features |= NETIF_F_SG;
6089 if (bp->flags & USING_DAC_FLAG)
6090 dev->features |= NETIF_F_HIGHDMA;
6091 dev->features |= NETIF_F_IP_CSUM;
6092#ifdef BCM_VLAN
6093 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
6094#endif
6095 dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
6096
6097 netif_carrier_off(bp->dev);
6098
6099 return 0; 6511 return 0;
6100} 6512}
6101 6513
@@ -6140,6 +6552,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
6140 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL; 6552 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
6141 bnx2_reset_chip(bp, reset_code); 6553 bnx2_reset_chip(bp, reset_code);
6142 bnx2_free_skbs(bp); 6554 bnx2_free_skbs(bp);
6555 pci_save_state(pdev);
6143 bnx2_set_power_state(bp, pci_choose_state(pdev, state)); 6556 bnx2_set_power_state(bp, pci_choose_state(pdev, state));
6144 return 0; 6557 return 0;
6145} 6558}
@@ -6153,6 +6566,7 @@ bnx2_resume(struct pci_dev *pdev)
6153 if (!netif_running(dev)) 6566 if (!netif_running(dev))
6154 return 0; 6567 return 0;
6155 6568
6569 pci_restore_state(pdev);
6156 bnx2_set_power_state(bp, PCI_D0); 6570 bnx2_set_power_state(bp, PCI_D0);
6157 netif_device_attach(dev); 6571 netif_device_attach(dev);
6158 bnx2_init_nic(bp); 6572 bnx2_init_nic(bp);
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 878eee58f12a..bd6288d6350f 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -1,6 +1,6 @@
1/* bnx2.h: Broadcom NX2 network driver. 1/* bnx2.h: Broadcom NX2 network driver.
2 * 2 *
3 * Copyright (c) 2004, 2005, 2006 Broadcom Corporation 3 * Copyright (c) 2004-2007 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -24,8 +24,11 @@ struct tx_bd {
24 u32 tx_bd_haddr_hi; 24 u32 tx_bd_haddr_hi;
25 u32 tx_bd_haddr_lo; 25 u32 tx_bd_haddr_lo;
26 u32 tx_bd_mss_nbytes; 26 u32 tx_bd_mss_nbytes;
27 #define TX_BD_TCP6_OFF2_SHL (14)
27 u32 tx_bd_vlan_tag_flags; 28 u32 tx_bd_vlan_tag_flags;
28 #define TX_BD_FLAGS_CONN_FAULT (1<<0) 29 #define TX_BD_FLAGS_CONN_FAULT (1<<0)
30 #define TX_BD_FLAGS_TCP6_OFF0_MSK (3<<1)
31 #define TX_BD_FLAGS_TCP6_OFF0_SHL (1)
29 #define TX_BD_FLAGS_TCP_UDP_CKSUM (1<<1) 32 #define TX_BD_FLAGS_TCP_UDP_CKSUM (1<<1)
30 #define TX_BD_FLAGS_IP_CKSUM (1<<2) 33 #define TX_BD_FLAGS_IP_CKSUM (1<<2)
31 #define TX_BD_FLAGS_VLAN_TAG (1<<3) 34 #define TX_BD_FLAGS_VLAN_TAG (1<<3)
@@ -34,6 +37,7 @@ struct tx_bd {
34 #define TX_BD_FLAGS_END (1<<6) 37 #define TX_BD_FLAGS_END (1<<6)
35 #define TX_BD_FLAGS_START (1<<7) 38 #define TX_BD_FLAGS_START (1<<7)
36 #define TX_BD_FLAGS_SW_OPTION_WORD (0x1f<<8) 39 #define TX_BD_FLAGS_SW_OPTION_WORD (0x1f<<8)
40 #define TX_BD_FLAGS_TCP6_OFF4_SHL (12)
37 #define TX_BD_FLAGS_SW_FLAGS (1<<13) 41 #define TX_BD_FLAGS_SW_FLAGS (1<<13)
38 #define TX_BD_FLAGS_SW_SNAP (1<<14) 42 #define TX_BD_FLAGS_SW_SNAP (1<<14)
39 #define TX_BD_FLAGS_SW_LSO (1<<15) 43 #define TX_BD_FLAGS_SW_LSO (1<<15)
@@ -6292,6 +6296,41 @@ struct l2_fhdr {
6292#define MII_BNX2_DSP_ADDRESS 0x17 6296#define MII_BNX2_DSP_ADDRESS 0x17
6293#define MII_BNX2_DSP_EXPAND_REG 0x0f00 6297#define MII_BNX2_DSP_EXPAND_REG 0x0f00
6294 6298
6299#define MII_BNX2_BLK_ADDR 0x1f
6300#define MII_BNX2_BLK_ADDR_IEEE0 0x0000
6301#define MII_BNX2_BLK_ADDR_GP_STATUS 0x8120
6302#define MII_BNX2_GP_TOP_AN_STATUS1 0x1b
6303#define MII_BNX2_GP_TOP_AN_SPEED_MSK 0x3f00
6304#define MII_BNX2_GP_TOP_AN_SPEED_10 0x0000
6305#define MII_BNX2_GP_TOP_AN_SPEED_100 0x0100
6306#define MII_BNX2_GP_TOP_AN_SPEED_1G 0x0200
6307#define MII_BNX2_GP_TOP_AN_SPEED_2_5G 0x0300
6308#define MII_BNX2_GP_TOP_AN_SPEED_1GKV 0x0d00
6309#define MII_BNX2_GP_TOP_AN_FD 0x8
6310#define MII_BNX2_BLK_ADDR_SERDES_DIG 0x8300
6311#define MII_BNX2_SERDES_DIG_1000XCTL1 0x10
6312#define MII_BNX2_SD_1000XCTL1_FIBER 0x01
6313#define MII_BNX2_SD_1000XCTL1_AUTODET 0x10
6314#define MII_BNX2_SERDES_DIG_MISC1 0x18
6315#define MII_BNX2_SD_MISC1_FORCE_MSK 0xf
6316#define MII_BNX2_SD_MISC1_FORCE_2_5G 0x0
6317#define MII_BNX2_SD_MISC1_FORCE 0x10
6318#define MII_BNX2_BLK_ADDR_OVER1G 0x8320
6319#define MII_BNX2_OVER1G_UP1 0x19
6320#define MII_BNX2_BLK_ADDR_BAM_NXTPG 0x8350
6321#define MII_BNX2_BAM_NXTPG_CTL 0x10
6322#define MII_BNX2_NXTPG_CTL_BAM 0x1
6323#define MII_BNX2_NXTPG_CTL_T2 0x2
6324#define MII_BNX2_BLK_ADDR_CL73_USERB0 0x8370
6325#define MII_BNX2_CL73_BAM_CTL1 0x12
6326#define MII_BNX2_CL73_BAM_EN 0x8000
6327#define MII_BNX2_CL73_BAM_STA_MGR_EN 0x4000
6328#define MII_BNX2_CL73_BAM_NP_AFT_BP_EN 0x2000
6329#define MII_BNX2_BLK_ADDR_AER 0xffd0
6330#define MII_BNX2_AER_AER 0x1e
6331#define MII_BNX2_AER_AER_AN_MMD 0x3800
6332#define MII_BNX2_BLK_ADDR_COMBO_IEEEB0 0xffe0
6333
6295#define MIN_ETHERNET_PACKET_SIZE 60 6334#define MIN_ETHERNET_PACKET_SIZE 60
6296#define MAX_ETHERNET_PACKET_SIZE 1514 6335#define MAX_ETHERNET_PACKET_SIZE 1514
6297#define MAX_ETHERNET_JUMBO_PACKET_SIZE 9014 6336#define MAX_ETHERNET_JUMBO_PACKET_SIZE 9014
@@ -6429,13 +6468,15 @@ struct bnx2 {
6429 u32 last_status_idx; 6468 u32 last_status_idx;
6430 6469
6431 u32 flags; 6470 u32 flags;
6432#define PCIX_FLAG 1 6471#define PCIX_FLAG 0x00000001
6433#define PCI_32BIT_FLAG 2 6472#define PCI_32BIT_FLAG 0x00000002
6434#define ONE_TDMA_FLAG 4 /* no longer used */ 6473#define ONE_TDMA_FLAG 0x00000004 /* no longer used */
6435#define NO_WOL_FLAG 8 6474#define NO_WOL_FLAG 0x00000008
6436#define USING_DAC_FLAG 0x10 6475#define USING_MSI_FLAG 0x00000020
6437#define USING_MSI_FLAG 0x20 6476#define ASF_ENABLE_FLAG 0x00000040
6438#define ASF_ENABLE_FLAG 0x40 6477#define MSI_CAP_FLAG 0x00000080
6478#define ONE_SHOT_MSI_FLAG 0x00000100
6479#define PCIE_FLAG 0x00000200
6439 6480
6440 /* Put tx producer and consumer fields in separate cache lines. */ 6481 /* Put tx producer and consumer fields in separate cache lines. */
6441 6482
@@ -6484,6 +6525,7 @@ struct bnx2 {
6484 6525
6485 /* Used to synchronize phy accesses. */ 6526 /* Used to synchronize phy accesses. */
6486 spinlock_t phy_lock; 6527 spinlock_t phy_lock;
6528 spinlock_t indirect_lock;
6487 6529
6488 u32 phy_flags; 6530 u32 phy_flags;
6489#define PHY_SERDES_FLAG 1 6531#define PHY_SERDES_FLAG 1
@@ -6495,6 +6537,13 @@ struct bnx2 {
6495#define PHY_INT_MODE_LINK_READY_FLAG 0x200 6537#define PHY_INT_MODE_LINK_READY_FLAG 0x200
6496#define PHY_DIS_EARLY_DAC_FLAG 0x400 6538#define PHY_DIS_EARLY_DAC_FLAG 0x400
6497 6539
6540 u32 mii_bmcr;
6541 u32 mii_bmsr;
6542 u32 mii_bmsr1;
6543 u32 mii_adv;
6544 u32 mii_lpa;
6545 u32 mii_up1;
6546
6498 u32 chip_id; 6547 u32 chip_id;
6499 /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */ 6548 /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
6500#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000) 6549#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000)
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h
index 21d368ff424d..b49f439e0f67 100644
--- a/drivers/net/bnx2_fw.h
+++ b/drivers/net/bnx2_fw.h
@@ -15,680 +15,1071 @@
15 */ 15 */
16 16
17static u8 bnx2_COM_b06FwText[] = { 17static u8 bnx2_COM_b06FwText[] = {
18 0x1f, 0x8b, 0x08, 0x08, 0x09, 0x83, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 18 0x1f, 0x8b, 0x08, 0x00, 0x45, 0x30, 0xe7, 0x45, 0x00, 0x03, 0xdc, 0x5a,
19 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5b, 0x7d, 0x6c, 19 0x6b, 0x6c, 0x1c, 0xd7, 0x75, 0x3e, 0x33, 0x3b, 0x4b, 0xae, 0xc8, 0x15,
20 0x5b, 0xd7, 0x75, 0x3f, 0xef, 0xf1, 0x51, 0x7a, 0x96, 0x68, 0xf9, 0x99, 20 0x35, 0xa2, 0xc6, 0xf4, 0x5a, 0xa2, 0xed, 0x5d, 0x72, 0x28, 0x12, 0x96,
21 0x7e, 0x96, 0x59, 0x4f, 0xb1, 0x49, 0xf1, 0xc9, 0xd2, 0x62, 0x2d, 0x63, 21 0xec, 0x6e, 0x68, 0xda, 0x62, 0x8c, 0x8d, 0xb4, 0xd9, 0xa5, 0x0c, 0xa1,
22 0x34, 0x35, 0xd1, 0x3a, 0x26, 0x66, 0x48, 0xda, 0x71, 0x36, 0x67, 0xa0, 22 0x65, 0x6b, 0x4a, 0xa2, 0x6d, 0x05, 0x11, 0x02, 0x62, 0x49, 0xa9, 0x46,
23 0x1d, 0x05, 0x51, 0x51, 0xaf, 0xd0, 0x48, 0xd9, 0xcd, 0xb2, 0x0c, 0x73, 23 0x50, 0xb7, 0x92, 0xab, 0xb6, 0x81, 0x6b, 0x4b, 0x6b, 0x92, 0x6a, 0x09,
24 0x96, 0xb4, 0x70, 0xbc, 0xb4, 0xa1, 0x25, 0x79, 0xf5, 0x06, 0x45, 0xcf, 24 0x84, 0xe6, 0x08, 0x11, 0x43, 0x19, 0xa9, 0x11, 0x10, 0xa4, 0x1c, 0xbb,
25 0xb3, 0x34, 0x39, 0xc0, 0x82, 0x41, 0x10, 0x9d, 0x3a, 0x7f, 0x30, 0xa5, 25 0xc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x39, 0xb1, 0x26, 62 0x94, 0x54, 0xa2, 0x80, 0x19, 0x47, 0xce, 0xbe, 0x4b, 0x1d, 0xa5, 0x7c,
63 0xff, 0x85, 0x29, 0x35, 0x71, 0x2b, 0x0d, 0x1b, 0x8c, 0x0f, 0x80, 0x05, 63 0xf1, 0x4b, 0x4a, 0x7e, 0xf2, 0x0e, 0x19, 0xb2, 0x49, 0xe7, 0x9f, 0xdd,
64 0x1f, 0x74, 0x25, 0x79, 0x2a, 0x44, 0xc7, 0xec, 0x80, 0x92, 0x3a, 0x75, 64 0xea, 0xaf, 0x19, 0x33, 0x72, 0x67, 0x06, 0xe5, 0xa4, 0x17, 0x37, 0xf2,
65 0x37, 0x25, 0x63, 0x64, 0xaa, 0xd4, 0x25, 0xbe, 0x2d, 0x14, 0x43, 0x34, 65 0x67, 0x76, 0x4a, 0x2e, 0x2d, 0x8e, 0x29, 0x1d, 0xea, 0xdd, 0xf9, 0xd2,
66 0x6e, 0x93, 0x92, 0xb4, 0x99, 0x5e, 0xed, 0x18, 0x6f, 0x13, 0xb0, 0xe8, 66 0xa0, 0x8c, 0x7b, 0x62, 0xe4, 0x3c, 0x4b, 0x46, 0x4b, 0x2d, 0x78, 0xde,
67 0xeb, 0xf0, 0x51, 0x97, 0x91, 0x22, 0x9d, 0x71, 0x46, 0x7f, 0x50, 0x49, 67 0xa4, 0xc6, 0xa2, 0xaf, 0x35, 0x22, 0x1d, 0x76, 0x5e, 0x62, 0xe8, 0xb7,
68 0x8b, 0x39, 0x44, 0x7f, 0x78, 0x8c, 0x02, 0x74, 0xba, 0x68, 0x4a, 0xd8, 68 0xd1, 0xdf, 0x6c, 0xf4, 0xa9, 0x39, 0x54, 0x7f, 0x72, 0x4c, 0xe2, 0xd8,
69 0x72, 0x39, 0x19, 0x33, 0x00, 0x07, 0xda, 0xd9, 0x26, 0x0d, 0xe3, 0x39, 69 0x9b, 0xa3, 0xc7, 0x56, 0x2a, 0xb9, 0xb4, 0x8d, 0x71, 0x83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, 0x05, 0xb3, 0xb6, 0xed, 0xea, 0x82, 0xd7, 114 0x27, 0xf6, 0x4c, 0x60, 0xce, 0x67, 0x21, 0x97, 0x9f, 0x60, 0x4c, 0x46,
115 0x66, 0xf1, 0xde, 0xc2, 0xe4, 0xb3, 0x58, 0x8e, 0xfc, 0xc0, 0x35, 0x06, 115 0x16, 0x3d, 0xf0, 0xe3, 0x74, 0x54, 0xf6, 0xa9, 0x67, 0xbd, 0x9a, 0xae,
116 0x3d, 0x6c, 0x96, 0x38, 0x7c, 0x4b, 0xe2, 0x00, 0x5c, 0x01, 0x37, 0x5a, 116 0xf0, 0xb3, 0x98, 0xec, 0x75, 0x78, 0x1f, 0x3c, 0xb3, 0xc0, 0x63, 0xb6,
117 0xe2, 0x6f, 0x04, 0x4b, 0xea, 0xda, 0x4c, 0x43, 0xf7, 0x7d, 0xad, 0x18, 117 0xff, 0xe1, 0x16, 0xbf, 0xcd, 0xfb, 0xf3, 0x9a, 0xfe, 0x87, 0xfc, 0xf7,
118 0xbf, 0xec, 0xe3, 0x75, 0xdc, 0x27, 0x29, 0x69, 0xe8, 0xc9, 0xd8, 0xb4, 118 0xca, 0x1f, 0x28, 0x9c, 0x5c, 0x28, 0x13, 0xc7, 0x24, 0x1d, 0x71, 0xe5,
119 0x46, 0xd9, 0xd8, 0x26, 0x21, 0xd7, 0xd9, 0x58, 0xd5, 0x06, 0x8c, 0x4e, 119 0x48, 0x5f, 0x1a, 0x76, 0x65, 0x1b, 0xe9, 0xd1, 0xae, 0x7a, 0xf2, 0x3c,
120 0xd4, 0xdb, 0x00, 0xfe, 0x8e, 0x6d, 0x80, 0xa3, 0xfb, 0x63, 0xd3, 0x6c, 120 0x6b, 0xba, 0x8d, 0xc0, 0x0a, 0x49, 0x9a, 0xd0, 0xb3, 0x51, 0xb5, 0x97,
121 0x0b, 0x1c, 0xdd, 0x3f, 0x36, 0xc1, 0x36, 0x41, 0xcc, 0x09, 0xfd, 0x67, 121 0x75, 0xa6, 0x4f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129 0xfe, 0x98, 0x90, 0x4d, 0xef, 0x2f, 0x09, 0x1b, 0x94, 0x8c, 0x7d, 0x08, 129 0x41, 0xbb, 0x94, 0x90, 0xb3, 0x93, 0x92, 0x3d, 0x7c, 0xaa, 0x57, 0xfa,
130 0xf9, 0x75, 0x69, 0xe4, 0xea, 0x1f, 0xdb, 0xfa, 0x2b, 0x1e, 0x1f, 0xb2, 130 0x60, 0x9f, 0x73, 0x93, 0x57, 0x2a, 0xe0, 0xdb, 0xbd, 0x75, 0xe2, 0x02,
131 0x05, 0x76, 0xdf, 0x84, 0x3c, 0xb9, 0x76, 0x9f, 0xed, 0x71, 0x88, 0x6d, 131 0x83, 0xe1, 0xef, 0x7b, 0xa2, 0x12, 0xc9, 0x64, 0xa0, 0x0b, 0x69, 0xe5,
132 0x26, 0xf4, 0x8d, 0x6d, 0x70, 0x80, 0xd4, 0x19, 0x4d, 0xda, 0x69, 0x5d, 132 0x83, 0x97, 0xfe, 0x2c, 0xeb, 0xfe, 0x65, 0xed, 0x3a, 0xf8, 0x79, 0xcc,
133 0xda, 0xe9, 0x00, 0x6c, 0x34, 0xb7, 0x0d, 0xd9, 0x36, 0x45, 0x1b, 0xf6, 133 0xdb, 0x93, 0x56, 0x7a, 0x13, 0xfe, 0xcb, 0x01, 0x57, 0x72, 0xe9, 0x8f,
134 0x1a, 0xf6, 0x70, 0x77, 0x3a, 0x35, 0xc1, 0xfe, 0x10, 0xbe, 0x7b, 0x86, 134 0xa1, 0x5b, 0x01, 0x4d, 0x81, 0x6d, 0xd0, 0x07, 0x7d, 0x10, 0xf2, 0x6d,
135 0x75, 0xf8, 0xdb, 0x43, 0x23, 0xd3, 0xc2, 0x07, 0xb0, 0xff, 0x80, 0x65, 135 0xad, 0xc0, 0x17, 0x07, 0xf2, 0x0b, 0xfc, 0x11, 0xfd, 0x44, 0x82, 0x58,
136 0x66, 0x1b, 0xce, 0xb6, 0x1c, 0xfb, 0x2e, 0x62, 0xdd, 0x8a, 0xad, 0x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, 0xf6, 0x77, 0x0e,
144 0x9b, 0x1d, 0xbf, 0xd9, 0x15, 0x1e, 0x05, 0xff, 0xd3, 0x2f, 0x7e, 0x05, 144 0x62, 0xcf, 0x03, 0xc0, 0xee, 0x7e, 0x60, 0xf7, 0x1e, 0x60, 0x77, 0x1f,
145 0xdf, 0x3c, 0x4d, 0x07, 0xa7, 0x0e, 0x2b, 0x39, 0xfb, 0x08, 0xe0, 0x97, 145 0xb0, 0x3b, 0x0b, 0xec, 0xee, 0x05, 0x6e, 0xf7, 0x00, 0xb7, 0xd3, 0xe0,
146 0x83, 0xd5, 0x01, 0x9b, 0x07, 0xec, 0x97, 0x31, 0xef, 0xd3, 0xa4, 0xdf, 146 0x8d, 0x23, 0xb3, 0xc0, 0xf1, 0x59, 0xe8, 0xcb, 0x2c, 0xe6, 0x28, 0xcc,
147 0x1e, 0x19, 0x48, 0x28, 0xc0, 0xe3, 0x45, 0x01, 0x2f, 0x7d, 0x71, 0x97, 147 0x88, 0xf1, 0x35, 0xec, 0xe1, 0xe8, 0x54, 0x6a, 0x16, 0xfa, 0x9d, 0x18,
148 0xb1, 0x53, 0xf0, 0x3f, 0x40, 0xef, 0x15, 0x2f, 0x80, 0xbe, 0xbd, 0xf0, 148 0x32, 0xa1, 0x07, 0xe9, 0xbb, 0x61, 0x6f, 0x88, 0x9b, 0xca, 0x83, 0x32,
149 0x39, 0x91, 0x67, 0x61, 0x93, 0xe1, 0x8f, 0x22, 0x57, 0x31, 0x2d, 0x7c, 149 0x0c, 0xbf, 0xdf, 0xb6, 0xb5, 0x1d, 0xfa, 0x84, 0x68, 0x24, 0x11, 0xe8,
150 0x11, 0x29, 0x0f, 0x76, 0xa7, 0x41, 0xef, 0x38, 0xfc, 0xd3, 0x00, 0xfc, 150 0x68, 0xbf, 0x14, 0xbc, 0x76, 0xbb, 0xcd, 0xec, 0x42, 0x5f, 0x2a, 0x89,
151 0x53, 0x0c, 0xbe, 0xa9, 0x07, 0x7e, 0xc9, 0x82, 0x5f, 0x0a, 0x83, 0x1f, 151 0x18, 0xd5, 0x38, 0x74, 0x3a, 0x65, 0x8c, 0x9c, 0x26, 0x0f, 0x26, 0x81,
152 0x06, 0xcd, 0xc2, 0x47, 0xcd, 0x42, 0xfe, 0xe7, 0x66, 0x48, 0x19, 0x04, 152 0x83, 0x15, 0x19, 0x4f, 0x53, 0x4f, 0x2b, 0xf2, 0x5c, 0x3a, 0xd5, 0x5b,
153 0xad, 0xcf, 0xc1, 0x3f, 0x26, 0x63, 0x77, 0x42, 0xcf, 0x22, 0x17, 0x66, 153 0x94, 0x46, 0x39, 0xe9, 0x4c, 0x2a, 0xdf, 0x6f, 0x65, 0x4e, 0x29, 0x1f,
154 0xd5, 0x41, 0xca, 0xc1, 0x9f, 0x77, 0x6e, 0x8b, 0x62, 0xbd, 0x26, 0x4a, 154 0x3a, 0xec, 0xe2, 0x5a, 0x6a, 0x33, 0x0a, 0xa7, 0xb9, 0xd7, 0x76, 0xfc,
155 0x84, 0x5c, 0x1d, 0xe5, 0xdf, 0x7e, 0x85, 0xac, 0x7f, 0x06, 0xef, 0x22, 155 0xa2, 0x58, 0xf7, 0x57, 0x90, 0x91, 0x25, 0x7d, 0x3d, 0x62, 0x1c, 0xee,
156 0x61, 0xa2, 0x3d, 0x94, 0xb5, 0xa3, 0x46, 0xa7, 0xda, 0x03, 0x18, 0x6e, 156 0x2c, 0x02, 0x39, 0x53, 0xf6, 0x22, 0x56, 0xcb, 0x4f, 0xb6, 0x27, 0xda,
157 0x87, 0x95, 0x03, 0x53, 0x11, 0x05, 0xfb, 0x03, 0xcd, 0x27, 0x60, 0xeb, 157 0x4d, 0x4b, 0x86, 0x2c, 0x43, 0x46, 0x61, 0x5f, 0x7d, 0xe9, 0xff, 0xa9,
158 0xcb, 0x34, 0x1e, 0x63, 0x3d, 0x29, 0xd3, 0xf3, 0xb1, 0xc8, 0x40, 0x9e, 158 0x9c, 0x74, 0xf8, 0xbc, 0x5e, 0xfe, 0x5c, 0x61, 0x31, 0xd6, 0x9e, 0x9f,
159 0x5a, 0xe9, 0x98, 0x39, 0x21, 0x7c, 0xbc, 0x16, 0x3f, 0x21, 0x74, 0x2c, 159 0xc6, 0xba, 0x51, 0xf0, 0x9b, 0xeb, 0x72, 0x1e, 0xb4, 0x81, 0x8b, 0x96,
160 0x67, 0xe1, 0x59, 0xec, 0x54, 0xb2, 0x53, 0xbc, 0x7e, 0x14, 0x5a, 0xee, 160 0x9b, 0x9a, 0x2d, 0xca, 0x2e, 0xd8, 0xe9, 0x06, 0xc9, 0x6d, 0xaf, 0x93,
161 0xc7, 0x93, 0xe7, 0x07, 0xdd, 0xfa, 0x49, 0x39, 0xd8, 0x9d, 0x87, 0x77, 161 0xec, 0x40, 0x52, 0x0a, 0x53, 0xbb, 0x80, 0x8d, 0x31, 0x65, 0xab, 0x85,
162 0x88, 0x18, 0x8b, 0x58, 0x39, 0x35, 0x11, 0x0d, 0x45, 0x55, 0x8d, 0x86, 162 0xc1, 0xa4, 0x3c, 0x36, 0xc5, 0xbe, 0x2c, 0xf6, 0x9a, 0x3a, 0x95, 0x15,
163 0x35, 0x85, 0x46, 0x61, 0x6f, 0xd2, 0xb1, 0xff, 0x2c, 0x1f, 0x33, 0x79, 163 0xee, 0xd5, 0x90, 0xec, 0xc1, 0xac, 0x3c, 0xe6, 0x65, 0x65, 0x04, 0xf2,
164 0xbc, 0x99, 0xbe, 0x2a, 0xfc, 0x0d, 0xd6, 0x2e, 0x4c, 0x63, 0x5d, 0x3f, 164 0x3a, 0x0b, 0x5e, 0x1e, 0xf2, 0x5c, 0x79, 0x0e, 0xbe, 0x26, 0x7f, 0x1a,
165 0xf8, 0xcb, 0xeb, 0xf2, 0x3c, 0x68, 0xc3, 0xf6, 0x6b, 0x56, 0xe4, 0xd9, 165 0x58, 0xeb, 0xae, 0x07, 0x2e, 0xa6, 0xce, 0x31, 0xc6, 0x37, 0x19, 0x87,
166 0x3c, 0xed, 0x00, 0x6d, 0xd9, 0x66, 0xc1, 0x3e, 0x0c, 0x60, 0xed, 0x5e, 166 0x82, 0x97, 0x7f, 0x34, 0x45, 0x5e, 0x9a, 0x32, 0x7d, 0xaf, 0x01, 0x3c,
167 0xd8, 0x4f, 0x3c, 0x93, 0xbd, 0x1c, 0x07, 0x05, 0x68, 0xd8, 0x64, 0x79, 167 0x48, 0x82, 0x77, 0xae, 0xfc, 0xb1, 0x97, 0x3a, 0x9f, 0x35, 0x81, 0xc5,
168 0xd4, 0xe5, 0x98, 0xe9, 0x19, 0xf3, 0xcb, 0xb1, 0x20, 0xfe, 0xe0, 0x7f, 168 0xe9, 0xde, 0x88, 0x34, 0x24, 0x30, 0xce, 0x1f, 0x93, 0x4f, 0x47, 0x20,
169 0x4d, 0x96, 0x19, 0x6e, 0x73, 0x4c, 0xc6, 0x34, 0x09, 0xd3, 0xdc, 0x64, 169 0xd7, 0x22, 0xc6, 0xa6, 0xd0, 0xcf, 0x77, 0x1d, 0xfc, 0xb2, 0x18, 0x07,
170 0x02, 0x34, 0x8b, 0x9c, 0x4d, 0x10, 0xd3, 0x0c, 0x46, 0x7b, 0x7f, 0x82, 170 0x5d, 0xb5, 0x53, 0xe7, 0x67, 0x4d, 0x8e, 0x4f, 0x42, 0x3e, 0x36, 0xc6,
171 0xbe, 0x64, 0xaf, 0xf7, 0x3b, 0xb6, 0xb0, 0x55, 0x49, 0xc1, 0x17, 0xa8, 171 0x03, 0xf8, 0x6c, 0xde, 0xa7, 0x8d, 0x02, 0x69, 0xf0, 0xa8, 0x53, 0x88,
172 0x56, 0x0b, 0x7c, 0x45, 0x98, 0x5e, 0x15, 0xb0, 0x64, 0xa8, 0xf1, 0x68, 172 0x49, 0xcb, 0xc4, 0xd4, 0xf6, 0x73, 0xaf, 0x0b, 0xd7, 0xf9, 0x22, 0xc6,
173 0xe8, 0x4b, 0x74, 0xab, 0xb0, 0x11, 0x09, 0xc3, 0x4b, 0xe3, 0xff, 0x52, 173 0x7f, 0x88, 0x38, 0xdc, 0x96, 0x79, 0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, 0x0a, 0x5b, 0xdc, 0xa7, 0xd1, 0x09, 0xd1, 0x56, 0x28, 181 0x9d, 0xf4, 0xfc, 0xb8, 0xd0, 0x44, 0xec, 0x38, 0x8b, 0xd8, 0x31, 0xaf,
182 0x31, 0x18, 0x09, 0x2d, 0xa8, 0x1c, 0x4b, 0x33, 0x6c, 0x18, 0xf1, 0x4a, 182 0x6c, 0xc6, 0xce, 0x22, 0xd7, 0x80, 0xce, 0xfb, 0xf6, 0x32, 0x5f, 0xba,
183 0x40, 0xc2, 0x22, 0x9e, 0xb3, 0xdd, 0x98, 0x30, 0x84, 0x7e, 0x53, 0xf4, 183 0x4f, 0x86, 0xcf, 0x7c, 0x3f, 0x6e, 0x22, 0xce, 0x2a, 0x38, 0xa4, 0x8b,
184 0x1f, 0xab, 0xe8, 0xa8, 0x13, 0xff, 0xa9, 0x88, 0x11, 0x0b, 0x88, 0x11, 184 0xe3, 0xcf, 0x81, 0x4e, 0xf2, 0x4e, 0x86, 0x18, 0x57, 0x21, 0x16, 0x7e,
185 0x53, 0x42, 0x47, 0x8d, 0x04, 0x72, 0x04, 0xd0, 0xdc, 0xd1, 0xcf, 0x42, 185 0x84, 0x32, 0x1e, 0xed, 0x7e, 0x88, 0x7c, 0x2b, 0x82, 0xe8, 0x53, 0x3e,
186 0x91, 0x71, 0xc9, 0xb1, 0x5c, 0x0e, 0x00, 0x99, 0x13, 0x8e, 0x7d, 0xa4, 186 0x8e, 0x49, 0x91, 0x71, 0xe8, 0x62, 0xe4, 0x09, 0x19, 0x9a, 0xa7, 0x2f,
187 0x3c, 0xc7, 0x91, 0xa3, 0xea, 0x53, 0x34, 0x5c, 0x60, 0x3f, 0x8e, 0x3f, 187 0xc4, 0xcf, 0x23, 0x26, 0x02, 0xc7, 0x94, 0xcf, 0x6a, 0x87, 0x3e, 0x14,
188 0x9b, 0x6d, 0x2d, 0xec, 0xa3, 0xf0, 0xc5, 0x51, 0xf0, 0x39, 0x0f, 0x1a, 188 0xc1, 0xef, 0x8d, 0x3a, 0x0e, 0x3b, 0x08, 0xf9, 0xf6, 0x43, 0xfe, 0x19,
189 0xac, 0x97, 0x74, 0xdd, 0x4f, 0x07, 0xec, 0x3d, 0xa0, 0x79, 0x9c, 0x46, 189 0x19, 0x39, 0x33, 0x42, 0xdd, 0xee, 0x9a, 0x97, 0x54, 0xd7, 0x49, 0xd9,
190 0x4e, 0x8d, 0xb0, 0xcc, 0xf6, 0x14, 0x28, 0xd2, 0x73, 0x8c, 0xb6, 0x1b, 190 0x66, 0xcf, 0xc1, 0x06, 0xb3, 0x83, 0x95, 0x5d, 0x66, 0x86, 0xef, 0x9c,
191 0x73, 0x2c, 0xdf, 0x83, 0xe5, 0x1d, 0xe0, 0x85, 0xd0, 0x51, 0xc8, 0x20, 191 0xc0, 0x3b, 0xb8, 0xce, 0x8f, 0xc8, 0xd1, 0x32, 0xfb, 0x9e, 0x05, 0xdf,
192 0x65, 0x0b, 0x23, 0xf4, 0x58, 0x89, 0xfb, 0xf2, 0xa0, 0x1d, 0xe2, 0xda, 192 0x11, 0x17, 0xf7, 0x1c, 0xd4, 0xf6, 0x80, 0xf9, 0xac, 0x60, 0xbe, 0x11,
193 0xfe, 0xfd, 0x52, 0xce, 0x31, 0x9f, 0xe6, 0xce, 0x37, 0x22, 0xe7, 0x63, 193 0x3d, 0x1f, 0xc7, 0x71, 0x0c, 0xdf, 0x59, 0x9a, 0x77, 0x37, 0x7d, 0x22,
194 0x38, 0x86, 0xe1, 0x6f, 0xaa, 0xf3, 0xee, 0x14, 0x3c, 0x8d, 0x18, 0x5d, 194 0x30, 0xa8, 0xc3, 0xac, 0xec, 0x8a, 0xe2, 0xf9, 0x73, 0x3d, 0xbc, 0xc7,
195 0x6a, 0x79, 0x87, 0x1f, 0xe3, 0xcf, 0xf7, 0xf3, 0x3b, 0xe6, 0x81, 0xef, 195 0x3c, 0xf0, 0x89, 0xb6, 0xdb, 0x8f, 0xb1, 0x83, 0x98, 0x73, 0x9d, 0xb4,
196 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, 0x1e, 0xbf, 0x60, 0x7c, 0x0d,
211 0xc0, 0x7d, 0x84, 0xba, 0xa1, 0x6b, 0x22, 0x8f, 0x39, 0x51, 0x8b, 0x17, 211 0xb1, 0x4e, 0x6e, 0xfe, 0x8a, 0x91, 0x87, 0x5e, 0xcc, 0x7b, 0x77, 0x43,
212 0xf3, 0xbc, 0x9e, 0xcf, 0x5f, 0xc6, 0x3c, 0xdc, 0xcf, 0x70, 0x78, 0x2f, 212 0x9f, 0x68, 0x57, 0x36, 0xd6, 0x4e, 0x25, 0xfe, 0xc9, 0x6c, 0x4f, 0xce,
213 0x3c, 0x41, 0x23, 0x90, 0xc7, 0x5c, 0x7f, 0x57, 0x68, 0x0c, 0xdf, 0xa4, 213 0x01, 0x03, 0x0e, 0x81, 0xb1, 0xbe, 0x2c, 0x5d, 0x25, 0xdb, 0x45, 0x33,
214 0x4a, 0x4d, 0x74, 0x54, 0xe3, 0xf1, 0x48, 0x38, 0xaf, 0x1e, 0x42, 0xdc, 214 0xaa, 0xf1, 0x8f, 0xed, 0x94, 0xfd, 0xb0, 0xc0, 0x58, 0x1a, 0xf6, 0x80,
215 0xf3, 0xb8, 0xea, 0xb7, 0x7e, 0xe6, 0x67, 0xbf, 0xe3, 0xb7, 0xae, 0x29, 215 0xcf, 0x7b, 0x64, 0xb8, 0x9c, 0x91, 0xc2, 0x99, 0x6d, 0xf6, 0x28, 0x72,
216 0xd5, 0xb9, 0x10, 0x87, 0x8a, 0xdc, 0x60, 0x41, 0x19, 0x2c, 0x5d, 0x52, 216 0xf5, 0x25, 0xda, 0x89, 0x75, 0x45, 0x60, 0x1d, 0xfc, 0xb7, 0x27, 0xc5,
217 0x92, 0x85, 0x6b, 0x4a, 0xaa, 0xc4, 0x30, 0x8e, 0xce, 0x67, 0xcf, 0x74, 217 0xba, 0x0c, 0x31, 0xaf, 0x03, 0xfa, 0x84, 0xbe, 0xd2, 0x92, 0x4e, 0xde,
218 0x82, 0x4e, 0x1f, 0x89, 0xef,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8,
233 0x0e, 0x36, 0xe9, 0xac, 0x9d, 0x34, 0x58, 0x9f, 0x92, 0x31, 0xf6, 0x9d, 233 0x41, 0xab, 0xb1, 0xef, 0x5b, 0x8c, 0x0b, 0xe1, 0x7b, 0x7f, 0x6c, 0xf9,
234 0xbb, 0x65, 0xde, 0x1d, 0x92, 0x71, 0xf7, 0xa7, 0x64, 0x2c, 0x7b, 0x00, 234 0x71, 0xe3, 0x77, 0x6d, 0x5f, 0x57, 0x83, 0xf6, 0x8f, 0x6a, 0xda, 0x1c,
235 0xb1, 0xec, 0x66, 0x1a, 0xed, 0xe1, 0x9c, 0xa4, 0x05, 0xcf, 0x75, 0x78, 235 0xfb, 0xdf, 0x35, 0x7d, 0x3b, 0x36, 0x2e, 0x6f, 0xdf, 0x59, 0xb7, 0xf2,
236 0x22, 0x6e, 0xed, 0x49, 0x48, 0xbd, 0xfc, 0x0c, 0x62, 0x5c, 0xd8, 0xff, 236 0x9d, 0x89, 0x9a, 0x31, 0x2f, 0x37, 0x2f, 0x6f, 0xff, 0xe9, 0x2a, 0xef,
237 0x1e, 0xe4, 0x37, 0x19, 0xc4, 0x6a, 0x56, 0x1f, 0xc7, 0xe5, 0xb0, 0x65, 237 0xec, 0xd9, 0xb0, 0xbc, 0xef, 0xd1, 0x4d, 0x35, 0x63, 0xa0, 0x53, 0x0e,
238 0xef, 0x37, 0x39, 0x76, 0xfe, 0x2e, 0x19, 0x03, 0xbb, 0xed, 0x56, 0xc0, 238 0x72, 0xab, 0x60, 0xfc, 0x03, 0x37, 0xf9, 0xcf, 0xc9, 0xdf, 0x5a, 0x5d,
239 0xa4, 0xd1, 0xd7, 0x8a, 0x6f, 0x7e, 0x07, 0xb2, 0xdf, 0x86, 0xf6, 0xce, 239 0x52, 0x5b, 0x47, 0xdb, 0x84, 0x1c, 0x2e, 0x18, 0xb0, 0x39, 0xdb, 0xcc,
240 0x3a, 0x18, 0xe4, 0xb3, 0x56, 0x16, 0x7d, 0x11, 0xc0, 0xb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x81, 0xfa, 0xe5,
270 0xde, 0xab, 0x89, 0xa9, 0xd7, 0xf8, 0xc9, 0xe2, 0x78, 0x89, 0x61, 0x74, 270 0x88, 0xe7, 0xe7, 0x0c, 0x03, 0xa5, 0x01, 0xf4, 0x29, 0xda, 0x13, 0x8c,
271 0x19, 0x2f, 0x05, 0x64, 0x5e, 0x63, 0xc8, 0x3c, 0x87, 0x63, 0x6d, 0xae, 271 0x35, 0x4d, 0x93, 0xb1, 0x66, 0x0a, 0xc9, 0x87, 0xbf, 0x97, 0xb6, 0xad,
272 0xb1, 0xd6, 0xc7, 0x50, 0x0b, 0x43, 0xc1, 0x6d, 0xcc, 0x13, 0x8e, 0xa1, 272 0xac, 0x65, 0x06, 0x7b, 0x69, 0xbc, 0xb0, 0x7c, 0x2f, 0xbb, 0x94, 0xde,
273 0xda, 0x28, 0x39, 0xe3, 0xc4, 0x50, 0x4e, 0x9d, 0xcd, 0xcd, 0x71, 0x5c, 273 0x9b, 0xe0, 0x9d, 0x8f, 0x4d, 0x9c, 0xf3, 0x7c, 0x94, 0xb8, 0x35, 0x50,
274 0x5c, 0xd9, 0x0f, 0xef, 0xc0, 0x3e, 0x45, 0x9e, 0x14, 0x74, 0xea, 0x7f, 274 0x1a, 0x54, 0xf3, 0x8e, 0xaf, 0x98, 0x57, 0xb0, 0xc7, 0x03, 0x6b, 0x3c,
275 0x1a, 0xec, 0xf6, 0x51, 0xf4, 0x8f, 0xba, 0xfd, 0x9e, 0x5c, 0xc3, 0xc5, 275 0xe3, 0xfe, 0x19, 0x5b, 0xd8, 0x7a, 0xff, 0x81, 0x0c, 0x2f, 0x63, 0xce,
276 0x85, 0x7d, 0xbd, 0x1b, 0xd3, 0xed, 0x96, 0x31, 0x1d, 0x62, 0x18, 0xdb, 276 0x2e, 0xa3, 0xa0, 0xe2, 0xb6, 0x83, 0x4a, 0x1e, 0x85, 0xd2, 0x10, 0xae,
277 0xc9, 0xbb, 0xf6, 0x16, 0x33, 0xe8, 0xe3, 0x75, 0x11, 0x1b, 0x12, 0xc7, 277 0xb4, 0x17, 0x35, 0x8f, 0xb2, 0x99, 0x51, 0x25, 0x83, 0x11, 0xb5, 0xc7,
278 0x49, 0x90, 0xaf, 0xfd, 0x91, 0x50, 0x58, 0xad, 0xc7, 0xab, 0x75, 0xa1, 278 0xb9, 0xd2, 0x23, 0x88, 0xd7, 0xbe, 0x0e, 0x3f, 0x18, 0xae, 0x2b, 0x3a,
279 0x16, 0xaf, 0x41, 0xf1, 0xdd, 0xf8, 0x92, 0xef, 0x48, 0xc4, 0x92, 0xe3, 279 0x18, 0x43, 0x5e, 0x15, 0x43, 0x78, 0x4a, 0x9a, 0x59, 0x33, 0xbc, 0x82,
280 0xf6, 0x10, 0xe8, 0xc5, 0xf8, 0xb9, 0xba, 0xe1, 0xc6, 0xc9, 0x8c, 0xd3, 280 0x35, 0xb8, 0xe7, 0x38, 0xe4, 0x6f, 0xf8, 0xcf, 0xd5, 0xfa, 0x01, 0xcf,
281 0x3f, 0x82, 0xc6, 0xbb, 0x15, 0xfe, 0x7e, 0xcc, 0xde, 0x2f, 0xe8, 0x96, 281 0xeb, 0x42, 0xf4, 0x54, 0x10, 0xbf, 0x26, 0x40, 0x43, 0xf8, 0x9d, 0x63,
282 0x15, 0xb8, 0x0e, 0x7b, 0x70, 0x1d, 0x91, 0xb8, 0xb2, 0x2e, 0xb0, 0x7e, 282 0xd2, 0xe7, 0x51, 0x56, 0xed, 0x89, 0x11, 0xe4, 0xbb, 0x05, 0x09, 0x62,
283 0x78, 0x6b, 0x9a, 0xa6, 0xd8, 0x1b, 0x70, 0x0e, 0xf3, 0xb9, 0xb9, 0x6a, 283 0x11, 0xae, 0x4f, 0x0c, 0xc8, 0x23, 0x97, 0x4a, 0x60, 0x7f, 0x01, 0x5f,
284 0x2d, 0x0c, 0xf9, 0xb6, 0xc1, 0x1f, 0x02, 0xd7, 0xac, 0x88, 0x43, 0x03, 284 0x03, 0x9e, 0xc6, 0x2f, 0xd4, 0xea, 0xc7, 0x38, 0xe8, 0x19, 0xf6, 0xc8,
285 0x0b, 0xf5, 0x34, 0x1c, 0xc7, 0x5a, 0x88, 0xdb, 0x81, 0x8f, 0xcb, 0xf3, 285 0xa7, 0x40, 0x6f, 0x83, 0xb5, 0x2f, 0xab, 0xfd, 0x8c, 0xa9, 0xda, 0xe7,
286 0x26, 0x89, 0xcf, 0x37, 0xc5, 0xdc, 0x63, 0xa2, 0x06, 0xea, 0xd3, 0x39, 286 0xfa, 0xba, 0x40, 0x7f, 0x47, 0x11, 0xb7, 0xf8, 0xfa, 0xf8, 0x7b, 0x9a,
287 0x77, 0xc9, 0x0a, 0xde, 0x69, 0x92, 0x77, 0x8f, 0x56, 0xf0, 0x73, 0x78, 287 0x37, 0x81, 0xde, 0xc6, 0xb5, 0x0e, 0x30, 0x47, 0xa4, 0x5d, 0x05, 0x3a,
288 0x1c, 0x90, 0x74, 0xe5, 0xdc, 0x95, 0x75, 0x5a, 0xf0, 0xa7, 0x9d, 0x73, 288 0xd2, 0x61, 0xef, 0x57, 0xbc, 0xe0, 0x33, 0x95, 0x13, 0x2a, 0x39, 0x0f,
289 0xd3, 0x41, 0x6a, 0x14, 0x23, 0x2f, 0x0c, 0xa9, 0xdb, 0x1c, 0x3a, 0x3a, 289 0x55, 0xe5, 0xbc, 0xbe, 0x46, 0x67, 0x3b, 0x6d, 0xdf, 0x46, 0x69, 0x8b,
290 0x31, 0xf2, 0xda, 0xba, 0x18, 0xf9, 0xb6, 0x20, 0xc7, 0x5a, 0xc3, 0x50, 290 0xb0, 0x69, 0xd0, 0xf7, 0xd2, 0x32, 0xdb, 0xef, 0x5a, 0xa3, 0xae, 0x1c,
291 0x82, 0x79, 0xf8, 0xba, 0x97, 0x6d, 0xc8, 0x36, 0x70, 0x3d, 0x5f, 0x53, 291 0x97, 0xc8, 0xcc, 0x0f, 0xc0, 0xcb, 0xdb, 0x91, 0xd7, 0x20, 0xcb, 0x9f,
292 0xbb, 0xec, 0x59, 0xa6, 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0xb9,
307 0x6b, 0xae, 0x95, 0x5a, 0xf6, 0x2c, 0xcb, 0x93, 0x6a, 0xac, 0xe8, 0xc2, 307 0xee, 0xaf, 0x13, 0xcb, 0xd2, 0xf0, 0xf3, 0xf0, 0xc7, 0x15, 0xb9, 0x3f,
308 0x19, 0xd4, 0xd9, 0xf7, 0x87, 0x9c, 0xdb, 0xc4, 0x48, 0xe4, 0xd3, 0xeb, 308 0x7d, 0xa5, 0x72, 0xd1, 0xdd, 0x20, 0x85, 0xed, 0x07, 0x34, 0x9e, 0x1f,
309 0xe8, 0xed, 0x93, 0x65, 0xda, 0x19, 0xbb, 0x56, 0xbe, 0x68, 0xad, 0xa3, 309 0x78, 0x32, 0xe7, 0x16, 0x61, 0x1f, 0xfa, 0xdb, 0xc2, 0x64, 0x0c, 0x51,
310 0x6c, 0xef, 0x43, 0x32, 0x97, 0x5c, 0x78, 0x28, 0x69, 0xe5, 0x43, 0x3e, 310 0x29, 0xff, 0x9a, 0x65, 0xae, 0xf7, 0xf6, 0x7a, 0x69, 0xd8, 0xf6, 0x02,
311 0xf7, 0x7c, 0x62, 0x42, 0x47, 0x84, 0xc8, 0xbf, 0x20, 0xcd, 0x0d, 0x20, 311 0x8b, 0x63, 0xc4, 0x99, 0x39, 0x27, 0xae, 0xea, 0xdd, 0x37, 0xb9, 0xec,
312 0x71, 0x6e, 0xd9, 0xfe, 0x02, 0x1f, 0x10, 0xb1, 0x6d, 0x9c, 0x33, 0x03, 312 0xb7, 0x21, 0xd3, 0xdf, 0x92, 0x39, 0xc4, 0x13, 0xf3, 0xbd, 0xa0, 0x71,
313 0xa2, 0xd6, 0xb6, 0xd1, 0xe2, 0x7e, 0x03, 0xfc, 0xbe, 0x8f, 0xe6, 0x90, 313 0x7b, 0x0b, 0xc6, 0xd3, 0xee, 0xc8, 0xf3, 0xdf, 0x96, 0xa1, 0x41, 0xf2,
314 0x43, 0x14, 0x44, 0x1e, 0xde, 0x0e, 0x78, 0x37, 0x0f, 0xbf,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0x3d, 336 0x5d, 0x94, 0xd5, 0xeb, 0x43, 0x13, 0x35, 0xf5, 0xa1, 0x8d, 0xaa, 0x3e,
337 0x72, 0xea, 0x51, 0x17, 0xa9, 0x71, 0x3d, 0xea, 0x78, 0x5d, 0x3d, 0x2a, 337 0xc4, 0x79, 0xfc, 0xfa, 0x10, 0xdb, 0x6d, 0xdd, 0xbd, 0xa1, 0x3a, 0x08,
338 0x28, 0xea, 0x51, 0x3c, 0x8f, 0x53, 0x8f, 0x12, 0xed, 0xbe, 0x88, 0xa7, 338 0xf0, 0x54, 0xe5, 0x84, 0xb6, 0x31, 0xe8, 0x05, 0x18, 0x45, 0x2c, 0xbf,
339 0xee, 0x42, 0xf4, 0xee, 0x64, 0x07, 0x68, 0x66, 0xd0, 0xf7, 0x1a, 0xda, 339 0xb9, 0xea, 0x8f, 0x96, 0xf0, 0xca, 0x50, 0xba, 0x75, 0x2d, 0xbc, 0x1a,
340 0x34, 0x45, 0xc8, 0xdb, 0x4a, 0x35, 0xd0, 0x07, 0x6e, 0xb8, 0xbe, 0xa2, 340 0xf4, 0x63, 0x90, 0x65, 0x58, 0x35, 0x5e, 0x8d, 0x53, 0x5e, 0xab, 0x67,
341 0xd0, 0x06, 0xcc, 0x9b, 0xec, 0x7b, 0xd8, 0x53, 0x63, 0x61, 0x9a, 0xff, 341 0xde, 0x3c, 0x56, 0x5a, 0x9a, 0x77, 0x0c, 0xb2, 0x1d, 0xaa, 0xd6, 0x50,
342 0x62, 0xea, 0x2c, 0x07, 0x45, 0x9d, 0xe5, 0x87, 0x6b, 0xbc, 0x75, 0x96, 342 0xd6, 0x8a, 0x85, 0x1c, 0x39, 0xb6, 0xea, 0x37, 0xb8, 0x44, 0x76, 0xe5,
343 0x45, 0xba, 0x7e, 0x9d, 0xe5, 0x60, 0x83, 0x3a, 0xcb, 0x5b, 0x54, 0xad, 343 0x37, 0x38, 0x43, 0x1c, 0xd0, 0xd9, 0xd6, 0x5d, 0x50, 0x79, 0xd5, 0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1, 0xaa, 0x95, 0xb9, 0xc1, 351 0x70, 0x1d, 0xa5, 0x15, 0xf3, 0xb2, 0x8f, 0x6d, 0xf6, 0xc3, 0x2e, 0xe0,
352 0x1b, 0x90, 0xb9, 0xcc, 0xaa, 0x65, 0x8e, 0xe5, 0xcd, 0x39, 0xf7, 0xdd, 352 0x67, 0xb2, 0xaa, 0xce, 0xf1, 0x9b, 0x9a, 0x87, 0x07, 0xb0, 0xe7, 0x24,
353 0x60, 0xf1, 0xfa, 0x1d, 0x02, 0xa7, 0x77, 0x1b, 0xc8, 0xfb, 0x18, 0xec, 353 0x64, 0x41, 0x3e, 0xb6, 0xab, 0x38, 0x32, 0x6b, 0x25, 0x8c, 0x5c, 0x27,
354 0x8e, 0x33, 0xbf, 0x2e, 0xd7, 0xab, 0x8f, 0x87, 0x9f, 0x6d, 0x66, 0xff, 354 0xbc, 0xd3, 0x24, 0xbf, 0xd9, 0x27, 0x64, 0xa4, 0x4c, 0x1d, 0x6f, 0x45,
355 0xbd, 0x72, 0x3d, 0xb1, 0xde, 0x7f, 0xaf, 0xe4, 0x47, 0x15, 0x61, 0x93, 355 0xdc, 0x6d, 0xa1, 0xef, 0x00, 0xda, 0x41, 0x8c, 0xd4, 0x5d, 0x9d, 0x83,
356 0xb3, 0x25, 0xae, 0xed, 0x7b, 0xf9, 0x33, 0x8f, 0x9c, 0x00, 0x7d, 0x42, 356 0x76, 0x38, 0xc7, 0x7a, 0x9f, 0x73, 0x3d, 0x3e, 0x67, 0x27, 0x68, 0x0e,
357 0x0f, 0x98, 0xae, 0x41, 0xf0, 0x01, 0xeb, 0xd8, 0x4f, 0xc9, 0x5a, 0x16, 357 0xef, 0xa3, 0x08, 0x7f, 0x83, 0x3e, 0x25, 0x73, 0xc6, 0x8a, 0x01, 0x2d,
358 0x9e, 0x05, 0x97, 0x7f, 0xad, 0xb0, 0x99, 0xee, 0x18, 0xdb, 0x01, 0x0b, 358 0x49, 0xda, 0xf4, 0x75, 0xcc, 0xc7,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dd, 0xdc, 0xd6, 0xd4, 0xf8, 0xdd, 388 0x06, 0x78, 0x74, 0x58, 0xef, 0x73, 0x47, 0x0d, 0x1e, 0x0d, 0xd4, 0xd8,
389 0xec, 0xd3, 0xc2, 0xa4, 0xba, 0xfd, 0xb7, 0x07, 0x98, 0xae, 0xa4, 0xde, 389 0xec, 0xe7, 0x89, 0x47, 0x97, 0xd7, 0x7d, 0xfe, 0x78, 0xc4, 0x7d, 0x6d,
390 0x16, 0xe0, 0xb8, 0x76, 0xde, 0xf6, 0x8b, 0x3b, 0x05, 0xc9, 0x18, 0xd7, 390 0x59, 0x15, 0x87, 0xfc, 0x7d, 0x3c, 0x2d, 0x66, 0xe6, 0xb3, 0xcc, 0xdf,
391 0xcc, 0xb8, 0x5d, 0xa5, 0xab, 0xba, 0x2c, 0x5d, 0xfd, 0x95, 0xfa, 0x3f, 391 0x3e, 0x89, 0x7c, 0xc2, 0x38, 0x42, 0x99, 0x34, 0xa9, 0x78, 0xd5, 0xb7,
392 0xd3, 0xd2, 0xc7, 0x70, 0xa2, 0x36, 0xc6, 0x34, 0x75, 0xe7, 0xe3, 0xf3, 392 0x3d, 0xf8, 0xf2, 0xf9, 0xa8, 0xbc, 0xf7, 0x50, 0x4c, 0x7e, 0x75, 0x2f,
393 0x66, 0x5e, 0x47, 0xdc, 0x63, 0xc0, 0xf3, 0x60, 0x33, 0xb5, 0x0d, 0x0e, 393 0xbf, 0x95, 0x59, 0xba, 0x7e, 0xc5, 0x76, 0xb4, 0xc1, 0xf7, 0x43, 0x48,
394 0xf9, 0x2d, 0xef, 0xba, 0x6c, 0x43, 0x76, 0x90, 0x37, 0xc7, 0x5a, 0x7e, 394 0x24, 0x94, 0xdf, 0xe1, 0x3b, 0x81, 0x3d, 0xdb, 0x78, 0xce, 0x67, 0x5b,
395 0xcd, 0xa8, 0x38, 0x1b, 0x49, 0xf6, 0x47, 0x85, 0xec, 0xb0, 0xac, 0x69, 395 0xe4, 0x42, 0xf3, 0x8d, 0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a8, 0x3d, 410 0x75, 0x30, 0x9f, 0xaa, 0xe1, 0x61, 0x1d, 0x75, 0x8e, 0x03, 0xd7, 0xbb,
411 0x70, 0x8c, 0xbf, 0xe6, 0xda, 0x30, 0x95, 0xe9, 0xed, 0x98, 0xfb, 0x3d, 411 0xa2, 0xd2, 0x34, 0x78, 0x20, 0xea, 0x86, 0xd7, 0x25, 0x46, 0xf5, 0x2e,
412 0xc3, 0x78, 0x6b, 0x8a, 0x2e, 0x9d, 0xf8, 0x2e, 0x51, 0x58, 0xe6, 0x6f, 412 0xfb, 0xfe, 0xb4, 0xf6, 0x9a, 0xed, 0xea, 0xdb, 0x99, 0xef, 0x33, 0xa2,
413 0xce, 0x7c, 0xb9, 0x29, 0xae, 0x25, 0xde, 0x8f, 0xfd, 0x33, 0xfc, 0x6e, 413 0x4a, 0x07, 0x2d, 0x75, 0x36, 0xef, 0xd7, 0xea, 0xcc, 0x0d, 0xf5, 0x2f,
414 0x25, 0x39, 0x55, 0x2e, 0xa7, 0x31, 0x3e, 0xd6, 0x7b, 0xaf, 0xc8, 0x8d, 414 0x8f, 0x3c, 0x66, 0xbc, 0xa7, 0x23, 0x69, 0x99, 0x7f, 0xd1, 0xc0, 0x5a,
415 0xd4, 0x38, 0x0d, 0x71, 0x8e, 0xac, 0x2d, 0xc9, 0x91, 0xd3, 0xd0, 0x35, 415 0x6b, 0x5f, 0x39, 0xc0, 0x3d, 0xae, 0x57, 0xeb, 0xc7, 0x59, 0x27, 0x0b,
416 0xc4, 0x20, 0x76, 0x13, 0xbe, 0x75, 0xe3, 0x91, 0xcf, 0xae, 0x75, 0x64, 416 0xf0, 0x4c, 0x36, 0xfb, 0xf5, 0xb3, 0x4f, 0x63, 0x4b, 0x0d, 0x35, 0xb6,
417 0xe4, 0xbb, 0x12, 0x0f, 0x1e, 0xff, 0xfb, 0x80, 0x7b, 0x0f, 0x28, 0x77, 417 0x14, 0xec, 0xd3, 0xcf, 0x57, 0xf9, 0xdd, 0x7a, 0x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, 0x34, 0x4f, 0x2d, 0x9d, 0x09, 0x5f,
492 0x8e, 0x02, 0x52, 0x2a, 0xf7, 0xca, 0x85, 0xba, 0xbf, 0x08, 0x89, 0x03, 492 0x28, 0xef, 0x56, 0x7e, 0xec, 0xc5, 0xf2, 0xff, 0x52, 0x77, 0x6d, 0xb1,
493 0x70, 0x06, 0x29, 0x2a, 0x3f, 0xe2, 0xc0, 0x8d, 0x1b, 0x54, 0x5d, 0xde, 493 0x6d, 0x9d, 0xf7, 0xfd, 0xcf, 0x43, 0xea, 0x12, 0xdd, 0x7c, 0x24, 0xd3,
494 0x37, 0xb3, 0x63, 0xaf, 0x77, 0xd7, 0x8e, 0x03, 0x11, 0x07, 0x27, 0xbb, 494 0x32, 0x2d, 0xd1, 0xf2, 0x39, 0xd2, 0xb1, 0xc5, 0xd8, 0x5a, 0xc7, 0x6a,
495 0xf6, 0xcc, 0xce, 0xec, 0xcc, 0x37, 0x6f, 0xbe, 0xf7, 0x37, 0xfd, 0xbe, 495 0xca, 0x26, 0xac, 0x5a, 0xc2, 0x52, 0xf4, 0x65, 0x59, 0x36, 0xd0, 0x97,
496 0x78, 0x8d, 0x5a, 0xdb, 0x5b, 0xf3, 0x55, 0xec, 0xe7, 0xaf, 0x37, 0x18, 496 0x76, 0x1e, 0x16, 0xa0, 0x0e, 0x65, 0x3b, 0x1d, 0xd0, 0x07, 0xb7, 0xd9,
497 0x57, 0xed, 0xba, 0xe4, 0xa9, 0xf5, 0xe3, 0x9a, 0x72, 0xd9, 0x1b, 0xf0, 497 0x80, 0xa4, 0x03, 0x6c, 0x96, 0xb2, 0x1c, 0xaf, 0x53, 0x4d, 0x36, 0x66,
498 0xfe, 0xc7, 0x68, 0x51, 0xd8, 0x86, 0x94, 0xad, 0xee, 0xc5, 0x40, 0x9b, 498 0xd5, 0xac, 0x1b, 0x50, 0x4e, 0x92, 0x9d, 0xb4, 0x50, 0xc0, 0x64, 0xbd,
499 0xd9, 0xff, 0x33, 0x16, 0x03, 0x3e, 0x9b, 0x68, 0xad, 0x6d, 0x8a, 0xed, 499 0x60, 0xd8, 0x43, 0xad, 0xc9, 0xf6, 0xf6, 0xb2, 0x87, 0x6c, 0xd8, 0x83,
500 0x71, 0xd9, 0x16, 0xde, 0xda, 0xc2, 0xb6, 0x10, 0x3c, 0x16, 0xfd, 0x9e, 500 0x81, 0x0d, 0x98, 0x63, 0x05, 0x68, 0x96, 0x02, 0x49, 0x87, 0x15, 0x43,
501 0xb1, 0xa8, 0xc9, 0xea, 0xa1, 0x16, 0xed, 0x74, 0x88, 0x21, 0xbf, 0x9d, 501 0x1e, 0x36, 0x70, 0xff, 0xdf, 0x77, 0x21, 0x0f, 0x0f, 0x0f, 0x75, 0x89,
502 0x67, 0x6c, 0x05, 0xca, 0xce, 0x4f, 0x5d, 0x36, 0x3c, 0xe0, 0x73, 0xdc, 502 0x9d, 0x01, 0x33, 0x60, 0x88, 0xe7, 0x9c, 0xef, 0x9c, 0xf3, 0x7d, 0xff,
503 0x59, 0xeb, 0xc0, 0x27, 0xb5, 0x9d, 0x1a, 0x51, 0xed, 0x01, 0x8f, 0xc9, 503 0xef, 0x7f, 0xbf, 0x9d, 0x3a, 0x3f, 0x8f, 0xd8, 0xc3, 0xdc, 0xca, 0x5b,
504 0xc5, 0x45, 0x82, 0xbe, 0x86, 0x36, 0xe3, 0x82, 0xe3, 0xfa, 0x39, 0x14, 504 0x0c, 0x8b, 0xbb, 0x42, 0x96, 0xcd, 0xe5, 0x69, 0x28, 0x48, 0xd8, 0x0f,
505 0x8f, 0xf1, 0xfa, 0x1b, 0x88, 0xe5, 0x70, 0xda, 0x3f, 0xd9, 0x76, 0xae, 505 0x0a, 0x30, 0x0c, 0x44, 0x6e, 0x86, 0x8c, 0xcd, 0x47, 0xc5, 0xbe, 0x4a,
506 0x9c, 0xe5, 0xbd, 0x42, 0xd4, 0x63, 0xbd, 0xef, 0x52, 0xdb, 0x82, 0xa8, 506 0x5e, 0x71, 0xcc, 0x95, 0x5b, 0x51, 0xdb, 0x5b, 0x99, 0x73, 0x21, 0xf7,
507 0x27, 0xe3, 0x20, 0x1c, 0x1d, 0xd0, 0xe1, 0xe2, 0x8d, 0x74, 0x3f, 0xff, 507 0x42, 0xe6, 0x85, 0x00, 0x9e, 0xab, 0x17, 0x8f, 0x3b, 0x32, 0x2f, 0x64,
508 0x9e, 0x13, 0xcc, 0xdd, 0x7f, 0xdd, 0x1d, 0x36, 0x3f, 0x34, 0x64, 0xae, 508 0x64, 0x01, 0xe7, 0xfa, 0x3d, 0x72, 0xae, 0x9d, 0x71, 0x00, 0x39, 0x44,
509 0xde, 0x56, 0xdc, 0x5d, 0xd9, 0x89, 0x06, 0x85, 0xaf, 0xc1, 0xad, 0x7b, 509 0xc8, 0x05, 0xc7, 0x9c, 0x85, 0x5f, 0xc3, 0x37, 0x2e, 0xbd, 0x3d, 0xff,
510 0x41, 0x76, 0x5d, 0xe0, 0x3d, 0x7c, 0xa8, 0xba, 0x7f, 0xef, 0x84, 0x7d, 510 0xaa, 0x7c, 0xe7, 0xb0, 0x78, 0xe7, 0x2e, 0xc5, 0xb3, 0x74, 0x0e, 0x78,
511 0xe8, 0x99, 0x16, 0x62, 0x1d, 0x44, 0x8e, 0xe5, 0x2b, 0x53, 0xc8, 0x45, 511 0x3c, 0x30, 0x93, 0x1f, 0x8d, 0x04, 0x19, 0xbf, 0x67, 0xca, 0xb0, 0xa5,
512 0xaa, 0xe6, 0xef, 0x78, 0xf3, 0x3c, 0x20, 0x3f, 0x55, 0x9e, 0x87, 0xca, 512 0x9b, 0xe9, 0x6b, 0x1b, 0xc1, 0x33, 0xd1, 0x00, 0xcf, 0x7a, 0x9a, 0x60,
513 0x23, 0xc5, 0x7b, 0x24, 0x02, 0xf2, 0x3c, 0xdc, 0x32, 0x18, 0xf5, 0xea, 513 0xdb, 0xbb, 0xca, 0xbb, 0x25, 0xec, 0xe4, 0x79, 0xe4, 0xb7, 0xeb, 0xfc,
514 0xdf, 0xc3, 0x2d, 0x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73, 0x74, 0x0e, 0xb9, 0xef, 536 0x2c, 0xe4, 0x8f, 0xa7, 0x7c, 0xf7, 0xae, 0x5a, 0x77, 0x95, 0xad, 0x8d,
537 0x14, 0x1a, 0xc6, 0xa5, 0xe2, 0x3b, 0xe9, 0x1b, 0x38, 0x77, 0x04, 0xb2, 537 0x95, 0xf7, 0xa7, 0xc4, 0xba, 0xa2, 0x4f, 0x27, 0x51, 0x13, 0x57, 0xad,
538 0x1b, 0xf2, 0xfc, 0xf4, 0x6c, 0xd8, 0x34, 0x1c, 0x1f, 0x03, 0xfc, 0x08, 538 0x09, 0xf2, 0xd6, 0x41, 0x41, 0x0e, 0x68, 0x3a, 0xd4, 0x75, 0xe2, 0x80,
539 0xc0, 0xa9, 0x7a, 0x7e, 0x90, 0x0d, 0x3d, 0x68, 0x0e, 0x87, 0x7c, 0x73, 539 0x45, 0xcc, 0xa7, 0x0e, 0xca, 0x2d, 0x4b, 0x70, 0x9f, 0x17, 0x16, 0x35,
540 0x28, 0xf1, 0x06, 0x6e, 0x8f, 0x58, 0xbc, 0x83, 0x9e, 0x38, 0xc5, 0x9d, 540 0x39, 0x32, 0xa7, 0xe4, 0xc8, 0xa2, 0x8b, 0x8f, 0x37, 0xea, 0xed, 0x7d,
541 0x18, 0x93, 0xee, 0x80, 0x78, 0x41, 0xc4, 0xfa, 0xf9, 0xfa, 0xcb, 0xef, 541 0x3e, 0x7a, 0xbb, 0xbb, 0xb6, 0x43, 0xd4, 0xb8, 0x35, 0xa9, 0xed, 0xf0,
542 0x7c, 0x51, 0xf3, 0xaf, 0xad, 0x49, 0x6d, 0xba, 0x3c, 0xad, 0x4d, 0x15, 542 0xab, 0x99, 0xc2, 0xd8, 0x17, 0x59, 0x5f, 0xf9, 0x14, 0xf4, 0x15, 0x13,
543 0x51, 0xee, 0xa2, 0x56, 0xdb, 0x97, 0x36, 0x5d, 0x1c, 0x11, 0x7c, 0x30, 543 0x35, 0x4b, 0x52, 0x67, 0xc1, 0x75, 0x96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84, 0x65, 0xf3, 0x67, 0xbd, 0xad, 0xf9, 0x33, 0x54, 551 0x79, 0x7c, 0x62, 0x91, 0x3c, 0xf5, 0x13, 0x5b, 0x98, 0xf7, 0x91, 0xba,
552 0x39, 0xd4, 0xed, 0xa2, 0x35, 0x0b, 0x71, 0x92, 0xf0, 0x2f, 0x75, 0x77, 552 0x79, 0x6b, 0xf8, 0xe2, 0x37, 0x7c, 0x40, 0x09, 0x86, 0xa9, 0xd6, 0x7f,
553 0xb4, 0x9b, 0x41, 0xf2, 0x4f, 0xc5, 0x7e, 0x82, 0x1f, 0xc9, 0xb9, 0xba, 553 0x3b, 0xe0, 0x73, 0x8f, 0x65, 0x69, 0x23, 0xfd, 0xd7, 0x6e, 0xd0, 0x7f,
554 0x41, 0x98, 0x3b, 0x9b, 0xbe, 0x6f, 0x30, 0x57, 0xdb, 0xb1, 0x29, 0x37, 554 0x17, 0x37, 0x9d, 0xf7, 0xc3, 0xf2, 0x02, 0x59, 0xc3, 0x1d, 0x74, 0x84,
555 0x9f, 0x2b, 0xc3, 0x33, 0x57, 0xd8, 0x8b, 0x9a, 0xcd, 0x95, 0xf2, 0x43, 555 0x9e, 0xcb, 0xf3, 0xae, 0xd3, 0x81, 0x3d, 0x38, 0x85, 0x31, 0xda, 0x37,
556 0x2a, 0xdf, 0xdc, 0x51, 0xc8, 0x93, 0x45, 0xf7, 0x5c, 0xed, 0x8c, 0x7f, 556 0xae, 0x7d, 0x63, 0x3d, 0x2a, 0x1f, 0x58, 0xe7, 0x2c, 0x74, 0x28, 0x3c,
557 0x4e, 0xce, 0xd9, 0x4e, 0xfb, 0xe0, 0x1a, 0x8f, 0x43, 0x34, 0xd0, 0x76, 557 0xc6, 0x75, 0xd8, 0x62, 0xab, 0x3c, 0x3f, 0xd8, 0x65, 0x4f, 0x8a, 0x39,
558 0x12, 0x2c, 0x33, 0xfc, 0x6b, 0xeb, 0x86, 0x5c, 0x5b, 0xcc, 0x2b, 0x9e, 558 0xb2, 0x5d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3e, 0x06,
588 0x29, 0xfa, 0x78, 0xca, 0xe9, 0xe3, 0x9b, 0xa2, 0x3f, 0xe3, 0x54, 0xa8, 588 0xe0, 0x85, 0x6b, 0x87, 0xaf, 0x4f, 0xcb, 0x3f, 0x36, 0x8c, 0x3c, 0x00,
589 0xe6, 0x0d, 0x1f, 0xe1, 0xeb, 0x98, 0xb2, 0xd1, 0x35, 0x90, 0xab, 0xdf, 589 0xf8, 0xb3, 0x9f, 0xa2, 0xb3, 0xd7, 0x81, 0xc3, 0x06, 0x63, 0xdb, 0x08,
590 0x6c, 0x43, 0xc6, 0x04, 0x71, 0xb2, 0x03, 0x01, 0xfa, 0x80, 0xee, 0xd2, 590 0xcd, 0x86, 0x51, 0x57, 0x24, 0x6a, 0x73, 0x54, 0x2c, 0x51, 0xd6, 0x0a,
591 0x07, 0xe2, 0x55, 0x7d, 0x60, 0x45, 0xe8, 0x09, 0xbb, 0x1c, 0x1d, 0x34, 591 0x9d, 0x15, 0x75, 0x8f, 0xfb, 0x23, 0xeb, 0x94, 0x66, 0xb9, 0x97, 0xa5,
592 0xd8, 0x16, 0x97, 0xcb, 0xe3, 0xcc, 0x1b, 0xd8, 0xf8, 0xa4, 0x1d, 0x7d, 592 0x73, 0x2c, 0x63, 0xcf, 0x2d, 0xd5, 0x74, 0xfc, 0xc6, 0xda, 0xc7, 0x7a,
593 0xda, 0xaa, 0x9e, 0x99, 0xc3, 0xba, 0x65, 0x8d, 0x4b, 0xfb, 0xe5, 0x09, 593 0x1c, 0x5f, 0x17, 0x38, 0x1e, 0xdd, 0x10, 0xc7, 0x8f, 0x56, 0x71, 0x7c,
594 0xce, 0xac, 0xa8, 0xcc, 0x3e, 0x30, 0xa3, 0xa4, 0xa5, 0x93, 0xf1, 0xa9, 594 0xae, 0x4f, 0xe2, 0xf3, 0x45, 0x7e, 0x56, 0x0f, 0x1d, 0x16, 0xcf, 0xcd,
595 0x50, 0x84, 0x16, 0xac, 0x28, 0x15, 0xac, 0x14, 0x73, 0x70, 0xf0, 0xe3, 595 0xf2, 0xef, 0x4e, 0x3a, 0x2c, 0xfb, 0x62, 0xf0, 0xbb, 0x99, 0xc7, 0xe7,
596 0xd0, 0x80, 0x46, 0x11, 0x96, 0x35, 0x11, 0x2a, 0x95, 0x94, 0x4e, 0x76, 596 0xb3, 0x74, 0xfe, 0x7a, 0x36, 0x90, 0x12, 0x35, 0x0a, 0xee, 0xbe, 0x1e,
597 0x86, 0xc8, 0x2c, 0xc6, 0xa4, 0x0d, 0x9b, 0x71, 0x9a, 0x1f, 0x33, 0xe6, 597 0xfa, 0x7e, 0x8c, 0x6b, 0x86, 0xff, 0x9a, 0x2f, 0xc9, 0x9a, 0xab, 0x92,
598 0x49, 0x43, 0xcc, 0x8b, 0x93, 0xa3, 0x0e, 0x0c, 0x8a, 0x38, 0x4b, 0xfd, 598 0xe4, 0x4f, 0xf4, 0x76, 0x7c, 0xd0, 0x83, 0xff, 0xf5, 0x36, 0xe6, 0x05,
599 0xe5, 0x91, 0x28, 0xb5, 0xa7, 0xa5, 0xcd, 0x68, 0x86, 0xdb, 0xf8, 0xc2, 599 0x25, 0x03, 0x4f, 0x6c, 0xe0, 0xff, 0x68, 0xc4, 0xcb, 0x5e, 0x1f, 0xbd,
600 0x8a, 0xd1, 0x95, 0x7c, 0xd2, 0x38, 0xc1, 0xed, 0x64, 0xac, 0x64, 0x62, 600 0xf9, 0x8d, 0x3e, 0x19, 0xbb, 0xda, 0xc8, 0xff, 0xe1, 0xc6, 0xd1, 0xba,
601 0x92, 0x9f, 0x5d, 0x2c, 0x45, 0x28, 0x67, 0x45, 0xa8, 0x50, 0x4a, 0x19, 601 0x58, 0x3e, 0xf3, 0xfd, 0x84, 0xaa, 0xff, 0x7b, 0xa7, 0x4f, 0xca, 0x0b,
602 0x43, 0x6d, 0xa2, 0xcd, 0x18, 0xda, 0x7c, 0x49, 0x1f, 0x33, 0x4e, 0x92, 602 0xd4, 0x04, 0xa6, 0x19, 0x0e, 0x6f, 0xb2, 0xae, 0x32, 0x48, 0xad, 0xaf,
603 0xbb, 0xcd, 0xaf, 0x9c, 0x36, 0xbd, 0x6d, 0xfd, 0x61, 0xe3, 0xfe, 0x44, 603 0xe8, 0xb5, 0x0e, 0x0a, 0x7e, 0xeb, 0xf6, 0xe7, 0x5c, 0x56, 0xb5, 0xe0,
604 0xa8, 0x32, 0x7b, 0x9f, 0xf1, 0x92, 0x5b, 0x9d, 0x60, 0xd9, 0x14, 0x13, 604 0x39, 0xd7, 0x9a, 0x2e, 0x0b, 0x5b, 0xa8, 0x39, 0xbd, 0x35, 0xcf, 0xc3,
605 0x67, 0xdb, 0x68, 0xe9, 0x34, 0xcb, 0x1d, 0x9c, 0x6d, 0x61, 0xd0, 0x62, 605 0x8a, 0x7a, 0x64, 0x82, 0x17, 0xdf, 0xd0, 0x2f, 0x05, 0xfb, 0x4b, 0x86,
606 0x39, 0x4e, 0xef, 0x57, 0xed, 0x07, 0x12, 0x43, 0x39, 0x91, 0x43, 0x84, 606 0xd4, 0x83, 0x27, 0x59, 0xbf, 0xdd, 0x6e, 0x0c, 0xe9, 0x61, 0x75, 0x44,
607 0x33, 0x17, 0x2a, 0xb3, 0xbf, 0x9b, 0x5e, 0x7f, 0x3f, 0xeb, 0x5b, 0x1f, 607 0x6f, 0x4f, 0x0e, 0xef, 0x6f, 0xec, 0x83, 0xb4, 0x39, 0x32, 0xaf, 0x3d,
608 0xc5, 0x28, 0x72, 0x15, 0x71, 0xdd, 0x36, 0x5d, 0x1b, 0x4f, 0x5e, 0xd9, 608 0x25, 0x78, 0xc1, 0xe5, 0xb1, 0x0a, 0x4d, 0xc7, 0xbb, 0x29, 0x33, 0xc6,
609 0x14, 0x79, 0x68, 0x09, 0x5a, 0x33, 0xa5, 0x3c, 0xcd, 0x71, 0xf9, 0x15, 609 0xef, 0x9e, 0x44, 0x4f, 0xac, 0x20, 0x65, 0x99, 0x7e, 0x33, 0x63, 0x8f,
610 0x94, 0x5b, 0x4b, 0xd0, 0x3d, 0x91, 0x8f, 0xd6, 0x4e, 0x77, 0xf4, 0x18, 610 0x29, 0x7d, 0x51, 0xfb, 0xdd, 0xdb, 0x54, 0xee, 0xc3, 0x45, 0x11, 0xab,
611 0x85, 0x6e, 0x9a, 0xc6, 0xbc, 0xf0, 0x0b, 0x57, 0x66, 0x87, 0x86, 0x0d, 611 0x94, 0xfd, 0x84, 0xf8, 0xf7, 0x92, 0x7e, 0xf6, 0x45, 0x11, 0x33, 0xcd,
612 0xd2, 0xae, 0xa2, 0x1e, 0xff, 0xbf, 0x89, 0xfb, 0x28, 0x61, 0x7e, 0x66, 612 0x5c, 0x6f, 0x55, 0xe3, 0x3a, 0x5d, 0xe3, 0x30, 0xa6, 0x53, 0x8d, 0xc5,
613 0xac, 0x31, 0x5e, 0x49, 0xc3, 0xf1, 0x12, 0x64, 0xf3, 0x41, 0x89, 0xa5, 613 0x33, 0xb5, 0x4e, 0xd1, 0xae, 0xf8, 0x2d, 0xe8, 0x30, 0xad, 0x6a, 0xf5,
614 0x39, 0x23, 0x42, 0xd0, 0x5f, 0x61, 0x7b, 0xeb, 0x35, 0x27, 0x7b, 0xa4, 614 0x70, 0xfd, 0x02, 0xcd, 0x54, 0xd7, 0xd2, 0xc9, 0x63, 0xff, 0x5b, 0xf5,
615 0xfe, 0xe4, 0x3b, 0x9b, 0x43, 0x9f, 0x19, 0x71, 0x9f, 0xcf, 0x51, 0x7b, 615 0xf2, 0xe8, 0x64, 0x9d, 0x17, 0xf3, 0x6e, 0x9c, 0x13, 0xd6, 0x12, 0x14,
616 0x66, 0xc6, 0x92, 0xef, 0xb9, 0x52, 0xee, 0xa5, 0x25, 0x6e, 0x7b, 0x64, 616 0x71, 0x24, 0xfe, 0xad, 0xde, 0x73, 0xa6, 0x3a, 0x27, 0xe4, 0x6d, 0xd8,
617 0xf8, 0x8c, 0x73, 0xa6, 0x0f, 0xff, 0xd9, 0x8b, 0x7b, 0x85, 0xb7, 0x7d, 617 0x11, 0xf9, 0x2c, 0x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b, 0x6d, 632 0xbf, 0x2a, 0xea, 0xdd, 0xe4, 0x6f, 0xe0, 0xf6, 0x2f, 0xab, 0x3d, 0xab,
633 0x60, 0x0e, 0xf8, 0x5e, 0xcc, 0x81, 0x46, 0x33, 0x31, 0x2e, 0x53, 0xda, 633 0xcb, 0x09, 0x89, 0x8c, 0x18, 0x5f, 0xa5, 0x0b, 0x4b, 0x1b, 0xf9, 0x66,
634 0x4f, 0x95, 0x92, 0xc2, 0x35, 0xb0, 0x03, 0x0c, 0x35, 0xc6, 0x4e, 0xa6, 634 0xfc, 0xea, 0x5b, 0xbb, 0xb6, 0x58, 0xdf, 0xba, 0xbe, 0x53, 0xd6, 0x8c,
635 0x0e, 0x3b, 0xb2, 0x0e, 0x30, 0xb3, 0xe4, 0xb7, 0xad, 0xed, 0x32, 0xf8, 635 0xe1, 0xfd, 0x7e, 0xba, 0x97, 0x77, 0x6d, 0xee, 0x7a, 0xd5, 0xef, 0xd0,
636 0x5d, 0x0d, 0xc6, 0x56, 0x58, 0xc4, 0x91, 0x24, 0x47, 0x67, 0x42, 0x90, 636 0xb4, 0xac, 0x35, 0x56, 0xb8, 0x70, 0xbd, 0x89, 0x7f, 0xf3, 0x49, 0x21,
637 0x59, 0xb7, 0x18, 0x53, 0x3c, 0x17, 0x3c, 0x7e, 0xda, 0xf5, 0x41, 0x96, 637 0x2f, 0xcf, 0xca, 0x38, 0xc3, 0x80, 0xec, 0x6d, 0x16, 0xa2, 0xe5, 0x6a,
638 0x39, 0x4f, 0x09, 0x1b, 0xf4, 0x94, 0xa9, 0xc7, 0x33, 0x64, 0x5f, 0xd6, 638 0xed, 0x67, 0x50, 0xd5, 0x7f, 0x30, 0x53, 0x7c, 0xa4, 0x75, 0x9f, 0x3a,
639 0xcc, 0x31, 0x91, 0xeb, 0xb6, 0x54, 0xf6, 0x9e, 0x31, 0x91, 0xe1, 0xb1, 639 0x57, 0x15, 0x71, 0xa7, 0xb4, 0x2b, 0x8f, 0x22, 0xa4, 0xf2, 0x24, 0x70,
640 0x57, 0x78, 0xf4, 0xca, 0xa1, 0x76, 0xaa, 0x38, 0x31, 0x4c, 0x85, 0x55, 640 0xdf, 0x48, 0x18, 0x75, 0x5b, 0xb2, 0xd6, 0x12, 0x63, 0x50, 0xe7, 0x08,
641 0xdb, 0x7e, 0xc8, 0xfc, 0x7f, 0xcd, 0x84, 0xcc, 0xfe, 0xdb, 0xae, 0xc4, 641 0x1b, 0x12, 0x75, 0xae, 0xf0, 0xfb, 0x35, 0xab, 0x05, 0xc5, 0x78, 0xf8,
642 0x74, 0x5a, 0x36, 0x55, 0xdf, 0xee, 0x08, 0x7c, 0x31, 0x47, 0xa4, 0x77, 642 0x9f, 0xb4, 0x5d, 0x78, 0x5a, 0xd0, 0x98, 0x7c, 0xa7, 0xac, 0xd9, 0x5c,
643 0x37, 0xaa, 0xaf, 0xc4, 0xbf, 0xe3, 0xbb, 0xbf, 0x04, 0x97, 0x59, 0xab, 643 0x5c, 0x39, 0x23, 0xea, 0x24, 0x93, 0xaa, 0xf6, 0x33, 0x43, 0x5d, 0x42,
644 0x96, 0x85, 0xed, 0xf8, 0xd2, 0xd8, 0xc2, 0x2a, 0xce, 0x7e, 0x7b, 0xfc, 644 0x6f, 0xfa, 0xf8, 0x35, 0x9b, 0xe7, 0xc2, 0xdb, 0xaf, 0xd9, 0x74, 0xdf,
645 0xea, 0xf9, 0xd5, 0x5c, 0x1f, 0x4b, 0xd8, 0x94, 0x4e, 0x76, 0x68, 0x79, 645 0xb3, 0xbd, 0x9a, 0x4d, 0x93, 0xd7, 0x6e, 0x2c, 0xc8, 0x9a, 0xcd, 0xfa,
646 0x3c, 0xf7, 0x5c, 0x98, 0x86, 0x19, 0x97, 0x38, 0x83, 0x6b, 0x6c, 0x34, 646 0x58, 0x80, 0xf4, 0x43, 0x65, 0x5c, 0xf2, 0x48, 0xea, 0x7f, 0x5f, 0x72,
647 0x2c, 0xce, 0x38, 0xd9, 0xcd, 0x78, 0xc8, 0x0a, 0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0xf7, 0xa6, 0x91,
673 0xb3, 0xdc, 0x7b, 0xcd, 0xa2, 0x93, 0xf9, 0x2f, 0xed, 0x95, 0x74, 0x7a,
674 0x89, 0x86, 0xc7, 0x79, 0xfc, 0x14, 0x7c, 0xbd, 0x76, 0x2c, 0xc9, 0x4a,
675 0xe4, 0x5c, 0xb9, 0x8d, 0x16, 0x59, 0x5b, 0x0f, 0x3a, 0x25, 0xe1, 0xbb,
676 0x63, 0x99, 0x51, 0x40, 0x6f, 0x55, 0x63, 0xa1, 0x95, 0x9f, 0xdb, 0x4f,
677 0xcb, 0x45, 0xd0, 0x7c, 0x8b, 0xea, 0x11, 0x82, 0xb1, 0x01, 0xea, 0x73,
678 0xfe, 0x84, 0xe1, 0xf5, 0x05, 0x91, 0x47, 0xb9, 0x58, 0xb8, 0x24, 0xff,
679 0x96, 0x5e, 0x52, 0xef, 0xe0, 0xf7, 0x95, 0xff, 0x86, 0x12, 0x7d, 0x96,
680 0xcb, 0x36, 0x73, 0xff, 0xf3, 0xd7, 0x3f, 0x8e, 0x6f, 0x4b, 0xff, 0xc8,
681 0xa6, 0x6b, 0xfa, 0x87, 0xfb, 0xd9, 0x5a, 0x17, 0x39, 0xd6, 0x2f, 0xfb,
682 0x37, 0x00, 0x06, 0x9d, 0xd0, 0xad, 0xd2, 0x80, 0xa5, 0x31, 0x65, 0x47,
683 0x92, 0xc1, 0x49, 0x9a, 0x2d, 0x47, 0x8d, 0x4c, 0x01, 0x3a, 0x30, 0xff,
684 0x2d, 0x5d, 0xd9, 0x2d, 0x7d, 0x2e, 0xfa, 0x1e, 0xf0, 0xf5, 0x9d, 0x3c,
685 0xfe, 0x3f, 0xfa, 0x65, 0xee, 0xb5, 0xfb, 0x7c, 0x0f, 0x9f, 0x7f, 0x2e,
686 0x52, 0x7f, 0xfe, 0x31, 0x3e, 0xdf, 0xc7, 0xe7, 0xe1, 0x87, 0x84, 0x9f,
687 0x31, 0x46, 0x39, 0xde, 0x9f, 0xd9, 0x32, 0xf3, 0xa9, 0x57, 0x58, 0x5e,
688 0x2c, 0xe9, 0x71, 0xbb, 0x50, 0x97, 0x23, 0xf6, 0xc4, 0xe0, 0x31, 0x97,
689 0xf3, 0x63, 0x3c, 0x6e, 0x90, 0x82, 0xaf, 0x58, 0x34, 0xbb, 0xa4, 0x71,
690 0x52, 0xe7, 0xd4, 0xbf, 0xc3, 0xf0, 0x45, 0xde, 0xce, 0x47, 0xbb, 0x25,
691 0xfc, 0x62, 0xc2, 0x87, 0x89, 0x3c, 0x8e, 0x2b, 0x02, 0xf7, 0xec, 0x49,
692 0xab, 0xfa, 0x7e, 0xe0, 0x96, 0x88, 0x73, 0xf0, 0x1a, 0x58, 0x2e, 0x4d,
693 0x39, 0x66, 0xae, 0x9a, 0x8f, 0xf6, 0xe7, 0x03, 0xf2, 0xfe, 0xff, 0xda,
694 0x25, 0xfb, 0xa3, 0xbe, 0x3f, 0xa0, 0xfb, 0x24, 0x4a, 0x9d, 0x00, 0x39,
695 0xca, 0x01, 0x01, 0x9b, 0xe0, 0x02, 0xe4, 0x95, 0xc1, 0xbf, 0x79, 0x3d,
696 0x69, 0xcc, 0xb1, 0xad, 0x5f, 0xf7, 0x7c, 0x91, 0xeb, 0x3a, 0xc6, 0xf3,
697 0x4d, 0xf1, 0xba, 0xf4, 0xf9, 0x04, 0x1f, 0xfb, 0xed, 0x2f, 0x9e, 0xd5,
698 0x91, 0x46, 0x5d, 0x70, 0xe6, 0x54, 0x47, 0x3a, 0x13, 0x93, 0xfb, 0x5c,
699 0xf3, 0xd1, 0x46, 0xaa, 0x3e, 0xda, 0xb9, 0xfc, 0x78, 0x3f, 0xfc, 0x15,
700 0xc6, 0x35, 0xde, 0xef, 0xf0, 0x15, 0x1e, 0x8b, 0x7a, 0x84, 0x1c, 0xff,
701 0xed, 0x52, 0xf9, 0x3c, 0x8d, 0xb8, 0x22, 0xf3, 0x23, 0xb4, 0x5e, 0x81,
702 0x7b, 0x9f, 0xe0, 0x67, 0x48, 0xdd, 0xa2, 0xf9, 0x7b, 0xa8, 0x21, 0xff,
703 0xa5, 0x11, 0xc7, 0x36, 0xf2, 0xab, 0x8a, 0x38, 0xa2, 0x0f, 0x9e, 0x6d,
704 0xd4, 0x83, 0xe0, 0x9e, 0xf0, 0x8b, 0x4d, 0x37, 0xd0, 0x2b, 0xe8, 0x38,
705 0x44, 0x2f, 0xcc, 0x67, 0xe9, 0x31, 0xde, 0xab, 0x3f, 0x30, 0x3e, 0x83,
706 0x38, 0x3b, 0xc9, 0x5c, 0x27, 0x86, 0x71, 0xde, 0x89, 0x9d, 0x33, 0x52,
707 0xe0, 0x8b, 0x95, 0x90, 0xd3, 0x45, 0xad, 0x4c, 0xab, 0xbf, 0x49, 0x23,
708 0x6c, 0xcf, 0x81, 0x66, 0x9d, 0x48, 0x8a, 0x40, 0x6f, 0xb6, 0x79, 0x84,
709 0x71, 0x62, 0xba, 0x0c, 0x7c, 0x36, 0xe8, 0x8b, 0x45, 0xa2, 0xe7, 0x8b,
710 0x23, 0xe6, 0xf7, 0xc8, 0xb1, 0x6a, 0xd7, 0x6d, 0x33, 0xc9, 0xf3, 0x48,
711 0x95, 0x5f, 0xa2, 0xf7, 0x44, 0xdf, 0x12, 0xc0, 0x51, 0xef, 0xfb, 0x1f,
712 0xd1, 0x99, 0x34, 0xe6, 0xbd, 0x75, 0xfa, 0x3c, 0xb9, 0x2d, 0xfa, 0xec,
713 0xf0, 0xa1, 0xcf, 0x7f, 0x54, 0x78, 0x53, 0x61, 0x1c, 0xed, 0xa0, 0x99,
714 0x02, 0x72, 0xbf, 0x3e, 0x8b, 0xfe, 0x52, 0x85, 0x0c, 0xf3, 0xa5, 0x4c,
715 0x8d, 0x2f, 0x5d, 0x4d, 0x06, 0x13, 0xa0, 0x71, 0xf4, 0x65, 0x53, 0xf9,
716 0x3e, 0x58, 0xc7, 0x00, 0x8d, 0x2c, 0x74, 0x22, 0xf6, 0xb5, 0x9a, 0x9c,
717 0x48, 0xa8, 0xfa, 0x7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2e, 0x75,
747 0x7c, 0x50, 0xe6, 0xf2, 0x8a, 0x5c, 0x6c, 0x5c, 0xdb, 0x88, 0xbf, 0xbd,
748 0xcd, 0x38, 0x05, 0x99, 0x2a, 0x75, 0x7c, 0xf0, 0x9a, 0x5b, 0x0d, 0xfd,
749 0x90, 0x81, 0x73, 0x93, 0xf4, 0x4d, 0x96, 0xb7, 0xc3, 0xaf, 0xc0, 0x1f,
750 0xfc, 0xfb, 0xc0, 0x9b, 0x52, 0x96, 0x06, 0xf9, 0x18, 0x7d, 0x8e, 0x82,
751 0xa2, 0x96, 0x69, 0x3a, 0x1c, 0x13, 0xf5, 0x1f, 0x92, 0x46, 0x4f, 0x89,
752 0x9e, 0x73, 0x3f, 0x12, 0xbc, 0xc9, 0xce, 0x5a, 0x06, 0xf4, 0x11, 0xf8,
753 0x54, 0x64, 0xee, 0xd5, 0x49, 0xa7, 0xf7, 0xed, 0x5d, 0x53, 0xa3, 0x94,
754 0xe8, 0x07, 0xde, 0x4b, 0x9a, 0x55, 0x3d, 0x04, 0x04, 0xbf, 0x37, 0x0f,
755 0xe8, 0x9a, 0x48, 0x7d, 0xac, 0x65, 0x85, 0x3e, 0xee, 0xf2, 0x5c, 0x37,
756 0x3d, 0xd7, 0xab, 0x79, 0x72, 0x2c, 0xf3, 0x58, 0xce, 0x93, 0xec, 0x39,
757 0x84, 0xbe, 0x71, 0xc0, 0x3f, 0xf3, 0xc0, 0x7e, 0xf3, 0x73, 0xca, 0x06,
758 0xca, 0xac, 0x8c, 0x44, 0x7a, 0x8d, 0x98, 0x91, 0x19, 0xfb, 0x97, 0x4a,
759 0x22, 0x0d, 0xbd, 0xe8, 0xc6, 0x6e, 0xc9, 0xe3, 0x30, 0xaf, 0x6c, 0x1c,
760 0xaa, 0xdb, 0xa9, 0x95, 0x2e, 0x5a, 0x15, 0x7d, 0xb5, 0xa0, 0x63, 0xe0,
761 0x7e, 0x3c, 0x27, 0x6b, 0xb6, 0xb0, 0x7d, 0x77, 0x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 0x9d, 0x12, 0xef, 0x26, 0xba, 0x23, 0xde,
777 0xcb, 0x3a, 0x53, 0xfc, 0x71, 0x3a, 0x13, 0x96, 0xef, 0xcf, 0xc5, 0x51,
778 0x73, 0xd5, 0x49, 0xb3, 0x63, 0xa3, 0xaa, 0xe6, 0xea, 0xcd, 0x26, 0x35,
779 0x57, 0xed, 0xb4, 0x36, 0x0f, 0xbb, 0xb7, 0x9d, 0xe9, 0xdd, 0x14, 0xb9,
780 0x7a, 0x6b, 0xf3, 0xa2, 0x1f, 0x3e, 0xaf, 0xa7, 0xb2, 0x3e, 0xc3, 0xaa,
781 0x79, 0x26, 0xde, 0x2d, 0x74, 0xa7, 0xdb, 0xcb, 0xbf, 0xc5, 0xf3, 0x49,
782 0x58, 0x99, 0x09, 0xf7, 0x3a, 0xc4, 0x7c, 0xd7, 0xa7, 0xc5, 0xb8, 0xa0,
783 0x67, 0x5c, 0x82, 0x32, 0x13, 0x98, 0xbf, 0x18, 0xf3, 0x3f, 0xc9, 0xb8,
784 0x5e, 0x8f, 0xfb, 0x7e, 0x8b, 0x72, 0x42, 0xdf, 0xe7, 0xbf, 0x4b, 0x3d,
785 0x81, 0xf5, 0x02, 0xfc, 0x26, 0x06, 0xe3, 0x3f, 0xe6, 0x66, 0x51, 0x76,
786 0x89, 0xd7, 0x75, 0xbd, 0x2b, 0xf0, 0xa0, 0xf0, 0x93, 0x4a, 0xa6, 0x2e,
787 0xb7, 0xa5, 0xde, 0xbf, 0x2e, 0x6d, 0xae, 0x28, 0x39, 0xd7, 0x20, 0x4b,
788 0x21, 0x47, 0xb3, 0x95, 0xa0, 0x03, 0xbd, 0x0f, 0xb6, 0xd0, 0x25, 0xe6,
789 0x63, 0x32, 0x3f, 0x89, 0x79, 0x2a, 0xf3, 0x32, 0x49, 0x47, 0xa9, 0xba,
790 0xcf, 0x32, 0x48, 0x5c, 0x1e, 0xae, 0xe5, 0x45, 0xba, 0xe2, 0xe6, 0x21,
791 0x57, 0xdc, 0xdc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 0x3c, 0xd3, 0x1d, 0xcb, 0x90, 0xb7, 0x58,
836 0x86, 0x48, 0x5a, 0x4d, 0x28, 0xdf, 0x9e, 0xa6, 0x55, 0x6f, 0x4d, 0xa6,
837 0xa6, 0x4d, 0xc8, 0x6d, 0x0a, 0x1c, 0x1d, 0xad, 0xa7, 0xd1, 0x3b, 0x4c,
838 0xa3, 0x2d, 0x53, 0xfd, 0xf4, 0xa0, 0x88, 0x3d, 0xb3, 0xad, 0x39, 0xe6,
839 0xd1, 0xa9, 0x20, 0x74, 0xac, 0x10, 0xd3, 0x13, 0x74, 0x4c, 0x9b, 0xe1,
840 0xde, 0x4f, 0xeb, 0xc5, 0x76, 0x1e, 0x03, 0x9a, 0xdd, 0xab, 0x8e, 0xf3,
841 0x4c, 0xb3, 0x90, 0x7b, 0xd7, 0x02, 0x77, 0x0a, 0x06, 0xeb, 0x62, 0x21,
842 0x33, 0x43, 0xe0, 0x9f, 0x42, 0x3f, 0xe3, 0x7d, 0x5f, 0x65, 0x7e, 0x0f,
843 0xdf, 0x29, 0x7a, 0x77, 0x95, 0x20, 0x3b, 0x22, 0xb7, 0x99, 0x7f, 0x5e,
844 0x28, 0x5e, 0x63, 0x3a, 0xef, 0xa3, 0x2f, 0x17, 0x21, 0x9f, 0x01, 0x23,
845 0x3e, 0x2e, 0x91, 0xf0, 0x7d, 0x19, 0x53, 0x58, 0xfb, 0xfe, 0xac, 0x21,
846 0xf0, 0xe4, 0xaf, 0x01, 0x07, 0x86, 0xfd, 0xdd, 0x3d, 0xe8, 0x69, 0x9f,
847 0x30, 0x5a, 0x95, 0x8f, 0x17, 0xbf, 0x31, 0x1e, 0x63, 0x01, 0x37, 0x1c,
848 0x37, 0x8b, 0x2f, 0xe2, 0x1b, 0x11, 0x71, 0x86, 0x87, 0x97, 0x5f, 0x5d,
849 0xe5, 0xfb, 0x05, 0xbc, 0x26, 0x93, 0x41, 0xd4, 0x87, 0xd3, 0xd7, 0x82,
850 0x53, 0x93, 0xf4, 0x72, 0x19, 0xf3, 0xbe, 0x42, 0xb3, 0x61, 0xf0, 0x1f,
851 0x3b, 0x7e, 0x9f, 0x24, 0xec, 0xda, 0x59, 0xdf, 0xfc, 0xa2, 0x3f, 0x4f,
852 0xb3, 0x92, 0x42, 0x3f, 0x6e, 0x63, 0x7b, 0x07, 0xb0, 0x79, 0x83, 0x71,
853 0x2d, 0x0e, 0x1f, 0x80, 0xe2, 0x67, 0xdf, 0x67, 0x9e, 0x83, 0x3d, 0xc3,
854 0x71, 0x3d, 0x0f, 0x5b, 0x53, 0x3c, 0xcc, 0x71, 0xf1, 0xb0, 0x5c, 0x95,
855 0x87, 0x31, 0x2e, 0x08, 0xde, 0x05, 0xde, 0x74, 0x82, 0xf5, 0x45, 0xf9,
856 0x1b, 0x7a, 0xe0, 0x4e, 0xc1, 0xab, 0x98, 0xb7, 0xb3, 0xfd, 0xb0, 0x58,
857 0xce, 0x06, 0x8e, 0x08, 0x9e, 0xa1, 0xf1, 0xf9, 0xa9, 0x01, 0x49, 0x07,
858 0xed, 0xd2, 0x1f, 0x79, 0x0a, 0x7c, 0xca, 0x6f, 0xfc, 0x67, 0x78, 0x1c,
859 0xc6, 0x3b, 0x91, 0xd7, 0x99, 0x7f, 0x2d, 0xc6, 0x63, 0x22, 0x06, 0x22,
860 0x6d, 0x9c, 0x2c, 0xdb, 0x01, 0xbb, 0x90, 0x6b, 0x69, 0x25, 0xab, 0xfc,
861 0x4b, 0xd7, 0x1f, 0xc1, 0xaf, 0x88, 0x3d, 0x4e, 0xf4, 0x1a, 0x72, 0x1d,
862 0x16, 0xd6, 0x31, 0x5b, 0xa4, 0xd0, 0x4c, 0x1c, 0xb9, 0x71, 0xe0, 0xeb,
863 0x1f, 0xf0, 0xba, 0xb1, 0xaf, 0x1f, 0x60, 0x5f, 0xe5, 0xb5, 0x89, 0x63,
864 0x62, 0x5e, 0xb3, 0xcb, 0x35, 0xfe, 0x37, 0x97, 0x1f, 0x30, 0x16, 0x0b,
865 0x72,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x89, 0x1b,
880 0x46, 0x4a, 0xf8, 0x08, 0xda, 0x9d, 0x2e, 0x6a, 0x63, 0x39, 0x78, 0x8e,
881 0xd0, 0xe7, 0xcc, 0xb6, 0x10, 0x3b, 0xb9, 0xca, 0x38, 0x36, 0x1b, 0xb7,
882 0x23, 0xcf, 0x0b, 0x7b, 0x12, 0xf2, 0x01, 0xdf, 0x4e, 0x01, 0xac, 0x30,
883 0x07, 0xfe, 0xbd, 0x8c, 0x9e, 0x95, 0x71, 0x5e, 0x3f, 0x7c, 0xbd, 0x23,
884 0xd6, 0x5d, 0x96, 0x2b, 0x57, 0x85, 0x3f, 0xe5, 0x12, 0xeb, 0x92, 0xb6,
885 0x79, 0x54, 0xd0, 0x99, 0x31, 0xc4, 0x54, 0xc1, 0x74, 0x82, 0x1c, 0x81,
886 0xfd, 0xa2, 0xa7, 0x8e, 0xb4, 0x51, 0x78, 0x95, 0x2b, 0xaa, 0x57, 0x41,
887 0x1a, 0xb4, 0xbf, 0x75, 0x5f, 0x42, 0xfa, 0xa1, 0x7d, 0x28, 0x6e, 0x1d,
888 0xca, 0xeb, 0xa7, 0x86, 0x3d, 0x66, 0x89, 0xde, 0x8c, 0x80, 0x9d, 0xf0,
889 0x03, 0x1a, 0x63, 0x0c, 0x37, 0xfd, 0x9d, 0x1a, 0xb7, 0xbd, 0x7f, 0x5e,
890 0xd4, 0xdc, 0xbf, 0x59, 0x96, 0x32, 0x34, 0xc7, 0xb6, 0xf8, 0xec, 0xb8,
891 0x5b, 0xa7, 0xb0, 0x0b, 0xd3, 0xc2, 0x07, 0x33, 0x40, 0xc9, 0x85, 0x31,
892 0xfa, 0x7c, 0x1e, 0x3c, 0x88, 0xee, 0x27, 0x1d, 0xf1, 0xcd, 0x25, 0x9e,
893 0xd3, 0x18, 0xa5, 0xca, 0x80, 0x51, 0x80, 0x66, 0x99, 0xcb, 0xe7, 0x0a,
894 0x88, 0xbd, 0xf3, 0xef, 0x12, 0xbe, 0xa9, 0xf2, 0x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0x39, 0x59, 0x6e, 0xe6, 0xaf, 0xc2, 0x3e, 0xa0, 0xf6, 0x1c,
925 0xfe, 0x04, 0xc0, 0x4a, 0xfb, 0x14, 0x10, 0xdb, 0x03, 0x3e, 0x22, 0x56,
926 0xf2, 0x17, 0x94, 0x9a, 0xf7, 0xc6, 0x38, 0x37, 0xba, 0xe7, 0x7d, 0x9f,
927 0x7b, 0xa0, 0x6b, 0x83, 0x16, 0xec, 0x88, 0xb4, 0xd5, 0x35, 0xbc, 0xde,
928 0x0d, 0x1c, 0x29, 0xda, 0xd9, 0x12, 0x18, 0x63, 0x4f, 0x98, 0xce, 0x23,
929 0x8e, 0xaf, 0x7c, 0xbe, 0xc7, 0xf3, 0x72, 0xdd, 0xe6, 0xb8, 0xc0, 0x07,
930 0xe8, 0xa3, 0x91, 0x74, 0x30, 0xcd, 0x7b, 0x2a, 0xfd, 0xbd, 0x99, 0xe5,
931 0x88, 0xda, 0x27, 0x1e, 0x8b, 0xe7, 0xf9, 0xd6, 0xf3, 0x61, 0x7f, 0xec,
932 0x57, 0x57, 0xab, 0x79, 0xc1, 0x90, 0x05, 0x15, 0xfa, 0x05, 0xcb, 0xb9,
933 0xe0, 0xb8, 0x29, 0xfa, 0x28, 0xdc, 0x2a, 0x8f, 0xb3, 0x7e, 0x88, 0x3d,
934 0x84, 0xaf, 0x50, 0xfb, 0x72, 0x7f, 0x31, 0x44, 0x3d, 0x87, 0x58, 0xea,
935 0x1b, 0xe4, 0xb0, 0x7e, 0x68, 0x8c, 0x23, 0xbf, 0xdb, 0xe2, 0x7b, 0xd0,
936 0xff, 0x69, 0xbf, 0x95, 0xa2, 0x2e, 0xf8, 0x09, 0xd0, 0xa7, 0xd9, 0xca,
937 0xd5, 0xd1, 0xd4, 0x69, 0x41, 0x53, 0xa9, 0x95, 0xd3, 0x8a, 0xa6, 0x4e,
938 0x2b, 0x7f, 0xf9, 0x69, 0x45, 0x53, 0xa7, 0x15, 0x4d, 0x9d, 0x56, 0x34,
939 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 0x19, 0x3f, 0x5e, 0x66, 0xfc, 0x38, 0xd2, 0x04, 0x3f, 0x0c, 0x0f,
999 0x7e, 0x1c, 0x15, 0xf8, 0xf1, 0xeb, 0x43, 0x1b, 0xe1, 0xc7, 0x91, 0xe0,
1000 0x46, 0x3e, 0x1e, 0x8d, 0x9b, 0x03, 0xb4, 0x54, 0x74, 0x68, 0x79, 0xde,
1001 0x8e, 0x27, 0x68, 0x35, 0x22, 0x63, 0x83, 0x53, 0xa2, 0x4e, 0x65, 0x51,
1002 0xe0, 0x55, 0x5a, 0xf8, 0x2f, 0xfd, 0xbf, 0x1b, 0x68, 0x29, 0xf8, 0xcb,
1003 0x3d, 0x99, 0xce, 0xaf, 0x5e, 0xfc, 0x3b, 0xde, 0xc7, 0xdb, 0x2b, 0xa1,
1004 0x10, 0xae, 0x05, 0xa7, 0xc2, 0xb4, 0xb6, 0x82, 0xef, 0x12, 0x46, 0xe8,
1005 0x4e, 0x31, 0x4a, 0xb7, 0x8b, 0x03, 0xb4, 0x56, 0x1c, 0xa2, 0xbb, 0x45,
1006 0xbc, 0x03, 0x30, 0xe7, 0x63, 0x01, 0x73, 0x83, 0x0e, 0x87, 0x79, 0xcc,
1007 0xf2, 0x00, 0xad, 0x2e, 0x6b, 0x7c, 0x05, 0xae, 0x62, 0xff, 0xe1, 0x27,
1008 0xf0, 0xc7, 0x81, 0xe9, 0x3a, 0x1c, 0x90, 0xf7, 0x60, 0xef, 0x67, 0x1b,
1009 0x6b, 0x64, 0x45, 0x9e, 0xa5, 0xc9, 0x38, 0xd2, 0x32, 0x65, 0x0b, 0x5f,
1010 0xea, 0xe1, 0x20, 0x74, 0xd9, 0xc4, 0x3e, 0xea, 0xe1, 0x3d, 0x70, 0x90,
1011 0x27, 0x34, 0xc4, 0x7a, 0xe9, 0x0e, 0xa1, 0x87, 0x26, 0x9d, 0x50, 0x64,
1012 0x9a, 0x2a, 0x97, 0x0c, 0x07, 0x3d, 0x0f, 0xd3, 0xfc, 0x3c, 0x43, 0xf9,
1013 0x71, 0xba, 0x5d, 0xf8, 0xe4, 0xd5, 0x39, 0x11, 0x8b, 0x7d, 0x96, 0xe7,
1014 0x0c, 0xf9, 0x58, 0x8b, 0x73, 0x50, 0x35, 0xce, 0xd1, 0xce, 0xeb, 0x96,
1015 0xb4, 0x34, 0xe3, 0xf0, 0xb8, 0x32, 0x8f, 0x2b, 0x23, 0x76, 0xc6, 0xe7,
1016 0x97, 0x11, 0xb7, 0x8d, 0xd2, 0xda, 0x3c, 0x68, 0x0e, 0x7e, 0x89, 0x5a,
1017 0xac, 0x74, 0x6d, 0x05, 0xe7, 0xe1, 0x9b, 0xa8, 0xc5, 0x4a, 0xd7, 0x54,
1018 0xac, 0x74, 0x6d, 0x65, 0x4a, 0xf0, 0xe1, 0xd9, 0xff, 0xdd, 0x14, 0x60,
1019 0x19, 0x30, 0x85, 0x19, 0xba, 0x4e, 0x53, 0x0d, 0x7a, 0xbf, 0x4e, 0x0c,
1020 0x78, 0x6c, 0x58, 0x50, 0x05, 0x7f, 0x18, 0xba, 0x62, 0x84, 0xa1, 0x0d,
1021 0xb8, 0xfd, 0xe3, 0x02, 0x34, 0xd3, 0x79, 0x4a, 0x0c, 0x30, 0x3c, 0x23,
1022 0x80, 0x79, 0x49, 0x18, 0x9a, 0x97, 0x60, 0x73, 0xaf, 0xfc, 0x0c, 0x90,
1023 0xbb, 0x7a, 0x6c, 0xc0, 0x6d, 0x7c, 0x48, 0xf9, 0x23, 0x83, 0x56, 0xfe,
1024 0x30, 0xb0, 0x38, 0xa9, 0x43, 0xf4, 0x37, 0xad, 0x7f, 0x2c, 0x07, 0x1b,
1025 0x5f, 0x6b, 0x02, 0x9a, 0xdb, 0x3c, 0x85, 0x94, 0xb9, 0x5b, 0x60, 0xbd,
1026 0x89, 0x75, 0x5d, 0x26, 0xb1, 0x76, 0xc3, 0xd2, 0x42, 0x0c, 0x19, 0xe9,
1027 0x09, 0x62, 0x06, 0x22, 0x3d, 0xd9, 0x00, 0xcb, 0x4e, 0x16, 0x60, 0x5e,
1028 0x11, 0x02, 0xd6, 0x0f, 0x0c, 0xd0, 0x3a, 0xe6, 0x00, 0x78, 0x2c, 0xa1,
1029 0x89, 0x01, 0x74, 0x07, 0x27, 0xd0, 0xfe, 0x7e, 0x65, 0xf0, 0xba, 0xe3,
1030 0x06, 0x09, 0x88, 0xa1, 0x8b, 0x7a, 0x14, 0xe5, 0x41, 0x79, 0xd4, 0x49,
1031 0x85, 0x81, 0xc4, 0xfc, 0x04, 0xf2, 0x1f, 0xd0, 0x1f, 0x20, 0x3f, 0x02,
1032 0xf3, 0x93, 0x33, 0x50, 0x0e, 0xb4, 0x36, 0xaa, 0x79, 0x0d, 0x48, 0x1f,
1033 0x28, 0x0c, 0x41, 0x65, 0x2a, 0x68, 0x8c, 0x03, 0xc8, 0x5e, 0x22, 0x04,
1034 0x0d, 0x3b, 0x20, 0x0d, 0x64, 0x37, 0x4f, 0x11, 0x01, 0xf3, 0x93, 0x02,
1035 0x84, 0x18, 0x1a, 0xe0, 0xf9, 0x89, 0x1d, 0xe8, 0x52, 0x98, 0x9b, 0xfe,
1036 0xff, 0x3f, 0xa6, 0xc2, 0x02, 0x4c, 0x7b, 0xa0, 0xb5, 0xb5, 0xbf, 0xff,
1037 0x1f, 0x10, 0x61, 0x61, 0x68, 0x81, 0xaf, 0xd1, 0x0b, 0x94, 0x07, 0x95,
1038 0x73, 0x0b, 0x80, 0xac, 0x36, 0x78, 0xbd, 0x0d, 0x92, 0x07, 0x89, 0xfd,
1039 0x02, 0x96, 0x2b, 0xff, 0xff, 0x2f, 0x85, 0xab, 0x05, 0x01, 0x00, 0xb3,
1040 0x28, 0x79, 0xae, 0x58, 0x7d, 0x00, 0x00, 0x00 };
652 1041
653static u32 bnx2_COM_b06FwData[(0x0/4) + 1] = { 0x0 }; 1042static const u32 bnx2_COM_b06FwData[(0x0/4) + 1] = { 0x0 };
654static u32 bnx2_COM_b06FwRodata[(0x58/4) + 1] = { 1043static const u32 bnx2_COM_b06FwRodata[(0x88/4) + 1] = {
655 0x08002428, 0x0800245c, 0x0800245c, 0x0800245c, 0x0800245c, 0x0800245c, 1044 0x08001c1c, 0x08001c4c, 0x08001c4c, 0x08001c4c, 0x08001c4c, 0x08001c4c,
656 0x08002380, 0x0800245c, 0x080023e4, 0x0800245c, 0x0800231c, 0x0800245c, 1045 0x08001b74, 0x08001c4c, 0x08001bdc, 0x08001c4c, 0x08001b08, 0x08001c4c,
657 0x0800245c, 0x0800245c, 0x08002328, 0x00000000, 0x08003240, 0x08003270, 1046 0x08001c4c, 0x08001c4c, 0x08001b14, 0x00000000, 0x08002b58, 0x08002ba8,
658 0x080032a0, 0x080032d0, 0x08003300, 0x00000000, 0x00000000 }; 1047 0x08002bd8, 0x08002c08, 0x08002c38, 0x00000000, 0x080060cc, 0x080060cc,
659static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x0 }; 1048 0x080060cc, 0x080060cc, 0x080060cc, 0x08006100, 0x08006100, 0x08006140,
660static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x0 }; 1049 0x0800614c, 0x0800614c, 0x080060cc, 0x00000000, 0x00000000 };
1050static const u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x0 };
1051static const u32 bnx2_COM_b06FwSbss[(0x60/4) + 1] = { 0x0 };
661 1052
662static struct fw_info bnx2_com_fw_06 = { 1053static struct fw_info bnx2_com_fw_06 = {
663 .ver_major = 0x1, 1054 .ver_major = 0x3,
664 .ver_minor = 0x0, 1055 .ver_minor = 0x4,
665 .ver_fix = 0x0, 1056 .ver_fix = 0x3,
666 1057
667 .start_addr = 0x080008b4, 1058 .start_addr = 0x080000b4,
668 1059
669 .text_addr = 0x08000000, 1060 .text_addr = 0x08000000,
670 .text_len = 0x57bc, 1061 .text_len = 0x7d54,
671 .text_index = 0x0, 1062 .text_index = 0x0,
672 .gz_text = bnx2_COM_b06FwText, 1063 .gz_text = bnx2_COM_b06FwText,
673 .gz_text_len = sizeof(bnx2_COM_b06FwText), 1064 .gz_text_len = sizeof(bnx2_COM_b06FwText),
674 1065
675 .data_addr = 0x08005840, 1066 .data_addr = 0x08007e00,
676 .data_len = 0x0, 1067 .data_len = 0x0,
677 .data_index = 0x0, 1068 .data_index = 0x0,
678 .data = bnx2_COM_b06FwData, 1069 .data = bnx2_COM_b06FwData,
679 1070
680 .sbss_addr = 0x08005840, 1071 .sbss_addr = 0x08007e00,
681 .sbss_len = 0x1c, 1072 .sbss_len = 0x60,
682 .sbss_index = 0x0, 1073 .sbss_index = 0x0,
683 .sbss = bnx2_COM_b06FwSbss, 1074 .sbss = bnx2_COM_b06FwSbss,
684 1075
685 .bss_addr = 0x08005860, 1076 .bss_addr = 0x08007e60,
686 .bss_len = 0x88, 1077 .bss_len = 0x88,
687 .bss_index = 0x0, 1078 .bss_index = 0x0,
688 .bss = bnx2_COM_b06FwBss, 1079 .bss = bnx2_COM_b06FwBss,
689 1080
690 .rodata_addr = 0x080057c0, 1081 .rodata_addr = 0x08007d58,
691 .rodata_len = 0x58, 1082 .rodata_len = 0x88,
692 .rodata_index = 0x0, 1083 .rodata_index = 0x0,
693 .rodata = bnx2_COM_b06FwRodata, 1084 .rodata = bnx2_COM_b06FwRodata,
694}; 1085};
diff --git a/drivers/net/bnx2_fw2.h b/drivers/net/bnx2_fw2.h
index 680c769a3fc0..2c067531f031 100644
--- a/drivers/net/bnx2_fw2.h
+++ b/drivers/net/bnx2_fw2.h
@@ -1,13 +1,13 @@
1/* bnx2_fw2.h: Broadcom NX2 network driver. 1/* bnx2_fw2.h: Broadcom NX2 network driver.
2 * 2 *
3 * Copyright (c) 2006 Broadcom Corporation 3 * Copyright (c) 2004, 2005, 2006, 2007 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, except as noted below. 7 * the Free Software Foundation, except as noted below.
8 * 8 *
9 * This file contains firmware data derived from proprietary unpublished 9 * This file contains firmware data derived from proprietary unpublished
10 * source code, Copyright (c) 2006 Broadcom Corporation. 10 * source code, Copyright (c) 2004, 2005, 2006, 2007 Broadcom Corporation.
11 * 11 *
12 * Permission is hereby granted for the distribution of this firmware data 12 * Permission is hereby granted for the distribution of this firmware data
13 * in hexadecimal or equivalent format, provided this copyright notice is 13 * in hexadecimal or equivalent format, provided this copyright notice is
@@ -15,3289 +15,3260 @@
15 */ 15 */
16 16
17static u8 bnx2_COM_b09FwText[] = { 17static u8 bnx2_COM_b09FwText[] = {
18 0x1f, 0x8b, 0x08, 0x08, 0xac, 0xfb, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65, 18 0x1f, 0x8b, 0x08, 0x00, 0x0e, 0x34, 0xe7, 0x45, 0x00, 0x03, 0xdc, 0x5b,
19 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xdc, 0x5b, 0x6b, 0x70, 19 0x6d, 0x70, 0x5c, 0xd5, 0x79, 0x7e, 0xef, 0xd9, 0xbb, 0xf2, 0x5a, 0x92,
20 0x1b, 0xd7, 0x75, 0x3e, 0xfb, 0x00, 0x09, 0x91, 0x10, 0xb5, 0xa4, 0x60, 20 0xe5, 0x6b, 0x79, 0x23, 0x16, 0x4b, 0xc0, 0xae, 0x75, 0x6d, 0x69, 0xb0,
21 0x1a, 0x96, 0x68, 0x07, 0x20, 0x57, 0x22, 0x6a, 0xb1, 0x29, 0x4c, 0x33, 21 0x43, 0x16, 0xa1, 0x80, 0x9a, 0xd9, 0xc0, 0xb2, 0x2b, 0x33, 0x9e, 0x0c,
22 0x16, 0x9b, 0xc2, 0x12, 0x02, 0x50, 0xae, 0x26, 0xc3, 0x3a, 0x94, 0xcd, 22 0x69, 0x64, 0x50, 0x80, 0xb6, 0x4c, 0x46, 0xec, 0x1a, 0x9a, 0x4e, 0x87,
23 0xd8, 0x4a, 0xaa, 0xc9, 0x30, 0x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, 0xab, 104 0x7a, 0xcc, 0xca, 0x25, 0x65, 0x6b, 0x8d, 0xe5, 0x21, 0xeb, 0x4e, 0x9f,
105 0x18, 0x58, 0xeb, 0x70, 0x60, 0xad, 0xc3, 0x81, 0xb5, 0x8a, 0xe0, 0xad, 105 0xf2, 0x8c, 0x77, 0x9f, 0x74, 0x5e, 0x89, 0x7e, 0x36, 0x9e, 0x79, 0x43,
106 0xac, 0xd3, 0x81, 0x33, 0x79, 0xc2, 0xbc, 0x1c, 0xc5, 0x9c, 0x6f, 0x88, 106 0x6f, 0x94, 0x46, 0xce, 0x43, 0x1a, 0xf9, 0xfc, 0x66, 0x84, 0xc6, 0x27,
107 0x91, 0xa6, 0x2d, 0xf8, 0x36, 0xf9, 0x07, 0x18, 0x9f, 0x96, 0x73, 0x0e, 107 0x1b, 0xef, 0x47, 0x23, 0xef, 0x15, 0xff, 0x8f, 0x5a, 0x03, 0xda, 0x86,
108 0x78, 0x73, 0x3c, 0x24, 0x77, 0xa9, 0x71, 0xff, 0xb1, 0xc6, 0xa5, 0x31, 108 0xe4, 0x8d, 0x99, 0xaf, 0x98, 0x75, 0xf0, 0x7e, 0x8a, 0xf3, 0x7f, 0xab,
109 0xf8, 0x2c, 0x2c, 0xbb, 0xa2, 0xbc, 0xf7, 0x9f, 0x99, 0xe0, 0x37, 0xdb, 109 0x1e, 0xc8, 0x4b, 0xe5, 0x22, 0xeb, 0x2c, 0x44, 0xd6, 0xf9, 0x6e, 0x64,
110 0x93, 0x37, 0xb8, 0x6d, 0xde, 0x9f, 0xf5, 0xf6, 0xd2, 0xee, 0xbe, 0x57, 110 0x9d, 0xef, 0x46, 0xd6, 0xa9, 0x80, 0xa7, 0xb2, 0x51, 0x41, 0x86, 0x4b,
111 0x79, 0x53, 0x61, 0xc6, 0x62, 0x85, 0xb6, 0x2d, 0x29, 0xc3, 0x96, 0xfd, 111 0x34, 0x63, 0x72, 0x08, 0x73, 0xbe, 0x2e, 0xb1, 0x1c, 0xf5, 0x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a2, 0x6c, 0x68, 0x93, 0xf7, 119 0xb7, 0xb3, 0xa9, 0x9e, 0xba, 0x1d, 0xc3, 0x3b, 0x65, 0x78, 0x97, 0x39,
120 0xfe, 0xfd, 0x5a, 0xf5, 0xfc, 0x0d, 0x83, 0xeb, 0xf8, 0x57, 0xd1, 0x86, 120 0x63, 0x1b, 0x65, 0xe2, 0xf0, 0x35, 0xa6, 0x1c, 0xb6, 0x6f, 0xb6, 0x57,
121 0x60, 0x67, 0x93, 0xb3, 0xa6, 0xe4, 0x53, 0x31, 0x65, 0x0f, 0xf9, 0x54, 121 0x96, 0xcf, 0x76, 0xaf, 0x2c, 0x87, 0x38, 0x11, 0xc5, 0x70, 0xee, 0x15,
122 0x1d, 0x3f, 0x26, 0xa7, 0x1b, 0xf1, 0x83, 0xef, 0x11, 0x3f, 0x5c, 0xec, 122 0xf8, 0xe4, 0x52, 0xee, 0xe2, 0xa0, 0x35, 0x0b, 0x9d, 0x5b, 0x67, 0x68,
123 0x98, 0x98, 0x25, 0x8e, 0xd4, 0x71, 0xe3, 0xc8, 0xb4, 0x8f, 0x25, 0x9c, 123 0xb8, 0xc2, 0xd0, 0x00, 0x5a, 0xfb, 0x20, 0x59, 0x5a, 0x97, 0xb4, 0x68,
124 0x9b, 0x18, 0xe2, 0xe3, 0x07, 0xdf, 0x23, 0x7e, 0x18, 0x90, 0x15, 0xe7, 124 0x35, 0x95, 0xc9, 0xfb, 0xf0, 0x7d, 0x83, 0x6e, 0x0f, 0x74, 0x2e, 0x7c,
125 0xf4, 0xd7, 0x9f, 0x6a, 0x98, 0x7b, 0x4a, 0x61, 0x93, 0x8b, 0xcb, 0x6f, 125 0x86, 0xf8, 0xfe, 0x66, 0xc4, 0x5e, 0xf4, 0x40, 0x67, 0x93, 0xe0, 0x55,
126 0x06, 0x70, 0xbe, 0x0b, 0x18, 0x1d, 0x85, 0xfc, 0x7c, 0x8c, 0x26, 0x76, 126 0x88, 0xf5, 0xc4, 0xe0, 0x14, 0xec,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, 0x66, 0x80, 0xb7, 0xa2, 0x8d, 0xf6, 0x8e, 0x82, 0xde, 134 0x3c, 0x30, 0x4f, 0xac, 0xd1, 0xbe, 0x51, 0xec, 0x79, 0x04, 0x78, 0x78,
135 0x11, 0x60, 0xf1, 0x30, 0xb0, 0x78, 0x27, 0xb0, 0x78, 0x08, 0x58, 0x9c, 135 0x3b, 0xf0, 0x70, 0x37, 0xf0, 0x70, 0x18, 0x78, 0x98, 0x03, 0x16, 0x0e,
136 0x06, 0x0e, 0x0f, 0x02, 0x87, 0x07, 0x80, 0xc3, 0x29, 0xec, 0x2b, 0x2a, 136 0x01, 0x0b, 0x07, 0x81, 0x85, 0x59, 0xf0, 0x26, 0x29, 0x73, 0xc0, 0xc6,
137 0xf3, 0xc0, 0xe5, 0x79, 0xe0, 0xf3, 0x3c, 0xe4, 0x35, 0x31, 0x27, 0xda, 137 0x39, 0x60, 0xe4, 0x1c, 0xe6, 0x18, 0x9f, 0x15, 0xeb, 0x4b, 0xd8, 0xc3,
138 0x17, 0xb0, 0xfe, 0x63, 0x33, 0x89, 0xd3, 0xd0, 0xcd, 0x58, 0x51, 0x87, 138 0x63, 0x33, 0x99, 0x93, 0x90, 0xa5, 0x54, 0x45, 0x41, 0xfe, 0xb3, 0x43,
139 0x3d, 0xa5, 0x06, 0xa1, 0x23, 0x49, 0x29, 0x55, 0x46, 0xa5, 0x40, 0x3f, 139 0x90, 0xed, 0x7e, 0xa9, 0xfa, 0xb6, 0x94, 0x69, 0x53, 0xb7, 0xf7, 0x42,
140 0xb6, 0xb9, 0x07, 0xb6, 0x0b, 0xfb, 0x89, 0xf9, 0x71, 0xd3, 0x5a, 0xef, 140 0xd7, 0x20, 0xef, 0x29, 0x31, 0x7f, 0x1b, 0xcc, 0xf3, 0x1f, 0x45, 0xdc,
141 0xfa, 0xf7, 0x22, 0xf6, 0x1f, 0x83, 0x27, 0x89, 0xb8, 0xc8, 0xb0, 0xe4, 141 0xbf, 0xa3, 0x2c, 0xa6, 0x45, 0xce, 0x48, 0xc9, 0xeb, 0x75, 0x0a, 0xaa,
142 0x9d, 0x1e, 0x2b, 0xab, 0x27, 0x31, 0x8e, 0xed, 0xb8, 0xb6, 0xf7, 0x78, 142 0x1f, 0xfd, 0x58, 0xce, 0xaa, 0xfb, 0x8f, 0x5c, 0xaf, 0xf6, 0x1e, 0x21,
143 0x42, 0x1b, 0x3f, 0xce, 0x3d, 0x4d, 0x03, 0xe3, 0xaa, 0x32, 0x95, 0xa2, 143 0x5f, 0xa6, 0x81, 0x57, 0x75, 0x99, 0xcc, 0x52, 0xb7, 0xea, 0x72, 0x22,
144 0xad, 0x56, 0xe5, 0x54, 0x2a, 0x31, 0x58, 0x94, 0x56, 0x39, 0x12, 0x9d, 144 0x9b, 0x19, 0xaa, 0x48, 0x9b, 0x4c, 0x25, 0xa7, 0xb5, 0xad, 0xb5, 0x73,
145 0x56, 0xfe, 0xcd, 0x4c, 0x1f, 0x53, 0xfa, 0x51, 0xb0, 0x71, 0x2d, 0x77, 145 0x87, 0xb5, 0xbd, 0x2a, 0xbb, 0x78, 0xd6, 0x06, 0x54, 0xe9, 0x08, 0xf7,
146 0x6b, 0xf9, 0xe3, 0xf4, 0x3b, 0x3d, 0xf8, 0x85, 0x40, 0x0b, 0xe7, 0x37, 146 0xdf, 0x8b, 0x5f, 0x1c, 0xb4, 0x70, 0x7e, 0x5b, 0x86, 0x07, 0x1d, 0xf5,
147 0x65, 0x68, 0x40, 0xb4, 0x7d, 0xbd, 0x45, 0xa0, 0x62, 0xc2, 0x3a, 0x87, 147 0x40, 0x5f, 0x05, 0x08, 0x96, 0x71, 0xce, 0x62, 0xe5, 0xe2, 0x74, 0x6f,
148 0x95, 0x73, 0xd3, 0x3d, 0xb1, 0x9c, 0x6e, 0xca, 0x98, 0xa9, 0xc9, 0x04, 148 0xaa, 0xa8, 0x6c, 0x19, 0xb3, 0x2d, 0x19, 0x87, 0x7c, 0x0f, 0x67, 0xdf,
149 0xec, 0x65, 0x28, 0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57, 0xe6, 0x81, 0xff, 0xc5, 0x23, 0xc0, 0x41, 0xb7, 0x03, 0x98, 0x95,
157 0x70, 0xd5, 0x6e, 0x03, 0x06, 0x26, 0xce, 0xd2, 0x3e, 0x0c, 0xc4, 0x5a, 157 0x59, 0xa0, 0x4d, 0x8d, 0xc1, 0xef, 0xab, 0x6a, 0x5e, 0xf7, 0xc8, 0x91,
158 0x25, 0xc5, 0xeb, 0x2e, 0x39, 0x3e, 0xa3, 0xcb, 0xb3, 0xb7, 0xc5, 0xd1, 158 0x19, 0x25, 0xdf, 0xbe, 0x31, 0x8d, 0x32, 0xb0, 0x31, 0x9b, 0x39, 0x3d,
159 0x06, 0xd6, 0xa6, 0x12, 0x67, 0xc6, 0xf4, 0x2e, 0xb9, 0xb5, 0x23, 0x86, 159 0xa6, 0x7a, 0xe4, 0x86, 0xce, 0x14, 0xc6, 0xe5, 0x54, 0xc9, 0xdb, 0x18,
160 0xf7, 0x52, 0x5a, 0xde, 0xf9, 0x37, 0xf2, 0xf2, 0x64, 0x5c, 0xe7, 0x58, 160 0x03, 0x2f, 0x8f, 0xa7, 0x15, 0xfb, 0x2a, 0x29, 0x66, 0x63, 0x38, 0xff,
161 0x5d, 0x72, 0x29, 0x03, 0x3a, 0x56, 0xc4, 0xf8, 0x7f, 0x40, 0x7f, 0x97, 161 0x0a, 0xfa, 0xbf, 0x8f, 0xf5, 0x7a, 0x64, 0x16, 0xbe, 0xd6, 0xec, 0x4c,
162 0xcc, 0x21, 0xbe, 0x99, 0x03, 0x4d, 0xd9, 0x14, 0xb1, 0x30, 0x71, 0x72, 162 0x1e, 0xe3, 0x88, 0x5d, 0x99, 0xe3, 0x4b, 0x0a, 0x18, 0x33, 0x0b, 0xf9,
163 0x49, 0x07, 0x66, 0xcd, 0x41, 0x37, 0x47, 0x11, 0x3f, 0xcc, 0xfc, 0x37, 163 0x1e, 0x85, 0x2f, 0x33, 0x03, 0xd1, 0x69, 0x4d, 0xe3, 0x4c, 0x7b, 0x9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, 0x63, 0xaa, 0xad, 171 0xed, 0xb6, 0x1c, 0xd6, 0x65, 0x0b, 0xb4, 0x66, 0x52, 0xdc, 0xdf, 0x44,
172 0x81, 0xd6, 0x44, 0x8c, 0xfb, 0x9b, 0x2c, 0x27, 0xe5, 0x71, 0x87, 0xe3, 172 0xad, 0x5f, 0x9e, 0xf2, 0xd8, 0x1f, 0x7c, 0x9e, 0x6e, 0x37, 0xfd, 0x4f,
173 0xc1, 0xe7, 0xe9, 0x88, 0x37, 0x1e, 0xf1, 0x8e, 0xc3, 0x98, 0x29, 0x09, 173 0x83, 0x87, 0xf4, 0xdf, 0xfa, 0x41, 0x73, 0xa0, 0x5b, 0xf3, 0xd3, 0x49,
174 0x9a, 0x5d, 0xbb, 0x58, 0x98, 0x8e, 0xaa, 0x67, 0x47, 0x1c, 0x37, 0x36, 174 0xdd, 0x36, 0xe5, 0x05, 0x7e, 0x9a, 0x82, 0x2f, 0x37, 0x07, 0x5f, 0xae,
175 0xd2, 0x11, 0x3f, 0xcd, 0x23, 0x7e, 0xca, 0x29, 0x1b, 0xb1, 0x32, 0x88, 175 0xa8, 0xf5, 0xcc, 0xc9, 0xc3, 0xd7, 0x87, 0x9e, 0x04, 0x3a, 0x56, 0xad,
176 0xaf, 0xe1, 0x67, 0x5d, 0xfb, 0x28, 0x95, 0x49, 0xcb, 0x3d, 0xa0, 0x2f, 176 0x91, 0x96, 0xbb, 0x40, 0x5f, 0xa6, 0x02, 0x62, 0x0e, 0xab, 0x1c, 0xce,
177 0x51, 0x04, 0x31, 0xc7, 0x74, 0xb8, 0xeb, 0xec, 0x80, 0x14, 0x19, 0x63, 177 0x7d, 0x50, 0x2a, 0xf4, 0xf7, 0xce, 0xc6, 0x9e, 0x92, 0xb1, 0x2a, 0xed,
178 0x9d, 0x33, 0x1e, 0x91, 0xb1, 0x12, 0xfd, 0x1b, 0x7e, 0x8e, 0x6d, 0x31, 178 0x11, 0x7e, 0x9e, 0xeb, 0x30, 0xbe, 0xc8, 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2, 0xf3, 0x53, 0x03, 0xbc, 0xc7, 0x3c, 0xf0, 0x6d, 186 0xdf, 0x31, 0x0f, 0x6c, 0x91, 0xe3, 0x9e, 0x41, 0x5f, 0xf8, 0x7a, 0xde,
187 0x96, 0x3d, 0x8c, 0xb1, 0xa3, 0x98, 0x73, 0x8d, 0x64, 0x3b, 0x7d, 0x7a, 187 0x7a, 0x29, 0x74, 0x85, 0xf4, 0x52, 0x06, 0xe8, 0x27, 0x68, 0x1b, 0xbc,
188 0xa9, 0x03, 0x8c, 0x3f, 0xd8, 0x8e, 0xae, 0x77, 0x79, 0xff, 0x25, 0xc3, 188 0x39, 0xe0, 0xfd, 0x1f, 0xc6, 0x02, 0x99, 0x3c, 0x80, 0x32, 0xf5, 0xef,
189 0xd5, 0xc9, 0x11, 0xb4, 0x69, 0x7f, 0x07, 0x25, 0xe7, 0x24, 0xb0, 0x4f, 189 0x80, 0x14, 0xbd, 0x0c, 0xf6, 0x09, 0x1d, 0xf3, 0x3b, 0xac, 0x60, 0x8f,
190 0xf0, 0xb6, 0x32, 0xe1, 0xed, 0x11, 0xfc, 0x1f, 0x39, 0x0c, 0x3e, 0x48, 190 0xe0, 0xff, 0xc8, 0x39, 0xf0, 0x41, 0x2a, 0x01, 0x6f, 0xc8, 0x17, 0xf2,
191 0xd1, 0xe5, 0x0d, 0xf9, 0x42, 0x9e, 0xfc, 0x16, 0x74, 0xff, 0x61, 0x8c, 191 0xa4, 0x03, 0xb2, 0x0f, 0xb9, 0x87, 0xdc, 0x96, 0x34, 0x0f, 0xfe, 0xbd,
192 0x81, 0x7f, 0x50, 0x3c, 0x58, 0xea, 0x70, 0x63, 0xd1, 0x44, 0x31, 0xc3, 192 0x33, 0xf0, 0x8b, 0x33, 0x95, 0x3c, 0xe3, 0xb9, 0x4e, 0xe2, 0x26, 0x30,
193 0xfc, 0xa9, 0x83, 0x98, 0x07, 0xfc, 0xa9, 0x40, 0xb1, 0x30, 0xf7, 0x92, 193 0xcc, 0x87, 0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fe, 0x05, 0xc8, 0x61, 0x0b, 0xe8,
216 0x88, 0xbf, 0x93, 0x3f, 0x0d, 0x3d, 0x6c, 0x02, 0x3d, 0x3f, 0xe5, 0xc5, 216 0xf9, 0x94, 0xf1, 0x31, 0xbe, 0x61, 0x07, 0x72, 0xd8, 0x86, 0xba, 0xcf,
217 0x2c, 0x0f, 0x9a, 0xae, 0x1e, 0xb6, 0xa2, 0xef, 0x93, 0xe8, 0x6b, 0xc5, 217 0xa0, 0xae, 0x0d, 0x7d, 0xf6, 0xa3, 0x0f, 0x7d, 0x94, 0x0e, 0x53, 0x17,
218 0x98, 0x03, 0x18, 0xc3, 0x98, 0xa7, 0xcd, 0xeb, 0x0b, 0x8e, 0x63, 0xec, 218 0xed, 0x47, 0x5f, 0xe5, 0x0b, 0x58, 0x2b, 0x83, 0x7e, 0x1d, 0x98, 0xbb,
219 0xf3, 0x19, 0xac, 0x95, 0xc0, 0xb8, 0x36, 0xcc, 0xdd, 0x85, 0x31, 0xdb, 219 0x07, 0x7d, 0x6e, 0x46, 0x9f, 0xab, 0x50, 0xa6, 0x6f, 0xdb, 0x8d, 0xf2,
220 0x30, 0xe6, 0x46, 0xb4, 0x19, 0x33, 0x6f, 0x44, 0xfb, 0x13, 0x0d, 0xef, 220 0xa7, 0x9b, 0xc6, 0x5c, 0x83, 0xba, 0xcf, 0x36, 0xd5, 0x9d, 0x45, 0x1d,
221 0x7c, 0x0c, 0x7d, 0xb7, 0x37, 0xf4, 0x9d, 0x43, 0x1f, 0xf2, 0x50, 0xeb, 221 0x62, 0x62, 0xe7, 0x45, 0x33, 0xae, 0x82, 0x72, 0x57, 0x53, 0x9f, 0x57,
222 0xbc, 0xf7, 0x5e, 0x11, 0xed, 0xce, 0x86, 0x31, 0xaf, 0xa2, 0x0f, 0x71, 222 0x50, 0x37, 0x84, 0xba, 0xbf, 0xc2, 0x13, 0xb1, 0xb0, 0x43, 0x9a, 0xc2,
223 0xaf, 0xf5, 0x2d, 0x5c, 0x91,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27, 0x71, 0x72, 0x1e, 0x6f, 0x8e, 0xab, 245 0x90, 0xed, 0xbd, 0x3a, 0x26, 0x60, 0x3c, 0x50, 0x97, 0x5d, 0xd9, 0x4f,
246 0x1c, 0x83, 0xf9, 0x45, 0x55, 0x76, 0xa4, 0x5a, 0xa3, 0xe4, 0x43, 0x46, 246 0x25, 0xc9, 0x87, 0xbc, 0xfa, 0x71, 0x9c, 0x3e, 0xc3, 0xa2, 0x47, 0x9e,
247 0xff, 0x76, 0x88, 0x31, 0xc3, 0xa2, 0x43, 0x9e, 0xa5, 0xf0, 0x3c, 0x05, 247 0x65, 0xd1, 0x9e, 0x05, 0x26, 0xfc, 0xab, 0x14, 0x93, 0xac, 0x7b, 0xab,
248 0x4c, 0xf8, 0x27, 0xc9, 0x45, 0xd9, 0xf7, 0x76, 0x75, 0x01, 0x71, 0x95, 248 0x3e, 0x0f, 0xbf, 0x4a, 0xfb, 0x47, 0xda, 0xde, 0xd3, 0xbf, 0x83, 0x5d,
249 0x8a, 0x8f, 0x94, 0xbf, 0x67, 0x7c, 0xb7, 0x1f, 0xfc, 0x22, 0x4f, 0x47, 249 0xf7, 0xc9, 0xd3, 0x25, 0xf0, 0x39, 0xf4, 0x01, 0x7e, 0x40, 0x1f, 0x55,
250 0xc0, 0x67, 0x3f, 0x06, 0x78, 0x8d, 0x75, 0x15, 0x59, 0x1e, 0x07, 0x8b, 250 0x56, 0xfa, 0xd2, 0x22, 0x0f, 0xd5, 0xfe, 0x01, 0x36, 0x47, 0x05, 0xbe,
251 0x3c, 0x50, 0x7e, 0x19, 0x73, 0xea, 0x6e, 0xac, 0xc2, 0x3c, 0xdc, 0x66, 251 0x0a, 0xe3, 0x65, 0x97, 0xf5, 0x37, 0xc6, 0xe9, 0xcb, 0x05, 0xb6, 0x3e,
252 0x7f, 0x47, 0x88, 0xb1, 0x9c, 0xeb, 0xeb, 0x0d, 0xac, 0x87, 0xdc, 0xbe, 252 0x86, 0xf5, 0x10, 0x5f, 0xd7,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, 0xd6,
297 0x69, 0x19, 0x56, 0x35, 0x80, 0xee, 0xfe, 0x03, 0xc4, 0xab, 0x14, 0xfc, 297 0xdb, 0x75, 0x1e, 0x61, 0xeb, 0xc0, 0x7e, 0xe2, 0x55, 0x16, 0x76, 0x1d,
298 0x3a, 0xfc, 0x6f, 0x55, 0xee, 0x48, 0x5d, 0xac, 0x9e, 0xb7, 0xd7, 0x49, 298 0xf6, 0xb7, 0x2e, 0xb7, 0x65, 0xdf, 0xae, 0xbf, 0xe8, 0x6e, 0x94, 0xd2,
299 0xbe, 0xef, 0x8b, 0x1e, 0x66, 0x8f, 0x3d, 0x92, 0xb5, 0x8b, 0xb0, 0x0f, 299 0xce, 0xfb, 0x0c, 0x66, 0x2f, 0x7d, 0xad, 0xe0, 0x56, 0xa0, 0x1f, 0x41,
300 0xb7, 0x16, 0x39, 0x3e, 0x1d, 0x46, 0x14, 0xca, 0xbf, 0x0e, 0x59, 0x18, 300 0xce, 0x70, 0xef, 0x74, 0x02, 0x96, 0x80, 0x7f, 0x9d, 0x32, 0x3f, 0xf4,
301 0xfc, 0x1b, 0xc8, 0x70, 0xcb, 0x69, 0x16, 0xb0, 0x74, 0xe0, 0xf0, 0x42, 301 0x16, 0xce, 0x70, 0xc7, 0x49, 0x26, 0x9c, 0x14, 0x70, 0x78, 0x3e, 0xd9,
302 0x34, 0xa2, 0xea, 0x33, 0xd7, 0xd9, 0xec, 0xb7, 0x20, 0xd3, 0x51, 0x59, 302 0xae, 0xf3, 0xc5, 0x9f, 0x70, 0x59, 0xef, 0xe0, 0x4c, 0x47, 0x65, 0x1e,
303 0x40, 0xfc, 0x50, 0x1a, 0x04, 0x8d, 0x7d, 0x9d, 0x18, 0x4f, 0xbb, 0x23, 303 0xfe, 0x43, 0x75, 0x08, 0x34, 0xee, 0xec, 0x42, 0x7f, 0xea, 0x1d, 0x79,
304 0xcf, 0x47, 0xe1, 0x7b, 0xc9, 0xd3, 0x28, 0xc6, 0xef, 0xc2, 0x98, 0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, 0xd0, 0xe1, 0x7d, 0xa5, 0x0e, 0x39, 0xaf, 319 0xf3, 0x8e, 0x27, 0x64, 0xf8, 0x81, 0x6a, 0xa7, 0xbc, 0xa8, 0x79, 0xea,
320 0x78, 0x6a, 0xc9, 0xb9, 0x1a, 0x4f, 0x43, 0xde, 0xb7, 0x90, 0x83, 0xde, 320 0xc8, 0xd9, 0x06, 0x4f, 0xe3, 0xe6, 0xbb, 0xcc, 0x01, 0xf3, 0xcd, 0xa3,
321 0x77, 0x06, 0x03, 0x71, 0x11, 0xee, 0xcb, 0x19, 0xd0, 0x10, 0x97, 0x9e, 321 0x0f, 0x7e, 0x11, 0xde, 0x6b, 0x79, 0xd0, 0x90, 0x96, 0xde, 0x01, 0xc6,
322 0x7e, 0xe6, 0x6e, 0x45, 0x5c, 0x59, 0xa7, 0xd0, 0x70, 0x75, 0xeb, 0x17, 322 0x6e, 0x15, 0x3c, 0x99, 0xa7, 0xb0, 0xf0, 0x0c, 0xf2, 0x17, 0xbd, 0x03,
323 0x3d, 0xfd, 0xf0, 0x4b, 0xc0, 0xa1, 0x9e, 0xfe, 0xef, 0xa8, 0x7c, 0xae, 323 0xb0, 0x4b, 0xc0, 0xa1, 0xde, 0x81, 0x73, 0x3a, 0x9e, 0xab, 0xfa, 0x8e,
324 0x54, 0xb1, 0xb4, 0x3b, 0x1c, 0xb7, 0x46, 0x74, 0xce, 0xbe, 0x5c, 0x8d, 324 0x75, 0x9b, 0x17, 0xe4, 0x88, 0xce, 0xba, 0x17, 0xca, 0x11, 0xdd, 0xb3,
325 0x68, 0xa0, 0x99, 0x75, 0x0d, 0xbf, 0x46, 0x74, 0x4e, 0x54, 0x8d, 0xe8, 325 0x8e, 0x79, 0x8d, 0x30, 0x47, 0x74, 0x56, 0x74, 0x8e, 0xe8, 0xf8, 0x45,
326 0xe4, 0x15, 0x6a, 0x44, 0x99, 0xab, 0xaf, 0x11, 0x71, 0x7e, 0x53, 0xee, 326 0x72, 0x44, 0xf9, 0x4b, 0xcf, 0x11, 0x71, 0x7e, 0x5b, 0xee, 0x1c, 0x74,
327 0x1e, 0x10, 0xed, 0x4b, 0x5e, 0x8d, 0xe8, 0x82, 0xb8, 0x35, 0xa2, 0xf3, 327 0xd4, 0xaf, 0x9a, 0x1c, 0xd1, 0x1b, 0x12, 0xe4, 0x88, 0x5e, 0x94, 0xb5,
328 0xb2, 0x7a, 0x8d, 0xe8, 0x68, 0x43, 0x8d, 0x68, 0xbd, 0xaa, 0x11, 0x71, 328 0x73, 0x44, 0x87, 0x9a, 0x72, 0x44, 0x9b, 0x75, 0x8e, 0x88, 0xf3, 0x04,
329 0x1e, 0xb7, 0x46, 0xc4, 0x76, 0xbe, 0x7f, 0x30, 0x50, 0xeb, 0x00, 0xfe, 329 0x39, 0x22, 0x96, 0x4b, 0x03, 0x43, 0x91, 0x5c, 0x07, 0xf0, 0xd7, 0xbb,
330 0x3a, 0xb7, 0x82, 0x6f, 0x96, 0x36, 0xea, 0xf8, 0x98, 0x46, 0xec, 0xbf, 330 0x01, 0x7c, 0x73, 0xac, 0x51, 0x2f, 0xc4, 0x34, 0x62, 0xff, 0x15, 0x0d,
331 0xbe, 0xe6, 0xbf, 0xea, 0xf8, 0xa6, 0x29, 0x9d, 0xbb, 0x12, 0xbe, 0x8d, 331 0xfb, 0xb5, 0x8c, 0x6f, 0x96, 0x96, 0xb9, 0x8b, 0xe1, 0xdb, 0x68, 0xe0,
332 0xba, 0x71, 0xc9, 0x32, 0x6c, 0x9b, 0xaa, 0xc5, 0x2e, 0xbf, 0xdc, 0xcc, 332 0x97, 0xac, 0xc0, 0xb6, 0xc9, 0x86, 0xef, 0xe2, 0xad, 0x63, 0x0c, 0x3d,
333 0x1c, 0x7a, 0xb2, 0x5c, 0x9f, 0x77, 0x12, 0xf2, 0x1e, 0xab, 0xd5, 0x49, 333 0x51, 0x5b, 0x9e, 0x77, 0x02, 0xbc, 0x1e, 0x6b, 0xe4, 0x49, 0xce, 0xe7,
334 0x2e, 0x15, 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x4b, 0xb0, 0x51, 0xa7, 0x40,
349 0x6d, 0xa0, 0x39, 0xb8, 0x8f, 0x22, 0xfc, 0x13, 0xfa, 0x94, 0xcc, 0x19, 349 0x73, 0x74, 0x1f, 0x88, 0x89, 0x07, 0x51, 0xa7, 0xcf, 0x9c, 0xbe, 0x65,
350 0x5b, 0xfa, 0xb4, 0xc4, 0x69, 0xe7, 0x57, 0x31, 0x1f, 0xfb, 0xb6, 0xa9, 350 0x48, 0x4b, 0x9a, 0x7a, 0x7e, 0x09, 0xf3, 0xb1, 0xee, 0x94, 0x8e, 0xc7,
351 0x7c, 0xac, 0x30, 0xc0, 0xbd, 0xd2, 0xd7, 0x2d, 0x82, 0x3e, 0xf4, 0x95, 351 0xca, 0x83, 0xdc, 0x2b, 0x6d, 0xdd, 0x22, 0xe8, 0x43, 0x5d, 0x95, 0x31,
352 0x98, 0x03, 0xd2, 0xef, 0xf9, 0x39, 0x5a, 0x44, 0xe5, 0x68, 0x9d, 0x8a, 352 0x20, 0xed, 0x5e, 0x18, 0xa3, 0xb5, 0xeb, 0x18, 0xad, 0x4b, 0xf3, 0x83,
353 0x1f, 0xe4, 0xf5, 0x8d, 0x61, 0x62, 0x65, 0xa7, 0xcd, 0x3d, 0x0c, 0x7b, 353 0xbc, 0xbe, 0x35, 0x41, 0xac, 0xec, 0x72, 0xb9, 0x87, 0x33, 0x06, 0xeb,
354 0x58, 0xc7, 0xb6, 0x9b, 0x0b, 0x66, 0x74, 0xde, 0x3f, 0x02, 0xb9, 0xb2, 354 0x58, 0x0e, 0x62, 0xc1, 0xbc, 0xe2, 0xfb, 0xef, 0xe1, 0x5c, 0x99, 0xa7,
355 0x4e, 0xe3, 0xcb, 0xef, 0x21, 0x6f, 0xdf, 0x83, 0x52, 0xec, 0x94, 0xf0, 355 0x09, 0xcf, 0xef, 0x2b, 0x66, 0xdf, 0x43, 0x52, 0xe9, 0x92, 0xc4, 0x66,
356 0x7a, 0xd0, 0x93, 0x9f, 0x61, 0xdc,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 0xa8, 0x73, 0xdd, 0x4d, 0x32, 0xb8, 0x88, 0x78, 0xbf,
364 0xdf, 0xe3, 0xe9, 0x20, 0x65, 0xdd, 0xab, 0xbe, 0x11, 0x95, 0x9c, 0x47, 364 0xdb, 0xc8, 0x20, 0xcf, 0xba, 0x4f, 0x7f, 0x67, 0xaa, 0x7a, 0x4f, 0x05,
365 0xdc, 0x3c, 0x1f, 0x3a, 0x90, 0x2f, 0xf9, 0xb6, 0x06, 0x9e, 0x44, 0xfd, 365 0x71, 0xbe, 0x8b, 0x67, 0x35, 0xd4, 0x35, 0xf0, 0x24, 0x19, 0xb6, 0x91,
366 0x67, 0xe4, 0xa3, 0x8d, 0x98, 0x67, 0x0b, 0xe2, 0x35, 0xf0, 0x48, 0xf5, 366 0x8f, 0x2e, 0x7c, 0x9e, 0x1d, 0xf0, 0xd7, 0xc0, 0x23, 0x5d, 0xbf, 0x32,
367 0x2f, 0xaf, 0x09, 0x5f, 0x1e, 0xcf, 0xa4, 0x18, 0xc2, 0xd8, 0x53, 0x03, 367 0x27, 0x7c, 0x61, 0x3c, 0x93, 0x4a, 0x1c, 0x7d, 0x4f, 0x0c, 0x42, 0xc7,
368 0xb0, 0xf1, 0x01, 0x62, 0x54, 0x1a, 0x79, 0x0f, 0xf5, 0x90, 0xba, 0xb9, 368 0x07, 0x89, 0x51, 0x35, 0xc4, 0x3d, 0x94, 0x43, 0xca, 0xe6, 0xb6, 0xfe,
369 0x29, 0xb9, 0x43, 0x67, 0x4c, 0xb5, 0x07, 0xb6, 0x47, 0x7d, 0x8d, 0xcb, 369 0x5d, 0x8a, 0x3e, 0xd5, 0x13, 0x88, 0x83, 0x29, 0xaf, 0x69, 0xd9, 0xe5,
370 0x8e, 0xca, 0xa6, 0x33, 0xe7, 0x74, 0xae, 0x51, 0xad, 0xe6, 0x99, 0x2b, 370 0x6f, 0x3b, 0x7d, 0x56, 0x71, 0x8d, 0x7a, 0xbd, 0xc4, 0x58, 0xd1, 0x11,
371 0x5a, 0xa2, 0x77, 0xf7, 0xff, 0x45, 0x98, 0x7e, 0xe9, 0x7a, 0xdb, 0xf0, 371 0xb5, 0x75, 0xe0, 0xbf, 0x13, 0xb4, 0x4b, 0x57, 0xb8, 0x31, 0x23, 0x6b,
372 0x74, 0x2d, 0x83, 0x7b, 0xea, 0xed, 0xeb, 0xf0, 0xf7, 0xfc, 0xc6, 0xfe, 372 0x79, 0xbc, 0x53, 0x6e, 0x7f, 0x08, 0x7b, 0xcf, 0xef, 0xfd, 0xaf, 0xa1,
373 0x03, 0xf4, 0xc7, 0x60, 0xf3, 0xf4, 0xef, 0xcc, 0x47, 0xb6, 0x7a, 0xe3, 373 0x3e, 0x05, 0x9d, 0xa7, 0x7d, 0x67, 0x3c, 0x72, 0x93, 0xe9, 0xd7, 0xad,
374 0x7a, 0xd4, 0xf7, 0xcf, 0x6c, 0xea, 0x56, 0xef, 0xbb, 0x13, 0xfd, 0x4f, 374 0xbf, 0x57, 0x16, 0xb2, 0x37, 0x98, 0x6f, 0x57, 0xb4, 0x3f, 0x19, 0xda,
375 0x82, 0x3e, 0x7b, 0x99, 0x9c, 0x79, 0x46, 0x21, 0xa7, 0xf2, 0x19, 0xbe, 375 0xec, 0x15, 0xe7, 0xcc, 0xfb, 0x12, 0x45, 0x1d, 0xcf, 0x70, 0xbc, 0x96,
376 0xaf, 0x74, 0x12, 0x39, 0x88, 0x19, 0xa8, 0xa5, 0x87, 0xbd, 0xdc, 0x8d, 376 0x49, 0xc4, 0x20, 0x76, 0x24, 0x97, 0x9e, 0x30, 0xb1, 0x1b, 0x75, 0xac,
377 0x36, 0x16, 0x81, 0x0c, 0xb7, 0x7b, 0xb9, 0x0a, 0xf3, 0xd7, 0xe5, 0x67, 377 0x1d, 0x67, 0xe8, 0x9b, 0x58, 0x85, 0xf1, 0xeb, 0xca, 0x7b, 0x12, 0x6b,
378 0x13, 0x56, 0xd7, 0x81, 0x0d, 0xef, 0x43, 0x07, 0x1a, 0xe5, 0x17, 0x86, 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0x33, 0x08, 0xef, 0xb4, 0x51, 0x5f, 0xf3, 0xd0, 0xd7, 0x65, 0x5f, 0x26,
423 0x58, 0xc6, 0xd5, 0xc7, 0xa0, 0x2e, 0x12, 0x1f, 0x8a, 0x62, 0xd8, 0xd0, 423 0x90, 0xc7, 0xa8, 0x2c, 0x12, 0x1f, 0x2a, 0x12, 0x73, 0x7d, 0xfa, 0x47,
424 0x9d, 0x12, 0x74, 0xa8, 0xe4, 0xfb, 0x24, 0x9e, 0x83, 0xe2, 0x19, 0x53, 424 0x56, 0xb9, 0x1a, 0xda, 0x24, 0xde, 0x5b, 0xe2, 0x7d, 0xd7, 0xc0, 0xf6,
425 0xd7, 0xf7, 0x86, 0xec, 0x45, 0x2f, 0x07, 0x7b, 0x9b, 0xb4, 0x03, 0x2f, 425 0xc6, 0xdd, 0x45, 0x13, 0x83, 0x5d, 0xd1, 0x06, 0xda, 0x81, 0x97, 0x21,
426 0x7d, 0xcc, 0x94, 0x63, 0xae, 0xdd, 0x50, 0x7f, 0x39, 0xbf, 0x67, 0x3f, 426 0x66, 0xca, 0xe1, 0x40, 0x6f, 0x28, 0xbf, 0x9c, 0xdf, 0xe8, 0x0f, 0x65,
427 0xd4, 0x55, 0x6f, 0x9d, 0xa1, 0x15, 0xb8, 0x16, 0x5f, 0x51, 0xdb, 0x32, 427 0xd5, 0xac, 0x33, 0xbc, 0x0a, 0xd7, 0xd2, 0xab, 0x72, 0x5b, 0xb1, 0x4b,
428 0xae, 0x02, 0xd7, 0x46, 0x6a, 0xb8, 0xf6, 0x59, 0x99, 0xaf, 0xe5, 0xdb, 428 0xc0, 0xb5, 0x91, 0x06, 0xae, 0x7d, 0x51, 0xe6, 0x1a, 0xf1, 0xf6, 0x19,
429 0xc3, 0x72, 0xc0, 0xd9, 0xc5, 0x33, 0x36, 0xc7, 0x32, 0xf2, 0xe1, 0xe4, 429 0xd9, 0xef, 0xed, 0xe1, 0x3d, 0x9d, 0xc3, 0x79, 0xf9, 0x68, 0xe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ff, 0x71, 0x5b, 0x80, 0x83, 0x17, 0x8a, 0x59, 0x3e, 0xdf, 0xce,
445 0x96, 0x9f, 0x88, 0xb0, 0xae, 0xb7, 0xe8, 0x5c, 0x89, 0xd6, 0x95, 0x79, 445 0xbc, 0xde, 0xa2, 0x77, 0x31, 0x5a, 0x57, 0xc7, 0xbd, 0xb1, 0x55, 0x71,
446 0xaf, 0xb1, 0x22, 0xef, 0x1d, 0xf5, 0xf2, 0xda, 0xcf, 0xa9, 0xbc, 0xd7, 446 0xaf, 0x6d, 0xe2, 0xda, 0x5f, 0xd2, 0x71, 0x6f, 0xc0, 0x63, 0xee, 0x25,
447 0xe5, 0x31, 0xf7, 0x12, 0xcc, 0xa3, 0x6c, 0x60, 0x21, 0xbf, 0xa9, 0x10, 447 0x1a, 0x47, 0xb9, 0xc0, 0x42, 0x7e, 0x53, 0x21, 0x3e, 0xd0, 0x47, 0x81,
448 0x1f, 0x26, 0x94, 0xdf, 0xca, 0x4f, 0xdf, 0x09, 0x3e, 0x47, 0x57, 0xd1, 448 0x9f, 0x35, 0xfd, 0x8b, 0xe0, 0x73, 0x72, 0x0d, 0xb9, 0xf9, 0xb8, 0xed,
449 0x9b, 0x8f, 0xda, 0x4f, 0xf8, 0x7b, 0x3f, 0x2c, 0x6e, 0xbd, 0x6e, 0x27, 449 0x44, 0xb8, 0xf7, 0x73, 0x12, 0xe4, 0xeb, 0x76, 0x83, 0x16, 0xc6, 0x56,
450 0x68, 0x61, 0x6e, 0x15, 0xf2, 0xf4, 0xe1, 0xbb, 0xde, 0x39, 0x53, 0x7f, 450 0x71, 0x23, 0x0f, 0x3f, 0x35, 0xf7, 0x2a, 0xc3, 0x7e, 0x61, 0x1c, 0xdf,
451 0x9c, 0x9f, 0xc7, 0xd7, 0xbe, 0xbb, 0x16, 0x33, 0xcb, 0xea, 0x27, 0x1b, 451 0xf8, 0xee, 0x5a, 0xc9, 0xaf, 0xc8, 0x9f, 0x74, 0x33, 0x0d, 0x8d, 0x73,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 0x7c, 0x7b, 481 0x4b, 0x3f, 0xcd, 0x7b, 0x63, 0xc0, 0x50, 0xf0, 0xed, 0xf9, 0x55, 0xdf,
482 0x66, 0xc5, 0x77, 0xec, 0xe0, 0x59, 0xb3, 0x64, 0xed, 0xec, 0xd0, 0x53, 482 0xb1, 0xa3, 0x77, 0xcd, 0xfa, 0x1b, 0x77, 0x87, 0x9e, 0xf5, 0x25, 0xd1,
483 0x15, 0x09, 0x77, 0x90, 0xe6, 0x99, 0xfa, 0xd9, 0xef, 0xc5, 0xca, 0x0e, 483 0x49, 0x9a, 0x67, 0x96, 0xef, 0x8f, 0x2f, 0xfa, 0xbb, 0xb4, 0x6d, 0x7b,
484 0xe5, 0xdb, 0x9e, 0xac, 0x2c, 0xab, 0xfd, 0x28, 0x19, 0x4e, 0x94, 0x9f, 484 0xc6, 0x5f, 0x91, 0xfb, 0xd1, 0x67, 0x38, 0x5e, 0xfb, 0x1e, 0xec, 0xdb,
485 0x04, 0x2f, 0x5e, 0x51, 0xfe, 0xed, 0x88, 0x23, 0x37, 0x19, 0x42, 0x79, 485 0x39, 0x8b, 0xf6, 0x6d, 0xca, 0x93, 0xab, 0x63, 0xc2, 0xf3, 0x10, 0x0b,
486 0x88, 0x06, 0x1e, 0xa8, 0x33, 0x1c, 0xee, 0xf7, 0xfd, 0x2e, 0x25, 0x57, 486 0x3c, 0xd0, 0x77, 0x38, 0x82, 0xef, 0xfb, 0x3d, 0xfa, 0x5c, 0x03, 0xac,
487 0x17, 0x2b, 0x76, 0x06, 0xce, 0x60, 0xd4, 0x65, 0xeb, 0x9e, 0xcd, 0x70, 487 0x58, 0x88, 0xdc, 0xc1, 0x58, 0x3e, 0xdb, 0xe0, 0x6e, 0x46, 0x70, 0x16,
488 0x65, 0xe1, 0x9e, 0x1f, 0x21, 0x3f, 0x97, 0x0e, 0xed, 0xb2, 0xdd, 0xf3, 488 0xc1, 0xfd, 0x11, 0xed, 0x6f, 0x1e, 0xdc, 0xe3, 0x06, 0xf7, 0x47, 0x7a,
489 0x23, 0x3d, 0x73, 0xec, 0xeb, 0x6c, 0xf0, 0x7d, 0x61, 0xe8, 0x00, 0xcf, 489 0x67, 0x59, 0xd7, 0xd5, 0x64, 0xfb, 0x12, 0x90, 0x01, 0xde, 0x3b, 0xe2,
490 0x1d, 0xf1, 0xcc, 0x37, 0x69, 0x56, 0xb5, 0x8e, 0x55, 0xbf, 0x6d, 0x5f, 490 0xbd, 0x71, 0xd2, 0xac, 0x73, 0x1d, 0xff, 0x47, 0xdd, 0xd5, 0xc7, 0xb6,
491 0x5b, 0xcd, 0xd5, 0x5d, 0xb3, 0x5b, 0xad, 0x79, 0x9d, 0x87, 0x59, 0xfe, 491 0x75, 0x5d, 0xf7, 0xc3, 0x47, 0xea, 0xc3, 0xb4, 0x2c, 0x53, 0x32, 0x25,
492 0x59, 0xef, 0x94, 0xf6, 0xff, 0xd4, 0x5d, 0x7b, 0x6c, 0x1b, 0xf7, 0x7d, 492 0xd3, 0x96, 0x2c, 0xbf, 0x27, 0x3d, 0x59, 0x72, 0xac, 0x14, 0xac, 0xab,
493 0xff, 0xf2, 0x48, 0x3d, 0xac, 0xe7, 0x49, 0xa6, 0x64, 0x5a, 0x52, 0x94, 493 0xad, 0x02, 0x46, 0xa4, 0x0c, 0x49, 0x7f, 0xb4, 0x08, 0x06, 0xfa, 0xa3,
494 0x3b, 0xe9, 0x64, 0x29, 0xb1, 0x12, 0x70, 0x9e, 0xba, 0x0a, 0x88, 0x9a, 494 0x99, 0x8b, 0x66, 0xab, 0x4b, 0xd9, 0x4e, 0x0a, 0xf4, 0x0f, 0xb7, 0xc5,
495 0xb0, 0x24, 0xfd, 0x58, 0x10, 0x0c, 0xb4, 0xad, 0x64, 0xee, 0x92, 0xad, 495 0x80, 0x6c, 0x58, 0x60, 0x86, 0xb4, 0x12, 0x63, 0x56, 0x4c, 0xd6, 0x66,
496 0x0e, 0x25, 0xa7, 0x1d, 0x30, 0x60, 0x6e, 0xd6, 0x02, 0x69, 0x07, 0xc7, 496 0x85, 0x0c, 0xd8, 0x30, 0x4e, 0x54, 0x9c, 0x14, 0x50, 0xc6, 0x04, 0x69,
497 0x0c, 0x65, 0x27, 0xc6, 0xaa, 0x88, 0x4c, 0xcc, 0x6a, 0x1d, 0xb0, 0x62, 497 0x83, 0xa2, 0x58, 0x61, 0x45, 0x76, 0x36, 0x6c, 0x7f, 0x65, 0x43, 0xd0,
498 0x1c, 0xa5, 0x38, 0x69, 0xa7, 0x80, 0x69, 0xda, 0x04, 0xc5, 0xfe, 0xb1, 498 0x05, 0x9b, 0xb3, 0x38, 0x76, 0xb0, 0x06, 0x45, 0xd6, 0x7d, 0x62, 0x18,
499 0x26, 0x3b, 0x7b, 0x61, 0x7f, 0x04, 0xdb, 0x80, 0x1a, 0x5b, 0x81, 0xba, 499 0xd0, 0x0d, 0xdc, 0xf9, 0xdd, 0x0f, 0xf2, 0xf1, 0xf1, 0x51, 0x1f, 0x89,
500 0x76, 0x8a, 0x65, 0x1b, 0xe0, 0x34, 0xdb, 0xb0, 0x75, 0x58, 0x0b, 0xee, 500 0x33, 0x60, 0x02, 0x04, 0xbe, 0xf7, 0x78, 0xdf, 0x7b, 0xf7, 0x9e, 0x7b,
501 0xfb, 0xf9, 0x3d, 0xc8, 0x23, 0x79, 0xd4, 0xc3, 0x71, 0x06, 0x4c, 0x80, 501 0xce, 0xb9, 0xbf, 0x73, 0xee, 0x39, 0x87, 0x9e, 0x7b, 0xdb, 0x9b, 0xf3,
502 0x40, 0xde, 0xf1, 0x77, 0x77, 0xbf, 0xdf, 0xf7, 0xf7, 0x7d, 0xbf, 0x6e, 502 0xb9, 0xca, 0x77, 0x8e, 0x8a, 0x77, 0x0e, 0x28, 0x9d, 0xa5, 0xe3, 0xc5,
503 0x2e, 0x33, 0x1e, 0xf2, 0x33, 0x7e, 0xcf, 0x15, 0x61, 0x5f, 0x37, 0xd2, 503 0x63, 0xc6, 0x6c, 0x61, 0x22, 0xe2, 0x67, 0xfe, 0x9e, 0xad, 0xc2, 0xbe,
504 0xe1, 0x36, 0x83, 0x67, 0xa4, 0x0e, 0x9e, 0xd5, 0x34, 0xc1, 0xf6, 0x78, 504 0x6e, 0x87, 0xe1, 0xd6, 0xa2, 0x67, 0xbc, 0x85, 0x9e, 0xcd, 0x32, 0xc1,
505 0x99, 0x77, 0x4b, 0xd8, 0xc9, 0xf3, 0xc8, 0x63, 0xd7, 0x39, 0x0e, 0x12, 505 0xf6, 0x78, 0x5d, 0x77, 0x4b, 0xda, 0xc9, 0xeb, 0x88, 0x85, 0xd7, 0x31,
506 0x76, 0x65, 0x1a, 0x5a, 0x72, 0xe7, 0x37, 0x54, 0x60, 0x77, 0xb2, 0x0c, 506 0x0e, 0x92, 0x76, 0x75, 0x19, 0xba, 0xe2, 0x8c, 0x6f, 0x68, 0xd0, 0xee,
507 0xbb, 0x3d, 0xff, 0x8f, 0x60, 0x77, 0x4d, 0xe8, 0xbf, 0xdf, 0x2e, 0x22, 507 0x74, 0x9d, 0x76, 0x3b, 0xff, 0x1f, 0xd1, 0xee, 0x1d, 0x81, 0x7f, 0x5f,
508 0x6f, 0x4d, 0xeb, 0x00, 0xba, 0x6e, 0x09, 0x70, 0x04, 0x3f, 0xb5, 0xf3, 508 0xad, 0x22, 0x6e, 0x4d, 0x63, 0x00, 0x9d, 0x3b, 0x04, 0x3a, 0x42, 0x9f,
509 0xeb, 0x04, 0x9e, 0x8a, 0xbc, 0xe2, 0x52, 0xe9, 0x3b, 0xe1, 0xb2, 0x9f, 509 0x5a, 0xe5, 0x15, 0x82, 0x4e, 0x45, 0x5c, 0x71, 0xad, 0xf6, 0x5a, 0xb4,
510 0x92, 0xed, 0x12, 0xd8, 0x27, 0xf0, 0xe7, 0x35, 0x96, 0x91, 0x47, 0x6f, 510 0xee, 0xa7, 0x64, 0xbb, 0x04, 0xf6, 0x09, 0xfc, 0x79, 0xed, 0xd7, 0xc8,
511 0x4b, 0x46, 0x42, 0x57, 0xaa, 0xb5, 0x4f, 0x7e, 0xbb, 0xcb, 0x6d, 0x9f, 511 0x63, 0x1f, 0x6b, 0x8d, 0x04, 0x56, 0x72, 0xdb, 0x27, 0x0c, 0x08, 0x1d,
512 0x1c, 0xdd, 0xa1, 0x7d, 0x72, 0x5a, 0xda, 0x27, 0xa9, 0xed, 0xdb, 0x27, 512 0xf6, 0xc9, 0xb1, 0x4d, 0xda, 0x27, 0xe7, 0xa5, 0x7d, 0x92, 0xdd, 0xb8,
513 0x03, 0x75, 0x79, 0x5d, 0x95, 0xf5, 0xec, 0xdc, 0x3e, 0x31, 0x36, 0xb5, 513 0x7d, 0xb2, 0xbb, 0x25, 0xae, 0xab, 0x31, 0x9e, 0xcd, 0xdb, 0x27, 0xc6,
514 0x4f, 0x46, 0x5d, 0xbe, 0x18, 0xcc, 0xf7, 0x57, 0x29, 0x75, 0x0c, 0x3c, 514 0x9a, 0xf6, 0xc9, 0x90, 0xc3, 0x17, 0x83, 0xfe, 0xfe, 0x06, 0x65, 0x8f,
515 0x4e, 0xc3, 0x19, 0x30, 0x3e, 0x56, 0xe3, 0x17, 0xfe, 0x38, 0x61, 0xfd, 515 0x43, 0xc7, 0x69, 0x3a, 0x83, 0xc6, 0xc7, 0x5d, 0x7e, 0xe1, 0x4f, 0x93,
516 0xd7, 0xff, 0xc7, 0xb0, 0x1e, 0xac, 0xf3, 0x79, 0x57, 0xd6, 0x03, 0x21, 516 0xd6, 0xbf, 0xf8, 0x3f, 0xa6, 0xf5, 0x50, 0x8b, 0xcf, 0xbb, 0x31, 0x1e,
517 0xfe, 0x51, 0x60, 0x3d, 0xd8, 0xd0, 0x77, 0xda, 0x38, 0x67, 0xb1, 0xda, 517 0x0a, 0xef, 0xd8, 0x14, 0x8e, 0x77, 0xd3, 0x7a, 0xa8, 0xad, 0xef, 0xb4,
518 0x77, 0x3a, 0x62, 0x34, 0xe2, 0xed, 0x7f, 0xe4, 0xf2, 0xa9, 0xba, 0xf9, 518 0x7d, 0xcc, 0x62, 0xb3, 0xef, 0x74, 0xd4, 0x68, 0xa7, 0xdb, 0xff, 0xd8,
519 0x3b, 0x68, 0x8a, 0x7c, 0x47, 0xc7, 0xf5, 0xb3, 0x40, 0x4b, 0x76, 0x2a, 519 0xe1, 0x53, 0x75, 0xea, 0x77, 0xc8, 0x14, 0xf9, 0x8e, 0x4d, 0xe8, 0x77,
520 0x45, 0xb0, 0x99, 0xf0, 0xbc, 0x90, 0xa0, 0xb5, 0x1a, 0x7d, 0x8b, 0x9f, 520 0x41, 0x96, 0xac, 0x6c, 0x96, 0x60, 0x33, 0xe1, 0x7d, 0x11, 0x21, 0x6b,
521 0xc7, 0xeb, 0x7b, 0xf5, 0x09, 0x21, 0xa7, 0xa4, 0xff, 0x01, 0xe3, 0x27, 521 0x2e, 0xbc, 0xc5, 0xef, 0x63, 0x7a, 0xbe, 0xf8, 0x87, 0x62, 0x9d, 0x92,
522 0x7c, 0xf3, 0x62, 0xac, 0xcc, 0x6f, 0x52, 0xfe, 0x08, 0xa5, 0xfb, 0x37, 522 0xfe, 0x07, 0xb4, 0x0f, 0xfb, 0xce, 0x88, 0xb6, 0x32, 0xbe, 0x49, 0xf9,
523 0xf2, 0x43, 0xd4, 0xcb, 0xbc, 0x9d, 0xd9, 0x0a, 0x9a, 0xc6, 0xef, 0xe6, 523 0x23, 0x14, 0xf6, 0x6f, 0xe7, 0x87, 0x68, 0x5d, 0xf3, 0x36, 0x67, 0x2b,
524 0x7d, 0x09, 0x55, 0xd9, 0x5a, 0xe0, 0x9f, 0xa7, 0x59, 0x2f, 0x18, 0x29, 524 0x68, 0x19, 0xdf, 0xcb, 0xf3, 0x12, 0x69, 0xb2, 0xb5, 0xa0, 0x3f, 0xcf,
525 0xeb, 0x04, 0xd5, 0x7b, 0x73, 0x4e, 0xd8, 0x74, 0x9a, 0x77, 0x26, 0x64, 525 0x33, 0x2e, 0x18, 0xad, 0x63, 0x82, 0xe6, 0xb9, 0xb9, 0x28, 0x6c, 0x3a,
526 0xee, 0xa9, 0x38, 0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e, 0xb8, 0xdd, 0x2b, 0x6f, 0x0a, 0x7d, 0x7a, 0x92, 0x71, 0xc8, 0x67,
534 0xba, 0x25, 0xa9, 0x8b, 0xe0, 0x77, 0x96, 0x35, 0xaf, 0x86, 0x18, 0x57, 534 0x80, 0x43, 0x42, 0xc8, 0x5b, 0x92, 0x58, 0x04, 0xdf, 0x17, 0x19, 0x8f,
535 0x8e, 0xd0, 0x53, 0xac, 0x6b, 0x5f, 0xa2, 0x7b, 0x94, 0x7d, 0x16, 0x71, 535 0x44, 0x98, 0x57, 0x7e, 0x44, 0xe7, 0x18, 0x6b, 0x5f, 0xa7, 0xfd, 0xca,
536 0xe5, 0x99, 0x22, 0x8f, 0xdf, 0x47, 0xa9, 0x27, 0xec, 0x89, 0x08, 0x1d, 536 0x3e, 0x83, 0xdc, 0xea, 0x38, 0x53, 0xc4, 0xf1, 0xfb, 0x28, 0xfb, 0x98,
537 0xa1, 0x53, 0x22, 0x67, 0x06, 0xf1, 0x3d, 0xe4, 0x1c, 0xdc, 0x2b, 0x9e, 537 0x35, 0x19, 0xa7, 0x1f, 0xd1, 0x59, 0x11, 0x33, 0x83, 0xfd, 0x3d, 0xc4,
538 0x2f, 0x7d, 0x19, 0x77, 0x22, 0xa7, 0x6e, 0xfb, 0xf9, 0xfb, 0xba, 0x56, 538 0x1c, 0x3c, 0x20, 0xde, 0x2f, 0x7d, 0x19, 0xf7, 0x23, 0xa6, 0x6e, 0xe3,
539 0x2f, 0x2a, 0x9e, 0xb9, 0xaa, 0x68, 0x4a, 0x9c, 0xe3, 0xeb, 0x9f, 0x31, 539 0xf1, 0xfb, 0x2a, 0xb7, 0x8e, 0xdb, 0xe1, 0x9d, 0x4b, 0x4a, 0xa6, 0xc4,
540 0xea, 0xaf, 0x8f, 0x18, 0xf1, 0x62, 0xdc, 0x88, 0xae, 0x60, 0xdc, 0x33, 540 0x35, 0xbe, 0xff, 0x49, 0xa3, 0xf5, 0xfe, 0xb8, 0x91, 0xaa, 0xa6, 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, 0xf3, 0x83, 0xbd, 0xf5, 548 0x3e, 0x21, 0x88, 0x7c, 0xaf, 0x90, 0x8c, 0x6b, 0x85, 0x8d, 0xb5, 0xc2,
549 0xa0, 0x98, 0x23, 0xdb, 0x5b, 0x56, 0x8c, 0xa4, 0xaf, 0x7b, 0xbe, 0x58, 549 0xfd, 0x83, 0xbd, 0x05, 0x9f, 0x8f, 0xb0, 0xb7, 0xcc, 0x24, 0x49, 0x5f,
550 0x55, 0xff, 0xe9, 0x51, 0x07, 0x39, 0xe2, 0x51, 0x07, 0xe9, 0xa6, 0xb5, 550 0xf7, 0x99, 0xaa, 0xd3, 0xbf, 0xeb, 0x95, 0x4b, 0x39, 0xea, 0x91, 0x4b,
551 0x80, 0x8b, 0xd6, 0x42, 0x2e, 0xbd, 0x6d, 0x88, 0xed, 0x96, 0x0e, 0xe6, 551 0xe9, 0x94, 0xb5, 0x80, 0x43, 0xd6, 0x22, 0x0e, 0xdc, 0x36, 0xcc, 0x76,
552 0x21, 0xb0, 0x5b, 0xda, 0xc8, 0xff, 0xb2, 0xdb, 0x6e, 0xa9, 0xad, 0x45, 552 0x4b, 0x0f, 0xeb, 0x90, 0x1e, 0xb1, 0x6d, 0xe2, 0xbf, 0xea, 0xb4, 0x5b,
553 0x07, 0xdd, 0x41, 0x37, 0x93, 0x36, 0x4c, 0x3c, 0x57, 0xae, 0x63, 0xe7, 553 0xdc, 0x79, 0xf1, 0x90, 0x3b, 0x60, 0x33, 0x69, 0xc3, 0xa4, 0x4a, 0xf5,
554 0x75, 0x57, 0x6a, 0x0e, 0x57, 0xea, 0xea, 0x23, 0xbd, 0xe6, 0x3b, 0x5c, 554 0x9c, 0x7a, 0x1e, 0x77, 0x23, 0x6f, 0xb1, 0xd2, 0x92, 0x63, 0xe9, 0xd5,
555 0x37, 0x5f, 0xc8, 0xaf, 0x48, 0x43, 0x9d, 0xce, 0xcb, 0xae, 0xba, 0x53, 555 0xdf, 0x91, 0x96, 0xfe, 0x62, 0xfd, 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, 0xdf, 0xc8, 0x9e, 0x89, 0xde,
578 0x6a, 0x4e, 0xdd, 0x78, 0x70, 0x67, 0xe2, 0xc3, 0xc0, 0x87, 0xe1, 0x3a, 578 0x1b, 0x9e, 0x16, 0x39, 0xa7, 0x4e, 0x3e, 0xb8, 0x3f, 0xfb, 0xc3, 0xe0,
579 0x5e, 0xf5, 0xd1, 0xfd, 0xfd, 0xb5, 0x70, 0x6d, 0xf3, 0xf4, 0x55, 0x79, 579 0x87, 0x91, 0x16, 0x5d, 0xf5, 0xc9, 0xfd, 0xfd, 0x6e, 0xba, 0x06, 0x3d,
580 0xc7, 0x81, 0x11, 0xf3, 0x87, 0x9f, 0xfa, 0x21, 0x9a, 0xbf, 0x08, 0x1c, 580 0x7d, 0x55, 0xde, 0xfb, 0xc0, 0xd8, 0xf3, 0x87, 0x9f, 0xba, 0x4a, 0x67,
581 0x36, 0x18, 0xdb, 0x46, 0x69, 0x21, 0x88, 0xba, 0x22, 0x51, 0x9b, 0xa3, 581 0xae, 0x81, 0x87, 0x0d, 0xe6, 0xb6, 0x31, 0xca, 0x87, 0x91, 0x57, 0x24,
582 0xe2, 0x86, 0xb2, 0x56, 0x68, 0x5e, 0xd4, 0x40, 0x8e, 0x85, 0x6e, 0xf2, 582 0x72, 0x73, 0xf4, 0xbe, 0xa1, 0xc8, 0x15, 0x3a, 0x23, 0x72, 0x20, 0xc7,
583 0xbc, 0xe7, 0x8b, 0x29, 0x3a, 0xc5, 0x32, 0xf6, 0xd4, 0x4a, 0x45, 0x77, 583 0x23, 0xf7, 0x78, 0x3d, 0x3c, 0x53, 0x7d, 0x9b, 0xce, 0x56, 0x82, 0xfc,
584 0xaf, 0xaf, 0x83, 0xac, 0xc6, 0xf1, 0x9b, 0x02, 0xc7, 0x87, 0x36, 0xc5, 584 0xdf, 0xc0, 0xee, 0xad, 0x79, 0x90, 0xcd, 0x3c, 0x7e, 0x4f, 0xf0, 0xf8,
585 0xf1, 0xc3, 0x65, 0x1c, 0xff, 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 0x3b, 0xd2, 0x57, 673 0xc3, 0x96, 0x73, 0xfe, 0x79, 0xe3, 0x95, 0x63, 0x9b, 0xc2, 0x2b, 0xd9,
674 0x52, 0x89, 0x8a, 0xbe, 0xe2, 0xbe, 0x77, 0x39, 0x07, 0xa6, 0x5f, 0xf6, 674 0x74, 0x03, 0xaf, 0x38, 0x9f, 0xad, 0xb1, 0xcb, 0xe4, 0xa0, 0xac, 0xf7,
675 0x7b, 0x00, 0x0c, 0xda, 0xa1, 0x8b, 0x25, 0x00, 0x4b, 0x63, 0xc6, 0x0e, 675 0x00, 0x1a, 0x6c, 0x05, 0x16, 0x4b, 0x83, 0x96, 0x46, 0xcc, 0x8a, 0x24,
676 0x45, 0xfd, 0x53, 0xb4, 0x50, 0x1c, 0x32, 0x92, 0x59, 0xe8, 0xcc, 0xfc, 676 0xfc, 0x33, 0x94, 0xaf, 0x5e, 0xa7, 0x4c, 0x11, 0x98, 0x99, 0x3f, 0xcb,
677 0x99, 0x8f, 0xee, 0x91, 0x3e, 0x1a, 0x7d, 0x0d, 0xf8, 0xca, 0x6e, 0x1e, 677 0xe7, 0x76, 0x4a, 0x1f, 0x8d, 0xbe, 0x07, 0x7a, 0x65, 0x07, 0xb7, 0xff,
678 0xff, 0x7a, 0xbf, 0xcc, 0xcb, 0x76, 0x9f, 0xef, 0xe2, 0xf3, 0x7b, 0x42, 678 0xeb, 0x41, 0x19, 0x97, 0xed, 0xbc, 0xde, 0xcb, 0xd7, 0xbf, 0x10, 0x69,
679 0xd5, 0xe7, 0x77, 0xf1, 0xf9, 0xde, 0x04, 0xf6, 0xd0, 0x58, 0x82, 0x5f, 679 0xbe, 0xbe, 0x85, 0xaf, 0xf7, 0xa7, 0x31, 0x87, 0xc6, 0x15, 0xf8, 0x25,
680 0xd2, 0xa1, 0x34, 0xef, 0xcd, 0x42, 0x91, 0x65, 0xeb, 0xcb, 0xcc, 0x47, 680 0x27, 0x29, 0xc7, 0xf3, 0x93, 0xaf, 0xf2, 0xda, 0x7a, 0x95, 0xf5, 0x55,
681 0x57, 0xf4, 0xb8, 0x3e, 0xd4, 0xec, 0x88, 0x3d, 0x31, 0x78, 0xcc, 0xb9, 681 0x45, 0xb7, 0x1b, 0x40, 0xce, 0x8e, 0x98, 0x13, 0x83, 0xdb, 0x5c, 0x2c,
682 0xcc, 0x04, 0x8f, 0x1b, 0x24, 0xff, 0xcb, 0x6c, 0x8b, 0xae, 0x68, 0x5c, 682 0x4c, 0x71, 0xbb, 0x21, 0xf2, 0x5f, 0x35, 0x29, 0x5f, 0xd1, 0xbc, 0xaa,
683 0xd5, 0xf9, 0xf6, 0xdf, 0xe8, 0x93, 0x39, 0x55, 0xdf, 0xdd, 0x23, 0xe1, 683 0xe3, 0xed, 0xdf, 0x18, 0x90, 0x31, 0x55, 0xef, 0xec, 0x94, 0xf4, 0x9b,
684 0xe7, 0x08, 0x9e, 0x72, 0x9e, 0xe1, 0xf2, 0xbc, 0xc0, 0x43, 0x7b, 0xda, 684 0x14, 0x3e, 0x4f, 0xc4, 0x73, 0x3c, 0x23, 0xf8, 0xd0, 0x9a, 0x31, 0xeb,
685 0x2a, 0x3f, 0xbf, 0x13, 0x78, 0xd5, 0x8a, 0xbc, 0xd9, 0xc0, 0x12, 0xf3, 685 0xef, 0xdf, 0x06, 0xbe, 0x42, 0xdd, 0x54, 0x1e, 0x03, 0xeb, 0xc5, 0x98,
686 0xc5, 0x19, 0xc7, 0x4c, 0x97, 0x73, 0xd5, 0x1e, 0x1f, 0x90, 0xd7, 0xbf, 686 0x1d, 0xca, 0xd5, 0x63, 0xd5, 0x9e, 0xdb, 0x2d, 0xef, 0xff, 0xe9, 0x80,
687 0xd9, 0x27, 0xfb, 0x83, 0x7e, 0x6b, 0x40, 0xf7, 0x48, 0x94, 0x32, 0x07, 687 0xac, 0x55, 0x7a, 0x5b, 0x9d, 0xeb, 0x35, 0x07, 0xf1, 0xcb, 0x3e, 0x41,
688 0xf9, 0xcb, 0x3e, 0x01, 0x1b, 0xff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 0xf6, 0xef, 0xa1, 0x96, 0x38, 0x98, 0x56, 0x1e, 0x5b, 0xcb,
696 0xf5, 0x38, 0xb6, 0x99, 0x1f, 0x56, 0xc4, 0x13, 0x3d, 0xf0, 0x6c, 0xb3, 696 0x0f, 0x2b, 0xf6, 0x13, 0x3d, 0xf8, 0x6c, 0xad, 0x7a, 0x06, 0xef, 0x08,
697 0x7e, 0x06, 0xd7, 0x84, 0x1f, 0x2d, 0x56, 0x47, 0xaf, 0xa0, 0xe3, 0x00, 697 0x3f, 0x5a, 0xb2, 0x45, 0x5e, 0x21, 0xc7, 0x01, 0xfa, 0xce, 0x7c, 0x96,
698 0xfd, 0xce, 0x62, 0x8a, 0x76, 0xf1, 0x5e, 0xfd, 0xa6, 0xf1, 0x00, 0xe2, 698 0xb6, 0xf0, 0x5c, 0x7d, 0xc3, 0xf8, 0x35, 0xec, 0xb7, 0x93, 0x8c, 0x79,
699 0xed, 0x24, 0x73, 0x9e, 0x18, 0xc6, 0x19, 0x67, 0xe2, 0x94, 0x11, 0x01, 699 0x62, 0x1a, 0x17, 0xec, 0xc9, 0xb3, 0x06, 0xd3, 0xb9, 0x90, 0xad, 0x05,
700 0xbf, 0x2c, 0x05, 0x9c, 0x0e, 0x6a, 0x66, 0x5a, 0xfd, 0x65, 0x1a, 0x65, 700 0xec, 0x1e, 0xea, 0x64, 0x59, 0xfd, 0x22, 0x8d, 0xb1, 0xfd, 0x07, 0x99,
701 0xfb, 0x0f, 0x34, 0xeb, 0x84, 0xe2, 0x04, 0x7a, 0xb3, 0xcd, 0x43, 0xac, 701 0xb5, 0x23, 0x29, 0x82, 0xbc, 0x59, 0xa1, 0xc3, 0xcc, 0x13, 0xc9, 0x2a,
702 0x13, 0xc7, 0x8a, 0xc0, 0x67, 0x83, 0x3e, 0x9f, 0x23, 0xfa, 0x5c, 0x6e, 702 0xf8, 0xd9, 0xa0, 0x27, 0x4a, 0x44, 0x8f, 0x97, 0xc6, 0x42, 0xdf, 0x27,
703 0xd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fe, 0x78, 0x9e, 0x69, 710 0xfa, 0x5b, 0x66, 0x92, 0xf5, 0xe3, 0x1c, 0xcb, 0x72, 0xae, 0xf8, 0x00,
711 0x39, 0x9d, 0xbd, 0x97, 0x0a, 0xc1, 0x21, 0x1a, 0x59, 0xd6, 0xfd, 0x4d, 711 0x2d, 0x86, 0x87, 0x69, 0x74, 0x41, 0xd7, 0x37, 0xc1, 0x58, 0xff, 0x6d,
712 0x44, 0xce, 0xc6, 0xa0, 0xe4, 0x49, 0x7a, 0xdd, 0x9f, 0x10, 0xbe, 0x0b, 712 0x48, 0xea, 0x24, 0x3d, 0xee, 0x5f, 0x11, 0xbe, 0x0b, 0xf3, 0xfa, 0xa7,
713 0xeb, 0xd2, 0xc7, 0xb5, 0xee, 0xf6, 0x2d, 0xf8, 0xd2, 0x25, 0x45, 0xb3, 713 0x35, 0xee, 0xad, 0xeb, 0xe8, 0xa5, 0xbf, 0x52, 0x32, 0x5b, 0xbb, 0x91,
714 0xa5, 0xcb, 0xd1, 0x30, 0xa5, 0xa2, 0x53, 0xaf, 0xf4, 0x03, 0xff, 0x47, 714 0x88, 0x52, 0x36, 0x31, 0xfd, 0x97, 0x82, 0xff, 0x47, 0xaf, 0xc3, 0x0f,
715 0x2e, 0xc1, 0x0f, 0x07, 0x1e, 0x6d, 0x51, 0x22, 0x53, 0x0b, 0x8b, 0x21, 715 0x07, 0x1d, 0x6d, 0x52, 0xba, 0xe0, 0xa6, 0xc5, 0x30, 0x8f, 0x1b, 0xdf,
716 0x5e, 0x37, 0x7e, 0x2f, 0x7d, 0x30, 0x17, 0x7e, 0x40, 0xc8, 0xfe, 0xd1, 716 0xd7, 0xfe, 0x79, 0x36, 0xfa, 0x94, 0x58, 0xfb, 0xc7, 0xae, 0x73, 0x3b,
717 0x4b, 0x3c, 0x4e, 0xca, 0x26, 0xc5, 0x37, 0xbc, 0xf0, 0x50, 0xf7, 0xc5, 717 0xb1, 0x36, 0x69, 0xbd, 0xe1, 0xc5, 0x87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, 0xf3,
740 0x42, 0xae, 0x43, 0x1d, 0xdf, 0x2b, 0x72, 0xdc, 0x65, 0x1f, 0x23, 0xfc, 740 0x07, 0x44, 0x8c, 0xbb, 0xac, 0x63, 0x84, 0xef, 0xd6, 0xd2, 0x6f, 0x6f,
741 0xb6, 0x19, 0x7f, 0x7b, 0x97, 0x71, 0x0a, 0x32, 0x55, 0xda, 0xa5, 0xe0, 741 0x31, 0x4f, 0x61, 0x4d, 0x95, 0x76, 0x29, 0x74, 0xcd, 0x8d, 0x96, 0xba,
742 0x35, 0x97, 0xeb, 0x7a, 0x22, 0x03, 0xe7, 0xa6, 0xe8, 0x25, 0x96, 0xb7, 742 0xc4, 0xe0, 0xb9, 0x19, 0xfa, 0x2e, 0xaf, 0xb7, 0xa3, 0x57, 0xe1, 0x3f,
743 0x23, 0x2f, 0xc3, 0x7f, 0xfc, 0x38, 0xf0, 0x26, 0x9f, 0xa2, 0x41, 0x3e, 743 0xfe, 0x2a, 0xf8, 0xa6, 0x0c, 0x1e, 0x1b, 0xbd, 0x8a, 0xba, 0x48, 0x7e,
744 0x46, 0x5f, 0x24, 0xbf, 0xa8, 0x73, 0x8a, 0x05, 0x27, 0x44, 0x6d, 0x88, 744 0x91, 0xe7, 0x94, 0x0c, 0x4f, 0x8a, 0xdc, 0x10, 0x29, 0xa3, 0x27, 0x45,
745 0xa4, 0xd1, 0x59, 0xd1, 0x8b, 0xee, 0x2d, 0xc1, 0x9b, 0xec, 0x94, 0x65, 745 0x2d, 0xba, 0x1f, 0x0a, 0xdd, 0x64, 0x65, 0x4d, 0x03, 0x78, 0x04, 0x3e,
746 0x40, 0x1f, 0x81, 0x0f, 0x46, 0xe6, 0x60, 0x1d, 0x77, 0x7a, 0xde, 0xed, 746 0x18, 0x19, 0x83, 0x75, 0xc2, 0xee, 0x7b, 0x6b, 0x20, 0x36, 0x41, 0xf1,
747 0x9b, 0x19, 0xa7, 0x48, 0x3f, 0xf0, 0x5e, 0xd2, 0xac, 0xea, 0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x35, 0xd7, 0x21, 0xe3, 0x07, 0x22,
755 0x0e, 0x1a, 0xdf, 0x1f, 0xba, 0xc4, 0xfb, 0x19, 0x5f, 0xfb, 0x69, 0xe9, 755 0xd7, 0x79, 0x3e, 0x53, 0xcb, 0xff, 0x55, 0x3b, 0x2d, 0x6a, 0xdc, 0xa0,
756 0xa4, 0xe8, 0x71, 0x83, 0xb1, 0x5d, 0x34, 0x27, 0x74, 0x7e, 0xd6, 0x5f, 756 0x2d, 0x63, 0x48, 0x81, 0xf9, 0x19, 0xbf, 0x34, 0xd9, 0x55, 0x33, 0xe8,
757 0xaa, 0xec, 0xaa, 0x29, 0xcc, 0x33, 0x85, 0xd8, 0x8a, 0xe1, 0xfc, 0xbe, 757 0x67, 0x16, 0x7b, 0x2b, 0x86, 0xfd, 0x22, 0xcb, 0x98, 0xdc, 0x2b, 0x4f,
758 0x2f, 0x99, 0x97, 0xb1, 0xf2, 0x78, 0x4d, 0xac, 0x7c, 0x56, 0xc4, 0xca, 758 0xb9, 0xf6, 0xca, 0x4f, 0x8a, 0xbd, 0x72, 0xec, 0x93, 0x83, 0xae, 0xa0,
759 0x11, 0x27, 0x07, 0x5c, 0x01, 0x4b, 0xaf, 0x9c, 0x16, 0xec, 0x63, 0x98, 759 0xa5, 0x57, 0x4c, 0x0b, 0xe6, 0x31, 0xca, 0xf3, 0x68, 0xd2, 0xc5, 0x6b,
760 0x90, 0x1b, 0x7e, 0xee, 0xa2, 0xe0, 0x37, 0xe1, 0x98, 0x5f, 0xe6, 0x57, 760 0x42, 0xdf, 0x44, 0x93, 0x7e, 0x19, 0x5f, 0x9d, 0xa2, 0xac, 0x88, 0xbf,
761 0xc7, 0x79, 0xc6, 0x06, 0x5d, 0x60, 0x7c, 0xb0, 0x27, 0x36, 0x58, 0x97, 761 0x96, 0x9f, 0x71, 0x23, 0x61, 0x5b, 0x93, 0xab, 0x8c, 0x29, 0x2a, 0xc5,
762 0x58, 0xc9, 0x7e, 0x99, 0xae, 0xe4,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 0x2b, 0x59, 0xd8, 0xdf, 0x06, 0xe3, 0x39, 0x66, 0x34, 0x44, 0xa9, 0x15, 777 0x8f, 0x1b, 0xcc, 0xf7, 0xe8, 0x91, 0x49, 0xd9, 0x0a, 0x63, 0xc0, 0x6b,
778 0xa6, 0xef, 0x8b, 0x1d, 0xbe, 0x8d, 0xec, 0x95, 0x52, 0xb2, 0x2a, 0x97, 778 0x7b, 0x7d, 0xab, 0xc5, 0x37, 0x6a, 0x99, 0xa6, 0xd8, 0x96, 0x66, 0x3f,
779 0xa5, 0xda, 0xef, 0x2e, 0x6d, 0xae, 0x21, 0x72, 0x96, 0x20, 0x33, 0x21, 779 0xbc, 0xb4, 0xc1, 0x86, 0xc9, 0xbe, 0x82, 0x35, 0x14, 0xeb, 0x67, 0xb6,
780 0x2f, 0x53, 0x25, 0xbf, 0x03, 0xfd, 0x0e, 0xb6, 0xd0, 0x59, 0xe6, 0x57, 780 0xe6, 0xb7, 0x81, 0xf7, 0x60, 0x1b, 0x5d, 0x60, 0xfd, 0x25, 0xe3, 0x93,
781 0x32, 0x1f, 0x89, 0x79, 0x27, 0xf3, 0x2c, 0x49, 0x2f, 0xf1, 0xaa, 0xd7, 781 0x58, 0x97, 0xb2, 0x0e, 0x93, 0xf2, 0x93, 0x6a, 0xfa, 0x39, 0x04, 0xc9,
782 0x0d, 0x48, 0x9c, 0x1d, 0xa9, 0xe4, 0x41, 0xba, 0xe2, 0xe9, 0x01, 0x57, 782 0xc3, 0xa3, 0x8d, 0xb8, 0x48, 0xc7, 0xfe, 0x7a, 0xc0, 0xb1, 0xbf, 0x1e,
783 0x3c, 0xdd, 0x74, 0xe5, 0x41, 0x06, 0x85, 0x3e, 0x56, 0xd1, 0xa1, 0x82, 783 0x72, 0xc4, 0x45, 0x86, 0x05, 0x3e, 0x6b, 0x60, 0xaa, 0xb0, 0xc2, 0x54,
784 0x4a, 0x87, 0x82, 0xae, 0x25, 0x79, 0x59, 0xa1, 0xcc, 0xcb, 0x76, 0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xcf, 0x97,
836 0x73, 0x4b, 0x4c, 0xef, 0xbd, 0xf4, 0x85, 0x1c, 0xe4, 0x31, 0x60, 0xc4, 836 0x6c, 0x96, 0xfb, 0x7e, 0xfa, 0x56, 0x09, 0xeb, 0x34, 0x68, 0xc4, 0xe7,
837 0xc7, 0x79, 0x12, 0x3e, 0x30, 0x63, 0x06, 0x6b, 0x1f, 0x4b, 0x19, 0x02, 837 0x65, 0x12, 0xbe, 0x31, 0x23, 0x86, 0xb1, 0x8f, 0x67, 0x0d, 0xc1, 0x27,
838 0x4f, 0x9e, 0x01, 0x1c, 0x18, 0xf6, 0x67, 0xf6, 0xa2, 0x67, 0x7d, 0xc4, 838 0x7f, 0x0a, 0x3a, 0x30, 0xed, 0x5f, 0xdc, 0x85, 0xda, 0xf3, 0x71, 0xa3,
839 0x68, 0x56, 0x3e, 0x45, 0x7c, 0xc7, 0x78, 0x8c, 0x05, 0xdc, 0x70, 0xdc, 839 0x53, 0xf9, 0x1a, 0x71, 0x8c, 0xf6, 0x68, 0x0b, 0xba, 0xe1, 0xbc, 0xdd,
840 0x28, 0xfe, 0x88, 0xf7, 0x42, 0x84, 0x19, 0x1e, 0xb5, 0x7c, 0xeb, 0x02, 840 0xbe, 0x24, 0x7e, 0xb3, 0x21, 0x0a, 0xff, 0x9b, 0x4b, 0x7f, 0x5d, 0xe2,
841 0x7a, 0x91, 0x02, 0x5e, 0xd3, 0x51, 0x3f, 0x6a, 0xc5, 0xe9, 0x39, 0xbc, 841 0xfb, 0x05, 0xbd, 0x66, 0x12, 0x7e, 0xe4, 0x90, 0xd3, 0xd3, 0xfe, 0xd8,
842 0xff, 0xe0, 0x85, 0x22, 0xe6, 0xbd, 0x48, 0x0b, 0x41, 0xf0, 0x21, 0x3b, 842 0x0c, 0x3d, 0x5b, 0x45, 0xbf, 0xaf, 0x52, 0x3e, 0x0c, 0x7d, 0x64, 0x45,
843 0x7c, 0x9d, 0x24, 0xec, 0x5a, 0x59, 0xbf, 0xfc, 0xbc, 0x37, 0x6f, 0xb3, 843 0xef, 0x90, 0xa4, 0x5d, 0x37, 0xe3, 0xce, 0x27, 0xbc, 0x75, 0x9c, 0x99,
844 0xa2, 0x42, 0x1f, 0x6e, 0x61, 0xfb, 0x06, 0xb0, 0x79, 0x8b, 0x71, 0x2d, 844 0x10, 0x38, 0xb9, 0x8b, 0xf5, 0x0b, 0x68, 0xf3, 0x13, 0xe6, 0x35, 0x7e,
845 0x0c, 0x9b, 0x5f, 0xf1, 0xb5, 0x37, 0x99, 0xe7, 0x60, 0xcf, 0x3a, 0x85, 845 0x5f, 0x41, 0xeb, 0xb7, 0x1f, 0xb3, 0xce, 0xc1, 0x9c, 0xe1, 0x7c, 0x6d,
846 0x8c, 0xf1, 0xe2, 0x65, 0x1b, 0x8a, 0x97, 0x39, 0x2e, 0x5e, 0x96, 0x2e, 846 0x9d, 0xb6, 0xaa, 0x74, 0x9a, 0xed, 0xd0, 0x69, 0xb9, 0xba, 0x4e, 0x63,
847 0xf3, 0x32, 0xc6, 0x09, 0xc1, 0xc3, 0xc0, 0xa3, 0x66, 0x59, 0x4f, 0x94, 847 0xde, 0x10, 0xba, 0x0c, 0xba, 0xea, 0x51, 0xc6, 0x91, 0xf2, 0x18, 0xf8,
848 0xdf, 0xa1, 0xff, 0xed, 0x16, 0x3c, 0x8b, 0x79, 0x3d, 0xdb, 0x0d, 0x85, 848 0x70, 0x87, 0xd0, 0x5d, 0xac, 0xfb, 0xd9, 0xae, 0x58, 0xac, 0x66, 0x7d,
849 0x62, 0xca, 0x77, 0x48, 0xf0, 0x0e, 0x8d, 0xd7, 0xff, 0xa3, 0xe8, 0xa1, 849 0x87, 0x85, 0x0e, 0xd1, 0xfc, 0xbd, 0x7f, 0xb7, 0x94, 0x8b, 0x6e, 0xa1,
850 0x55, 0xf0, 0x81, 0xf4, 0x2c, 0xf8, 0x95, 0xd7, 0xf8, 0xff, 0x02, 0x6c, 850 0x0f, 0x72, 0x27, 0xa1, 0xb7, 0xbc, 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75, 0x26, 0x3a, 0xa1, 0x7c, 0x3b, 0x11, 0xbe,
888 0x64, 0x78, 0x5c, 0xf9, 0x68, 0x42, 0x7c, 0x1e, 0x7e, 0x2f, 0x8b, 0x1e, 888 0x0e, 0x7f, 0x99, 0x49, 0x5f, 0x2e, 0x58, 0xd9, 0x0c, 0x49, 0x9f, 0x05,
889 0xcd, 0xd8, 0xa9, 0x24, 0x49, 0xdf, 0x03, 0xf1, 0x1c, 0x0c, 0x96, 0xad, 889 0x71, 0x1f, 0x0c, 0x5e, 0x7b, 0x77, 0xb0, 0x0e, 0x39, 0x21, 0xfc, 0x16,
890 0xbb, 0x99, 0x57, 0x1c, 0x17, 0xfe, 0x07, 0xd6, 0x44, 0x16, 0x31, 0x1e, 890 0x8c, 0x54, 0xe6, 0xd1, 0x1e, 0x3e, 0x87, 0x7e, 0x82, 0x9d, 0x96, 0x29,
891 0xbe, 0x83, 0x5e, 0x82, 0xbd, 0x95, 0xcc, 0x3e, 0xa0, 0xc6, 0x96, 0xc8, 891 0x3e, 0xa5, 0xda, 0xd6, 0x28, 0xc4, 0xbc, 0x10, 0xfa, 0x55, 0x3b, 0x1b,
892 0x64, 0x5c, 0x30, 0x7f, 0xc9, 0x49, 0x85, 0x8d, 0xca, 0xf5, 0xf0, 0x5d, 892 0x35, 0x1a, 0xf7, 0xc3, 0xe7, 0x71, 0x42, 0xe0, 0xc8, 0x11, 0xb6, 0x79,
893 0x1c, 0x17, 0xfa, 0xe1, 0x30, 0xdb, 0x30, 0x62, 0x5c, 0x69, 0x4e, 0xf8, 893 0x44, 0xbb, 0xda, 0xac, 0xf0, 0x5f, 0xf0, 0x79, 0xf9, 0x81, 0x21, 0xfd,
894 0x21, 0xf8, 0x38, 0xff, 0xd3, 0x01, 0xfd, 0x6e, 0x03, 0x9c, 0x97, 0xfe, 894 0x9b, 0x08, 0xb8, 0x2e, 0xfd, 0x1a, 0xfc, 0xcc, 0x32, 0xf7, 0xa3, 0x29,
895 0x09, 0xbe, 0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x52, 0x8f, 0x4f, 0xc6, 0xda, 0x50, 0xa3, 0xff, 0xe0, 0x75, 0xcf, 0x7f,
925 0xfa, 0x0f, 0x96, 0x73, 0xfe, 0x03, 0xa6, 0xe8, 0xb9, 0x70, 0xb9, 0x78, 925 0x30, 0x24, 0x6a, 0x37, 0xdc, 0xa8, 0x1e, 0x64, 0xbc, 0x89, 0x39, 0x85,
926 0x80, 0xf5, 0x47, 0xec, 0x21, 0x7c, 0x87, 0xda, 0xb7, 0xfb, 0xf6, 0x30, 926 0x0f, 0x52, 0xfb, 0x88, 0x1f, 0xda, 0x4b, 0xbd, 0x07, 0x18, 0x05, 0x18,
927 0x75, 0xed, 0x67, 0xa9, 0x6f, 0x90, 0xc3, 0x7a, 0xa3, 0x71, 0x00, 0xf9, 927 0x64, 0x33, 0xbe, 0x34, 0x0e, 0x22, 0xce, 0xdc, 0xe4, 0x7b, 0x50, 0x73,
928 0xe1, 0x16, 0x5f, 0x83, 0x5e, 0x51, 0x63, 0x56, 0x9c, 0x3a, 0xe0, 0x4f, 928 0x6a, 0xdc, 0x4c, 0x51, 0x0f, 0xfc, 0x10, 0xa8, 0x25, 0x6d, 0xe6, 0x9a,
929 0x40, 0x0f, 0x68, 0x2b, 0x5d, 0x45, 0x53, 0xb3, 0x82, 0xa6, 0xe2, 0x6b, 929 0x64, 0xec, 0x94, 0x90, 0xb1, 0xd4, 0xf2, 0x29, 0x25, 0x63, 0xa7, 0x94,
930 0xb3, 0x8a, 0xa6, 0x66, 0x95, 0xff, 0x7c, 0x56, 0xd1, 0xd4, 0xac, 0xa2, 930 0x1f, 0xfe, 0x94, 0x92, 0xb1, 0x53, 0x4a, 0xc6, 0x4e, 0x29, 0x19, 0x3b,
931 0xa9, 0x59, 0x45, 0x53, 0xb3, 0x8c, 0xd7, 0xa3, 0xac, 0xaf, 0x42, 0xf7, 931 0xc5, 0x7c, 0x3e, 0xc6, 0xf8, 0x16, 0x58, 0x44, 0xfb, 0x41, 0x7b, 0x29,
932 0xd0, 0xfe, 0xcb, 0x2e, 0x4a, 0xe6, 0x70, 0x1e, 0xf2, 0xb8, 0x96, 0xae, 932 0x53, 0xc2, 0x75, 0xac, 0xcf, 0x6e, 0x39, 0x7b, 0x69, 0x44, 0xca, 0x19,
933 0x7e, 0x6d, 0x58, 0xfb, 0x47, 0x0b, 0x32, 0xcf, 0x8e, 0x9f, 0x85, 0x3d, 933 0x63, 0x13, 0x19, 0xaf, 0xc7, 0xef, 0xc2, 0x1c, 0xfc, 0x1e, 0xd3, 0xef,
934 0x78, 0x98, 0xe1, 0x77, 0xcd, 0x37, 0xbf, 0x88, 0xb9, 0xfa, 0x28, 0x26, 934 0x23, 0x3a, 0x33, 0x8f, 0xbe, 0xfa, 0x28, 0x29, 0x6a, 0xc9, 0x76, 0x50,
935 0x7a, 0xc0, 0x36, 0x51, 0xd4, 0xad, 0xe3, 0x9a, 0xa8, 0xeb, 0x92, 0xb6, 935 0xc2, 0x89, 0x85, 0x43, 0xc8, 0x0f, 0x93, 0xb6, 0x5f, 0xb6, 0x6d, 0xae,
936 0x5c, 0xaa, 0x61, 0x8d, 0x97, 0xc6, 0x8b, 0x69, 0xb5, 0x5f, 0xb5, 0x76, 936 0x98, 0xe6, 0x93, 0x98, 0x9a, 0x2f, 0xb7, 0x5d, 0xd4, 0x45, 0xe9, 0x22,
937 0x4e, 0x0b, 0x25, 0xb2, 0x80, 0x2b, 0x72, 0x21, 0x2d, 0xde, 0x1b, 0x01, 937 0xe8, 0x8a, 0x98, 0x4a, 0x93, 0xe7, 0x46, 0xd0, 0x49, 0x86, 0x44, 0xb9,
938 0xa7, 0x94, 0xe9, 0x01, 0x83, 0xa3, 0x0a, 0x06, 0x4f, 0x8b, 0x35, 0x22, 938 0x68, 0x70, 0x4c, 0xd1, 0xe0, 0xdb, 0x62, 0x8c, 0x88, 0x49, 0x84, 0x2f,
939 0x97, 0x10, 0x3e, 0xc8, 0xc6, 0x70, 0x48, 0x67, 0x46, 0xf9, 0x3e, 0x8c, 939 0xb3, 0x3d, 0x1d, 0x72, 0x85, 0x31, 0x7e, 0x0e, 0xcb, 0xc2, 0xc1, 0x08,
940 0xfb, 0x07, 0x42, 0xcc, 0x83, 0xb6, 0x0b, 0x07, 0xf7, 0xda, 0x1b, 0xf1, 940 0xeb, 0xa4, 0x8d, 0xd3, 0xa1, 0x31, 0xf6, 0x76, 0xba, 0x67, 0xa3, 0x79,
941 0x9a, 0xed, 0xd6, 0xd3, 0x5c, 0x77, 0xc9, 0x8e, 0x90, 0x92, 0x1b, 0x52, 941 0x39, 0x77, 0x1c, 0x6b, 0x49, 0x44, 0xad, 0x23, 0x12, 0x17, 0x6f, 0xb1,
942 0xef, 0xdd, 0xe5, 0xd8, 0x89, 0x14, 0xcf, 0xed, 0x2f, 0xc2, 0x7f, 0x39, 942 0x6b, 0x74, 0x34, 0xba, 0x97, 0x8f, 0xad, 0x74, 0x96, 0x0e, 0x90, 0xd1,
943 0x44, 0x6d, 0x25, 0x3a, 0x12, 0x06, 0x3e, 0x77, 0xb1, 0x5d, 0xc9, 0x73, 943 0x57, 0xa3, 0xbf, 0x60, 0x39, 0xe8, 0x66, 0x39, 0x38, 0xaa, 0xec, 0x92,
944 0x18, 0x2b, 0xd1, 0x85, 0xf0, 0x3e, 0xb6, 0x5d, 0xf6, 0xb3, 0x0e, 0x3a, 944 0xa3, 0x75, 0xbb, 0x64, 0xcf, 0x1e, 0xc4, 0x65, 0x64, 0xc4, 0xbe, 0xd7,
945 0xca, 0xff, 0x4e, 0xc4, 0xef, 0xc3, 0xbc, 0x3a, 0xf8, 0xda, 0x7e, 0x32, 945 0x56, 0x55, 0x43, 0x00, 0xbe, 0x6f, 0x9c, 0x77, 0x51, 0x7c, 0x18, 0xe7,
946 0x7a, 0x52, 0x66, 0x2b, 0xeb, 0x07, 0x47, 0x2a, 0xf6, 0x88, 0x05, 0xff, 946 0xf8, 0x2d, 0x22, 0x6b, 0x32, 0xee, 0x1b, 0xdf, 0x23, 0xb0, 0xbb, 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67, 0x73, 0x18, 0x1e, 0xac, 0x83, 0xe1, 0xb4, 1013 0xc8, 0x28, 0xfc, 0x21, 0x8d, 0xbd, 0xde, 0xd5, 0x65, 0x5c, 0x87, 0x4f,
1014 0xd0, 0x83, 0xe2, 0x7c, 0xcf, 0x58, 0xee, 0x04, 0xc3, 0x73, 0x96, 0x69, 1014 0xa4, 0xb1, 0xd7, 0xbb, 0xaa, 0xf6, 0x7a, 0x57, 0x97, 0x63, 0x42, 0x6f,
1015 0x69, 0xb7, 0xa2, 0x25, 0x1d, 0x93, 0xed, 0x26, 0xf5, 0xfe, 0x1f, 0xa1, 1015 0xe7, 0x4b, 0x4c, 0xf7, 0x92, 0x5f, 0xc5, 0x39, 0xee, 0x53, 0xbf, 0x2d,
1016 0xeb, 0x4b, 0xfe, 0x33, 0x54, 0xc3, 0x7f, 0x28, 0x10, 0x1d, 0x97, 0xd7, 1016 0xf4, 0x98, 0xf0, 0x69, 0xf7, 0xd9, 0x6b, 0xd3, 0xf0, 0x50, 0x0b, 0x0d,
1017 0xa7, 0x8b, 0xaf, 0x0c, 0x6b, 0xff, 0x5b, 0x9a, 0xef, 0xbb, 0x90, 0xdb, 1017 0x63, 0x02, 0x67, 0xa5, 0xf8, 0x99, 0xc9, 0xd2, 0x63, 0xff, 0x3b, 0x60,
1018 0x49, 0x4c, 0x97, 0xe5, 0xa6, 0x67, 0xce, 0xe0, 0x76, 0x9f, 0xad, 0x71, 1018 0x78, 0x46, 0x00, 0xf3, 0x9e, 0x30, 0x34, 0xef, 0xc1, 0xe6, 0x8e, 0xf9,
1019 0xe1, 0xc4, 0x6d, 0xe0, 0x93, 0xbc, 0x47, 0x05, 0x9f, 0xfe, 0x77, 0x16, 1019 0x19, 0x20, 0xf7, 0x14, 0xd9, 0x80, 0xfb, 0x16, 0x90, 0xf2, 0x4a, 0x06,
1020 0xc0, 0xb2, 0x93, 0x05, 0x98, 0x57, 0x84, 0x80, 0xf5, 0x03, 0x03, 0xb4, 1020 0xad, 0xbc, 0x02, 0xa6, 0x09, 0x75, 0x88, 0xfe, 0xa6, 0xf5, 0x9f, 0xe5,
1021 0x8e, 0x39, 0x00, 0x1e, 0x53, 0x68, 0x02, 0xe6, 0x19, 0xa7, 0xf5, 0x40, 1021 0x60, 0xe3, 0x80, 0x4d, 0x40, 0x73, 0x9b, 0xa7, 0x90, 0x32, 0xf7, 0x0c,
1022 0xfb, 0xfb, 0x95, 0xc1, 0xeb, 0x5d, 0x1b, 0xa0, 0x67, 0x4f, 0x2d, 0xea, 1022 0xac, 0x6f, 0xb1, 0xae, 0x6d, 0xb4, 0x01, 0xef, 0xb1, 0x5e, 0x34, 0x85,
1023 0x79, 0x2c, 0x07, 0xca, 0xa3, 0x4e, 0x2a, 0x0c, 0x24, 0xe6, 0x27, 0x90, 1023 0x85, 0x61, 0x49, 0x0f, 0x03, 0xb0, 0x7e, 0x00, 0xa5, 0x75, 0x50, 0x1d,
1024 0xff, 0x80, 0xfe, 0x00, 0xf9, 0x11, 0x98, 0x9f, 0x9c, 0x81, 0x72, 0xa0, 1024 0x01, 0x4f, 0xef, 0x02, 0x4d, 0x40, 0xf7, 0x39, 0x01, 0xdb, 0xa2, 0xce,
1025 0x35, 0x53, 0xcd, 0x6b, 0x40, 0xfa, 0x40, 0x61, 0x08, 0x2a, 0x53, 0x41, 1025 0xfd, 0xca, 0xe0, 0xb5, 0xb2, 0x0d, 0xd0, 0x73, 0xab, 0x16, 0xf5, 0x88,
1026 0x63, 0x1d, 0x40, 0xf6, 0x12, 0x21, 0x68, 0xd8, 0x01, 0x69, 0x20, 0xbb, 1026 0xc9, 0x83, 0xf2, 0x99, 0x93, 0x0a, 0x03, 0x19, 0x79, 0x81, 0x0d, 0x9a,
1027 0x79, 0x8a, 0x08, 0x98, 0x9f, 0x14, 0x20, 0xc4, 0xd0, 0x00, 0xcf, 0x4f, 1027 0x17, 0xc0, 0xe1, 0x04, 0x4c, 0xeb, 0xc0, 0x32, 0x6a, 0x8d, 0x2e, 0xd0,
1028 0xec, 0x40, 0x97, 0xc2, 0xdc, 0xf4, 0xff, 0xff, 0x31, 0x15, 0x16, 0x60, 1028 0x3c, 0x1e, 0x16, 0x97, 0x7e, 0x90, 0x18, 0x03, 0x54, 0x8c, 0x05, 0xc8,
1029 0xda, 0x03, 0xad, 0xf9, 0xfc, 0xfd, 0xff, 0x80, 0x08, 0x0b, 0x43, 0x0b, 1029 0x97, 0x01, 0xb6, 0x29, 0x41, 0x7e, 0x05, 0xe5, 0x05, 0x90, 0xd9, 0x20,
1030 0x7c, 0xed, 0x9e, 0xb0, 0x3c, 0xa8, 0x9c, 0x5b, 0x00, 0x64, 0xb5, 0xc1, 1030 0xbf, 0x83, 0xca, 0x4e, 0x50, 0x5e, 0x04, 0xb2, 0x97, 0x08, 0x41, 0xfd,
1031 0xeb, 0x6d, 0x16, 0xf0, 0x7d, 0xc4, 0x0b, 0x18, 0x7e, 0x01, 0xcb, 0x95, 1031 0x0c, 0xa4, 0x81, 0xec, 0xe6, 0x29, 0x22, 0x60, 0x7e, 0x52, 0x80, 0x10,
1032 0xff, 0xff, 0x97, 0xc2, 0xd5, 0x82, 0x00, 0x00, 0xd4, 0xc2, 0xcb, 0x42, 1032 0x43, 0x03, 0x3c, 0x1f, 0x10, 0x1b, 0xc6, 0x30, 0xf5, 0x31, 0x64, 0xe4,
1033 0x60, 0x7c, 0x00, 0x00, 0x00 }; 1033 0x1b, 0x88, 0x19, 0x88, 0x7c, 0xc3, 0xce, 0x70, 0x40, 0x00, 0x16, 0x56,
1034static u32 bnx2_COM_b09FwData[(0x0/4) + 1] = { 0x0 }; 1034 0xff, 0xff, 0x1f, 0x53, 0x61, 0x01, 0xa6, 0x53, 0xd0, 0x3a, 0xd6, 0xdf,
1035static u32 bnx2_COM_b09FwRodata[(0x88/4) + 1] = { 1035 0xff, 0x0f, 0x88, 0xb0, 0x30, 0xb4, 0xc0, 0xd7, 0x23, 0xe6, 0xc8, 0x83,
1036 0x08001ad8, 0x08001b14, 0x08001b14, 0x08001b14, 0x08001b14, 0x08001b14, 1036 0xca, 0xd0, 0x05, 0x40, 0x56, 0x1b, 0xbc, 0x4d, 0xc0, 0x02, 0xbe, 0xef,
1037 0x08001a24, 0x08001b14, 0x08001a98, 0x08001b14, 0x080019ac, 0x08001b14, 1037 0x79, 0x01, 0xc3, 0x2f, 0x60, 0x99, 0xf5, 0xff, 0xff, 0x52, 0xb8, 0x5a,
1038 0x08001b14, 0x08001b14, 0x080019b8, 0x0, 0x08002a2c, 0x08002a7c, 1038 0x10, 0x00, 0x00, 0x19, 0x3f, 0x16, 0x21, 0xc4, 0x7d, 0x00, 0x00, 0x00 };
1039 0x08002aac, 0x08002adc, 0x08002b0c, 0x0, 0x08005fac, 0x08005fac, 1039
1040 0x08005fac, 0x08005fac, 0x08005fac, 0x08005fd8, 0x08005fd8, 0x08006018, 1040static const u32 bnx2_COM_b09FwData[(0x0/4) + 1] = { 0x0 };
1041 0x08006024, 0x08006024, 0x08005fac, 0x0, 0x0 }; 1041static const u32 bnx2_COM_b09FwRodata[(0x88/4) + 1] = {
1042static u32 bnx2_COM_b09FwBss[(0x88/4) + 1] = { 0x0 }; 1042 0x08001b68, 0x08001ba4, 0x08001ba4, 0x08001ba4, 0x08001ba4, 0x08001ba4,
1043static u32 bnx2_COM_b09FwSbss[(0x5c/4) + 1] = { 0x0 }; 1043 0x08001ab4, 0x08001ba4, 0x08001b28, 0x08001ba4, 0x08001a3c, 0x08001ba4,
1044 0x08001ba4, 0x08001ba4, 0x08001a48, 0x00000000, 0x08002abc, 0x08002b0c,
1045 0x08002b3c, 0x08002b6c, 0x08002b9c, 0x00000000, 0x0800604c, 0x0800604c,
1046 0x0800604c, 0x0800604c, 0x0800604c, 0x08006078, 0x08006078, 0x080060b8,
1047 0x080060c4, 0x080060c4, 0x0800604c, 0x00000000, 0x00000000 };
1048static const u32 bnx2_COM_b09FwBss[(0x88/4) + 1] = { 0x0 };
1049static const u32 bnx2_COM_b09FwSbss[(0x60/4) + 1] = { 0x0 };
1044 1050
1045static struct fw_info bnx2_com_fw_09 = { 1051static struct fw_info bnx2_com_fw_09 = {
1046 .ver_major = 0x1, 1052 .ver_major = 0x3,
1047 .ver_minor = 0x0, 1053 .ver_minor = 0x4,
1048 .ver_fix = 0x0, 1054 .ver_fix = 0x3,
1049 1055
1050 .start_addr = 0x080000b0, 1056 .start_addr = 0x080000b4,
1051 1057
1052 .text_addr = 0x08000000, 1058 .text_addr = 0x08000000,
1053 .text_len = 0x7c5c, 1059 .text_len = 0x7dc0,
1054 .text_index = 0x0, 1060 .text_index = 0x0,
1055 .gz_text = bnx2_COM_b09FwText, 1061 .gz_text = bnx2_COM_b09FwText,
1056 .gz_text_len = sizeof(bnx2_COM_b09FwText), 1062 .gz_text_len = sizeof(bnx2_COM_b09FwText),
1057 1063
1058 .data_addr = 0x08007d00, 1064 .data_addr = 0x08007e60,
1059 .data_len = 0x0, 1065 .data_len = 0x0,
1060 .data_index = 0x0, 1066 .data_index = 0x0,
1061 .data = bnx2_COM_b09FwData, 1067 .data = bnx2_COM_b09FwData,
1062 1068
1063 .sbss_addr = 0x08007d00, 1069 .sbss_addr = 0x08007e60,
1064 .sbss_len = 0x5c, 1070 .sbss_len = 0x60,
1065 .sbss_index = 0x0, 1071 .sbss_index = 0x0,
1066 .sbss = bnx2_COM_b09FwSbss, 1072 .sbss = bnx2_COM_b09FwSbss,
1067 1073
1068 .bss_addr = 0x08007d60, 1074 .bss_addr = 0x08007ec0,
1069 .bss_len = 0x88, 1075 .bss_len = 0x88,
1070 .bss_index = 0x0, 1076 .bss_index = 0x0,
1071 .bss = bnx2_COM_b09FwBss, 1077 .bss = bnx2_COM_b09FwBss,
1072 1078
1073 .rodata_addr = 0x08007c60, 1079 .rodata_addr = 0x08007dc0,
1074 .rodata_len = 0x88, 1080 .rodata_len = 0x88,
1075 .rodata_index = 0x0, 1081 .rodata_index = 0x0,
1076 .rodata = bnx2_COM_b09FwRodata, 1082 .rodata = bnx2_COM_b09FwRodata,
1077}; 1083};
1078 1084
1079static u8 bnx2_CP_b09FwText[] = { 1085static u8 bnx2_CP_b09FwText[] = {
1080 0x1f, 0x8b, 0x08, 0x08, 0x8e, 0xfc, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65, 1086 0x1f, 0x8b, 0x08, 0x00, 0x0f, 0x34, 0xe7, 0x45, 0x00, 0x03, 0xbd, 0x7d,
1081 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xbd, 0x7d, 0x0d, 0x74, 1087 0x0d, 0x74, 0x5c, 0x57, 0x7d, 0xe7, 0xff, 0xdd, 0x19, 0x49, 0x63, 0x59,
1082 0x5c, 0x57, 0x7d, 0xe7, 0xff, 0xdd, 0x79, 0x92, 0xc6, 0xb2, 0x2c, 0x3f, 1088 0x96, 0x9f, 0xe5, 0x89, 0x32, 0x51, 0x84, 0x3d, 0x23, 0x3d, 0xd9, 0x22,
1083 0xcb, 0x63, 0x65, 0x22, 0x0b, 0x7b, 0x46, 0x7a, 0xb2, 0x95, 0x58, 0x64, 1089 0x12, 0xe1, 0xc5, 0x11, 0xac, 0xda, 0x2a, 0xe9, 0x30, 0x92, 0x3f, 0x12,
1084 0xc7, 0xae, 0x00, 0x6d, 0x3b, 0x85, 0xe9, 0x48, 0xb2, 0x9d, 0x0f, 0x8a, 1090 0x02, 0xab, 0x10, 0x43, 0xb3, 0x1c, 0x4a, 0xc5, 0x48, 0x4e, 0x02, 0x04,
1085 0x4c, 0x44, 0x4f, 0x5a, 0xe8, 0x22, 0xc6, 0x76, 0x48, 0x80, 0xb2, 0x4e, 1091 0xea, 0x40, 0xe8, 0x86, 0xdd, 0xec, 0x66, 0x32, 0x92, 0x3f, 0x9a, 0x8e,
1086 0x09, 0x69, 0x80, 0x04, 0x0f, 0x23, 0xf9, 0x83, 0x74, 0xec, 0x51, 0x12, 1092 0x3d, 0x93, 0x44, 0x89, 0xbd, 0xdd, 0x9c, 0xad, 0x90, 0x14, 0x3b, 0x74,
1087 0xc5, 0x76, 0x4f, 0x73, 0x58, 0x55, 0x92, 0x1d, 0x43, 0xa7, 0x1e, 0x27, 1093 0x07, 0x4f, 0xe2, 0x98, 0x96, 0x73, 0x0a, 0x8d, 0x50, 0x8c, 0x9b, 0xe6,
1088 0x71, 0x68, 0xf6, 0x6c, 0x68, 0xb4, 0x4a, 0xe2, 0xa6, 0x3d, 0xd9, 0xd6, 1094 0xb0, 0xdd, 0xd0, 0xa6, 0x34, 0xdb, 0x86, 0x22, 0x8c, 0x81, 0xf4, 0x2c,
1089 0xf4, 0x84, 0x6e, 0xda, 0x43, 0x77, 0x85, 0x71, 0x88, 0x4b, 0xb3, 0x4b, 1095 0xdd, 0x86, 0x42, 0x77, 0xd3, 0x36, 0xe5, 0xed, 0xef, 0x77, 0xef, 0x7d,
1090 0xf8, 0x68, 0x61, 0xa1, 0xe5, 0xed, 0xef, 0x77, 0xef, 0x7d, 0xd2, 0xe8, 1096 0x9a, 0x91, 0x34, 0xce, 0x07, 0xdd, 0xad, 0xcf, 0x79, 0x7e, 0xf3, 0xee,
1091 0xc3, 0x09, 0xa1, 0xbb, 0xf5, 0x39, 0xcf, 0x6f, 0xde, 0xfd, 0xfc, 0xdf, 1097 0xbb, 0x1f, 0xff, 0xfb, 0xbf, 0xff, 0xef, 0xfb, 0xbf, 0x4f, 0x97, 0x8b,
1092 0xff, 0xfd, 0x7f, 0xdf, 0x0f, 0xad, 0x17, 0xa9, 0x17, 0xfb, 0x6f, 0x15, 1098 0x34, 0x8b, 0xfd, 0xb7, 0x01, 0xd7, 0xd5, 0xc9, 0xfd, 0xe3, 0x57, 0x5f,
1093 0x9e, 0x6d, 0x89, 0x7d, 0xbb, 0xb7, 0x5e, 0xd7, 0x73, 0x1d, 0x7e, 0x6e, 1099 0x39, 0x70, 0x25, 0x9f, 0xa3, 0x91, 0x68, 0x44, 0xde, 0xc4, 0xbf, 0xe4,
1094 0x75, 0x57, 0x46, 0x95, 0xbc, 0x89, 0x7f, 0x89, 0x9f, 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, 0x28, 0x88, 0x4c, 0x0d, 0x38, 0x12, 0x19, 0x92,
1102 0xd2, 0x1d, 0x2f, 0xf5, 0x46, 0xf6, 0x07, 0x11, 0xdf, 0xf7, 0x7a, 0xa5, 1108 0xb3, 0xe3, 0x03, 0xf7, 0x04, 0xca, 0xf3, 0xfc, 0x45, 0x69, 0x19, 0x3c,
1103 0xa1, 0x27, 0xdb, 0x8d, 0xf4, 0xf2, 0x56, 0x51, 0x7e, 0x54, 0xb2, 0x15, 1109 0x37, 0x80, 0xf7, 0x65, 0x41, 0xdd, 0xbd, 0xd7, 0x9c, 0x28, 0xc4, 0x44,
1104 0x69, 0x50, 0xbe, 0x8f, 0x77, 0xbd, 0xa8, 0x74, 0xd2, 0xcb, 0x46, 0x5c, 1110 0x0d, 0xf5, 0xbc, 0x90, 0x89, 0x5c, 0x25, 0x7c, 0x7f, 0x56, 0x7a, 0xfc,
1105 0x29, 0x54, 0x2e, 0xac, 0x30, 0x6d, 0x96, 0xec, 0xfb, 0x6f, 0xa2, 0xe6, 1111 0xa7, 0x05, 0xe5, 0xe5, 0x98, 0x64, 0x2a, 0xd2, 0x82, 0x32, 0xdc, 0x9b,
1106 0x8d, 0x36, 0x4b, 0x51, 0x99, 0x8d, 0xc4, 0x05, 0xfd, 0x00, 0xe6, 0x06, 1112 0x51, 0x27, 0xe5, 0x66, 0x22, 0xae, 0xe4, 0x2b, 0x3f, 0x5e, 0x67, 0xc6,
1107 0x19, 0x2e, 0x25, 0x24, 0x5b, 0x64, 0xbf, 0xae, 0xe4, 0x3c, 0xf6, 0xd9, 1113 0x9d, 0xb3, 0xf7, 0xbf, 0x8e, 0x99, 0x3b, 0xc6, 0x2d, 0xc6, 0x64, 0x29,
1108 0x80, 0xfa, 0x2b, 0x9d, 0xe5, 0xcb, 0xb3, 0xec, 0x4b, 0x28, 0x9b, 0x40, 1114 0x92, 0x10, 0xc0, 0x82, 0x79, 0x25, 0x64, 0xb2, 0x98, 0x94, 0x4c, 0x81,
1109 0xb9, 0x56, 0x79, 0xbc, 0x12, 0x97, 0xc7, 0x2a, 0x31, 0x79, 0xb4, 0x72, 1115 0xb0, 0x45, 0x25, 0xeb, 0x12, 0xae, 0x04, 0xda, 0xb7, 0x39, 0xf5, 0xeb,
1110 0x87, 0x64, 0x50, 0xf7, 0x6c, 0x05, 0x7d, 0x97, 0x6a, 0xa5, 0x77, 0xac, 1116 0xb3, 0xee, 0x0b, 0xa8, 0x9b, 0x44, 0xbd, 0x4e, 0x79, 0x12, 0x75, 0x4f,
1111 0x5e, 0xb2, 0x63, 0xed, 0xf1, 0x9c, 0x04, 0xc1, 0x27, 0x52, 0x1f, 0x95, 1117 0x57, 0xe2, 0xf2, 0x44, 0xe5, 0x57, 0x25, 0x8d, 0xb6, 0x8f, 0x57, 0x30,
1112 0xa1, 0x26, 0x94, 0x2f, 0x31, 0x2f, 0xbe, 0x20, 0x2f, 0x97, 0xda, 0xe2, 1118 0x76, 0xb1, 0x51, 0x86, 0xa7, 0x9b, 0x25, 0x33, 0xdd, 0x9d, 0xc8, 0x4a,
1113 0xe5, 0x94, 0x23, 0x99, 0xc1, 0x64, 0x7c, 0x48, 0xf1, 0xbb, 0x46, 0xb2, 1119 0x10, 0x7c, 0xda, 0xff, 0xa8, 0x8c, 0xb5, 0xa1, 0x7e, 0x91, 0xef, 0x12,
1114 0x5d, 0xf8, 0x1e, 0x70, 0x25, 0xe2, 0x07, 0xc1, 0x1d, 0xa9, 0x26, 0xc0, 1120 0x2b, 0xde, 0x65, 0xfd, 0x3e, 0x37, 0xab, 0x1c, 0x49, 0xef, 0x4d, 0x25,
1115 0x91, 0x4c, 0x24, 0x14, 0xeb, 0xb2, 0x5e, 0x32, 0x9f, 0x50, 0x51, 0xc9, 1121 0xc6, 0x14, 0x9f, 0x1b, 0x24, 0xd3, 0x8f, 0xe7, 0xd1, 0xa8, 0x44, 0xbc,
1116 0x57, 0xae, 0x93, 0x44, 0x53, 0x10, 0xbc, 0x37, 0xe5, 0x21, 0x5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0x2d, 0xdb, 0xef, 0xac, 0x2c, 0xbb, 0xbd,
1124 0xea, 0xc5, 0x40, 0x9a, 0x09, 0x33, 0xf3, 0x14, 0xf2, 0x50, 0x34, 0x9d, 1130 0x85, 0xb0, 0x8a, 0xe2, 0xef, 0xb8, 0x9e, 0x6b, 0x3a, 0xde, 0xed, 0x36,
1125 0xc2, 0xbc, 0xb9, 0x72, 0x08, 0x63, 0xbb, 0x38, 0x96, 0xf4, 0xda, 0x14, 1131 0x60, 0x5e, 0xa3, 0x7e, 0xca, 0xdd, 0xa9, 0x9e, 0x0f, 0xa4, 0x9d, 0x30,
1126 0xde, 0x53, 0xfc, 0xdd, 0x34, 0x14, 0x49, 0x07, 0x41, 0x36, 0x35, 0x2e, 1132 0xf3, 0x9d, 0xc2, 0x3b, 0x54, 0x1d, 0xf2, 0xb1, 0x6e, 0xae, 0x1c, 0xc2,
1127 0xb9, 0x72, 0xd2, 0x9b, 0x05, 0x70, 0xbd, 0x63, 0x71, 0x8c, 0x1f, 0xe3, 1133 0xdc, 0xce, 0x4f, 0xa7, 0xdc, 0x2e, 0x85, 0xfb, 0x3c, 0x7f, 0x07, 0x41,
1128 0x88, 0x65, 0x92, 0x6b, 0xa4, 0xcb, 0xce, 0xcf, 0x5f, 0xa2, 0xef, 0x76, 1134 0xc6, 0xcf, 0xe9, 0x35, 0xfd, 0xee, 0x74, 0x02, 0xcf, 0x80, 0x3f, 0x9e,
1129 0xef, 0x0e, 0xd5, 0xee, 0xa5, 0x54, 0xd2, 0x9b, 0x90, 0x3f, 0xc4, 0x77, 1135 0x4e, 0x6d, 0x92, 0xab, 0xed, 0xba, 0x7c, 0x13, 0x63, 0x76, 0xbb, 0x77,
1130 0x10, 0xec, 0x4a, 0x25, 0xe3, 0x79, 0xcc, 0xdd, 0xa5, 0x62, 0x4c, 0x5e, 1136 0xa8, 0x6e, 0xd7, 0x57, 0x29, 0x77, 0x56, 0xce, 0xe0, 0x39, 0x08, 0x6e,
1131 0x2e, 0x26, 0x41, 0xa9, 0xc9, 0xce, 0x49, 0xd9, 0x92, 0x9a, 0x04, 0xdc, 1137 0xf4, 0x53, 0x89, 0x1c, 0xd6, 0xec, 0x42, 0x21, 0x2e, 0xdf, 0x2b, 0xa4,
1132 0x05, 0x3c, 0x07, 0x99, 0x57, 0x46, 0x5e, 0x99, 0x75, 0x83, 0xe0, 0xe6, 1138 0x40, 0xc5, 0xa9, 0xde, 0x39, 0xe9, 0xf3, 0xe7, 0x00, 0x6f, 0x1e, 0xd7,
1133 0xd4, 0x89, 0x60, 0xa8, 0xd9, 0xd0, 0xfe, 0xd3, 0x25, 0xcc, 0x2b, 0xe6, 1139 0x41, 0xbe, 0x2b, 0xe3, 0x5d, 0x99, 0x6d, 0x83, 0xe0, 0x26, 0xff, 0x37,
1134 0xe9, 0xb1, 0x12, 0xe6, 0xb5, 0x84, 0x39, 0xd5, 0xf3, 0xdf, 0x89, 0xf9, 1140 0x83, 0xb1, 0x76, 0xc3, 0x17, 0x4f, 0x15, 0xb1, 0x9e, 0x80, 0xf9, 0x74,
1135 0x27, 0x8d, 0x90, 0x3e, 0xb6, 0x59, 0x7a, 0x7d, 0xb7, 0x7d, 0x8b, 0x64, 1141 0x11, 0xeb, 0x89, 0xb5, 0x7a, 0x5c, 0xaf, 0x7b, 0x2f, 0xd6, 0x9d, 0xb4,
1136 0x4b, 0x8e, 0x64, 0x53, 0x3f, 0x09, 0x32, 0x9a, 0x27, 0xc4, 0xe9, 0x2d, 1142 0x41, 0xba, 0xd8, 0x61, 0x69, 0xf9, 0x03, 0xf6, 0x2e, 0x92, 0x29, 0x3a,
1137 0x91, 0x26, 0x6b, 0x00, 0x2b, 0x3f, 0x7f, 0xdd, 0x96, 0x8b, 0x3a, 0x18, 1143 0x92, 0xf1, 0xff, 0x31, 0x48, 0x6b, 0x7e, 0x11, 0x67, 0xb8, 0x48, 0x5a,
1138 0x06, 0xe7, 0x83, 0xf9, 0x51, 0xe5, 0xd7, 0xd9, 0xfc, 0x90,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0x96,
1153 0xe3, 0x80, 0xa9, 0x55, 0x86, 0x41, 0x8b, 0xbd, 0x82, 0xdf, 0x53, 0x84, 1159 0x98, 0xcc, 0xfa, 0xe0, 0x0b, 0xd7, 0xc0, 0x92, 0x2f, 0xc6, 0xa2, 0xc3,
1154 0x91, 0xfd, 0xb6, 0xe8, 0xdf, 0xc3, 0x63, 0x1b, 0xf4, 0x77, 0x6e, 0xa0, 1160 0x98, 0xf7, 0x70, 0xf9, 0x57, 0xd0, 0x7f, 0x8b, 0xfe, 0x0d, 0x7e, 0xb2,
1155 0x45, 0xf2, 0x53, 0xe1, 0x58, 0x28, 0x0f, 0x28, 0x03, 0x92, 0x87, 0x45, 1161 0x65, 0x51, 0xdc, 0xe3, 0xb8, 0x13, 0xe6, 0x90, 0x56, 0x21, 0x1b, 0xa6,
1156 0x28, 0x13, 0x82, 0xe0, 0xc1, 0x14, 0xe5, 0x42, 0x10, 0x3c, 0x96, 0xa2, 1162 0x3b, 0x65, 0x12, 0xb4, 0x3a, 0x2c, 0xf8, 0x3d, 0xcf, 0xb9, 0x10, 0xae,
1157 0x9c, 0x38, 0x07, 0xfe, 0xa7, 0x6c, 0x20, 0xaf, 0xae, 0x55, 0x9c, 0x83, 1163 0x0e, 0xfd, 0x7b, 0x72, 0x7a, 0x8b, 0x7e, 0xce, 0x8e, 0x76, 0x48, 0x6e,
1158 0x6c, 0x11, 0x7d, 0x40, 0x4e, 0xe4, 0xba, 0x4e, 0x40, 0x6e, 0x50, 0xae, 1164 0x3e, 0x9c, 0x33, 0xe5, 0x05, 0x65, 0x44, 0xea, 0xb0, 0x08, 0x65, 0x46,
1159 0x5c, 0xf8, 0x44, 0xd6, 0xcf, 0xc7, 0x23, 0x1a, 0x0f, 0x98, 0x6f, 0xc8, 1165 0x10, 0x3c, 0xe8, 0x53, 0x6e, 0x04, 0xc1, 0x69, 0x9f, 0x72, 0xe4, 0x0c,
1160 0xbc, 0x8c, 0x86, 0xbc, 0x4d, 0x0a, 0x5d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 0xb0, 0x4e, 0x3d,
1175 0x4f, 0xfe, 0x5d, 0x25, 0x43, 0xb1, 0x2d, 0xde, 0x2f, 0xa8, 0x06, 0xd0, 1181 0x96, 0x7f, 0xc6, 0x8e, 0xd3, 0x07, 0x2d, 0xf4, 0x5a, 0xeb, 0xd5, 0x28,
1176 0x58, 0xd2, 0x4b, 0x28, 0xf2, 0x97, 0xe4, 0x23, 0x69, 0x3f, 0xdf, 0x2b, 1182 0xd2, 0xce, 0xf2, 0x5e, 0xe8, 0x90, 0x0e, 0x65, 0xe4, 0x02, 0x65, 0x10,
1177 0x2a, 0xa6, 0x24, 0x90, 0xbe, 0x94, 0x6a, 0x52, 0xb2, 0x1f, 0xfc, 0x93, 1183 0xcb, 0x3a, 0x41, 0xe7, 0x71, 0xd0, 0x1d, 0xe5, 0x28, 0xf8, 0x8c, 0x73,
1178 0x81, 0x4e, 0xda, 0x15, 0xf4, 0x6a, 0x1e, 0x32, 0x65, 0xaf, 0x2c, 0x2b, 1184 0xa9, 0x6c, 0x90, 0xb1, 0x78, 0x9f, 0x7b, 0xb5, 0x6a, 0x01, 0x8d, 0xa5,
1179 0x7d, 0x39, 0x48, 0x19, 0x97, 0xce, 0xdc, 0x95, 0xf5, 0xa7, 0x7b, 0x6a, 1185 0xdc, 0xa4, 0x22, 0xff, 0x49, 0x2e, 0x32, 0xe4, 0xe5, 0x86, 0x45, 0xc5,
1180 0x41, 0xb3, 0x17, 0x51, 0x67, 0x07, 0x6a, 0xee, 0x2d, 0xbb, 0xd2, 0x57, 1186 0x95, 0x04, 0x32, 0xe2, 0xab, 0x36, 0x25, 0xf7, 0x80, 0xbf, 0xd2, 0xd0,
1181 0xee, 0x04, 0x2f, 0x38, 0x72, 0xde, 0x5f, 0x2d, 0xe7, 0x53, 0x28, 0x5b, 1187 0x59, 0x37, 0x06, 0xc3, 0x9a, 0xb7, 0x4c, 0xdd, 0x8b, 0xcb, 0x54, 0x5f,
1182 0x89, 0xc8, 0x4c, 0xcc, 0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, 0x11, 0xa7, 0xb7, 0xe2, 0x64, 0x60, 0xaf, 0xc5, 0x87, 0xe5, 0x30, 1210 0x77, 0xed, 0x52, 0xde, 0x95, 0x92, 0x9d, 0xef, 0x94, 0x03, 0x85, 0x77,
1205 0x7e, 0x8b, 0x17, 0x49, 0x3f, 0x89, 0xb7, 0xc1, 0x01, 0xf5, 0xce, 0x70, 1211 0x58, 0xd9, 0x82, 0x4b, 0xbe, 0xe4, 0x98, 0x79, 0x26, 0xf4, 0xba, 0xe7,
1206 0x89, 0xf2, 0xd2, 0xc7, 0xd8, 0x13, 0x72, 0x6e, 0x81, 0x0d, 0x45, 0x5c, 1212 0x8b, 0x39, 0x67, 0x94, 0xf0, 0xe3, 0xf7, 0x70, 0xa1, 0xcf, 0xdd, 0x24,
1207 0x28, 0xc9, 0x8d, 0x25, 0x4f, 0xe4, 0x25, 0x99, 0x1f, 0x07, 0x43, 0xec, 1213 0xa4, 0x81, 0x29, 0x67, 0xb8, 0xe2, 0xa4, 0x23, 0x43, 0x3d, 0x89, 0x49,
1208 0x4a, 0xb9, 0xf2, 0xde, 0x14, 0x68, 0xf7, 0x3a, 0x47, 0xb6, 0x5f, 0xe7, 1214 0x39, 0x8c, 0xdf, 0xe2, 0x46, 0x86, 0xbe, 0x84, 0xbb, 0xc1, 0xc1, 0x57,
1209 0xc2, 0xe6, 0xf1, 0xc7, 0xb7, 0x83, 0xfe, 0x31, 0xcf, 0x9a, 0x1e, 0xd4, 1215 0xb6, 0x43, 0xb6, 0x16, 0x29, 0x2f, 0x3d, 0xcc, 0x3d, 0x29, 0x67, 0x56,
1210 0x19, 0x81, 0x9d, 0x08, 0x6c, 0x9f, 0xe9, 0xea, 0x1b, 0x2e, 0xe6, 0x3e, 1216 0xd8, 0x58, 0xc4, 0x85, 0x92, 0xec, 0x74, 0xea, 0x78, 0x4e, 0x52, 0xb9,
1211 0xa6, 0xd2, 0xfb, 0x3e, 0x95, 0xed, 0xbe, 0x46, 0x72, 0x83, 0x0a, 0x38, 1217 0x19, 0x30, 0xc4, 0x8d, 0x7e, 0x54, 0xde, 0xe7, 0x83, 0x76, 0xaf, 0x74,
1212 0x6a, 0x1e, 0x82, 0x1e, 0xc4, 0xb8, 0x82, 0x00, 0xf4, 0x0c, 0x79, 0x7e, 1218 0x64, 0xd7, 0x95, 0x51, 0xd8, 0x44, 0xde, 0xcc, 0x2e, 0xc8, 0x58, 0xc8,
1213 0xf3, 0xcd, 0x91, 0x74, 0x8d, 0xf4, 0x0e, 0x36, 0xa3, 0x0e, 0xf3, 0x88, 1219 0xbe, 0x08, 0xe9, 0x41, 0x9d, 0x92, 0xb1, 0xe8, 0x10, 0xb0, 0x7d, 0xaa,
1214 0xaf, 0xaf, 0xa2, 0x9d, 0x64, 0xa2, 0x4f, 0xe4, 0x9e, 0x91, 0xee, 0x59, 1220 0x7f, 0x64, 0xb2, 0x90, 0xbd, 0x5d, 0x0d, 0xed, 0xff, 0x6c, 0x66, 0xe0,
1215 0x67, 0x78, 0xf4, 0x37, 0xc0, 0x93, 0x5b, 0x51, 0xff, 0x01, 0xd4, 0x7f, 1221 0xad, 0x92, 0xdd, 0xab, 0x80, 0xa3, 0xf6, 0x31, 0xc8, 0x4c, 0xcc, 0x2b,
1216 0xcd, 0x29, 0x8c, 0xfd, 0xc8, 0x19, 0x1e, 0xfb, 0x9e, 0x33, 0x32, 0xb6, 1222 0x08, 0x40, 0xcf, 0x90, 0xe7, 0x37, 0xdd, 0x14, 0x19, 0x6a, 0x90, 0xe1,
1217 0x61, 0x43, 0x7f, 0xcf, 0x86, 0x0d, 0xbb, 0x7b, 0x5c, 0x99, 0x00, 0x8f, 1223 0xbd, 0xed, 0x68, 0xc3, 0x77, 0xc4, 0xd7, 0x79, 0xe0, 0x33, 0x95, 0x1c,
1218 0x65, 0xbc, 0x0d, 0x1b, 0x46, 0x7a, 0xba, 0x80, 0x83, 0x2d, 0x5e, 0x9f, 1224 0x11, 0xb9, 0x7b, 0x6a, 0x60, 0xc9, 0x99, 0x2c, 0x7d, 0x10, 0x3c, 0x79,
1219 0xf8, 0xde, 0x76, 0x01, 0xff, 0xc4, 0xd8, 0x67, 0x14, 0xf9, 0x49, 0xe4, 1225 0x15, 0xda, 0x3f, 0x80, 0xf6, 0x2f, 0x3b, 0xf9, 0xe9, 0x57, 0x9c, 0xc9,
1220 0xb3, 0x7e, 0x5c, 0xe7, 0xf7, 0xca, 0x96, 0x78, 0x93, 0xb0, 0xff, 0x88, 1226 0xe9, 0xbf, 0x75, 0xa6, 0xa6, 0xb7, 0x6c, 0xd9, 0x39, 0xb8, 0x65, 0xcb,
1221 0x2d, 0x53, 0x13, 0x91, 0xfa, 0x07, 0xec, 0xfc, 0x66, 0x9c, 0x1a, 0x9f, 1227 0xf8, 0x60, 0xd4, 0xea, 0x97, 0x2d, 0x5b, 0xa6, 0x06, 0x07, 0x81, 0x83,
1222 0xe9, 0x1c, 0x0b, 0xd3, 0x39, 0xb7, 0x7f, 0x67, 0x6d, 0xd5, 0xd5, 0x48, 1228 0x3e, 0x77, 0x44, 0x3c, 0x77, 0x97, 0x80, 0x7f, 0xe2, 0x1c, 0x93, 0xfa,
1223 0xe7, 0x37, 0x71, 0x46, 0xbc, 0xd0, 0xc6, 0xa8, 0xd1, 0xb6, 0x61, 0xae, 1229 0x27, 0x85, 0xf7, 0x6c, 0xef, 0xe9, 0xf7, 0xc3, 0xd2, 0x97, 0x68, 0x13,
1224 0x48, 0x9a, 0x71, 0x65, 0x4f, 0xd1, 0x41, 0x1d, 0xd0, 0xc5, 0x19, 0xfb, 1230 0x8e, 0x1f, 0xb1, 0x75, 0xda, 0x01, 0xfb, 0x03, 0x76, 0x7d, 0x0b, 0xaa,
1225 0x1c, 0x05, 0x6c, 0x83, 0x68, 0xeb, 0xe8, 0x21, 0xd4, 0xa3, 0xcc, 0x48, 1231 0xc1, 0x63, 0x39, 0xe7, 0xc2, 0x72, 0xae, 0xed, 0x8f, 0xac, 0x2d, 0xbb,
1226 0x76, 0x8a, 0xfa, 0x00, 0xca, 0x6c, 0xf1, 0xd6, 0x0a, 0x6d, 0x89, 0x3b, 1232 0x11, 0xe5, 0x7c, 0x26, 0xce, 0x88, 0x17, 0xda, 0x22, 0x0d, 0xda, 0x76,
1227 0x25, 0x57, 0x22, 0x7f, 0x77, 0x00, 0x9e, 0xa8, 0x24, 0x9a, 0xf1, 0x5d, 1233 0xcc, 0x16, 0x48, 0x33, 0x51, 0x99, 0x28, 0xb4, 0xa1, 0x0d, 0xe8, 0xe2,
1228 0x81, 0x4d, 0xf1, 0x60, 0x8d, 0x58, 0xdb, 0x45, 0xe6, 0x6d, 0x91, 0x3b, 1234 0x94, 0xbd, 0x8e, 0x02, 0xb6, 0xbd, 0xe8, 0xeb, 0xe8, 0x21, 0xb4, 0xa3,
1229 0x94, 0xc0, 0xde, 0x18, 0x9a, 0x5c, 0x8f, 0x72, 0x0e, 0xf0, 0x42, 0xfb, 1235 0xcc, 0x48, 0xf5, 0x8a, 0xfa, 0x04, 0xea, 0xf4, 0xb9, 0x9b, 0x85, 0x36,
1230 0x03, 0xb4, 0x36, 0x99, 0x91, 0xec, 0x26, 0xf0, 0xc9, 0xa4, 0x87, 0x6f, 1236 0xc7, 0x71, 0xc9, 0x16, 0xc9, 0xdf, 0x3d, 0x80, 0x27, 0x26, 0xc9, 0x76,
1231 0xc0, 0x35, 0xf9, 0x16, 0xbc, 0x23, 0xfa, 0xdb, 0xc0, 0x09, 0xbc, 0xa6, 1237 0x3c, 0x57, 0x0e, 0xc0, 0x0e, 0x69, 0xb0, 0x3a, 0x33, 0x94, 0x17, 0xfc,
1232 0x22, 0x56, 0x67, 0x75, 0xa1, 0xef, 0xf7, 0x48, 0x76, 0x34, 0x4e, 0x5b, 1238 0x77, 0x87, 0x12, 0xef, 0x80, 0x8c, 0xcd, 0x5d, 0x8e, 0x7a, 0x0e, 0xf0,
1233 0x62, 0x75, 0xd6, 0xcf, 0x40, 0xd7, 0x2b, 0x28, 0x41, 0x8c, 0x61, 0xd2, 1239 0x42, 0x3b, 0x05, 0x36, 0xcb, 0x5c, 0x5a, 0x32, 0xdb, 0xee, 0xc5, 0xdd,
1234 0x81, 0x3c, 0xa9, 0x95, 0xdd, 0x8f, 0xe0, 0xf7, 0x83, 0xc6, 0xe6, 0xdd, 1240 0xc5, 0x73, 0x1e, 0xf7, 0xb7, 0xe0, 0x3e, 0x89, 0x7b, 0x08, 0x27, 0xf0,
1235 0x3d, 0xc9, 0x7e, 0x1a, 0x00, 0x13, 0x6c, 0x90, 0x47, 0x60, 0x9b, 0x3e, 1241 0xea, 0x47, 0xac, 0xce, 0xba, 0x06, 0x63, 0xff, 0x6b, 0xc9, 0x94, 0x12,
1236 0x02, 0x1b, 0xe4, 0x91, 0x66, 0x3c, 0x1c, 0x1b, 0xdb, 0x9f, 0x59, 0x03, 1242 0xb4, 0x39, 0x36, 0x66, 0xbc, 0xb4, 0xab, 0x44, 0x6d, 0x56, 0x32, 0x85,
1237 0x31, 0xa9, 0xbf, 0x73, 0xa4, 0x57, 0xd8, 0xea, 0xb9, 0x62, 0xca, 0x94, 1243 0xfa, 0xf0, 0x09, 0xbc, 0x83, 0x32, 0x7e, 0x12, 0xbf, 0x1f, 0xa4, 0x4d,
1238 0x2f, 0x76, 0xeb, 0xb7, 0xa1, 0xeb, 0x1e, 0xfb, 0x3b, 0xae, 0xf9, 0x3a, 1244 0x3c, 0x25, 0xe3, 0x73, 0x1c, 0xa7, 0x00, 0x98, 0x4a, 0x92, 0x3d, 0xf9,
1239 0xdf, 0x04, 0x9a, 0xaf, 0x74, 0x69, 0x99, 0x93, 0xf5, 0xf1, 0x86, 0xcd, 1245 0x00, 0xae, 0x69, 0x5c, 0x0f, 0xe3, 0xe2, 0xdc, 0xd8, 0xff, 0xe2, 0x26,
1240 0x99, 0x69, 0xe2, 0x18, 0xe3, 0x36, 0x2d, 0xae, 0xd3, 0x12, 0x4d, 0xd6, 1246 0x05, 0x5c, 0xf3, 0x39, 0x4b, 0x3a, 0xae, 0xe0, 0x37, 0x69, 0xb8, 0x42,
1241 0xde, 0x28, 0x59, 0x5b, 0x03, 0xb8, 0x19, 0x6a, 0x06, 0xc4, 0x94, 0xcf, 1247 0xdb, 0x06, 0xf4, 0x5b, 0x09, 0xe9, 0xda, 0xb7, 0xbf, 0x13, 0x9a, 0xaf,
1242 0x12, 0xe2, 0x93, 0x32, 0x00, 0xf4, 0x0b, 0x9b, 0xe2, 0xdc, 0x15, 0xe5, 1248 0x73, 0x6d, 0xa0, 0x99, 0xca, 0xa0, 0x96, 0x39, 0x19, 0x0f, 0xf7, 0x0a,
1243 0xdf, 0xac, 0xb6, 0xb1, 0xce, 0x56, 0x48, 0xc7, 0xa4, 0xed, 0x20, 0xb8, 1249 0x6c, 0x8f, 0x36, 0xce, 0xd1, 0xb3, 0x65, 0x9e, 0x2e, 0x4b, 0xea, 0xb2,
1244 0x3f, 0x55, 0x87, 0xf6, 0xc9, 0xf3, 0xb0, 0x40, 0x8e, 0x02, 0x26, 0x60, 1250 0x7e, 0x5b, 0x86, 0x7b, 0xa5, 0x41, 0xc6, 0xda, 0x01, 0x31, 0xe5, 0xb3,
1245 0xa2, 0xc6, 0x3f, 0xab, 0x69, 0xa0, 0xd6, 0x27, 0x0d, 0x57, 0xf3, 0x97, 1251 0x84, 0xf8, 0xa4, 0x0c, 0x00, 0xfd, 0xc2, 0x66, 0x38, 0x73, 0x51, 0xf9,
1246 0xe8, 0xf1, 0x9e, 0x05, 0x8f, 0xc1, 0xbe, 0x81, 0xfd, 0xd6, 0x01, 0xdb, 1252 0xb7, 0xa4, 0x6d, 0xb1, 0xc7, 0x2b, 0xa4, 0x63, 0xd2, 0x76, 0x10, 0xdc,
1247 0x98, 0x7d, 0x1c, 0xe6, 0xb7, 0xa7, 0xc0, 0x53, 0xd9, 0x39, 0x9e, 0x12, 1253 0xef, 0x37, 0xa1, 0x7f, 0xf2, 0xbc, 0x48, 0xc3, 0xd1, 0xa8, 0xcc, 0xb8,
1248 0x99, 0x28, 0x12, 0x37,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be, 0x73, 0x54, 0x79, 0x9b, 0x57, 0x97, 0x25, 0xa9,
1263 0x1d, 0x71, 0xd3, 0x7c, 0x83, 0x92, 0xd3, 0x6c, 0x43, 0xf3, 0x95, 0x95, 1269 0x87, 0xd1, 0x2e, 0x99, 0xed, 0x6f, 0x27, 0x8f, 0xb9, 0xca, 0x03, 0x2e,
1264 0x33, 0x1d, 0x5e, 0x41, 0xc8, 0x57, 0x9f, 0x93, 0x5b, 0x27, 0x8d, 0xfc, 1270 0x3d, 0xed, 0x1b, 0xe5, 0xd4, 0xc0, 0xc6, 0x55, 0xf5, 0xf5, 0xdd, 0xb1,
1265 0xdd, 0x0e, 0x19, 0x04, 0xff, 0xcc, 0x9b, 0x11, 0xc0, 0x3f, 0x98, 0x96, 1271 0xcf, 0x51, 0x7b, 0x77, 0xed, 0x3d, 0x69, 0xef, 0xb9, 0xe8, 0x00, 0xef,
1266 0x5b, 0x2b, 0xc4, 0xdb, 0xef, 0x02, 0x7f, 0x60, 0xe2, 0x7a, 0xea, 0x74, 1272 0x8e, 0x44, 0x87, 0x78, 0xc7, 0x1a, 0x0e, 0xb1, 0x0f, 0xcd, 0x57, 0x56,
1267 0xca, 0xdd, 0x3b, 0x61, 0xf7, 0xa2, 0x7c, 0x91, 0x38, 0x1f, 0xd2, 0x73, 1273 0xce, 0xf4, 0xb8, 0x79, 0x21, 0x5f, 0xfd, 0xa9, 0xdc, 0x32, 0x67, 0xe4,
1268 0x53, 0x28, 0xee, 0xd1, 0x73, 0x73, 0xb0, 0x38, 0x03, 0xfc, 0xdc, 0x06, 1274 0xef, 0x2e, 0xc8, 0x20, 0xf8, 0x6f, 0xee, 0xa2, 0x00, 0xfe, 0xbd, 0x65,
1269 0xba, 0x0f, 0x82, 0x99, 0x54, 0x01, 0x94, 0xf3, 0x11, 0xfc, 0x86, 0x1d, 1275 0xb9, 0xa5, 0x42, 0xbc, 0xfd, 0x06, 0xf0, 0xb7, 0x35, 0x4a, 0xde, 0x74,
1270 0x50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0x4d, 0x17, 0x17, 0x30,
1292 0x45, 0xca, 0x02, 0xe8, 0x9f, 0xe2, 0x08, 0xde, 0xb5, 0x5a, 0x26, 0x14, 1298 0xf6, 0x33, 0x9a, 0x67, 0x46, 0x20, 0xf3, 0xb3, 0xb0, 0x4b, 0xc6, 0x34,
1293 0x24, 0x94, 0x07, 0xac, 0x47, 0x99, 0x50, 0x2d, 0x77, 0x28, 0x6b, 0x28, 1299 0x4c, 0x97, 0x03, 0x3e, 0xf8, 0xba, 0x03, 0xb8, 0xcf, 0x35, 0xca, 0x52,
1294 0x7b, 0x28, 0x4b, 0xcc, 0x7c, 0xec, 0x7e, 0x90, 0x32, 0x1c, 0xb4, 0x10, 1300 0x9c, 0x76, 0xe4, 0x97, 0x75, 0xfd, 0x6c, 0xb1, 0x5b, 0xe3, 0x76, 0x66,
1295 0xa3, 0xfd, 0xe1, 0x19, 0x1f, 0x64, 0xec, 0x3e, 0x2b, 0x4f, 0x47, 0xf5, 1301 0x0d, 0xff, 0xd0, 0x3f, 0x0b, 0xe5, 0x81, 0x91, 0xc6, 0xb3, 0x05, 0xca,
1296 0x5c, 0xec, 0x29, 0xaa, 0x98, 0x2b, 0xa7, 0x91, 0x86, 0xe7, 0xf8, 0xc3, 1302 0x02, 0xe8, 0x9f, 0xc2, 0x14, 0xee, 0x8d, 0x5a, 0x26, 0xe4, 0x25, 0x94,
1297 0x78, 0x7f, 0x49, 0xf6, 0xe0, 0xc9, 0x1d, 0xff, 0x02, 0x7e, 0x73, 0x6e, 1303 0x07, 0x6c, 0x47, 0x99, 0x50, 0x2b, 0x77, 0x28, 0x6b, 0x28, 0x7b, 0x28,
1298 0xca, 0x28, 0x87, 0xa7, 0x74, 0x02, 0x6f, 0x3c, 0xa5, 0x31, 0x2b, 0x47, 1304 0x4b, 0xcc, 0x7a, 0x8c, 0x3f, 0x48, 0x19, 0x7e, 0x2d, 0xfc, 0x53, 0xda,
1299 0xc6, 0xad, 0x1c, 0xe1, 0x9c, 0xde,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 0x59, 0xb9, 0x16, 0xef,
1314 0x09, 0x4d, 0xdf, 0xb4, 0xef, 0x7a, 0xc7, 0x22, 0x96, 0xee, 0xd6, 0xd5, 1320 0xf4, 0xf1, 0x29, 0xf3, 0xc8, 0x4f, 0x07, 0xc1, 0x13, 0xaa, 0xc1, 0xf0,
1315 0x48, 0xfd, 0xef, 0x42, 0xc7, 0xa6, 0xa1, 0x63, 0x1b, 0xa1, 0x83, 0x17, 1321 0x3e, 0x7d, 0x8d, 0x7a, 0xfc, 0x04, 0xfb, 0x0b, 0xbc, 0x72, 0x02, 0xb6,
1316 0xcb, 0x88, 0x35, 0x35, 0x4b, 0x65, 0x04, 0xeb, 0x24, 0xe1, 0x75, 0x1f, 1322 0xdb, 0xae, 0xe5, 0x3e, 0x20, 0x2b, 0xe3, 0x31, 0x39, 0x59, 0x68, 0x91,
1317 0x44, 0xbd, 0x90, 0xfe, 0xa2, 0x9a, 0xd6, 0x72, 0x92, 0x77, 0xb6, 0x57, 1323 0xb9, 0x82, 0x82, 0xc1, 0x60, 0x64, 0x67, 0x44, 0x12, 0x5a, 0xff, 0xd2,
1318 0x46, 0x9c, 0x1d, 0x95, 0xc5, 0x3a, 0x68, 0x8b, 0xe7, 0x8a, 0x81, 0xf5, 1324 0xbe, 0x1b, 0x9e, 0x8e, 0x58, 0xba, 0x83, 0xc3, 0xd2, 0xfc, 0x1b, 0xd0,
1319 0x91, 0x22, 0x6d, 0xd4, 0x64, 0x2a, 0x0b, 0x9c, 0xec, 0x00, 0xcc, 0xcf, 1325 0xb1, 0x65, 0xe8, 0xd8, 0x56, 0xe8, 0xe0, 0xd5, 0x32, 0xa2, 0xab, 0x61,
1320 0x8c, 0xc2, 0x4f, 0xa7, 0x5c, 0x06, 0xcc, 0xa7, 0x01, 0xf3, 0xc4, 0xa8, 1326 0xad, 0x8c, 0x60, 0x9b, 0x14, 0xbc, 0xf2, 0x83, 0x68, 0x17, 0xd2, 0x5f,
1321 0x13, 0xda, 0x06, 0xc2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xf5, 0x94, 0x93, 0x5e, 0x33, 0xaf, 0x5a,
1336 0x94, 0x49, 0xf3, 0xb4, 0x68, 0x7c, 0x97, 0x56, 0xf4, 0x55, 0x6d, 0xaf, 1342 0x9a, 0xa3, 0xbc, 0x8d, 0xca, 0x4e, 0xd0, 0xc9, 0xce, 0x15, 0xb4, 0xa6,
1337 0xbb, 0x32, 0x60, 0xe6, 0xfc, 0x30, 0xe7, 0x9c, 0xbe, 0x48, 0xfb, 0x03, 1343 0xdd, 0x10, 0x4b, 0xc7, 0xeb, 0xec, 0xfc, 0x0e, 0x18, 0xbe, 0xf1, 0x63,
1338 0x03, 0x96, 0xbf, 0x92, 0xa3, 0x79, 0x79, 0xbb, 0x1d, 0xfb, 0x1f, 0x2e, 1344 0xd0, 0x87, 0x94, 0x37, 0x37, 0x1b, 0xdf, 0x5c, 0x4e, 0x00, 0xd6, 0xf0,
1339 0x33, 0x77, 0x8d, 0x73, 0x73, 0x37, 0x50, 0x59, 0x3c, 0x46, 0x91, 0xb6, 1345 0x99, 0xb4, 0xc9, 0xdf, 0x94, 0x49, 0x55, 0x5a, 0x34, 0xbe, 0x4b, 0xa7,
1340 0x07, 0x58, 0xcf, 0x85, 0x8d, 0x94, 0x92, 0x5a, 0x9f, 0xf2, 0x93, 0xb6, 1346 0x8e, 0x9f, 0x56, 0xed, 0xf5, 0xa8, 0x8c, 0x9a, 0x35, 0x3f, 0xcc, 0x35,
1341 0x12, 0xd2, 0x27, 0xb6, 0x78, 0x4d, 0xf0, 0x01, 0x9e, 0x5e, 0x62, 0x77, 1347 0xa7, 0x2f, 0xd2, 0xfd, 0xc0, 0xa8, 0xe5, 0xaf, 0x54, 0x29, 0x27, 0xbb,
1342 0x25, 0xac, 0xdc, 0xa4, 0x1f, 0x1c, 0xf6, 0x91, 0xb7, 0x72, 0x32, 0x8f, 1348 0xed, 0xdc, 0xbf, 0x5c, 0x67, 0xed, 0x5a, 0x97, 0xd7, 0x6e, 0xb4, 0xb2,
1343 0xf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xad, 0x84, 0x22, 0x6c, 1356 0xc7, 0x6f, 0xc6, 0x59, 0x95, 0x85, 0x59, 0xdb, 0xb1, 0xb0, 0xeb, 0x56,
1351 0x81, 0x0c, 0x80, 0x97, 0x39, 0x07, 0x8a, 0xb6, 0xeb, 0xb6, 0xbf, 0xa8, 1357 0xdb, 0xb2, 0x9c, 0x03, 0xed, 0xd9, 0x46, 0x63, 0x0b, 0x16, 0x69, 0x7f,
1352 0x31, 0x31, 0xe4, 0xd5, 0xb5, 0x52, 0xcf, 0x3e, 0xc9, 0x7f, 0x7c, 0xaf, 1358 0x52, 0x76, 0xd1, 0xfe, 0x8c, 0x35, 0x4a, 0x33, 0xe7, 0x33, 0x68, 0xcb,
1353 0xd2, 0xf6, 0xef, 0x52, 0x59, 0x56, 0xad, 0x7b, 0xae, 0x9e, 0xc3, 0x5f, 1359 0x68, 0xa7, 0xae, 0x9e, 0xdf, 0x6a, 0xff, 0x91, 0x70, 0x12, 0x6e, 0x43,
1354 0xff, 0x82, 0x39, 0x0a, 0xf1, 0x17, 0xd2, 0x45, 0x35, 0x0e, 0x49, 0x13, 1360 0x5b, 0x49, 0x45, 0xd8, 0x02, 0x19, 0xf5, 0xaf, 0xd5, 0x6b, 0xa0, 0x68,
1355 0x86, 0x16, 0x0c, 0x2d, 0x6e, 0xb4, 0xfa, 0x26, 0xa4, 0xbd, 0xab, 0x40, 1361 0xbb, 0xee, 0xf8, 0x76, 0x83, 0x89, 0x31, 0x27, 0xd1, 0x3f, 0xc7, 0x24,
1356 0x7b, 0xf7, 0x81, 0xc6, 0x28, 0xc3, 0x19, 0x97, 0x5b, 0x8b, 0xef, 0x23, 1362 0xff, 0xf1, 0x4e, 0x3b, 0xbf, 0x9e, 0x2c, 0xab, 0xd5, 0x3d, 0x97, 0x2d,
1357 0xf8, 0x0e, 0xf9, 0xe4, 0x4a, 0x32, 0x9c, 0xf2, 0x9b, 0x75, 0xb2, 0x56, 1363 0xe3, 0x6f, 0xe7, 0x8a, 0x35, 0x0a, 0xf1, 0x17, 0xd2, 0x45, 0x2d, 0x0e,
1358 0xee, 0x87, 0x7e, 0x2e, 0xeb, 0x70, 0xdc, 0x94, 0xff, 0xff, 0x15, 0xed, 1364 0x49, 0x13, 0xa4, 0x85, 0x90, 0x16, 0xb7, 0x5a, 0x7d, 0x13, 0xd2, 0xde,
1359 0xac, 0xad, 0x35, 0xf6, 0xca, 0x8d, 0xb5, 0x94, 0xaf, 0x6b, 0xe4, 0x60, 1365 0xa5, 0xa0, 0xbd, 0xfb, 0x80, 0x27, 0xca, 0x70, 0xc6, 0xed, 0x36, 0xe3,
1360 0x55, 0xda, 0x95, 0xe4, 0x77, 0xf5, 0x98, 0xd7, 0xff, 0x3f, 0x18, 0x73, 1366 0xf9, 0x08, 0x9e, 0x43, 0x3e, 0xb9, 0x98, 0x0c, 0xa7, 0xfc, 0x66, 0x9b,
1361 0x7c, 0xd1, 0x98, 0x3d, 0x3b, 0xe6, 0x77, 0x21, 0xbf, 0xc9, 0xf8, 0x38, 1367 0x8c, 0x95, 0xfb, 0xa1, 0x9f, 0xcb, 0x36, 0x9c, 0x37, 0xe5, 0xff, 0x57,
1362 0x1e, 0xf9, 0x2e, 0x1c, 0xb3, 0xc5, 0x85, 0x1e, 0x57, 0xb5, 0x9c, 0x08, 1368 0xe9, 0x77, 0x35, 0x1a, 0x3b, 0xfd, 0x43, 0x8d, 0x94, 0xaf, 0x9b, 0xe4,
1363 0x65, 0x04, 0xc7, 0x35, 0x60, 0xc7, 0xf0, 0xb9, 0xaa, 0x71, 0x0d, 0xbc, 1369 0x60, 0x4d, 0xd9, 0xc5, 0xe4, 0x77, 0xed, 0x9c, 0x2f, 0xff, 0x7f, 0x30,
1364 0x89, 0x71, 0xb5, 0x2e, 0x18, 0xd7, 0xf6, 0x2b, 0x8e, 0x6b, 0x39, 0x1e, 1370 0xe7, 0xc4, 0xaa, 0x39, 0xbb, 0x76, 0xce, 0x15, 0xbc, 0x6f, 0xc3, 0xfb,
1365 0x27, 0x2f, 0x87, 0xe3, 0x8b, 0xca, 0xae, 0x22, 0xc7, 0xd8, 0x8f, 0x31, 1371 0x16, 0xea, 0x82, 0x64, 0x55, 0xde, 0x58, 0x5c, 0xe8, 0x79, 0xd5, 0xca,
1366 0x1e, 0xd4, 0xfe, 0x80, 0x19, 0x63, 0xda, 0x8e, 0x51, 0x54, 0xdb, 0xb6, 1372 0x89, 0x50, 0x46, 0x70, 0x5e, 0x1f, 0xb1, 0x73, 0x78, 0xa0, 0x66, 0x5e,
1367 0x7f, 0x8f, 0xdf, 0xd5, 0xe3, 0xa3, 0xee, 0xff, 0x3e, 0x68, 0xba, 0x4e, 1373 0x1f, 0x79, 0x13, 0xf3, 0xea, 0x5c, 0x31, 0xaf, 0x5d, 0x17, 0x9d, 0x57,
1368 0xb2, 0x5d, 0x75, 0x56, 0xfe, 0xdf, 0x24, 0x1f, 0x2e, 0x71, 0xae, 0x93, 1374 0x3d, 0x1e, 0x27, 0x2f, 0x87, 0xf3, 0x8b, 0xc9, 0x8d, 0x05, 0xce, 0x71,
1369 0x19, 0x91, 0x51, 0xe8, 0xe0, 0xff, 0x5c, 0xcb, 0xd8, 0xfd, 0xf6, 0x94, 1375 0x27, 0xe6, 0x48, 0x18, 0xc2, 0x39, 0x0e, 0xd9, 0x39, 0x8a, 0xea, 0xda,
1370 0xd5, 0x63, 0xd0, 0x17, 0x3b, 0x60, 0xf3, 0xf5, 0x17, 0x55, 0x77, 0x44, 1376 0xf1, 0x73, 0xf8, 0x5d, 0x3b, 0x3f, 0xea, 0xfe, 0x1f, 0x83, 0xa6, 0x9b,
1371 0x82, 0xe0, 0xb6, 0xd4, 0xa7, 0xd1, 0xf7, 0x7e, 0xed, 0xab, 0x2e, 0x8d, 1377 0x24, 0xd3, 0xdf, 0x64, 0xe5, 0xff, 0x97, 0xe5, 0xd6, 0x22, 0xd7, 0x3a,
1372 0x9b, 0x3f, 0x57, 0x2b, 0x3e, 0xed, 0x0d, 0xea, 0x73, 0xe8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 0xf2, 0x03, 0xea, 0x36, 0xd8, 0x3a, 0xb7, 0x9d,
1380 0xab, 0x42, 0xfd, 0xb4, 0xca, 0xc6, 0x8d, 0x8c, 0x0d, 0x78, 0x65, 0xda, 1386 0xbc, 0x41, 0xed, 0x83, 0x6d, 0xb3, 0x0f, 0x76, 0xce, 0xbe, 0x0a, 0x6d,
1381 0x22, 0x8d, 0x78, 0xc0, 0x33, 0xf1, 0x47, 0xda, 0xaa, 0x1e, 0x7f, 0x63, 1387 0xcf, 0x9b, 0x41, 0x7b, 0x9d, 0x35, 0xb4, 0x46, 0x1b, 0x87, 0xf3, 0x23,
1382 0x9d, 0xf8, 0x2b, 0xeb, 0xa4, 0xfe, 0x73, 0x90, 0xaf, 0xd5, 0x34, 0xc5, 1388 0xee, 0x8f, 0x71, 0x0d, 0xfc, 0xa4, 0x7a, 0x45, 0xaf, 0x4b, 0xdb, 0x8a,
1383 0xb7, 0x67, 0x75, 0x0d, 0x69, 0x8b, 0x32, 0x38, 0xa4, 0x87, 0x8d, 0xaf, 1389 0xb2, 0xd7, 0x92, 0x55, 0xa1, 0x7e, 0xda, 0x60, 0xe3, 0x46, 0x94, 0xb7,
1384 0x23, 0x7f, 0xaf, 0x48, 0x4f, 0xfb, 0xb9, 0x2e, 0xb3, 0xbb, 0x5b, 0x56, 1390 0xaf, 0x45, 0x5b, 0xa4, 0x11, 0x17, 0x78, 0x26, 0xfe, 0x48, 0x5b, 0xb5,
1385 0x33, 0x1e, 0x90, 0xad, 0xcc, 0xc7, 0x04, 0x94, 0x5f, 0x1d, 0x13, 0xa0, 1391 0xf3, 0xdf, 0xd4, 0x24, 0x5e, 0x67, 0x93, 0x34, 0xdf, 0x0b, 0xf9, 0x5a,
1386 0x9f, 0xf5, 0x01, 0xe0, 0xec, 0x16, 0x3c, 0xfb, 0x64, 0x88, 0x71, 0x87, 1392 0x4b, 0x53, 0xbc, 0xbb, 0x56, 0xd7, 0x90, 0xb6, 0x28, 0x83, 0x43, 0x7a,
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 0x4f, 0x39, 0x3a, 0x76, 0x6c, 1400 0x8f, 0xf1, 0xf9, 0x07, 0x7c, 0xd2, 0xfa, 0x7b, 0x24, 0xbd, 0x1c, 0x9f,
1395 0x74, 0x6d, 0xa9, 0xce, 0xd8, 0xae, 0x8e, 0x8e, 0xff, 0xce, 0x80, 0xfa, 1401 0x17, 0xd0, 0x9b, 0xf8, 0x91, 0x21, 0xbd, 0xdf, 0xe6, 0xce, 0xca, 0x6e,
1396 0x66, 0xb4, 0x7d, 0xab, 0xb4, 0xfe, 0x9d, 0xd6, 0x65, 0x46, 0xeb, 0xc2, 1402 0x19, 0x8e, 0x33, 0xd6, 0xc9, 0x78, 0x9e, 0x97, 0x9b, 0x05, 0x0f, 0x4c,
1397 0x38, 0xe6, 0x8c, 0x17, 0xb1, 0xe5, 0xaa, 0xd3, 0xa7, 0xea, 0x42, 0x5b, 1403 0x16, 0x15, 0x2c, 0xf8, 0x46, 0x19, 0x73, 0x03, 0xd9, 0xe5, 0x3b, 0x3a,
1398 0xb0, 0x50, 0x09, 0xd3, 0x9e, 0x5c, 0x26, 0xed, 0x85, 0x65, 0xd2, 0xfe, 1404 0x76, 0x6c, 0x74, 0xed, 0x4c, 0x93, 0xb1, 0x5d, 0x1d, 0x1d, 0xff, 0x5d,
1399 0x76, 0x99, 0x34, 0x13, 0x17, 0xec, 0x2f, 0x5e, 0x46, 0xde, 0x88, 0xe6, 1405 0x04, 0xf5, 0x2d, 0x6a, 0xfb, 0x56, 0x69, 0xfd, 0xbb, 0xa0, 0xeb, 0x7c,
1400 0x55, 0x69, 0x36, 0xf6, 0x75, 0x7e, 0xae, 0xcc, 0x2a, 0xeb, 0x97, 0x31, 1406 0xae, 0x29, 0x8c, 0x63, 0x2e, 0xba, 0x11, 0x5b, 0xaf, 0xb6, 0xfc, 0x8b,
1401 0x46, 0x6c, 0x62, 0xc3, 0x39, 0x1d, 0x1b, 0xde, 0xe2, 0x6d, 0x53, 0x8c, 1407 0x36, 0x3e, 0x9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d, 0xb5, 0x7b, 0xda,
1409 0xa7, 0xed, 0x12, 0x79, 0x66, 0x4e, 0x16, 0x6f, 0x84, 0xcd, 0x24, 0x41, 1415 0xf8, 0x83, 0xfb, 0xc0, 0x57, 0x69, 0x21, 0x8c, 0x29, 0x5f, 0x84, 0x36,
1410 0xb6, 0x5b, 0x5a, 0x23, 0xa2, 0x63, 0x3c, 0x29, 0x23, 0x9b, 0x3b, 0xb8, 1416 0xf1, 0x5a, 0x5b, 0xf8, 0xb5, 0xfb, 0xfb, 0xa5, 0x8b, 0xf4, 0xe7, 0xc0,
1411 0xb6, 0x03, 0xfa, 0x37, 0xb6, 0x8a, 0x89, 0x9b, 0x86, 0x76, 0xca, 0x72, 1417 0x76, 0x78, 0xa3, 0xfd, 0x35, 0xcb, 0xc8, 0x74, 0x88, 0x2b, 0xf5, 0x33,
1412 0xb4, 0x7b, 0xbd, 0xa5, 0x5d, 0xae, 0xa9, 0xee, 0xa0, 0xcc, 0xc5, 0x9c, 1418 0xb6, 0x8b, 0x5c, 0xa4, 0x9d, 0xb6, 0x4b, 0xe4, 0xe9, 0x65, 0x59, 0xbc,
1413 0x18, 0x3a, 0xde, 0x5e, 0x94, 0x44, 0x48, 0xc7, 0x33, 0xf0, 0x8b, 0xab, 1419 0x15, 0x36, 0x93, 0x04, 0x99, 0x01, 0xe9, 0x8c, 0x88, 0x8e, 0xf1, 0xf8,
1414 0xe9, 0x78, 0x46, 0x52, 0x9a, 0x8e, 0x6b, 0x17, 0xd0, 0x71, 0xab, 0xa5, 1420 0x46, 0x36, 0xf7, 0x70, 0x6f, 0x07, 0xf4, 0x6f, 0x6c, 0x15, 0x13, 0x37,
1415 0xe3, 0x77, 0x44, 0x0d, 0x5d, 0x28, 0xad, 0xa7, 0x48, 0xa7, 0x86, 0x8e, 1421 0x0d, 0xed, 0x94, 0x7a, 0xb4, 0x7b, 0x9d, 0xa5, 0x5d, 0xee, 0xb9, 0xee,
1416 0x1d, 0x4d, 0xc7, 0x33, 0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a5, 1429 0xd6, 0x79, 0x2d, 0xfa, 0x6c, 0xb6, 0xfb, 0x16, 0x71, 0xbd, 0x2f, 0x9f,
1424 0xab, 0x65, 0x76, 0x37, 0x74, 0x05, 0x6d, 0x6c, 0x2d, 0xa7, 0x91, 0xd7, 1430 0x8e, 0x1b, 0x5a, 0xbd, 0x45, 0xcf, 0x9d, 0xf3, 0x3e, 0xfb, 0x06, 0x68,
1425 0x9a, 0xc8, 0x16, 0xff, 0xd9, 0xee, 0x5f, 0xe0, 0xba, 0x80, 0x0c, 0x39, 1431 0xd5, 0xac, 0xcd, 0xb9, 0xaa, 0xbf, 0xcd, 0x58, 0x54, 0xd2, 0xc4, 0xb0,
1426 0x48, 0x6b, 0x2b, 0x9b, 0x71, 0x29, 0xbf, 0x11, 0xdf, 0xdd, 0xd2, 0x56, 1432 0x19, 0x27, 0xbd, 0x98, 0xed, 0x68, 0xe4, 0x53, 0x83, 0x96, 0x4f, 0xad,
1427 0x56, 0x72, 0xfb, 0x58, 0x83, 0xec, 0x2b, 0xba, 0xf2, 0x51, 0xd4, 0xff, 1433 0x63, 0xcc, 0x35, 0xa8, 0xca, 0xec, 0x01, 0xe8, 0x0a, 0xda, 0xd8, 0x5a,
1428 0x48, 0xd1, 0x83, 0x3f, 0x3e, 0x1e, 0xa5, 0x5d, 0xb8, 0xb7, 0xc8, 0xf5, 1434 0x4e, 0xe3, 0x5d, 0x67, 0x32, 0x53, 0x78, 0x35, 0x88, 0x78, 0x8c, 0x0f,
1429 0x49, 0xc7, 0xac, 0x19, 0x2d, 0x58, 0xf3, 0x8c, 0x48, 0x5b, 0x47, 0x01, 1435 0x71, 0x5f, 0x40, 0xc6, 0x1c, 0x94, 0x75, 0x95, 0xcd, 0xbc, 0x94, 0xd7,
1430 0x9e, 0x8a, 0xb8, 0x3b, 0x01, 0x47, 0x5d, 0x3a, 0x2d, 0xaf, 0x74, 0x0f, 1436 0x8a, 0xe7, 0x01, 0xe9, 0x2a, 0x2b, 0xf9, 0xe8, 0x74, 0x8b, 0xec, 0x2f,
1431 0x38, 0xda, 0x97, 0x70, 0x7a, 0xe4, 0xc6, 0x4a, 0x5a, 0x6e, 0xa8, 0x98, 1437 0x44, 0xe5, 0xe3, 0x68, 0xff, 0xb1, 0x82, 0x0b, 0x7f, 0xfc, 0x4c, 0x8c,
1432 0x75, 0xd2, 0xf9, 0x75, 0xd0, 0xa4, 0x37, 0x0d, 0x9d, 0x93, 0xf1, 0x82, 1438 0x76, 0xe1, 0xbe, 0x02, 0xf7, 0x27, 0x59, 0x37, 0xbe, 0x6a, 0x7f, 0x36,
1433 0xe0, 0x3c, 0xe4, 0xb7, 0x3a, 0xe2, 0x4a, 0xb4, 0x23, 0x19, 0x9f, 0x16, 1439 0x22, 0x5d, 0x3d, 0x79, 0x78, 0x2a, 0x12, 0xdd, 0x03, 0x38, 0x9a, 0x86,
1434 0xf3, 0x7d, 0xb1, 0xfc, 0xe3, 0x60, 0x28, 0xe6, 0xca, 0x2b, 0x3e, 0xc7, 1440 0x86, 0xe4, 0x07, 0x03, 0x1b, 0x51, 0xf6, 0xb2, 0x1d, 0x6f, 0xd4, 0x31,
1435 0xd5, 0x23, 0xd7, 0x97, 0xab, 0xfb, 0xe3, 0x5a, 0xe9, 0x13, 0x51, 0xae, 1441 0xf1, 0xde, 0x41, 0x79, 0x77, 0x65, 0x48, 0xae, 0xaf, 0x98, 0x3d, 0xd5,
1436 0x4d, 0x64, 0x2b, 0xe5, 0x28, 0xe3, 0xe7, 0x22, 0x79, 0x69, 0x7b, 0x2b, 1442 0xea, 0x9e, 0x69, 0xca, 0x5d, 0x80, 0xfe, 0x49, 0xbb, 0x41, 0x70, 0xce,
1437 0x7c, 0x37, 0x48, 0xeb, 0xb6, 0xb7, 0x82, 0x56, 0x62, 0xd0, 0xf3, 0x5b, 1443 0xc3, 0xaa, 0x1f, 0x89, 0x4a, 0xac, 0x27, 0x95, 0x58, 0x10, 0xf3, 0x7c,
1438 0x01, 0xd7, 0x56, 0xc6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, 0x19, 1451 0x27, 0x86, 0xc5, 0x38, 0x20, 0xd1, 0xdd, 0xdb, 0x07, 0x65, 0x04, 0xf3,
1446 0x8a, 0xa4, 0x33, 0x1a, 0xff, 0xf8, 0x4e, 0xe4, 0xca, 0xdd, 0x98, 0x3b, 1452 0xdb, 0xb9, 0x66, 0x7e, 0xf7, 0x08, 0xe3, 0xab, 0xe7, 0x0b, 0x9c, 0x43,
1447 0x71, 0x73, 0x5d, 0xae, 0xe6, 0x8d, 0x9c, 0xdf, 0x6d, 0xd7, 0xad, 0x42, 1453 0x75, 0x5e, 0xea, 0x0b, 0x66, 0x5e, 0xb1, 0x9e, 0xd5, 0xf3, 0xd1, 0xed,
1448 0xbf, 0x29, 0x08, 0x94, 0xbf, 0x58, 0x56, 0x50, 0x47, 0x61, 0xec, 0xb2, 1454 0xd5, 0x09, 0xc0, 0xf2, 0x35, 0x9d, 0x57, 0x10, 0x04, 0x6f, 0xed, 0x39,
1449 0xdb, 0xee, 0x4b, 0x49, 0x31, 0x6e, 0x38, 0xe4, 0xa6, 0xa3, 0x89, 0x42, 1455 0x1f, 0x24, 0x2f, 0x49, 0xf5, 0x2e, 0x54, 0xf7, 0x77, 0xc6, 0x22, 0x43,
1450 0xb9, 0x0b, 0xbf, 0x1b, 0xf0, 0xfe, 0x45, 0xd8, 0x28, 0x3d, 0xb0, 0x61, 1456 0x69, 0xad, 0xcf, 0xf0, 0x9c, 0xcc, 0x96, 0xd3, 0x58, 0x47, 0x89, 0x66,
1451 0x24, 0xa6, 0x8c, 0x3c, 0x00, 0xfd, 0x76, 0xe4, 0x95, 0x22, 0x3f, 0x7a, 1457 0xfb, 0xa3, 0x9a, 0x4f, 0xb2, 0x5e, 0xda, 0xee, 0x61, 0x85, 0x3e, 0x54,
1452 0x89, 0xe1, 0x72, 0x2c, 0x31, 0x5a, 0xde, 0xcb, 0xfa, 0x28, 0x7b, 0xa5, 1458 0x10, 0x28, 0x6f, 0xb5, 0xdc, 0xa0, 0xbe, 0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x40, 0x4e, 0x42, 1473 0x10, 0xfc, 0xd8, 0x37, 0x6b, 0x3a, 0x55, 0x94, 0x29, 0x8c, 0x9b, 0xdb,
1468 0x86, 0xcd, 0x68, 0xba, 0xc9, 0xae, 0xe7, 0xff, 0x11, 0xf9, 0xe4, 0x0a, 1474 0xac, 0x88, 0x87, 0x58, 0xf2, 0x0e, 0x8c, 0xfd, 0x29, 0x8c, 0xbd, 0xbf,
1469 0xc6, 0x94, 0x7b, 0x7d, 0xda, 0xab, 0xb3, 0xc1, 0x8c, 0x4f, 0x99, 0xbc, 1475 0xcc, 0xf1, 0x20, 0x2b, 0x30, 0xf7, 0xa9, 0x4a, 0x08, 0x6f, 0xbd, 0xb1,
1470 0x4a, 0xc6, 0xbd, 0x7c, 0x27, 0xf4, 0x03, 0xd2, 0x1a, 0xe9, 0x63, 0x27, 1476 0xc3, 0x35, 0xef, 0xb5, 0x36, 0x5e, 0xf8, 0xac, 0x11, 0xd9, 0xae, 0xbc,
1471 0xb2, 0x91, 0x64, 0x62, 0x58, 0xb8, 0xc7, 0x89, 0xfb, 0x13, 0xb8, 0xef, 1477 0x7e, 0xd0, 0xd7, 0xe2, 0xa6, 0xa8, 0xfc, 0x22, 0xe4, 0x6e, 0x20, 0x8f,
1472 0x87, 0xf2, 0xc0, 0x85, 0x9c, 0xe3, 0x1c, 0x9a, 0xfe, 0x86, 0xcb, 0xf3, 1478 0x42, 0x9e, 0x2d, 0x6a, 0xba, 0xc9, 0x5c, 0xce, 0xff, 0x23, 0xf2, 0xeb,
1473 0x65, 0x0f, 0x08, 0xd7, 0x09, 0x93, 0xf1, 0xbd, 0xda, 0x26, 0x01, 0xd5, 1479 0xeb, 0x18, 0x5f, 0x1e, 0xf6, 0x68, 0xbb, 0x2e, 0x05, 0x8b, 0x1e, 0xe5,
1474 0x15, 0x59, 0x76, 0x33, 0x2c, 0x12, 0xbf, 0xaa, 0xbc, 0xde, 0x73, 0x05, 1480 0xf3, 0x06, 0x99, 0x71, 0x73, 0xbd, 0xd0, 0x15, 0x28, 0x6b, 0xa5, 0xbf,
1475 0x3e, 0x67, 0x1c, 0x21, 0x1a, 0xcd, 0x16, 0xe5, 0xb5, 0x48, 0xb7, 0xbc, 1481 0x9d, 0xcc, 0x44, 0x52, 0xc9, 0x49, 0x61, 0x3e, 0x14, 0x73, 0x15, 0x98,
1476 0x96, 0x4d, 0xd5, 0x4b, 0xaf, 0x96, 0xf9, 0xcc, 0xd3, 0xe9, 0xb3, 0x26, 1482 0x23, 0x44, 0xd9, 0x10, 0x85, 0xcc, 0xe3, 0x1a, 0x9a, 0xf1, 0x26, 0xcb,
1477 0xdd, 0x85, 0x2e, 0xe1, 0x9c, 0xf4, 0x40, 0x46, 0x4f, 0x00, 0x6e, 0xe2, 1483 0xd5, 0xba, 0x07, 0x84, 0x7b, 0x86, 0xa9, 0xc4, 0x3e, 0x6d, 0x9f, 0x88,
1478 0xb0, 0x87, 0x32, 0x89, 0xf3, 0xa7, 0x54, 0x3a, 0x16, 0xcd, 0x95, 0xa5, 1484 0x8c, 0x17, 0x58, 0x77, 0x3b, 0xac, 0x13, 0xaf, 0xa6, 0xbe, 0xce, 0xe1,
1479 0x2f, 0x57, 0xb4, 0xb1, 0x9e, 0x01, 0x8e, 0x7f, 0x95, 0xc5, 0x43, 0xa3, 1485 0x02, 0x9f, 0x87, 0x71, 0xac, 0x58, 0x2c, 0x53, 0x90, 0x97, 0x23, 0x03,
1480 0xb8, 0x80, 0xad, 0x2f, 0x92, 0x70, 0xe0, 0x2b, 0x43, 0xd7, 0x3f, 0xba, 1486 0xf2, 0x32, 0xed, 0xce, 0x61, 0xd0, 0xb6, 0xeb, 0xf1, 0xbd, 0x29, 0xcf,
1481 0x4a, 0x1a, 0x89, 0x9b, 0x1e, 0xf0, 0x52, 0x0d, 0x74, 0xd1, 0xfd, 0xcd, 1487 0xf8, 0xb2, 0x94, 0x19, 0xec, 0xa3, 0x9d, 0x9d, 0x53, 0x9a, 0x27, 0x44,
1482 0x5c, 0x37, 0xd5, 0x36, 0x64, 0xec, 0x63, 0xbf, 0xac, 0xd2, 0x7f, 0x1b, 1488 0xa1, 0x6d, 0x2c, 0x5b, 0x96, 0x91, 0x6c, 0xc1, 0xc6, 0x7a, 0x46, 0x39,
1483 0x57, 0xe9, 0x51, 0x2b, 0x2f, 0xa3, 0x7d, 0x94, 0x97, 0x4f, 0x97, 0x08, 1489 0xe7, 0x0d, 0x35, 0x73, 0x6f, 0x95, 0x28, 0x60, 0x1a, 0x89, 0x24, 0x9d,
1484 0x8f, 0x78, 0x11, 0x3f, 0xd1, 0xd7, 0x5b, 0x16, 0x15, 0x49, 0x7b, 0xd1, 1490 0x06, 0xef, 0x23, 0x2d, 0x46, 0xe7, 0x43, 0xee, 0xb7, 0xdd, 0xdf, 0xce,
1485 0xde, 0xf2, 0x42, 0xfa, 0x7f, 0xba, 0xf2, 0x61, 0x6b, 0x0b, 0x56, 0xc7, 1491 0x3d, 0x53, 0x05, 0x1f, 0x5a, 0xb5, 0xdf, 0x7e, 0x8d, 0x1a, 0xfa, 0xf3,
1486 0x54, 0xab, 0xf3, 0xc8, 0x83, 0xcb, 0xe5, 0x11, 0x26, 0x89, 0xae, 0x48, 1492 0x04, 0xf4, 0xa0, 0x95, 0x95, 0xb1, 0x91, 0xae, 0x65, 0xfa, 0xe6, 0xf8,
1487 0x5f, 0xf8, 0x54, 0x7b, 0x47, 0xde, 0xab, 0x15, 0xe2, 0x39, 0x80, 0xdc, 1493 0xd2, 0x1e, 0xf1, 0x92, 0x23, 0xc3, 0x65, 0x51, 0x91, 0x21, 0x37, 0x36,
1488 0x06, 0xae, 0xcb, 0x5c, 0xaf, 0xde, 0x8f, 0x79, 0xfb, 0x3f, 0x41, 0x26, 1494 0x5c, 0x5e, 0x49, 0xf3, 0x4f, 0x55, 0xfe, 0xbd, 0xb5, 0x05, 0x6b, 0x63,
1489 0xc6, 0x7c, 0x4f, 0xea, 0xe0, 0xdb, 0xbe, 0x0c, 0xdd, 0xf9, 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6d, 0xb4, 0x6d, 0x47, 0xef, 0x78, 0x73, 0x6d,
1497 0xee, 0x85, 0xcf, 0xbc, 0xb9, 0x7e, 0x07, 0xb8, 0xc7, 0x0e, 0x3e, 0x80, 1503 0x5b, 0xd1, 0x36, 0x16, 0x8e, 0xfb, 0x06, 0xdb, 0x6a, 0x7c, 0x5e, 0x33,
1498 0xb8, 0x11, 0xff, 0x36, 0xfc, 0xbe, 0x85, 0xed, 0x28, 0xda, 0xf7, 0x23, 1504 0x5c, 0x28, 0x2e, 0xc1, 0x4f, 0x4e, 0x4c, 0x48, 0xda, 0x19, 0x1f, 0xd0,
1499 0x95, 0x21, 0x19, 0xae, 0xec, 0xc4, 0x33, 0x88, 0xb4, 0x3e, 0x3c, 0xfb, 1505 0xf3, 0xb9, 0x66, 0xb8, 0x0c, 0x38, 0xe2, 0x41, 0x90, 0xf7, 0x43, 0x3d,
1500 0xf0, 0x3b, 0x8d, 0x47, 0xa2, 0x6e, 0xfa, 0xc2, 0x5d, 0xc3, 0x7e, 0x88, 1506 0xcc, 0x7f, 0xc7, 0x44, 0x3c, 0x96, 0x71, 0xdf, 0x92, 0xfe, 0x04, 0xa3,
1501 0x57, 0xae, 0xcd, 0xb3, 0x0f, 0xd8, 0x17, 0x5d, 0x3f, 0x41, 0x1f, 0x61, 1507 0xa4, 0x2e, 0xf3, 0xd9, 0x24, 0xcf, 0xfd, 0xc9, 0xf8, 0x46, 0xdc, 0x55,
1502 0xfa, 0x07, 0x50, 0x67, 0x1a, 0x69, 0x2b, 0x69, 0x7b, 0x62, 0xae, 0xab, 1508 0x17, 0x71, 0x92, 0xf5, 0x18, 0xef, 0xdd, 0x68, 0xcb, 0x23, 0x2c, 0x4f,
1503 0xeb, 0x54, 0xc3, 0x36, 0x1d, 0xce, 0x05, 0xf2, 0x0d, 0x8d, 0xf6, 0x16, 1509 0x45, 0x21, 0x4b, 0x4c, 0x79, 0xc4, 0x96, 0x03, 0x26, 0x3f, 0x9f, 0x04,
1504 0x43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, 0x6d, 0x1c, 0xfe, 0x7b, 0x59, 1517 0x84, 0x5c, 0xda, 0xed, 0xc1, 0xbd, 0x76, 0xbe, 0xdf, 0xc2, 0x7c, 0x7f,
1512 0xc4, 0x67, 0x1a, 0xdb, 0x0b, 0xde, 0x55, 0xe3, 0x2f, 0x59, 0x63, 0xc1, 1518 0xad, 0x59, 0x9a, 0x59, 0x5e, 0x5b, 0xb7, 0x51, 0xf6, 0xb8, 0xdb, 0xdd,
1513 0x38, 0xf3, 0x49, 0x68, 0x30, 0xaf, 0x4f, 0xcb, 0xe9, 0xfc, 0x35, 0x35, 1519 0xd8, 0x8a, 0xba, 0xe7, 0x51, 0x97, 0x65, 0x9e, 0xcb, 0x1c, 0x9d, 0xd9,
1514 0xd2, 0xe0, 0xf5, 0xeb, 0xdf, 0x2c, 0xd3, 0xe0, 0x81, 0x4f, 0x17, 0x95, 1520 0x32, 0xe9, 0xcc, 0xc0, 0xda, 0xd5, 0x13, 0x04, 0xd7, 0xf9, 0x1c, 0x37,
1515 0x61, 0x1a, 0xf3, 0x0a, 0x6b, 0x94, 0xde, 0xab, 0xa4, 0xf7, 0x28, 0xc9, 1521 0x08, 0xae, 0xf7, 0xfb, 0xdc, 0x67, 0xe5, 0xf9, 0xc0, 0xd8, 0x54, 0x21,
1516 0x83, 0xa9, 0x64, 0x62, 0x48, 0x25, 0xbd, 0x71, 0xd9, 0x0f, 0xb9, 0x43, 1522 0xed, 0x3c, 0x67, 0xe5, 0x75, 0x10, 0xbc, 0xec, 0xf7, 0xca, 0xef, 0x54,
1517 0x39, 0x39, 0x73, 0x7f, 0x44, 0xb8, 0x9f, 0xef, 0x5d, 0x92, 0xf5, 0x29, 1523 0x52, 0x8f, 0xd3, 0xe7, 0x3e, 0x83, 0xe7, 0x33, 0xbe, 0xc9, 0x2b, 0xfa,
1518 0x3f, 0x0b, 0x9f, 0x57, 0x94, 0x75, 0x95, 0x97, 0x1a, 0xcc, 0xd8, 0xb8, 1524 0x13, 0xb4, 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, 0xe0, 0xf3, 0x6a, 0x90, 0x8f, 0x31, 0xa6, 1539 0x1a, 0xf4, 0x7d, 0x0e, 0xfe, 0x78, 0x93, 0x3c, 0x08, 0x9a, 0x56, 0x03,
1534 0xf5, 0xbf, 0xeb, 0xad, 0x9d, 0xac, 0x79, 0x7f, 0x58, 0xef, 0x93, 0x79, 1540 0xa9, 0xe4, 0x82, 0x4a, 0xf5, 0xce, 0xa8, 0x94, 0x3f, 0xa6, 0xae, 0xe7,
1535 0xfe, 0x33, 0x59, 0xae, 0x77, 0xc0, 0x36, 0xc9, 0x69, 0xb9, 0x18, 0xfd, 1541 0xbc, 0x06, 0x89, 0x8b, 0x19, 0xe2, 0xb7, 0x08, 0xfc, 0x17, 0x81, 0xe3,
1536 0x69, 0x0e, 0xf0, 0x14, 0x2a, 0xb4, 0x43, 0xfe, 0x06, 0x76, 0x88, 0xd6, 1542 0x8b, 0xee, 0xf1, 0xfa, 0x56, 0xb7, 0x18, 0xfd, 0x96, 0xd3, 0xb4, 0x69,
1537 0x93, 0xf2, 0xed, 0x41, 0xe6, 0xb1, 0xdd, 0xec, 0xd5, 0xae, 0xd6, 0x0b, 1543 0xec, 0xf2, 0x3f, 0xf6, 0xc3, 0x35, 0x84, 0x6d, 0xc8, 0x1c, 0x99, 0xba,
1538 0x21, 0x2c, 0xc9, 0xce, 0x1c, 0xf2, 0x47, 0xb4, 0x1d, 0xef, 0xc9, 0xac, 1544 0x6b, 0x94, 0xe5, 0x1a, 0x41, 0x31, 0xe4, 0x40, 0xf7, 0xa9, 0xe4, 0x84,
1539 0xe7, 0xea, 0x7d, 0x27, 0xf9, 0xc1, 0x20, 0x78, 0xc5, 0x77, 0xe5, 0xa4, 1545 0x5a, 0x0a, 0x36, 0xed, 0xe8, 0xee, 0x7d, 0x42, 0xf7, 0x93, 0xf2, 0xd3,
1540 0x86, 0xf9, 0x05, 0xf4, 0xe1, 0xc8, 0xc4, 0x80, 0xfb, 0xd3, 0x93, 0x3e, 1546 0x2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x3f, 0xa1, 0x7f, 0x5b, 1568 0x4b, 0xff, 0x24, 0x66, 0xf3, 0x98, 0x15, 0x9e, 0x37, 0x58, 0xfe, 0x72,
1563 0x44, 0x3a, 0xe9, 0x41, 0x35, 0x45, 0xf4, 0x3e, 0x2d, 0x7e, 0x47, 0x61, 1569 0x25, 0xaf, 0xfd, 0xb7, 0x2f, 0xad, 0x37, 0x7c, 0x1a, 0xb5, 0xf9, 0x6b,
1564 0xf7, 0x06, 0x42, 0x9f, 0x8f, 0x36, 0x5d, 0xc6, 0xe3, 0xda, 0x50, 0x98, 1570 0xfc, 0xdd, 0xb1, 0xde, 0xee, 0xef, 0xe7, 0xd2, 0xf2, 0xfb, 0xeb, 0x69,
1565 0xe7, 0x21, 0x4f, 0x6d, 0x8a, 0xc0, 0x26, 0xaa, 0xf5, 0x1d, 0x1d, 0xa3, 1571 0x97, 0x34, 0x78, 0x43, 0xab, 0xca, 0x62, 0x28, 0xbb, 0x7d, 0xbd, 0x95,
1566 0x2e, 0xe8, 0x75, 0x00, 0xc6, 0xdf, 0x32, 0xf0, 0x63, 0x02, 0xe9, 0x47, 1572 0x0b, 0x28, 0xbb, 0x07, 0x7e, 0x1a, 0xf3, 0x34, 0xf8, 0x8e, 0x32, 0xb8,
1567 0xdf, 0xa4, 0xfd, 0x68, 0x87, 0xef, 0x1d, 0x10, 0xee, 0x67, 0x65, 0x7a, 1573 0x16, 0x27, 0x7d, 0x60, 0x45, 0xf2, 0x3c, 0xe5, 0x22, 0x6d, 0x4a, 0xcc,
1568 0xbb, 0xf7, 0x6d, 0x99, 0xa7, 0xf3, 0x19, 0x49, 0x66, 0x94, 0x03, 0xff, 1574 0x51, 0x7d, 0x27, 0x8c, 0xa3, 0xe3, 0x77, 0x3d, 0xdb, 0x9f, 0xf8, 0x26,
1569 0x75, 0xab, 0x23, 0xf5, 0xb0, 0x3d, 0x6e, 0x30, 0xfa, 0xcd, 0xe3, 0x9e, 1575 0xae, 0xe5, 0xdb, 0x53, 0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 0x47, 0x7b, 0xd5, 0x44, 0x03, 0x79, 1619 0xeb, 0x05, 0xf2, 0xb0, 0x3f, 0x08, 0x1a, 0xea, 0x85, 0xbd, 0xe7, 0x69,
1614 0x70, 0xdb, 0x19, 0xd0, 0xd7, 0x36, 0x8c, 0xa9, 0x2b, 0x79, 0x76, 0x46, 1620 0xbf, 0xf4, 0xb4, 0xa6, 0x2d, 0xd2, 0x58, 0x8b, 0xce, 0xd7, 0x7f, 0xd4,
1615 0x65, 0x4e, 0xac, 0x95, 0x57, 0x82, 0xa1, 0x66, 0x47, 0x9e, 0xd8, 0xc4, 1621 0x77, 0x62, 0x99, 0xfe, 0x3f, 0x32, 0x71, 0x1a, 0xbf, 0xdb, 0xfd, 0x1a,
1616 0x3c, 0x2d, 0xb7, 0x3f, 0xd5, 0x0b, 0xf9, 0xd4, 0xce, 0x73, 0x0b, 0x03, 1622 0xf8, 0x76, 0xa7, 0xb7, 0x05, 0x3e, 0x0a, 0x69, 0x88, 0xf1, 0xaf, 0xcb,
1617 0xf2, 0x2f, 0x77, 0x80, 0x06, 0x7f, 0xb8, 0xe9, 0x6b, 0xc1, 0x6c, 0xb3, 1623 0x75, 0x1e, 0x21, 0x03, 0x68, 0x33, 0x51, 0xc6, 0x09, 0x53, 0x83, 0x63,
1618 0x2b, 0x5b, 0x37, 0x25, 0xbd, 0xbc, 0xc2, 0x78, 0x4a, 0x18, 0x4f, 0x09, 1624 0xc2, 0x79, 0xa7, 0x12, 0x49, 0xa5, 0xed, 0xaa, 0xe0, 0x46, 0x9f, 0x39,
1619 0xe3, 0xe3, 0x98, 0x4b, 0x18, 0xd7, 0x15, 0xf7, 0x4a, 0xf5, 0x2c, 0x88, 1625 0xb6, 0xdc, 0x63, 0x21, 0x3f, 0xef, 0xff, 0xf4, 0x94, 0x97, 0x73, 0x23,
1620 0xcb, 0x1a, 0x3f, 0x2d, 0x93, 0x77, 0x65, 0x83, 0xdd, 0x2b, 0x35, 0x5c, 1626 0x36, 0x2f, 0x37, 0x53, 0x30, 0xb4, 0x39, 0x41, 0xda, 0x84, 0x3f, 0xb5,
1621 0x1f, 0xae, 0xb1, 0x65, 0x64, 0x3c, 0x28, 0xf8, 0x7f, 0x70, 0x55, 0xb6, 1627 0xd8, 0xff, 0xb7, 0x01, 0xed, 0xfb, 0xa4, 0x22, 0xed, 0xff, 0x4d, 0x30,
1622 0x2b, 0xb6, 0x58, 0xe7, 0xdc, 0x35, 0xaf, 0x73, 0x44, 0x9e, 0x33, 0xf3, 1628 0x17, 0x65, 0x5f, 0x84, 0x7b, 0xff, 0xa7, 0x33, 0x1a, 0x57, 0x77, 0xca,
1623 0x86, 0x39, 0xf3, 0xbd, 0x49, 0x6e, 0x86, 0x87, 0x0e, 0xdc, 0xaa, 0xf7, 1629 0x81, 0x22, 0x6d, 0xe1, 0x98, 0xce, 0xe7, 0x18, 0xf7, 0x69, 0xa7, 0xc5,
1624 0x3c, 0x77, 0xe0, 0x9b, 0x36, 0xd5, 0xa7, 0xf5, 0x3a, 0xe2, 0x4c, 0xf9, 1630 0x80, 0xc7, 0x0f, 0x01, 0x7f, 0x2d, 0xb0, 0xb9, 0x47, 0x50, 0x27, 0x22,
1625 0x1e, 0x3b, 0x77, 0xf7, 0x68, 0x3d, 0xbb, 0x75, 0xd3, 0xa5, 0x80, 0xfb, 1631 0x63, 0x60, 0xf1, 0xd9, 0x02, 0xf9, 0x93, 0xf7, 0x28, 0xea, 0xbb, 0x32,
1626 0xdc, 0xbc, 0x4d, 0xcb, 0xc5, 0x22, 0x68, 0xef, 0xd5, 0x69, 0xde, 0xe7, 1632 0x5f, 0xb8, 0x59, 0xe7, 0xdb, 0x9d, 0x46, 0xdb, 0x27, 0x71, 0xcd, 0x16,
1627 0x7a, 0x76, 0x41, 0x9f, 0x13, 0x01, 0xde, 0xe6, 0xe2, 0x62, 0xf5, 0x48, 1633 0x26, 0xd0, 0x66, 0xaf, 0xae, 0x3f, 0x5b, 0x62, 0x8e, 0xb2, 0x40, 0x2e,
1628 0xa3, 0xbe, 0xf8, 0x69, 0x83, 0x59, 0x47, 0xa5, 0x6c, 0x58, 0x83, 0x34, 1634 0xed, 0x97, 0xfc, 0x5c, 0x97, 0x8c, 0xc5, 0x17, 0x66, 0xa2, 0xcb, 0x71,
1629 0xd7, 0xec, 0x05, 0x5e, 0x90, 0xf7, 0xdf, 0xea, 0xcd, 0x9e, 0x8f, 0xea, 1635 0x99, 0x8f, 0x6f, 0xe0, 0x1e, 0x47, 0xfe, 0x4a, 0xee, 0x07, 0x4b, 0x74,
1630 0xb2, 0xe0, 0x31, 0xbd, 0x2f, 0x84, 0xfb, 0x03, 0x7f, 0x79, 0xa5, 0xb1, 1636 0x74, 0xbb, 0xea, 0x6d, 0xd3, 0x3e, 0xd7, 0xa0, 0xec, 0xac, 0x0c, 0xc9,
1631 0x4d, 0xc3, 0x7c, 0xa6, 0xff, 0x38, 0x98, 0xd0, 0x31, 0x36, 0xf6, 0xf5, 1637 0x4d, 0x95, 0xcf, 0x6e, 0x36, 0xb1, 0xa8, 0x15, 0xf1, 0xad, 0xc3, 0xc4,
1632 0x43, 0xfc, 0x5e, 0xbc, 0x5f, 0x24, 0xb4, 0x5d, 0xeb, 0x40, 0xf7, 0xda, 1638 0x8a, 0x3a, 0x1a, 0xe5, 0xb9, 0x25, 0x99, 0x3d, 0x25, 0x12, 0x39, 0x1a,
1633 0x5f, 0x16, 0x94, 0x89, 0xe7, 0x25, 0x22, 0x13, 0x55, 0x30, 0x4e, 0x10, 1639 0xc6, 0x12, 0x59, 0xe6, 0x4a, 0xd7, 0x95, 0x80, 0xeb, 0x14, 0x64, 0x6b,
1634 0xee, 0x52, 0xd7, 0xaa, 0xf9, 0xd8, 0xdd, 0x6a, 0xa4, 0x11, 0xc6, 0x75, 1640 0x3c, 0x26, 0x5f, 0xdc, 0x16, 0x8e, 0x95, 0x0b, 0xa6, 0xb7, 0xe5, 0xe4,
1635 0x8b, 0xf2, 0xc8, 0x1b, 0xad, 0x2b, 0x49, 0x37, 0xd3, 0xc2, 0xb4, 0xf9, 1641 0xd3, 0xb8, 0xb2, 0x57, 0xa6, 0x4a, 0x19, 0xc5, 0x71, 0xbf, 0x13, 0x50,
1636 0x31, 0xcd, 0x68, 0xfb, 0xb9, 0x6d, 0x95, 0xde, 0xfb, 0xc4, 0x35, 0x46, 1642 0x96, 0xa9, 0x21, 0x4f, 0x72, 0x6d, 0xe1, 0xd8, 0xf0, 0x6f, 0x76, 0x84,
1637 0xc6, 0x08, 0x63, 0x26, 0xdf, 0xf5, 0xff, 0x56, 0xd7, 0x19, 0x9a, 0xab, 1643 0xe3, 0xd3, 0xe6, 0x36, 0x67, 0x1e, 0xf2, 0xdc, 0x77, 0x01, 0xfd, 0x45,
1638 0xa3, 0xe7, 0x02, 0xf9, 0x6e, 0x55, 0x5e, 0x35, 0xdc, 0xd4, 0x5f, 0x43, 1644 0x86, 0xee, 0xde, 0x40, 0xdf, 0x61, 0x58, 0xd8, 0x0e, 0x32, 0x5d, 0xb1,
1639 0x9d, 0x75, 0xd0, 0x89, 0x17, 0x53, 0xab, 0xc3, 0xbd, 0xf0, 0xb0, 0x21, 1645 0x6f, 0xc2, 0x49, 0xf8, 0x6b, 0xe1, 0x5c, 0x4c, 0xc6, 0x81, 0xa3, 0xdc,
1640 0xb2, 0xd7, 0xd4, 0x5a, 0x99, 0x3f, 0x81, 0x79, 0x7d, 0x26, 0x65, 0x78, 1646 0xeb, 0xc2, 0xdb, 0xe7, 0x7a, 0xaa, 0x1e, 0xbc, 0xa3, 0x36, 0x96, 0xc8,
1641 0x51, 0xf3, 0x61, 0xf1, 0x36, 0xf8, 0xeb, 0xa1, 0xde, 0xa0, 0x9c, 0x26, 1647 0xf8, 0xe0, 0x3a, 0xe0, 0xad, 0x05, 0xe5, 0x1f, 0x94, 0xa9, 0x63, 0x6f,
1642 0x6f, 0x22, 0xad, 0x42, 0x9f, 0xe0, 0xc2, 0xea, 0x99, 0xae, 0x57, 0x03, 1648 0xdb, 0xcc, 0xb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xe8, 0xb3, 0x50, 0x27, 0x53, 0x4e, 0x34, 0xdb, 0x75, 0xde, 0xc4, 0xcd, 1685 0xe7, 0x0f, 0xdb, 0x7e, 0x30, 0x9c, 0xff, 0xe9, 0x8a, 0xc9, 0x7f, 0x3e,
1680 0x53, 0xed, 0xde, 0x73, 0xe0, 0xb5, 0x7e, 0x7f, 0x03, 0x6c, 0x66, 0xd1, 1686 0xbd, 0x46, 0xcf, 0x4d, 0x59, 0xde, 0xf0, 0xb4, 0x5f, 0xcc, 0x98, 0xf6,
1681 0x3a, 0xbf, 0x50, 0x5a, 0x6f, 0x6d, 0x83, 0x66, 0x19, 0x77, 0xb9, 0x56, 1687 0x19, 0xe8, 0xb6, 0x69, 0x3f, 0x69, 0xcf, 0x43, 0x19, 0x7b, 0xe9, 0x1b,
1682 0x93, 0xec, 0x19, 0x32, 0x3e, 0x66, 0x3c, 0xa1, 0x18, 0x23, 0xe6, 0xfa, 1688 0x3e, 0x79, 0xe7, 0xe3, 0x3a, 0x0f, 0xe5, 0x71, 0xda, 0x4d, 0xc5, 0x36,
1683 0x05, 0xcf, 0x39, 0x70, 0x9d, 0x9b, 0xf1, 0x90, 0xf1, 0x7b, 0x47, 0xfc, 1689 0x19, 0x99, 0xae, 0x85, 0x9b, 0xf0, 0xe6, 0xb4, 0x1c, 0xcd, 0x62, 0x7e,
1684 0xbc, 0x17, 0xb1, 0x67, 0x23, 0xb2, 0x45, 0x43, 0x9b, 0x7b, 0xb4, 0xad, 1690 0xe3, 0x7e, 0x2f, 0xe4, 0x9b, 0xa6, 0x25, 0x94, 0xa7, 0x72, 0xc3, 0x91,
1685 0x1a, 0x05, 0x3f, 0x7d, 0x0f, 0x74, 0xcf, 0xba, 0xa4, 0xfd, 0xef, 0x04, 1691 0x26, 0x51, 0x0f, 0x7c, 0x08, 0x73, 0x8e, 0xca, 0x66, 0xaf, 0xdb, 0xdd,
1686 0x93, 0xae, 0x89, 0x4f, 0x29, 0xd4, 0xcb, 0x6a, 0x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 0x5a, 0x61, 0xdd, 0x73, 0x21, 0xad, 0x24, 0xaa, 0x69, 0x25, 1736 0x87, 0x8e, 0x9c, 0x7a, 0x19, 0x17, 0x18, 0xec, 0x14, 0x08, 0xf3, 0xd4,
1731 0x3f, 0xee, 0xe0, 0x59, 0x0c, 0x07, 0xe9, 0x85, 0xed, 0x90, 0x5e, 0x00, 1737 0x20, 0x2e, 0x28, 0xb1, 0x53, 0x69, 0x5c, 0x23, 0xb8, 0xfe, 0xd2, 0x31,
1732 0x4b, 0xa5, 0x32, 0x47, 0x2f, 0x31, 0xb4, 0x73, 0xa8, 0xa4, 0x34, 0xad, 1738 0x3c, 0xd7, 0x09, 0x7c, 0x85, 0x3c, 0x02, 0x9c, 0xaf, 0xe0, 0xb9, 0xaf,
1733 0x0c, 0xa9, 0x50, 0x47, 0x78, 0x98, 0x73, 0xcc, 0xfd, 0x15, 0x69, 0x24, 1739 0x3b, 0x6f, 0x9c, 0xe7, 0x7e, 0xe2, 0x18, 0x9e, 0x7b, 0xc5, 0xa9, 0xf2,
1734 0x65, 0x69, 0x64, 0xfe, 0x2c, 0xd1, 0x22, 0xda, 0x00, 0xee, 0x79, 0x5e, 1740 0xdc, 0x59, 0x47, 0x3d, 0xfc, 0x8c, 0x13, 0x79, 0x98, 0xbe, 0xc4, 0x59,
1735 0x60, 0xb3, 0xa6, 0x8d, 0xfb, 0x53, 0x2f, 0xa0, 0xec, 0x28, 0x68, 0x23, 1741 0xc7, 0xf0, 0x7f, 0x44, 0x86, 0xf7, 0x82, 0x96, 0x1e, 0x5e, 0xc0, 0x45,
1736 0xc4, 0xc1, 0x03, 0x16, 0x07, 0x8b, 0xe7, 0xf2, 0xb4, 0xc5, 0xc1, 0xa8, 1742 0xba, 0x7a, 0x16, 0xe5, 0x2f, 0xac, 0x1a, 0xf7, 0xf9, 0x37, 0x31, 0xee,
1737 0xc5, 0x81, 0xe6, 0x97, 0x3c, 0xe7, 0x4c, 0x69, 0x1c, 0xd4, 0x69, 0x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0x69, 0x42, 0x5e, 0x44, 0xaf, 1765 0x5e, 0x1c, 0xf7, 0x9d, 0xeb, 0x51, 0x07, 0x72, 0x7d, 0x07, 0xcb, 0x92,
1760 0x15, 0xd4, 0x9c, 0x9a, 0x3f, 0xa7, 0xae, 0x8e, 0x8a, 0x5d, 0xc3, 0x4f, 1766 0xb8, 0x8b, 0x72, 0xdf, 0x19, 0x95, 0x73, 0x03, 0x7c, 0x66, 0xee, 0xbf,
1761 0x6b, 0xbd, 0x12, 0x39, 0x4a, 0x9d, 0xc3, 0xfd, 0x55, 0x3d, 0x98, 0xf7, 1767 0x44, 0xd9, 0xdf, 0xb9, 0x81, 0x4e, 0x79, 0x7c, 0x1e, 0x34, 0x01, 0xb9,
1762 0xe5, 0xf4, 0x8d, 0x31, 0x62, 0xb3, 0x98, 0x3f, 0x75, 0x86, 0x67, 0x8d, 1768 0x3f, 0x72, 0x82, 0x30, 0x89, 0xec, 0x9a, 0x65, 0x2c, 0xbd, 0xdb, 0x65,
1763 0x5b, 0xf1, 0x0e, 0xdb, 0x0b, 0xf5, 0x08, 0x74, 0xdf, 0xdb, 0x3f, 0xe1, 1769 0xdc, 0x94, 0xfb, 0x34, 0xb7, 0x0c, 0x70, 0x2c, 0xe8, 0x25, 0xe8, 0xb8,
1764 0x49, 0x3d, 0xf0, 0x3d, 0xa1, 0x80, 0x6b, 0x57, 0xd3, 0x42, 0x5e, 0x85, 1770 0xae, 0x1d, 0x46, 0x16, 0xa4, 0x67, 0x1b, 0x50, 0xce, 0x7e, 0xe1, 0x3f,
1765 0xb1, 0x69, 0x43, 0x0f, 0x8f, 0xbf, 0x21, 0x3f, 0x90, 0x26, 0x3a, 0x6d, 1771 0xee, 0x65, 0x3f, 0x61, 0x5b, 0x85, 0x39, 0x35, 0x6a, 0x7a, 0x59, 0x5a,
1766 0x6c, 0xc1, 0xb7, 0x31, 0x7e, 0xd2, 0xb6, 0xa1, 0x87, 0x47, 0x53, 0x19, 1772 0xa5, 0x3f, 0xce, 0xfc, 0x4c, 0xf6, 0x37, 0xfb, 0xe8, 0xd5, 0x7b, 0x21,
1767 0xc5, 0xbd, 0x51, 0x66, 0x1d, 0x94, 0xb4, 0x41, 0x9a, 0x4f, 0xe8, 0xf5, 1773 0xdc, 0x53, 0x36, 0xb6, 0x15, 0xd7, 0x44, 0xef, 0x29, 0xc0, 0xae, 0xba,
1768 0xd1, 0x8c, 0xbc, 0x2c, 0x99, 0xa6, 0x76, 0xd8, 0x5d, 0xff, 0xb6, 0x73, 1774 0x42, 0xdb, 0x17, 0x73, 0x15, 0xae, 0x20, 0x63, 0x51, 0xe1, 0x1a, 0x25,
1769 0x6c, 0xee, 0x2e, 0xd0, 0x34, 0x07, 0xdd, 0xc4, 0x7d, 0xca, 0x9d, 0xf2, 1775 0xe4, 0xd1, 0xe2, 0xf2, 0x3a, 0x6d, 0x69, 0x58, 0xb9, 0x4e, 0xa4, 0x15,
1770 0x5e, 0x9e, 0x57, 0x98, 0x70, 0xa0, 0x94, 0x9f, 0xd2, 0x7b, 0xbf, 0x77, 1776 0x7f, 0xcc, 0xda, 0x1e, 0x8b, 0x92, 0x83, 0x5d, 0xd6, 0xab, 0xd7, 0x6c,
1771 0x14, 0x57, 0xcb, 0xad, 0xa9, 0xa8, 0x5d, 0xe7, 0xac, 0x05, 0x1d, 0x40, 1777 0x11, 0xb6, 0xac, 0x5d, 0x33, 0x6d, 0xcf, 0xe6, 0xc3, 0x35, 0x1b, 0x85,
1772 0x50, 0x9f, 0xaa, 0xc5, 0x13, 0x75, 0x38, 0x7f, 0x17, 0x53, 0x99, 0xa4, 1778 0xc6, 0x29, 0xab, 0x4d, 0x5c, 0x33, 0x97, 0xf1, 0x6e, 0xe0, 0x3d, 0x87,
1773 0x22, 0xb3, 0xc3, 0xe7, 0x9f, 0x91, 0x2d, 0xde, 0x1e, 0x7d, 0xce, 0x4e, 1779 0x75, 0xca, 0x61, 0x8d, 0x72, 0xe5, 0x0e, 0x99, 0x3d, 0xa6, 0x3a, 0x1b,
1774 0x9c, 0xba, 0x53, 0x7f, 0xe9, 0xd1, 0x06, 0x25, 0xfd, 0xcc, 0xf8, 0xb5, 1780 0x44, 0x92, 0xe3, 0x5e, 0x87, 0x4c, 0xce, 0x33, 0x96, 0xb0, 0x05, 0x36,
1775 0x7a, 0x5d, 0xab, 0x3f, 0x15, 0x04, 0x39, 0xcc, 0x5f, 0x41, 0x4c, 0xfc, 1781 0xd8, 0x56, 0x5c, 0x9d, 0x78, 0x66, 0x3b, 0xf0, 0x54, 0x59, 0xa1, 0x6d,
1776 0x6c, 0xc2, 0x67, 0x1a, 0xfd, 0xda, 0x06, 0xa7, 0xf6, 0x4c, 0xa3, 0x63, 1782 0xd3, 0x1a, 0x3b, 0xeb, 0x71, 0x8c, 0xcd, 0x1c, 0xe1, 0x27, 0x80, 0x87,
1777 0x68, 0x45, 0x22, 0x2a, 0x5d, 0xef, 0xd4, 0x9c, 0xba, 0x93, 0x73, 0x06, 1783 0x2a, 0xef, 0x4c, 0xd5, 0xc4, 0x9f, 0x38, 0x57, 0xad, 0x43, 0x31, 0xdf,
1778 0xba, 0xf2, 0x1c, 0x43, 0x57, 0x31, 0x67, 0x9e, 0xae, 0xd6, 0xd9, 0xdf, 1784 0xb8, 0x5e, 0x4f, 0x1d, 0x87, 0x2a, 0x36, 0xbe, 0x19, 0x7b, 0x2a, 0x41,
1779 0x2a, 0x5d, 0x27, 0x99, 0x64, 0x1d, 0xc6, 0xdb, 0x5b, 0x0c, 0x61, 0x3c, 1785 0x7b, 0x2a, 0x5b, 0x72, 0xcd, 0xf9, 0x80, 0x51, 0xf8, 0x4e, 0x5e, 0xef,
1780 0x0c, 0xb8, 0x08, 0xcf, 0xdd, 0x18, 0xc3, 0x30, 0x9e, 0x3c, 0x60, 0x01, 1786 0x26, 0xd2, 0xfa, 0xd8, 0x0c, 0xe1, 0x8a, 0x85, 0x70, 0xad, 0x58, 0x33,
1781 0xb3, 0x9f, 0x2a, 0x00, 0xe6, 0x83, 0x78, 0x18, 0x27, 0x6b, 0x76, 0x22, 1787 0x9e, 0xe7, 0x5a, 0x1b, 0xe7, 0x98, 0x5a, 0xce, 0x5f, 0x34, 0xb1, 0x7d,
1782 0x13, 0xd5, 0xf0, 0x12, 0xc6, 0x1f, 0x5b, 0x78, 0x5f, 0x0f, 0x56, 0x4f, 1788 0xc6, 0x51, 0x3a, 0xeb, 0xc0, 0x74, 0xa7, 0xb6, 0x61, 0x45, 0x8d, 0xc9,
1783 0x66, 0xba, 0x8b, 0x80, 0x87, 0x70, 0xde, 0x07, 0x18, 0x69, 0x97, 0x8e, 1789 0x81, 0x22, 0xcf, 0x82, 0x31, 0x9e, 0x78, 0x23, 0xe3, 0x49, 0xbd, 0xb3,
1784 0xe2, 0xdb, 0x03, 0x7c, 0x63, 0x16, 0x26, 0xd0, 0xe3, 0xd8, 0x43, 0xf3, 1790 0xf2, 0x5e, 0x8c, 0xcd, 0x5c, 0x1d, 0x65, 0xe3, 0x37, 0x1b, 0x6c, 0x8e,
1785 0xbf, 0x8b, 0xb4, 0x93, 0x8f, 0xd9, 0xef, 0xd6, 0x45, 0x32, 0xe0, 0x15, 1791 0x48, 0x6d, 0x0c, 0xc7, 0xe4, 0xf2, 0xac, 0xcc, 0x8b, 0x4e, 0x8d, 0x2e,
1786 0x87, 0x78, 0x1e, 0x29, 0xbd, 0xe6, 0xc0, 0x0e, 0x00, 0xdf, 0xbf, 0xe4, 1792 0x61, 0x9d, 0x7f, 0x5d, 0xef, 0x0d, 0x4a, 0x29, 0x02, 0xed, 0x37, 0x3e,
1787 0x44, 0xce, 0xc4, 0xe5, 0x50, 0x91, 0x31, 0x84, 0xe3, 0x0e, 0xe7, 0x41, 1793 0x90, 0x1a, 0x34, 0xe7, 0x60, 0x92, 0xb2, 0xb3, 0x68, 0xe6, 0x7f, 0x5e,
1788 0xf9, 0x57, 0xa1, 0x4c, 0x5c, 0xc9, 0xc4, 0xd5, 0x78, 0xde, 0x82, 0x67, 1794 0xe7, 0xf4,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xf9, 0xef, 1816 0xe6, 0x94, 0x7d, 0x57, 0xde, 0xa1, 0x65, 0xfe, 0x01, 0x9f, 0xfa, 0x6b,
1811 0xd4, 0xfb, 0x26, 0xdb, 0xb6, 0xd1, 0x6e, 0xb9, 0x41, 0xeb, 0x70, 0x77, 1817 0x87, 0xfe, 0xdd, 0x38, 0x14, 0x04, 0xe7, 0x06, 0xee, 0x86, 0xad, 0xe2,
1812 0x89, 0x9d, 0xa4, 0x5a, 0x3c, 0x99, 0xb7, 0xd1, 0x76, 0x17, 0x93, 0x09, 1818 0xb9, 0xdf, 0x97, 0xee, 0xc4, 0xb0, 0xb6, 0x9d, 0xb0, 0x46, 0x7b, 0x9b,
1813 0xc2, 0xf5, 0x90, 0x70, 0x3f, 0xc1, 0x7e, 0x29, 0xa4, 0x1a, 0x25, 0x92, 1819 0x65, 0x9d, 0x77, 0xb3, 0xcd, 0x99, 0xc9, 0x41, 0x6e, 0xa6, 0x60, 0x33,
1814 0xe6, 0xba, 0x5c, 0xb2, 0x93, 0xb6, 0xd1, 0xc4, 0x98, 0x67, 0xcf, 0x9e, 1820 0xf1, 0x4c, 0x70, 0x8f, 0x7d, 0x97, 0x0b, 0x9a, 0x41, 0x47, 0x1f, 0x13,
1815 0xac, 0x96, 0x0b, 0xba, 0x9f, 0x5a, 0x0d, 0xa3, 0x39, 0x8f, 0xc6, 0x35, 1821 0x23, 0x63, 0xb2, 0x55, 0x19, 0xc3, 0x5c, 0x83, 0x34, 0x09, 0x39, 0x7a,
1816 0x2f, 0x9e, 0x81, 0x72, 0xf1, 0x6e, 0xd0, 0x7a, 0x67, 0xa2, 0xcc, 0xb3, 1822 0x44, 0x52, 0xfc, 0xee, 0x07, 0xc7, 0xce, 0xcb, 0xa5, 0xd0, 0xcb, 0x6c,
1817 0x4e, 0xf0, 0x97, 0xca, 0x31, 0x7d, 0xc6, 0xd4, 0x7b, 0x3b, 0xfc, 0xd8, 1823 0xa7, 0xbf, 0xd9, 0x83, 0x67, 0xee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3d, 0x1d, 0x66,
1847 0x66, 0xdd, 0x7c, 0xe1, 0xd9, 0x93, 0xe4, 0xc0, 0xac, 0x5e, 0x77, 0xe5, 1853 0xaf, 0xf1, 0x3b, 0x58, 0xe3, 0x8d, 0x58, 0x83, 0x93, 0x72, 0x7e, 0x66,
1848 0x9a, 0xa1, 0x8c, 0x46, 0xa0, 0xfd, 0x76, 0x77, 0x27, 0x7b, 0xcc, 0x59, 1854 0xe3, 0x0a, 0x1b, 0x36, 0x69, 0x63, 0x82, 0x33, 0x56, 0xf7, 0xd6, 0x97,
1849 0xc3, 0x84, 0xf4, 0x97, 0xcc, 0xf8, 0x2f, 0xea, 0x7d, 0x93, 0x66, 0x7f, 1855 0x11, 0xb5, 0xeb, 0x9f, 0xb0, 0x67, 0xcb, 0xc2, 0x1c, 0xa1, 0xa4, 0x5e,
1850 0xb8, 0xd9, 0x53, 0xb9, 0x5f, 0x2e, 0xa6, 0xa2, 0x55, 0x73, 0x5b, 0x27, 1856 0x9f, 0xd1, 0xca, 0x71, 0x8c, 0x37, 0x28, 0xe9, 0x19, 0xce, 0x73, 0xf9,
1851 0xc3, 0xc0, 0x85, 0x5e, 0xcb, 0x84, 0x5d, 0x9c, 0xeb, 0x7e, 0xbc, 0x89, 1857 0x9b, 0x11, 0x90, 0x87, 0x27, 0xa0, 0x57, 0x57, 0xd0, 0x25, 0xe8, 0x96,
1852 0x67, 0xd1, 0xa2, 0x98, 0x9f, 0xc2, 0x38, 0xcf, 0xa7, 0xb3, 0xdd, 0x2b, 1858 0x73, 0x73, 0x40, 0xbb, 0x8f, 0xca, 0x6c, 0x89, 0xf0, 0xf5, 0x24, 0x22,
1853 0xb5, 0x45, 0x31, 0xcb, 0xb3, 0x4e, 0x90, 0x95, 0x6f, 0xdd, 0x12, 0xaf, 1859 0xfa, 0xac, 0x19, 0x9e, 0x67, 0x4c, 0x8e, 0xfb, 0x70, 0x25, 0x3c, 0x67,
1854 0xd7, 0xf9, 0x2b, 0xec, 0x99, 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0x16, 0xfd, 0xad, 0x57, 0x99, 0x71, 0x8e, 1918 0xea, 0x33, 0xa6, 0xbf, 0xe1, 0x72, 0x73, 0x46, 0x81, 0x75, 0x5d, 0xd8,
1913 0x73, 0xee, 0x7e, 0x1e, 0xc8, 0xc5, 0x56, 0x35, 0x34, 0xbe, 0x80, 0x2e, 1919 0xa6, 0xb4, 0x73, 0x89, 0x47, 0xbd, 0x6e, 0x05, 0x25, 0x3c, 0x67, 0x00,
1914 0x41, 0xb7, 0x1c, 0x9b, 0x03, 0xda, 0xbd, 0x57, 0x26, 0x46, 0x09, 0x5f, 1920 0x6e, 0xae, 0x5c, 0xe1, 0xbe, 0x43, 0x91, 0x0e, 0x43, 0x5c, 0x7f, 0x5b,
1915 0x47, 0x3c, 0xa2, 0xcf, 0xf5, 0xe2, 0x7b, 0xdc, 0x9c, 0x27, 0xea, 0xad, 1921 0xf3, 0xc9, 0x78, 0x81, 0xb1, 0x95, 0x47, 0x83, 0xf4, 0x28, 0x79, 0x8c,
1916 0x84, 0x67, 0x7a, 0xd7, 0x00, 0xde, 0xc5, 0xe7, 0x7a, 0xad, 0x9e, 0xd6, 1922 0x7d, 0xf0, 0x7d, 0x41, 0xc7, 0x73, 0xf7, 0xfa, 0x8c, 0x15, 0x75, 0x1f,
1917 0x36, 0x04, 0xcf, 0xf7, 0x86, 0x63, 0x58, 0x8e, 0x9e, 0x02, 0x19, 0xd6, 1923 0xbf, 0x43, 0x85, 0x72, 0x0a, 0xfa, 0xb7, 0xb8, 0xe8, 0xf0, 0x1b, 0x78,
1918 0xfb, 0x7d, 0xd7, 0xca, 0xe9, 0x07, 0xe7, 0xce, 0x17, 0x34, 0xc1, 0x56, 1924 0x37, 0x0a, 0xee, 0xf3, 0x8b, 0xce, 0x77, 0xa7, 0x9f, 0xc5, 0x73, 0x83,
1919 0x69, 0x85, 0xa9, 0x3c, 0xe0, 0xa6, 0xb9, 0xef, 0x82, 0xfb, 0x0b, 0x3a, 1925 0xfd, 0xee, 0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x24, 0x9a, 0x98, 0x13,
1927 0xcf, 0xdf, 0xd3, 0x17, 0xce, 0xeb, 0x0b, 0x7a, 0x0d, 0x68, 0x5a, 0x88, 1933 0xf2, 0x42, 0x37, 0x73, 0x1c, 0xdb, 0x81, 0xab, 0x53, 0xc4, 0xd5, 0x5c,
1928 0x6b, 0xcf, 0xda, 0x10, 0xc7, 0x9d, 0x9c, 0xc6, 0x3d, 0xcb, 0x7c, 0x4b, 1934 0xa5, 0xcf, 0xbd, 0x04, 0x3c, 0xd1, 0xae, 0x79, 0xa2, 0xd5, 0x49, 0xbb,
1929 0xff, 0x06, 0x9d, 0x2b, 0xd3, 0x5e, 0x2b, 0xde, 0x8b, 0xf7, 0x4d, 0x86, 1935 0x37, 0x58, 0x9e, 0x78, 0x11, 0x3c, 0x71, 0x7e, 0x0d, 0x4f, 0x3c, 0x6d,
1930 0xfa, 0x86, 0x70, 0xdf, 0x09, 0xbd, 0x16, 0xec, 0x37, 0xf2, 0x6a, 0x56, 1936 0xe9, 0x7f, 0xa1, 0x86, 0x27, 0xe6, 0x6c, 0xd9, 0xcc, 0x45, 0x78, 0xe2,
1931 0x46, 0x2a, 0x5c, 0xc3, 0x64, 0x3b, 0x48, 0x2f, 0xd7, 0xc0, 0x1e, 0x58, 1937 0x52, 0x2f, 0xf5, 0xa5, 0x31, 0x79, 0x15, 0x3c, 0x21, 0x8a, 0x3c, 0x71,
1932 0x78, 0xbe, 0xba, 0x7f, 0x7e, 0x1e, 0x12, 0xe3, 0x42, 0x58, 0xee, 0xd6, 1938 0xa9, 0xe6, 0x09, 0xc6, 0x8e, 0xc8, 0x17, 0x9d, 0x90, 0x23, 0xe4, 0x8b,
1933 0x67, 0x17, 0xab, 0xef, 0x1e, 0xb9, 0xf2, 0xbf, 0x70, 0xfd, 0xd0, 0xc8, 1939 0xb3, 0xb2, 0x04, 0xbe, 0x78, 0x5e, 0x71, 0xec, 0x19, 0xda, 0x0a, 0x25,
1934 0x50, 0x0b, 0x47, 0x86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0x36,
1978 0x98, 0xff, 0xa2, 0x8e, 0xe5, 0x0e, 0xa6, 0x18, 0x27, 0x6a, 0x3f, 0x71, 1984 0xe9, 0x19, 0xfc, 0xa9, 0x84, 0x36, 0xe7, 0x7f, 0xba, 0x84, 0xdf, 0xee,
1979 0x87, 0x0a, 0x65, 0xd3, 0x2c, 0xd7, 0x10, 0x1c, 0xde, 0x21, 0xba, 0x0b, 1985 0x7c, 0x5e, 0x51, 0x86, 0xbd, 0x0a, 0x19, 0x26, 0xaa, 0xbe, 0x0c, 0xc3,
1980 0x1d, 0x5e, 0x9c, 0x52, 0xce, 0x37, 0xc7, 0x5c, 0x7c, 0xd7, 0xd8, 0xfb, 1986 0xbb, 0x32, 0xde, 0x95, 0xd9, 0xef, 0x8f, 0x7e, 0x3a, 0xe6, 0x52, 0x7e,
1981 0x42, 0x8d, 0x6e, 0x12, 0xf9, 0xeb, 0x70, 0xbc, 0xf1, 0x3c, 0xe6, 0xfb, 1987 0x50, 0x66, 0x40, 0x26, 0x15, 0x21, 0x93, 0x8a, 0x90, 0x53, 0x45, 0xc8,
1982 0x12, 0xe6, 0x7b, 0xf9, 0xfb, 0x41, 0x91, 0x57, 0x46, 0x5e, 0xf9, 0x43, 1988 0x25, 0xd8, 0x6c, 0x67, 0x8a, 0x90, 0x4b, 0x45, 0xc8, 0x25, 0xc8, 0xb8,
1983 0x41, 0xa6, 0x89, 0xf4, 0x47, 0x9a, 0x7b, 0x3d, 0x9f, 0x59, 0xef, 0x63, 1989 0x27, 0x20, 0xe3, 0x8c, 0x4c, 0x1b, 0x85, 0x4c, 0x9b, 0x91, 0xfb, 0xac,
1984 0x02, 0x6c, 0x67, 0xc1, 0x0b, 0x19, 0xae, 0x25, 0x07, 0xc7, 0x52, 0x37, 1990 0xae, 0x37, 0xb1, 0x92, 0x7e, 0xeb, 0x23, 0x0d, 0xe8, 0x18, 0xf2, 0x99,
1985 0x81, 0x17, 0x76, 0xca, 0x9f, 0xc0, 0x16, 0xf8, 0xe3, 0x4a, 0x1a, 0x3c, 1991 0x9a, 0xd8, 0xe0, 0x8d, 0x47, 0x34, 0xbf, 0xbb, 0x9e, 0xba, 0xc2, 0x61,
1986 0xd1, 0x03, 0x1e, 0xe9, 0x06, 0x5f, 0xa4, 0xb4, 0x5d, 0xfc, 0x28, 0x74, 1992 0x0e, 0xcd, 0x4f, 0xb4, 0xff, 0xbe, 0x9d, 0xbf, 0xa5, 0x09, 0x7c, 0xfd,
1987 0xde, 0xd9, 0x4a, 0xc9, 0xd9, 0x3b, 0x5a, 0x74, 0x72, 0xa3, 0x47, 0x41, 1993 0x03, 0xcb, 0xd7, 0xdb, 0x97, 0xf9, 0x3a, 0xe5, 0x30, 0x56, 0x5c, 0x9f,
1988 0x17, 0xdc, 0x03, 0xab, 0xae, 0xa9, 0x11, 0x37, 0x3e, 0x29, 0xa4, 0xff, 1994 0xaf, 0x3b, 0xec, 0xbb, 0x5c, 0xb0, 0x0e, 0x7c, 0xbd, 0x6e, 0x15, 0x5f,
1989 0x76, 0xee, 0xed, 0x68, 0x06, 0xae, 0xce, 0x10, 0x57, 0x93, 0x95, 0x2d, 1995 0xc7, 0xc0, 0xd7, 0x7b, 0xd6, 0xf0, 0xf5, 0x06, 0x67, 0x58, 0xb7, 0xe1,
1990 0xde, 0x3a, 0xf0, 0x41, 0xb3, 0xe6, 0x83, 0x46, 0x27, 0xe3, 0xdd, 0x64, 1996 0x19, 0x09, 0x3e, 0x37, 0x3a, 0x55, 0xbe, 0xbe, 0x47, 0xf3, 0xf5, 0x21,
1991 0xf9, 0x60, 0x04, 0x7c, 0x50, 0x58, 0xc2, 0x07, 0xcf, 0x58, 0x9a, 0x9f, 1997 0xf0, 0xf5, 0x75, 0x35, 0x7c, 0xbd, 0x47, 0x52, 0x37, 0x67, 0x22, 0x5b,
1992 0xae, 0xe2, 0x83, 0x49, 0x9b, 0x36, 0x7e, 0x05, 0x3e, 0xb8, 0xca, 0x4f, 1998 0x65, 0xfc, 0x7e, 0xd5,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4b, 0x05, 0x2d, 2042 0x19, 0x1b, 0xe4, 0x99, 0xdd, 0x70, 0x2f, 0xa2, 0xd7, 0xca, 0xba, 0x96,
2037 0x97, 0x06, 0x05, 0xef, 0xa9, 0x02, 0xe4, 0xd2, 0x08, 0xbe, 0x3d, 0x2d, 2043 0x9a, 0x98, 0x25, 0xf0, 0x3e, 0x2d, 0xc9, 0xcc, 0x00, 0xee, 0xf3, 0x1c,
2038 0x97, 0x62, 0x62, 0x6d, 0x64, 0x89, 0x5e, 0xc5, 0xfe, 0x27, 0x4b, 0xae, 2044 0x7b, 0xbf, 0x4c, 0x3d, 0x38, 0x01, 0x5b, 0x6e, 0x2f, 0x74, 0x0e, 0xcf,
2039 0xb6, 0xa5, 0x0a, 0xe3, 0xb0, 0x43, 0x4a, 0x23, 0x56, 0x67, 0x4b, 0xba, 2045 0x9f, 0x99, 0xef, 0x70, 0x13, 0x86, 0x59, 0xfd, 0xdd, 0x29, 0xfa, 0x80,
2040 0x49, 0x3a, 0x7a, 0x7e, 0x2a, 0xa1, 0x9d, 0x39, 0xdb, 0xcc, 0x3b, 0x8f, 2046 0xa4, 0x87, 0x04, 0x9e, 0x67, 0x6c, 0x5c, 0x29, 0x21, 0xf9, 0xc2, 0x05,
2041 0x5f, 0x54, 0x94, 0x61, 0x27, 0x20, 0xc3, 0x1e, 0xbe, 0x82, 0x0c, 0x43, 2047 0xf3, 0x6d, 0xcb, 0xc2, 0x4b, 0xb8, 0xbf, 0xde, 0x7a, 0x18, 0x3f, 0x64,
2042 0x5e, 0x19, 0x79, 0x65, 0xb6, 0xfb, 0xdd, 0x9f, 0x0e, 0x79, 0x94, 0x1f, 2048 0xd4, 0xdc, 0xd1, 0xd7, 0x92, 0xa4, 0xcb, 0x26, 0xc7, 0xa5, 0x1a, 0x37,
2043 0x94, 0x19, 0x90, 0x49, 0x25, 0xc8, 0xa4, 0x12, 0xe4, 0x54, 0x09, 0x72, 2049 0x99, 0x91, 0xc3, 0xda, 0x7e, 0x1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xc8, 0x91, 0xcf, 0xd4,
2073 0x25, 0xdf, 0x7d, 0xdd, 0xc9, 0x15, 0x2f, 0xe9, 0x7d, 0x85, 0x59, 0x1f, 2079 0x51, 0x77, 0xc1, 0xc8, 0x03, 0xe6, 0xa9, 0x7e, 0x1e, 0xba, 0x83, 0x6d,
2074 0xbf, 0xcb, 0xfc, 0x66, 0xf9, 0x4b, 0x8c, 0x71, 0x24, 0x12, 0xea, 0x81, 2080 0x51, 0xfe, 0x70, 0x9a, 0xbe, 0x2d, 0xfc, 0x9f, 0x56, 0x3c, 0xb7, 0xe3,
2075 0x56, 0xee, 0x3b, 0x18, 0x9c, 0x32, 0x76, 0x94, 0xe1, 0xd1, 0x06, 0xed, 2081 0x79, 0x56, 0xde, 0xbb, 0x37, 0xa6, 0xe7, 0x3d, 0x85, 0x79, 0x1c, 0x38,
2076 0x6b, 0x8c, 0xe0, 0x7b, 0xf7, 0x68, 0xa3, 0x53, 0xa0, 0x6d, 0x32, 0xd0, 2082 0x82, 0x39, 0x39, 0xc6, 0x76, 0x8e, 0x9e, 0x8a, 0x4a, 0xc3, 0x29, 0xf2,
2077 0xe0, 0xe4, 0xc7, 0xf7, 0xb4, 0x1a, 0x9b, 0x79, 0x20, 0xce, 0x3d, 0x85, 2083 0x1d, 0xcf, 0xda, 0x04, 0xc1, 0xbe, 0x7e, 0xd2, 0x6d, 0xca, 0xdd, 0xa9,
2078 0x19, 0xb5, 0x54, 0x26, 0x9f, 0x92, 0x50, 0x26, 0x27, 0x6f, 0xc9, 0xc0, 2084 0xcf, 0x96, 0x6e, 0x4f, 0x44, 0x80, 0x93, 0x03, 0x58, 0x8f, 0xa9, 0x82,
2079 0xb6, 0xce, 0x1d, 0xd1, 0xf7, 0xf7, 0x25, 0xda, 0x15, 0xc7, 0xf4, 0x09, 2085 0xe7, 0x66, 0x1c, 0x2f, 0x81, 0x79, 0xc2, 0x06, 0xec, 0x86, 0x2d, 0xd8,
2080 0xc8, 0xd7, 0x90, 0x16, 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46, 0x72, 0x51, 0xc6, 0x88, 0x3d,
2095 0xb6, 0xf7, 0x0b, 0xe5, 0x3a, 0xbd, 0x2f, 0xfc, 0xc0, 0x54, 0x4c, 0x66, 2101 0xfc, 0x9e, 0x61, 0xdd, 0x26, 0x99, 0x1a, 0xc8, 0xd9, 0x3c, 0x8f, 0x47,
2096 0x62, 0x8c, 0xeb, 0xf1, 0xde, 0x57, 0xfa, 0xca, 0x7e, 0xbc, 0x20, 0x79, 2102 0x12, 0xcc, 0x21, 0x26, 0x4e, 0xc6, 0x07, 0xc8, 0xeb, 0xab, 0xf7, 0x36,
2097 0x7b, 0xd6, 0x67, 0x95, 0xa5, 0x6d, 0xc6, 0x03, 0x79, 0x27, 0x42, 0xb8, 2103 0x62, 0x35, 0xf2, 0xc0, 0x91, 0xc5, 0x52, 0xb8, 0x17, 0xc2, 0xfe, 0xf0,
2098 0x0e, 0xd1, 0x69, 0x65, 0x5d, 0x43, 0x55, 0x9c, 0x12, 0x78, 0x1f, 0x93, 2104 0x3c, 0x63, 0xe4, 0x6d, 0x66, 0x4d, 0x3b, 0xc2, 0xc5, 0xfd, 0xca, 0x95,
2099 0x44, 0xb6, 0x1b, 0xef, 0x29, 0xf6, 0xfd, 0xa4, 0x8c, 0x3c, 0x58, 0x86, 2105 0x32, 0x56, 0x79, 0x94, 0xa9, 0xae, 0x96, 0xaf, 0x8f, 0x55, 0x8c, 0x6c,
2100 0x2d, 0xf7, 0x30, 0x74, 0x8e, 0x23, 0x10, 0x93, 0xfa, 0x2e, 0x14, 0xc2, 2106 0x9d, 0xa9, 0x84, 0xba, 0x25, 0x66, 0x74, 0xe9, 0x1a, 0x7d, 0x62, 0xa2,
2101 0x30, 0xa1, 0xef, 0xf5, 0xa3, 0xdf, 0x47, 0x7a, 0x88, 0xe3, 0xfb, 0xb2, 2107 0x99, 0x55, 0x7d, 0x42, 0xbd, 0xa8, 0xe4, 0x03, 0xf3, 0x1d, 0x12, 0x7d,
2102 0x8d, 0x25, 0xc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, 0x97, 0x2e, 0x63,
2124 0xd1, 0x71, 0x75, 0xa7, 0x9a, 0xbf, 0x4b, 0x41, 0xdb, 0xac, 0x93, 0x0b, 2130 0x8c, 0x36, 0xe3, 0x71, 0x6c, 0x96, 0x6d, 0x71, 0xa6, 0x4a, 0xdd, 0xf0,
2125 0x6c, 0xd6, 0xbf, 0x97, 0x99, 0xf7, 0x45, 0x31, 0x4e, 0xd0, 0xf0, 0x75, 2131 0xcd, 0x79, 0xae, 0x8a, 0xef, 0x77, 0x72, 0xed, 0xa0, 0x83, 0x5d, 0x7d,
2126 0x2f, 0x73, 0x1d, 0xb4, 0x39, 0x26, 0x97, 0xa4, 0x4f, 0xe3, 0x8f, 0xf2, 2132 0x66, 0x77, 0x42, 0xae, 0xb0, 0x31, 0x68, 0xea, 0xe1, 0x9f, 0x5f, 0xb1,
2127 0xb4, 0x01, 0x72, 0x70, 0x56, 0xeb, 0xd7, 0xb5, 0xbc, 0xf3, 0xf8, 0x08, 2133 0x77, 0x7b, 0x08, 0x7a, 0xec, 0x16, 0xc8, 0x23, 0xea, 0xe1, 0x43, 0x72,
2128 0x6d, 0xd7, 0xaf, 0x6b, 0x79, 0xb6, 0xd6, 0xda, 0xae, 0xd3, 0x90, 0xd3, 2134 0xb5, 0xa5, 0xe7, 0x95, 0x7a, 0xf8, 0xbc, 0x30, 0x4e, 0xdc, 0x8f, 0x77,
2129 0x94, 0xa3, 0x37, 0xca, 0x5f, 0xdb, 0x74, 0xa6, 0x25, 0xe3, 0xb3, 0x42, 2135 0xb9, 0x20, 0x06, 0x7a, 0x38, 0x5c, 0xe3, 0xab, 0xd1, 0xef, 0x6b, 0x1a,
2130 0x7d, 0x17, 0x83, 0x0c, 0xa5, 0x3c, 0xfd, 0x59, 0x6d, 0xd7, 0xe7, 0x6c, 2136 0x32, 0xfb, 0x61, 0x2b, 0xfd, 0x3e, 0xc8, 0x81, 0x78, 0xe8, 0xe7, 0x35,
2131 0x1b, 0x94, 0x9f, 0x46, 0x76, 0x6f, 0x76, 0xa6, 0x6d, 0x1a, 0xbf, 0xc3, 2137 0x2e, 0xef, 0xd7, 0xee, 0xb1, 0x6d, 0xa7, 0xfc, 0xfb, 0x89, 0xa3, 0xe4,
2132 0x18, 0xba, 0x9f, 0xc9, 0x59, 0x3e, 0x53, 0xce, 0x93, 0xc8, 0x5f, 0x83, 2138 0x21, 0xe9, 0x81, 0x2e, 0x63, 0x0e, 0xc8, 0x6f, 0x69, 0x9c, 0x89, 0x22,
2133 0x7c, 0xf2, 0xd9, 0x63, 0x9a, 0xcf, 0xb4, 0x7d, 0xe2, 0x74, 0xd9, 0x35, 2139 0xed, 0x6d, 0xd2, 0x30, 0x5a, 0x39, 0x9f, 0x0c, 0x73, 0x38, 0xf2, 0xb6,
2134 0x85, 0xb9, 0xf5, 0x80, 0x3c, 0xf9, 0x4c, 0x1d, 0xf5, 0xa6, 0x8d, 0x3c, 2140 0xed, 0x84, 0xdd, 0x93, 0xcf, 0xcb, 0xdc, 0x65, 0xd4, 0x83, 0x23, 0x91,
2135 0xf0, 0x90, 0xfe, 0x45, 0xe8, 0x0e, 0xd6, 0x45, 0xfa, 0xb1, 0x0c, 0xe6, 2141 0xf5, 0xfc, 0x7e, 0x22, 0xda, 0xf6, 0x18, 0xbd, 0x28, 0x61, 0x5f, 0x7c,
2136 0xf0, 0x24, 0xfc, 0x9f, 0x46, 0x7c, 0x37, 0xe3, 0x7b, 0x42, 0x7e, 0x75, 2142 0x6e, 0xa8, 0xe9, 0x9b, 0x76, 0x14, 0xef, 0xab, 0xcf, 0x91, 0x3d, 0xa3,
2137 0x30, 0xaa, 0xc7, 0x3d, 0x82, 0x71, 0x1c, 0x38, 0x82, 0x31, 0x39, 0xc6, 2143 0xf7, 0x19, 0xcd, 0xf7, 0x12, 0x42, 0x3e, 0x21, 0xef, 0x24, 0xf5, 0x59,
2138 0x76, 0x76, 0xcf, 0xb8, 0x52, 0x73, 0x86, 0x7c, 0xc7, 0x33, 0x86, 0x41, 2144 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0xc6, 0xb0, 0x5b, 0xd0, 0xfe,
2146 0x33, 0x4e, 0x32, 0x3e, 0xe4, 0x30, 0x4e, 0x91, 0xdd, 0x1c, 0xd1, 0x67, 2152 0xf5, 0xe2, 0xd8, 0x61, 0xfc, 0x3a, 0x22, 0x33, 0x7b, 0x3b, 0x01, 0xdb,
2147 0xc4, 0xa6, 0x19, 0x8b, 0xb8, 0xa5, 0x3d, 0xb2, 0x25, 0xb1, 0xdb, 0x49, 2153 0x5f, 0x5d, 0x66, 0xce, 0x20, 0x63, 0xad, 0xf4, 0xb7, 0xe7, 0xa3, 0x09,
2148 0x0e, 0xa8, 0x48, 0x72, 0xa0, 0xcf, 0x09, 0xcb, 0xf1, 0x0e, 0x6a, 0xc8, 2154 0xca, 0xb2, 0x2e, 0xc0, 0x32, 0x72, 0x94, 0xfa, 0xcc, 0xd3, 0x3c, 0x0e,
2149 0x19, 0xc0, 0x7a, 0xa0, 0xf4, 0x75, 0xd0, 0xd3, 0x79, 0x29, 0x1c, 0x6f, 2155 0x18, 0xdc, 0x06, 0xed, 0x87, 0x90, 0x2f, 0xdf, 0x22, 0xde, 0x03, 0x90,
2150 0x90, 0xa9, 0x62, 0xbb, 0x97, 0x55, 0x31, 0xe1, 0xbe, 0x12, 0x75, 0x0a, 2156 0x71, 0x47, 0x63, 0xd2, 0x73, 0xb4, 0x45, 0xb6, 0x1d, 0xa5, 0x1f, 0x52,
2151 0x44, 0x7f, 0x26, 0x2a, 0x13, 0xa3, 0x1b, 0x45, 0x69, 0xdb, 0xbd, 0x45, 2157 0xeb, 0x97, 0xd2, 0x2e, 0x7d, 0x04, 0x73, 0x7c, 0xb7, 0x96, 0x93, 0xdc,
2152 0xb2, 0x63, 0xa3, 0x72, 0xbe, 0x5b, 0x9a, 0x14, 0xda, 0xe7, 0xdd, 0xde, 2158 0xd3, 0xdc, 0x4f, 0xde, 0x45, 0xdd, 0x2c, 0x6c, 0xe6, 0xcc, 0x51, 0x57,
2153 0xea, 0x14, 0xd7, 0x11, 0x43, 0x5e, 0x58, 0x4f, 0x3e, 0x19, 0x05, 0x0e, 2159 0xef, 0x91, 0x66, 0x30, 0xe7, 0x6c, 0xd9, 0xc5, 0x38, 0x46, 0xe6, 0xe4,
2154 0x41, 0xb7, 0x8c, 0xeb, 0xd6, 0x09, 0xe5, 0xde, 0xed, 0x3a, 0x66, 0xca, 2160 0xe9, 0xa7, 0x8c, 0x76, 0x00, 0xc7, 0xef, 0xb5, 0xbc, 0xb3, 0xbe, 0xc3,
2155 0x38, 0x6d, 0xf5, 0x7a, 0x03, 0xf9, 0x23, 0xba, 0x2c, 0x7f, 0x4c, 0x96, 2161 0xf2, 0xe8, 0xcf, 0xc8, 0x7b, 0x5b, 0x3a, 0x8c, 0xec, 0x7c, 0x4b, 0x07,
2156 0xb8, 0x36, 0x23, 0x79, 0x97, 0x71, 0x61, 0x1f, 0xbf, 0xc7, 0x59, 0xb6, 2162 0x73, 0x93, 0x36, 0x7b, 0xbc, 0x37, 0x69, 0x7b, 0xc2, 0xc8, 0xd0, 0xd7,
2157 0x4e, 0x46, 0xba, 0xf3, 0x76, 0x8f, 0xc7, 0x37, 0xc1, 0x07, 0x1c, 0x9f, 2163 0xe2, 0x45, 0x01, 0x8e, 0xc2, 0x7d, 0x29, 0x7d, 0x96, 0x2f, 0x38, 0xe7,
2158 0x5e, 0x27, 0x01, 0xaf, 0x2f, 0x5e, 0xcf, 0x88, 0x56, 0xc9, 0x03, 0x47, 2164 0xeb, 0xf3, 0x2b, 0xfe, 0xa2, 0xfe, 0x3b, 0x21, 0xdc, 0x23, 0xab, 0x7e,
2159 0x66, 0x46, 0xc3, 0xf5, 0x0f, 0xb6, 0x87, 0xef, 0x71, 0x23, 0x6f, 0xb3, 2165 0x6f, 0x65, 0x57, 0x85, 0x71, 0xf2, 0xcf, 0x86, 0x7f, 0x97, 0xa4, 0x26,
2160 0x4b, 0xea, 0x11, 0x2e, 0xae, 0x55, 0x2e, 0x94, 0xb1, 0x4a, 0x9f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6a,
2175 0x7a, 0x56, 0xe3, 0xfc, 0x7e, 0x7d, 0x26, 0xbf, 0x41, 0x86, 0xcb, 0x21, 2181 0x71, 0xf2, 0x7c, 0x0d, 0x4e, 0x44, 0xad, 0xc4, 0xc9, 0xab, 0xc0, 0x89,
2176 0xce, 0x79, 0x06, 0x8e, 0xfb, 0x30, 0x5a, 0x25, 0x72, 0xac, 0x45, 0xfa, 2182 0xa8, 0xfa, 0x38, 0xc1, 0xbb, 0x32, 0xde, 0x69, 0x9c, 0xbc, 0xb4, 0x0a,
2177 0x53, 0xa2, 0x72, 0xa9, 0x95, 0x7a, 0xff, 0xca, 0xa9, 0x6e, 0x89, 0xe7, 2183 0x27, 0x4b, 0xcb, 0x71, 0x79, 0x83, 0x93, 0x17, 0x81, 0x93, 0xaf, 0x5a,
2178 0xba, 0x49, 0xab, 0xf7, 0xc9, 0x84, 0x9e, 0x8b, 0x16, 0xa9, 0x39, 0x46, 2184 0xd8, 0x2f, 0x58, 0x9c, 0xe0, 0x3e, 0x7f, 0x01, 0x75, 0x5e, 0xaa, 0xc1,
2179 0x1b, 0x25, 0x5c, 0xc3, 0xbb, 0xbd, 0xc5, 0xde, 0x41, 0x1d, 0x35, 0xe5, 2185 0xc9, 0x05, 0xe0, 0xe4, 0x25, 0x8b, 0x93, 0xef, 0x5b, 0x9c, 0x7c, 0x1f,
2180 0x44, 0x0e, 0xea, 0xf9, 0x9a, 0xd5, 0x7b, 0x0c, 0x6f, 0x9e, 0x62, 0x2c, 2186 0x75, 0x96, 0x80, 0x93, 0xf3, 0x75, 0x70, 0xf2, 0x22, 0x70, 0x12, 0xf6,
2181 0x9e, 0xf7, 0xfd, 0x31, 0x0e, 0xff, 0xaf, 0x99, 0xbf, 0x42, 0x8b, 0xb1, 2187 0x7b, 0x1e, 0xfd, 0x7c, 0xbf, 0x06, 0x27, 0x2f, 0xd6, 0xc1, 0x09, 0xf7,
2182 0x67, 0xd6, 0x58, 0x3b, 0xc6, 0xc4, 0xa9, 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, 0x78, 0xbd, 0x9c, 0x71, 0xd8, 0xf9, 0x3b, 0xc2, 0x1c,
2219 0x3a, 0x6d, 0x43, 0x18, 0xb9, 0xf9, 0x7a, 0xfc, 0x27, 0xc0, 0x51, 0xb8, 2225 0xbf, 0x18, 0x73, 0xc6, 0xa5, 0xeb, 0x54, 0x0b, 0xee, 0xa7, 0x2f, 0xd7,
2220 0xfe, 0x44, 0x3e, 0xe4, 0x1a, 0xb2, 0x3e, 0xb3, 0x92, 0x9a, 0xd1, 0x7f, 2226 0x67, 0x9b, 0x4f, 0x89, 0x2d, 0xd3, 0xf9, 0xe4, 0x78, 0x5e, 0xfd, 0x7d,
2221 0x53, 0x89, 0x6b, 0x61, 0xf3, 0xf7, 0x59, 0x6d, 0xaf, 0x30, 0x36, 0xfe, 2227 0xb5, 0x90, 0x1f, 0xaa, 0x7f, 0xa7, 0x40, 0xe4, 0xff, 0x02, 0xfb, 0x2e,
2222 0x4c, 0xf8, 0x37, 0x9c, 0xaa, 0xf6, 0x19, 0x56, 0xaf, 0x75, 0x31, 0xbe, 2228 0x88, 0x71, 0xec, 0x6e, 0x00, 0x00, 0x00 };
2223 0x34, 0xb7, 0x17, 0x28, 0x18, 0xd5, 0x77, 0xc2, 0xc5, 0x9c, 0x8b, 0xc5, 2229
2224 0x5a, 0xe7, 0x9b, 0x63, 0x12, 0xb8, 0x7e, 0xdc, 0xf9, 0x96, 0xcf, 0xb5, 2230static const u32 bnx2_CP_b09FwData[(0x0/4) + 1] = { 0x0 };
2225 0x71, 0xcf, 0x79, 0xb9, 0xe8, 0x83, 0xf7, 0xfe, 0x02, 0xe3, 0x68, 0x75, 2231static const u32 bnx2_CP_b09FwRodata[(0x118/4) + 1] = {
2226 0x5e, 0xc1, 0x9c, 0x1e, 0x2c, 0x65, 0x92, 0x9e, 0x8d, 0x83, 0x3f, 0x5b, 2232 0x0800061c, 0x0800083c, 0x08000780, 0x080007a8, 0x080007d0, 0x080007f8,
2227 0x6c, 0x75, 0x9e, 0x9b, 0x8f, 0x21, 0xf5, 0x84, 0x74, 0x71, 0x88, 0x79, 2233 0x08000654, 0x08000640, 0x08000864, 0x08000864, 0x08000670, 0x0800068c,
2228 0x65, 0xe4, 0x95, 0x19, 0xeb, 0xad, 0x77, 0x26, 0xc7, 0xec, 0x7e, 0x12, 2234 0x0800068c, 0x08000864, 0x080006a4, 0x080006b8, 0x08000864, 0x080006cc,
2229 0xa3, 0x8b, 0xe6, 0xd6, 0x5f, 0x06, 0xf4, 0xfa, 0x84, 0xeb, 0x4c, 0x4e, 2235 0x08000864, 0x08000864, 0x080006e0, 0x08000864, 0x08000864, 0x08000864,
2230 0x4d, 0xaf, 0x37, 0xfb, 0x8a, 0x6a, 0x91, 0x67, 0xf6, 0x58, 0x4e, 0x4c, 2236 0x08000864, 0x08000864, 0x08000864, 0x08000864, 0x08000864, 0x08000864,
2231 0xd5, 0xa2, 0x4c, 0xbd, 0x33, 0xa1, 0x63, 0x5e, 0xda, 0xf6, 0x70, 0xc6, 2237 0x08000864, 0x080006f4, 0x08000864, 0x08000708, 0x0800071c, 0x08000730,
2232 0xa7, 0xea, 0x9d, 0x29, 0xbd, 0xd6, 0x1c, 0x75, 0x4e, 0x8e, 0xb1, 0xed, 2238 0x08000864, 0x08000744, 0x08000758, 0x0800076c, 0x08003200, 0x08003218,
2233 0x28, 0xca, 0x88, 0x73, 0x0a, 0xed, 0x4d, 0x8d, 0xb5, 0xc7, 0xf7, 0x49, 2239 0x08003228, 0x08003238, 0x08003250, 0x08003268, 0x08003278, 0x08003288,
2234 0x3b, 0x6c, 0x01, 0xfe, 0x8d, 0x34, 0xde, 0x17, 0xe0, 0x3a, 0x53, 0x73, 2240 0x080032a8, 0x080032b8, 0x080032c8, 0x08003358, 0x08003298, 0x080032d8,
2235 0xed, 0x2a, 0xb4, 0xc3, 0xb2, 0xa4, 0x41, 0xf6, 0xeb, 0xa2, 0xfd, 0xa5, 2241 0x080032e8, 0x08003300, 0x08003320, 0x08003358, 0x08003338, 0x08003338,
2236 0x6b, 0x52, 0x4b, 0x71, 0x32, 0x06, 0x9c, 0x1c, 0xb4, 0x38, 0x39, 0x61, 2242 0x080050d4, 0x080050d4, 0x080050d4, 0x080050d4, 0x080050d4, 0x080050fc,
2237 0x71, 0x32, 0x5a, 0x85, 0x93, 0x87, 0x17, 0xe1, 0xe4, 0x04, 0x70, 0xf2, 2243 0x080050fc, 0x08005124, 0x08005174, 0x08005144, 0x00000000 };
2238 0xf0, 0x15, 0x70, 0x82, 0xbc, 0xf2, 0xc3, 0x16, 0x27, 0xf7, 0x2d, 0xc2, 2244static const u32 bnx2_CP_b09FwBss[(0x3b0/4) + 1] = { 0x0 };
2239 0x49, 0x7e, 0x2e, 0x16, 0x6f, 0x70, 0x32, 0x02, 0x9c, 0xd4, 0xb4, 0x1a, 2245static const u32 bnx2_CP_b09FwSbss[(0xa1/4) + 1] = { 0x0 };
2240 0xd8, 0x0f, 0x5a, 0x9c, 0xe0, 0x3d, 0x75, 0x10, 0x65, 0xee, 0xab, 0xc2,
2241 0xc9, 0x41, 0xe0, 0xe4, 0x3e, 0x8b, 0x93, 0xc3, 0x16, 0x27, 0x87, 0x51,
2242 0x26, 0x0f, 0x9c, 0x14, 0x96, 0xc1, 0xc9, 0x08, 0x70, 0x12, 0xb6, 0x5b,
2243 0x40, 0x3b, 0x87, 0xab, 0x70, 0x32, 0xb2, 0x0c, 0x4e, 0xb8, 0xe6, 0x1a,
2244 0xee, 0xe1, 0xbe, 0xfc, 0x06, 0x7b, 0xb8, 0x53, 0x9f, 0x7d, 0xe3, 0x3d,
2245 0xdc, 0x2c, 0x73, 0xb9, 0xea, 0xcc, 0xfb, 0xb3, 0x76, 0x4f, 0x9a, 0xd9,
2246 0xfb, 0x37, 0x7f, 0x0f, 0x5e, 0x3b, 0xf8, 0xbc, 0x90, 0xf7, 0xc4, 0xec,
2247 0x21, 0x75, 0xb7, 0x4d, 0x81, 0xd7, 0x8e, 0xca, 0x81, 0xe3, 0xb5, 0x87,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9e, 0x52, 0x32, 0x3f, 0xad, 0xc7, 0xce, 0x5d, 0xac, 0xc9, 0xc3, 0xb3,
2278 0xc2, 0xbd, 0xf8, 0xfc, 0x1b, 0x74, 0xdf, 0x68, 0xe5, 0x19, 0x77, 0xde,
2279 0x8f, 0xd8, 0x5f, 0x09, 0xf7, 0x86, 0xbf, 0xfe, 0x19, 0x10, 0xfd, 0x77,
2280 0x5d, 0xf4, 0xde, 0x70, 0x4d, 0x7b, 0xd2, 0x76, 0x26, 0xa6, 0x75, 0x84,
2281 0xa1, 0xf1, 0xf9, 0xbf, 0xe7, 0x22, 0xf2, 0x7f, 0x01, 0x95, 0xf6, 0x2d,
2282 0x58, 0xd0, 0x73, 0x00, 0x00, 0x00 };
2283static u32 bnx2_CP_b09FwData[(0x50/4) + 1] = {
2284 0x00010030, 0x00000030, 0x00000000, 0x00000001, 0x00010fd0, 0x00000fd0,
2285 0x00001430, 0x0000007f, 0x00030400, 0x00001000, 0x00000030, 0x00000020,
2286 0x00050200, 0x00001000, 0x00000030, 0x00000010, 0x00010400, 0x00000400,
2287 0x00001030, 0x00000020, 0x00000000 };
2288static u32 bnx2_CP_b09FwRodata[(0x118/4) + 1] = {
2289 0x080005d8, 0x080007f8, 0x0800073c, 0x08000764, 0x0800078c, 0x080007b4,
2290 0x08000610, 0x080005fc, 0x08000820, 0x08000820, 0x0800062c, 0x08000648,
2291 0x08000648, 0x08000820, 0x08000660, 0x08000674, 0x08000820, 0x08000688,
2292 0x08000820, 0x08000820, 0x0800069c, 0x08000820, 0x08000820, 0x08000820,
2293 0x08000820, 0x08000820, 0x08000820, 0x08000820, 0x08000820, 0x08000820,
2294 0x08000820, 0x080006b0, 0x08000820, 0x080006c4, 0x080006d8, 0x080006ec,
2295 0x08000820, 0x08000700, 0x08000714, 0x08000728, 0x08003740, 0x08003758,
2296 0x08003768, 0x08003778, 0x08003790, 0x080037a8, 0x080037b8, 0x080037c8,
2297 0x080037e8, 0x080037f8, 0x08003808, 0x08003898, 0x080037d8, 0x08003818,
2298 0x08003828, 0x08003840, 0x08003860, 0x08003898, 0x08003878, 0x08003878,
2299 0x080055f0, 0x080055f0, 0x080055f0, 0x080055f0, 0x080055f0, 0x08005618,
2300 0x08005618, 0x08005640, 0x08005690, 0x08005660, 0x00000000 };
2301static u32 bnx2_CP_b09FwBss[(0x870/4) + 1] = { 0x0 };
2302static u32 bnx2_CP_b09FwSbss[(0xe9/4) + 1] = { 0x0 };
2303 2246
2304static struct fw_info bnx2_cp_fw_09 = { 2247static struct fw_info bnx2_cp_fw_09 = {
2305 .ver_major = 0x1, 2248 .ver_major = 0x3,
2306 .ver_minor = 0x0, 2249 .ver_minor = 0x4,
2307 .ver_fix = 0x0, 2250 .ver_fix = 0x3,
2308 2251
2309 .start_addr = 0x0800006c, 2252 .start_addr = 0x0800006c,
2310 2253
2311 .text_addr = 0x08000000, 2254 .text_addr = 0x08000000,
2312 .text_len = 0x73cc, 2255 .text_len = 0x6ee8,
2313 .text_index = 0x0, 2256 .text_index = 0x0,
2314 .gz_text = bnx2_CP_b09FwText, 2257 .gz_text = bnx2_CP_b09FwText,
2315 .gz_text_len = sizeof(bnx2_CP_b09FwText), 2258 .gz_text_len = sizeof(bnx2_CP_b09FwText),
2316 2259
2317 .data_addr = 0x08007500, 2260 .data_addr = 0x08007020,
2318 .data_len = 0x50, 2261 .data_len = 0x0,
2319 .data_index = 0x0, 2262 .data_index = 0x0,
2320 .data = bnx2_CP_b09FwData, 2263 .data = bnx2_CP_b09FwData,
2321 2264
2322 .sbss_addr = 0x08007554, 2265 .sbss_addr = 0x08007024,
2323 .sbss_len = 0xe9, 2266 .sbss_len = 0xa1,
2324 .sbss_index = 0x0, 2267 .sbss_index = 0x0,
2325 .sbss = bnx2_CP_b09FwSbss, 2268 .sbss = bnx2_CP_b09FwSbss,
2326 2269
2327 .bss_addr = 0x08007640, 2270 .bss_addr = 0x080070d0,
2328 .bss_len = 0x870, 2271 .bss_len = 0x3b0,
2329 .bss_index = 0x0, 2272 .bss_index = 0x0,
2330 .bss = bnx2_CP_b09FwBss, 2273 .bss = bnx2_CP_b09FwBss,
2331 2274
2332 .rodata_addr = 0x080073d0, 2275 .rodata_addr = 0x08006ee8,
2333 .rodata_len = 0x118, 2276 .rodata_len = 0x118,
2334 .rodata_index = 0x0, 2277 .rodata_index = 0x0,
2335 .rodata = bnx2_CP_b09FwRodata, 2278 .rodata = bnx2_CP_b09FwRodata,
2336}; 2279};
2337 2280
2338static u8 bnx2_RXP_b09FwText[] = { 2281static u8 bnx2_RXP_b09FwText[] = {
2339 0x1f, 0x8b, 0x08, 0x08, 0x19, 0xfd, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65, 2282 0x1f, 0x8b, 0x08, 0x00, 0x0e, 0x34, 0xe7, 0x45, 0x00, 0x03, 0xec, 0x5c,
2340 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5c, 0x6b, 0x6c, 2283 0x5d, 0x6c, 0x1c, 0xd7, 0x75, 0x3e, 0xf3, 0x43, 0x6a, 0x49, 0xf1, 0x67,
2341 0x1c, 0xd7, 0x75, 0x3e, 0xf3, 0x20, 0xb5, 0xa2, 0xf8, 0x18, 0x2e, 0x57, 2284 0xb8, 0x5c, 0xb1, 0x2b, 0x99, 0x96, 0x77, 0xc9, 0x91, 0xc8, 0x58, 0x8a,
2342 0xcc, 0x4a, 0x66, 0xec, 0x5d, 0x71, 0x24, 0xb2, 0x16, 0x6b, 0x8c, 0xd8, 2285 0x31, 0xa2, 0x09, 0x5b, 0x48, 0x17, 0xf6, 0x76, 0x76, 0x25, 0xb1, 0xb1,
2343 0xad, 0x4d, 0x04, 0x6b, 0x7b, 0x33, 0xbb, 0x92, 0x98, 0x54, 0x85, 0x29, 2286 0x03, 0x53, 0xb6, 0x62, 0x07, 0x45, 0x6a, 0xb0, 0x4b, 0xb9, 0x0e, 0x8c,
2344 0x87, 0x75, 0x0c, 0xc3, 0x75, 0xd9, 0xa5, 0x1a, 0xbb, 0xae, 0x51, 0xc8, 2287 0x06, 0x90, 0xff, 0x52, 0xbf, 0xb0, 0xde, 0x2c, 0xa9, 0x58, 0x4d, 0x17,
2345 0x8f, 0xc4, 0x06, 0x6a, 0xd6, 0x9b, 0x25, 0xdd, 0xa8, 0xe9, 0x82, 0x43, 2288 0x9c, 0xb5, 0x4d, 0x9b, 0x0e, 0x60, 0xb7, 0x0b, 0x92, 0x12, 0xf5, 0xb0,
2346 0x4b, 0xaa, 0xe9, 0x02, 0x69, 0xbb, 0x20, 0xa9, 0xc7, 0x8f, 0x85, 0x56, 2289 0xd0, 0xb2, 0xa9, 0xdb, 0xea, 0xc1, 0x8e, 0x09, 0x56, 0xb1, 0x53, 0xa0,
2347 0x76, 0x52, 0xc7, 0xf9, 0xe1, 0x48, 0x50, 0x95, 0x20, 0x28, 0x0c, 0x43, 2290 0x2d, 0x5c, 0x27, 0x69, 0xfc, 0x10, 0x14, 0xaa, 0xec, 0xc4, 0x42, 0xd1,
2348 0x48, 0x8d, 0xd6, 0x3f, 0xda, 0x40, 0x95, 0x9f, 0x68, 0x92, 0x42, 0x41, 2291 0xa2, 0x02, 0x12, 0xd8, 0x29, 0x22, 0x7b, 0xfa, 0x7d, 0x77, 0x66, 0xc8,
2349 0x0b, 0xc7, 0x68, 0x6c, 0x4f, 0xbf, 0xef, 0xce, 0x0c, 0xb9, 0xa4, 0x5f, 2292 0x25, 0x2d, 0xdb, 0x41, 0x1f, 0xfa, 0xd2, 0xbd, 0xc0, 0x62, 0xee, 0xbd,
2350 0x40, 0x7f, 0xf4, 0x4f, 0xe7, 0x02, 0x8b, 0xb9, 0xf7, 0xce, 0x3d, 0xe7, 2293 0x73, 0xee, 0xb9, 0xe7, 0x9e, 0xff, 0x73, 0x87, 0xd2, 0x1f, 0x74, 0x48,
2351 0x9e, 0x7b, 0xde, 0xe7, 0x0e, 0xa5, 0xdf, 0xef, 0x94, 0x0e, 0x09, 0x5b, 2294 0xbb, 0x84, 0xad, 0x13,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e, 0x3e, 0x55, 0x04, 0x2f, 0x66, 0xbc, 0x94, 0x80, 0xcf,
2381 0x70, 0x46, 0xff, 0x9c, 0x6e, 0xdb, 0x56, 0x15, 0x6b, 0xab, 0xcd, 0x97, 2324 0x59, 0x77, 0xb4, 0x5f, 0x5e, 0xab, 0x27, 0xe5, 0xbb, 0x75, 0x3b, 0x59,
2382 0xf8, 0xef, 0x5f, 0xac, 0xe9, 0x9c, 0x82, 0xa9, 0x80, 0xee, 0x70, 0x2d, 2325 0x92, 0x6d, 0x52, 0x48, 0x58, 0xb2, 0x82, 0x35, 0xd3, 0xa0, 0x43, 0xb7,
2383 0xcf, 0xa1, 0xd6, 0xaa, 0xb3, 0x04, 0x6b, 0xa5, 0x32, 0x9d, 0xc3, 0x5c, 2326 0x6d, 0xab, 0x04, 0xd8, 0x52, 0xfd, 0x27, 0xfc, 0xb7, 0x32, 0xd6, 0xe4,
2384 0x73, 0x34, 0xe4, 0xef, 0x16, 0x9c, 0x97, 0x4f, 0x4b, 0xaa, 0x9e, 0x01, 2327 0xa8, 0x5a, 0x53, 0x04, 0xdd, 0x21, 0x2c, 0xcf, 0xa1, 0x60, 0xd5, 0x59,
2385 0xde, 0xb0, 0xff, 0xcf, 0xc0, 0x37, 0x80, 0xf3, 0x5e, 0xab, 0x7e, 0xee, 2328 0x02, 0x58, 0x29, 0x4e, 0x8e, 0x62, 0xae, 0xfe, 0x85, 0x50, 0x16, 0xad,
2386 0xa2, 0xa4, 0x74, 0xd9, 0x99, 0x2e, 0x0b, 0x78, 0xdb, 0xec, 0xc4, 0x98, 2329 0x38, 0x2f, 0x9f, 0xbb, 0x71, 0xbe, 0xdd, 0xe0, 0x89, 0x24, 0x74, 0xd9,
2387 0xf4, 0xf9, 0xfe, 0x7e, 0x47, 0xac, 0xaa, 0xd3, 0x03, 0x98, 0x8c, 0x54, 2330 0x93, 0x2c, 0x60, 0x66, 0xba, 0xde, 0x81, 0x31, 0x69, 0xf1, 0xfd, 0x23,
2388 0x9d, 0x6e, 0xe0, 0x69, 0x13, 0xcb, 0xe6, 0xb9, 0xb8, 0xd7, 0x66, 0xcc, 2331 0x8e, 0x58, 0x25, 0xa7, 0x1b, 0xbc, 0x4b, 0x49, 0xc9, 0xe9, 0xc2, 0x9a,
2389 0xfb, 0x5d, 0x46, 0xde, 0xf7, 0xa7, 0x73, 0xd2, 0x1d, 0xcc, 0xed, 0x56, 2332 0x16, 0xb1, 0x6c, 0x9e, 0x81, 0x78, 0xdb, 0x30, 0xef, 0x77, 0x1a, 0x19,
2390 0x38, 0xa6, 0x26, 0x34, 0xac, 0xfb, 0x05, 0x69, 0x4e, 0x24, 0xf3, 0xec, 2333 0xdf, 0x9f, 0x1c, 0x95, 0xae, 0x60, 0x6e, 0x1f, 0x70, 0x98, 0x32, 0x31,
2391 0xf3, 0x99, 0x13, 0x77, 0xfe, 0xda, 0x90, 0x96, 0x34, 0x68, 0xb9, 0x26, 2334 0xae, 0x01, 0xee, 0x03, 0xd2, 0x17, 0x8b, 0x67, 0xd8, 0xe7, 0x73, 0x54,
2392 0xec, 0x83, 0xff, 0x1e, 0xf8, 0xe0, 0x7c, 0x06, 0x63, 0xed, 0x3a, 0xe0, 2335 0xdc, 0xd9, 0x54, 0xb8, 0x6f, 0x87, 0x94, 0xbc, 0xeb, 0xc3, 0x3e, 0x78,
2393 0x19, 0xae, 0x0a, 0xf7, 0xe8, 0x93, 0xa5, 0x94, 0xe8, 0x57, 0x9c, 0xde, 2336 0xed, 0xe1, 0xcc, 0xce, 0x4e, 0x8c, 0xb5, 0x1b, 0x80, 0xc7, 0x29, 0x09,
2394 0x70, 0x5d, 0x37, 0x68, 0x8d, 0xf4, 0xa0, 0x5f, 0xe6, 0x16, 0xc9, 0xeb, 2337 0xf7, 0xd8, 0x21, 0x6b, 0x09, 0xd1, 0x2f, 0x39, 0xbd, 0x21, 0x5c, 0x17,
2395 0x1a, 0x64, 0x83, 0xe7, 0x8d, 0x15, 0xad, 0xd0, 0x3c, 0x82, 0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0x35, 0x3d, 0x21, 0x3d, 0xd4, 0x25, 0xea,
2403 0xd3, 0xb6, 0xdb, 0x6b, 0x4a, 0xc5, 0xd2, 0x25, 0x6b, 0x15, 0xe5, 0x3a, 2346 0x91, 0x9e, 0xcd, 0xcf, 0xfd, 0x69, 0x6f, 0x69, 0xff, 0x76, 0xc2, 0xc0,
2404 0x99, 0x73, 0x44, 0x8a, 0x35, 0xec, 0x69, 0x9b, 0xe0, 0x8d, 0x0d, 0xde, 2347 0x3e, 0x52, 0x0f, 0x4d, 0xda, 0x6e, 0x8f, 0x29, 0x45, 0x4b, 0x97, 0xb4,
2405 0xec, 0x3c, 0x32, 0xa8, 0xff, 0x96, 0x64, 0xfa, 0x2b, 0x9a, 0x19, 0xf2, 2348 0x95, 0x93, 0x1b, 0x64, 0xc6, 0x11, 0xc9, 0x41, 0xbf, 0x75, 0xdb, 0x04,
2406 0x71, 0x49, 0x6e, 0x51, 0xf0, 0x7a, 0xde, 0x81, 0x7e, 0x76, 0xb0, 0x8f, 2349 0x8f, 0x6c, 0xf0, 0x68, 0xcf, 0xa9, 0x41, 0xfd, 0x0e, 0x49, 0xf5, 0x15,
2407 0x7d, 0x13, 0x6a, 0x5f, 0x23, 0x6f, 0xa7, 0x97, 0x45, 0x34, 0x3d, 0xbf, 2350 0x35, 0x33, 0xe4, 0xe7, 0x82, 0xdc, 0xa6, 0xd6, 0xeb, 0x19, 0x07, 0x3a,
2408 0x1b, 0xf8, 0xa8, 0xb7, 0x5c, 0xf7, 0x04, 0x68, 0x24, 0xed, 0xec, 0xdb, 2351 0xd9, 0xce, 0x3e, 0xf6, 0x8d, 0xa9, 0x7d, 0x8d, 0x8c, 0x9d, 0x5c, 0x14,
2409 0x80, 0x49, 0x88, 0xeb, 0x74, 0xb5, 0xd0, 0x49, 0x79, 0x93, 0xd7, 0xe4, 2352 0xd1, 0xf4, 0xcc, 0x3e, 0xe0, 0xa3, 0xae, 0x12, 0xee, 0x29, 0xd0, 0x48,
2410 0x9d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f, 0x50, 0x3c, 0xe8, 2360 0x68, 0xe3, 0x18, 0xb6, 0x67, 0xe3, 0xfd, 0x7e, 0xd8, 0xfa, 0xc1, 0x41,
2418 0xc5, 0x79, 0x06, 0xe7, 0xc9, 0xaf, 0x0e, 0xe8, 0xb6, 0x26, 0x65, 0x27, 2361 0xf0, 0x87, 0x70, 0x76, 0x0a, 0xf2, 0xce, 0xba, 0xd8, 0xd3, 0x75, 0x6e,
2419 0x9b, 0xa1, 0xdc, 0x03, 0xda, 0x75, 0xd9, 0x74, 0x63, 0x2b, 0xed, 0x91, 2362 0x56, 0x3c, 0xe8, 0xc1, 0x79, 0x06, 0x67, 0xc9, 0xaf, 0x76, 0xe8, 0xb3,
2420 0xac, 0xa8, 0x87, 0xa6, 0x24, 0x47, 0xb9, 0x96, 0xeb, 0xb8, 0x3e, 0x3b, 2363 0x26, 0x05, 0x27, 0x9d, 0xa2, 0xfc, 0x03, 0xda, 0x75, 0xd9, 0x76, 0x4b,
2421 0x26, 0xfa, 0xaf, 0x7c, 0x6b, 0xdd, 0x59, 0x6d, 0xd9, 0x31, 0x0f, 0x1a, 2364 0x23, 0xed, 0x91, 0xac, 0xa8, 0x8f, 0xa6, 0xc4, 0x47, 0x08, 0x4b, 0x38,
2422 0x02, 0xde, 0x82, 0x27, 0x9f, 0xb6, 0x96, 0x7c, 0xdd, 0xc8, 0x3f, 0xae, 2365 0xc2, 0xa7, 0x0f, 0x8a, 0xfe, 0x6b, 0xdf, 0xda, 0x74, 0x56, 0x5b, 0x06,
2423 0x6d, 0x5d, 0x07, 0x9d, 0xe8, 0x27, 0x0d, 0x27, 0x3a, 0x03, 0x5b, 0x8b, 2366 0x66, 0x41, 0x43, 0xc0, 0x5b, 0xf0, 0xe4, 0xb3, 0x60, 0xc9, 0xd7, 0xad,
2424 0x68, 0x8a, 0x64, 0xa3, 0x85, 0x38, 0x3e, 0xe9, 0x1c, 0x5c, 0x0f, 0x1f, 2367 0xfc, 0x23, 0x6c, 0x23, 0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b5, 0x34, 0x6c, 0xdd, 0x4c, 2382 0xda, 0xdb, 0x01, 0xd8, 0x9b, 0xd3, 0x2a, 0x69, 0xe7, 0xef, 0x60, 0x6f,
2440 0xbf, 0x26, 0x3b, 0x33, 0xb3, 0xa2, 0xc9, 0x09, 0xce, 0x35, 0x30, 0xa7, 2383 0x4f, 0x39, 0x1a, 0x78, 0x23, 0x72, 0xa1, 0xdc, 0x01, 0x5b, 0x37, 0x93,
2441 0x7c, 0x71, 0xe0, 0x0b, 0x2e, 0x1b, 0x4f, 0x81, 0x2e, 0xdf, 0x9f, 0x05, 2384 0xef, 0xc8, 0x9e, 0xd4, 0xb4, 0x68, 0x72, 0x9a, 0x73, 0x35, 0xcc, 0x29,
2442 0xce, 0xf2, 0x88, 0x11, 0xda, 0x56, 0x34, 0x6f, 0xdd, 0xef, 0xda, 0xee, 2385 0xff, 0x1b, 0xd8, 0xf7, 0x45, 0xe3, 0x69, 0xd0, 0xe5, 0xfb, 0xd3, 0xc0,
2443 0xaf, 0x19, 0x52, 0x19, 0x6e, 0x93, 0xec, 0xf0, 0x12, 0x70, 0x4f, 0x3b, 2386 0x59, 0xd8, 0x6f, 0x84, 0xb6, 0x15, 0xcd, 0xa7, 0x10, 0xf3, 0xdc, 0xcf,
2444 0x81, 0x1d, 0x53, 0xd7, 0x97, 0x81, 0x7f, 0xce, 0x1b, 0x82, 0x1e, 0xd3, 2387 0x19, 0x52, 0x1c, 0x6e, 0x91, 0xf4, 0xf0, 0x02, 0x70, 0x4f, 0x3a, 0x81,
2445 0x0e, 0x40, 0x17, 0xf0, 0x2f, 0x03, 0xff, 0x5c, 0xb3, 0x4d, 0xbe, 0x6e, 2388 0x1d, 0x53, 0xd7, 0x17, 0x81, 0x7f, 0xc6, 0x1b, 0x82, 0x1e, 0xd3, 0x0e,
2446 0x46, 0xb1, 0x32, 0x3a, 0x4f, 0x37, 0x96, 0x45, 0xfb, 0x1e, 0x96, 0x2f, 2389 0x40, 0x17, 0xf0, 0x2f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3, 0x65, 0x3c, 0x4c, 0x9c, 0x3b, 0xd6, 0x70, 2404 0x7d, 0x6d, 0x1b, 0xb8, 0x53, 0x21, 0x3d, 0xbd, 0x6d, 0x1b, 0x38, 0x6c,
2462 0x8e, 0xac, 0xa7, 0xe7, 0xb0, 0xc0, 0x07, 0x25, 0xda, 0xf3, 0xb2, 0xe7, 2405 0xe2, 0x6c, 0x18, 0x0f, 0x13, 0xe7, 0xc0, 0x06, 0xce, 0xfd, 0x9b, 0xe9,
2463 0x62, 0x6d, 0x70, 0xe2, 0x8b, 0x82, 0x58, 0x37, 0xb2, 0x29, 0xf4, 0xc9, 2406 0x39, 0x21, 0xf0, 0x41, 0xb1, 0xd6, 0x8c, 0x1c, 0xb8, 0x50, 0x1e, 0x1c,
2464 0xe6, 0x1e, 0x17, 0xbc, 0x32, 0x85, 0x3e, 0x4e, 0x93, 0x2a, 0xe4, 0x7c, 2407 0xff, 0xa2, 0x20, 0xe6, 0xed, 0xdf, 0x16, 0xfa, 0x64, 0xf3, 0x80, 0x0b,
2465 0x7f, 0x43, 0xf6, 0x5c, 0x68, 0x98, 0xa1, 0x2e, 0x51, 0x27, 0xde, 0x86, 2408 0x5e, 0x99, 0x42, 0x1f, 0xa7, 0x49, 0x09, 0x72, 0x7e, 0xa8, 0x26, 0x07,
2466 0x8d, 0x75, 0x4e, 0x99, 0x88, 0xc3, 0xe7, 0x94, 0x8d, 0xc9, 0x44, 0xb5, 2409 0xd6, 0x6a, 0x12, 0xea, 0x12, 0x75, 0xe2, 0x32, 0x6c, 0x4c, 0x8a, 0xbb,
2467 0x26, 0x95, 0xed, 0xf9, 0x27, 0x7c, 0xe8, 0xe2, 0x94, 0x05, 0x3f, 0x5a, 2410 0x32, 0x1d, 0x13, 0x66, 0xc6, 0x82, 0xad, 0xc9, 0x78, 0x09, 0x3e, 0xd9,
2468 0x94, 0xce, 0x31, 0x37, 0x87, 0xf9, 0x06, 0x6d, 0x0b, 0x7e, 0x05, 0xb0, 2411 0xc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x68, 0x83, 0x4f, 0xcb, 0xe2,
2476 0xb9, 0xe6, 0x29, 0xd8, 0xab, 0xa2, 0x55, 0x26, 0x90, 0x13, 0xe8, 0xa3, 2419 0xd4, 0xfa, 0xc8, 0xbf, 0x85, 0xf6, 0xc9, 0xfe, 0xfb, 0x7e, 0xe0, 0xef,
2477 0xef, 0x43, 0x4f, 0x70, 0x16, 0xf8, 0xc0, 0x02, 0xb8, 0xa4, 0x8f, 0xbe, 2420 0xef, 0xe8, 0x0e, 0xe6, 0xde, 0x0a, 0x6d, 0x3a, 0xc2, 0x45, 0x3c, 0xc3,
2478 0x11, 0xda, 0x33, 0xfb, 0xef, 0xf8, 0x41, 0x7c, 0xf8, 0x7c, 0xb8, 0xff, 2421 0xda, 0x38, 0x72, 0x92, 0xf1, 0xba, 0xa9, 0xd1, 0x3f, 0xe7, 0x3c, 0xe6,
2479 0x3f, 0x75, 0x07, 0x3e, 0x20, 0xc2, 0x45, 0x3c, 0xc3, 0xda, 0x04, 0xf2, 2422 0x12, 0xcc, 0x23, 0xa6, 0x43, 0x3f, 0x27, 0xd9, 0x1c, 0xfc, 0x88, 0x8e,
2480 0x99, 0x89, 0xa6, 0xa9, 0xd1, 0x9f, 0x17, 0x3d, 0xe6, 0x21, 0xcc, 0x41, 2423 0xdc, 0xa2, 0x00, 0xbb, 0x31, 0x33, 0x57, 0x64, 0x46, 0xf9, 0x48, 0x89,
2481 0x1e, 0x0b, 0xfd, 0x22, 0x73, 0x8f, 0xce, 0x90, 0xa7, 0xb9, 0x28, 0xce, 2424 0xb5, 0x64, 0x9e, 0x00, 0xcc, 0x7f, 0xc0, 0xe6, 0xda, 0xba, 0x43, 0x3d,
2482 0x29, 0x7b, 0x43, 0xcc, 0xc9, 0x94, 0x9d, 0x36, 0xe5, 0x93, 0xa7, 0x73, 2425 0x0c, 0x7d, 0xbc, 0xf2, 0xbb, 0x80, 0xbd, 0xbc, 0x05, 0xf6, 0xdd, 0x46,
2483 0x9d, 0x58, 0x87,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9, 0x6d, 0x88, 0x55, 2433 0xf5, 0x2c, 0x7e, 0x45, 0x99, 0x7c, 0x16, 0xb9, 0x98, 0xdd, 0x42, 0x5e,
2491 0x9c, 0xdf, 0x6a, 0x05, 0x67, 0x8d, 0xe0, 0xee, 0xef, 0x5b, 0x3f, 0xfe, 2434 0x90, 0x35, 0x56, 0xc0, 0xa3, 0x68, 0xdd, 0x13, 0xbd, 0x9b, 0xc7, 0xf7,
2492 0x42, 0x72, 0xcd, 0x47, 0xd2, 0xc2, 0xa4, 0x80, 0x18, 0x01, 0x5e, 0x65, 2435 0xc5, 0x37, 0x7c, 0x25, 0x2d, 0x4d, 0xb2, 0x88, 0x15, 0xe0, 0x71, 0x6a,
2493 0xa6, 0x98, 0xc3, 0x15, 0x1b, 0x4a, 0xa6, 0x98, 0x1b, 0x83, 0x5f, 0x0c, 2436 0x42, 0xcf, 0x24, 0x24, 0x57, 0x0b, 0xf8, 0x8b, 0x78, 0x0b, 0xff, 0xc8,
2494 0xf2, 0xa2, 0x73, 0xde, 0x46, 0xd9, 0x59, 0xe0, 0x77, 0x01, 0x3c, 0xce, 2437 0x2e, 0x64, 0xb2, 0xee, 0x07, 0x23, 0x99, 0x53, 0xcf, 0xb2, 0x90, 0x4d,
2495 0x40, 0x87, 0xc6, 0x01, 0x2b, 0x87, 0x81, 0x83, 0xf1, 0xd7, 0xd1, 0xf3, 2438 0x0a, 0xba, 0x34, 0x86, 0xb5, 0x72, 0x02, 0x38, 0x18, 0x87, 0x1d, 0x3d,
2496 0x49, 0x29, 0x5b, 0xcc, 0x13, 0xda, 0x49, 0x67, 0x81, 0xf6, 0xaf, 0xe7, 2439 0x13, 0x97, 0x82, 0xc5, 0x7c, 0x41, 0xe5, 0x7a, 0x59, 0xfa, 0x01, 0x3d,
2497 0x37, 0x63, 0x8e, 0xfd, 0x7b, 0x7b, 0x02, 0x99, 0x75, 0x71, 0x3c, 0xa1, 2440 0xd3, 0x86, 0x39, 0xf6, 0x1f, 0xee, 0x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00, 0x3d, 0xb6, 0x94, 2455 0xff, 0x48, 0xe8, 0x9f, 0xbe, 0xf6, 0xa0, 0xab, 0x7c, 0x79, 0x98, 0x83,
2513 0x27, 0x91, 0x2f, 0x68, 0x83, 0xd6, 0x26, 0xad, 0x03, 0x76, 0x0c, 0x1b, 2456 0xc1, 0xef, 0x64, 0x15, 0xd4, 0x1b, 0xe0, 0x8f, 0x26, 0xef, 0x41, 0x8f,
2514 0x57, 0x63, 0x49, 0xb4, 0xe5, 0x2f, 0xcd, 0x2c, 0xd5, 0x74, 0xac, 0x45, 2457 0xdf, 0xa9, 0xb4, 0x83, 0x1e, 0x5b, 0x0a, 0xc7, 0x90, 0xbb, 0x68, 0x83,
2515 0xee, 0x93, 0x43, 0x1f, 0xb2, 0xbf, 0xb2, 0x40, 0x38, 0x5d, 0x5e, 0x5f, 2458 0xd6, 0x36, 0xad, 0x1d, 0x79, 0x18, 0xfc, 0x8e, 0x1a, 0x93, 0x67, 0x17,
2516 0x30, 0xe4, 0x4d, 0xe4, 0x52, 0x6f, 0xd9, 0x97, 0x66, 0x10, 0xb7, 0xfa, 2459 0xa7, 0x16, 0xca, 0x3a, 0x60, 0xc1, 0xf3, 0x51, 0xf4, 0xa1, 0x7f, 0x97,
2517 0x11, 0x23, 0x50, 0x8b, 0xec, 0xa4, 0x9f, 0xde, 0x61, 0xe2, 0x59, 0xc2, 2460 0x2a, 0x5c, 0xa7, 0xcb, 0xbb, 0x15, 0x43, 0x7e, 0x8e, 0xbc, 0xee, 0x3d,
2518 0x6f, 0x1f, 0x72, 0xc1, 0x8f, 0x86, 0xf9, 0xb8, 0xf5, 0xa4, 0x2d, 0x01, 2461 0xfb, 0xe2, 0x14, 0x6c, 0xb0, 0x0f, 0xf1, 0x0a, 0xb5, 0xd0, 0x1e, 0xc6,
2519 0x18, 0xae, 0x37, 0x41, 0x5b, 0x37, 0xe4, 0x9f, 0xb5, 0xa6, 0xe4, 0xf5, 2462 0x8c, 0x01, 0x13, 0xcf, 0x3c, 0x7e, 0x87, 0x91, 0xe7, 0x5d, 0x7b, 0xcd,
2520 0x1e, 0x95, 0xaf, 0x68, 0x9c, 0x0f, 0x7c, 0xd3, 0x87, 0xe7, 0xc9, 0x67, 2463 0x27, 0xc1, 0x93, 0xb6, 0x18, 0xd6, 0x10, 0xde, 0x04, 0x6d, 0x5d, 0xd0,
2521 0x03, 0x3a, 0xce, 0x31, 0xdf, 0xd1, 0x87, 0x12, 0x5f, 0x76, 0xac, 0x80, 2464 0xc1, 0xb4, 0x35, 0x21, 0xdd, 0x96, 0xca, 0x9d, 0x34, 0xce, 0x07, 0x7e,
2522 0xc3, 0x5c, 0x59, 0x08, 0xfa, 0xd1, 0x9c, 0x68, 0x51, 0x1c, 0xa3, 0x6f, 2465 0xf2, 0xe3, 0xf3, 0xe4, 0xb3, 0x01, 0x1d, 0xe2, 0x98, 0xef, 0xe8, 0xcf,
2523 0x2c, 0xc1, 0x4e, 0x38, 0x9e, 0x10, 0x25, 0x83, 0x75, 0xf2, 0x94, 0x84, 2466 0x89, 0x2f, 0x7d, 0x30, 0x8b, 0xc3, 0x5c, 0xaa, 0x04, 0xfd, 0x68, 0x4e,
2524 0x99, 0x3f, 0x3b, 0x33, 0x67, 0x53, 0xae, 0xf0, 0x71, 0xb5, 0x48, 0xae, 2467 0xb4, 0x28, 0xa6, 0xd2, 0x4f, 0xe7, 0x61, 0xab, 0x1c, 0x8f, 0x8b, 0x92,
2525 0x94, 0x51, 0xbb, 0x54, 0x17, 0xbe, 0x09, 0xb9, 0xea, 0x61, 0xbe, 0x0f, 2468 0xc1, 0x26, 0x79, 0x52, 0x8f, 0x56, 0xa7, 0x66, 0x6c, 0xca, 0xd5, 0x92,
2526 0x1b, 0x3f, 0x4e, 0xf9, 0xa2, 0xfe, 0x5b, 0x40, 0xee, 0xb3, 0x20, 0xc9, 2469 0xe9, 0x72, 0x24, 0x57, 0xca, 0x08, 0x75, 0x66, 0xe5, 0xdb, 0x90, 0xab,
2527 0xa0, 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0xdf, 0xa3, 0xce, 0x84, 2477 0xe1, 0x73, 0x28, 0xff, 0x8b, 0x53, 0xd9, 0xda, 0x75, 0x52, 0x78, 0xd6,
2535 0xff, 0x86, 0x3f, 0x9b, 0x4a, 0x65, 0x4f, 0xbb, 0x46, 0x47, 0xe8, 0x03, 2478 0x42, 0x9e, 0x69, 0xb0, 0x2e, 0x93, 0xc7, 0x9c, 0x3b, 0xe2, 0x94, 0xbd,
2536 0x6e, 0x49, 0x4a, 0x07, 0xf6, 0x82, 0x0f, 0x5c, 0x7a, 0x1a, 0x36, 0xa0, 2479 0x6e, 0xb3, 0x4e, 0x39, 0x49, 0x38, 0xd4, 0xbb, 0x1a, 0xf2, 0x97, 0x16,
2537 0x6a, 0x9a, 0x04, 0xfc, 0x0d, 0x73, 0x01, 0x93, 0x76, 0x8c, 0x3a, 0x30, 2480 0x99, 0x48, 0xa4, 0x57, 0x5c, 0x23, 0x19, 0xfa, 0xa3, 0x3b, 0x01, 0x87,
2538 0x9b, 0x71, 0x0d, 0xd6, 0x77, 0xb4, 0x67, 0x03, 0x81, 0x83, 0x70, 0xfb, 2481 0x3d, 0xbd, 0x0e, 0x59, 0x7b, 0x1e, 0xb6, 0xe0, 0xa0, 0x56, 0x4e, 0xc4,
2539 0x2c, 0xca, 0xcd, 0xb4, 0xe9, 0x57, 0x0b, 0xa1, 0x8f, 0x4b, 0x84, 0x7a, 2482 0xe0, 0xfb, 0x54, 0x7e, 0xa2, 0x7c, 0x4b, 0xe0, 0x4b, 0xa3, 0x9a, 0x91,
2540 0x69, 0x61, 0xfe, 0xf1, 0xd0, 0x27, 0x6f, 0xdc, 0x07, 0xf1, 0x02, 0xf9, 2483 0x73, 0xd9, 0x70, 0x8e, 0xf1, 0xd1, 0x02, 0xec, 0x72, 0x18, 0x43, 0xb6,
2541 0x64, 0xb0, 0x8e, 0xb0, 0x5a, 0x08, 0xdb, 0x17, 0xce, 0x75, 0x82, 0xdf, 2484 0xe2, 0xa4, 0x6f, 0x3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8, 0xc6, 0xf6, 0x70, 0x9c, 0x51, 0xbc, 0x38, 0xdb, 2499 0x8e, 0x74, 0xd0, 0xce, 0xd0, 0xe7, 0x7c, 0xfa, 0x4a, 0x56, 0xa7, 0x9e,
2557 0xe8, 0x90, 0xef, 0xd4, 0xb7, 0xc8, 0x72, 0x9d, 0xef, 0xdb, 0x65, 0xa9, 2500 0xfd, 0x00, 0xfa, 0x95, 0xae, 0x04, 0x3a, 0x49, 0xdc, 0xc4, 0x0b, 0xf9,
2558 0x3e, 0x78, 0xb5, 0x4f, 0xef, 0x97, 0xf3, 0xd7, 0x5c, 0x6f, 0xdd, 0xa3, 2501 0xd8, 0x6f, 0x00, 0x27, 0xde, 0xd5, 0x06, 0x81, 0xeb, 0x0d, 0xc5, 0x8b,
2559 0x23, 0x37, 0x98, 0xfc, 0x40, 0x7e, 0x39, 0xda, 0x23, 0x3f, 0xfe, 0x72, 2502 0xbb, 0x9d, 0xf4, 0x15, 0x84, 0x28, 0xff, 0x92, 0x3d, 0x38, 0x3c, 0xa0,
2560 0xf6, 0x99, 0x3f, 0xd5, 0x61, 0x03, 0xa3, 0x9d, 0xb4, 0x6d, 0xf4, 0x39, 2503 0xef, 0x92, 0x6a, 0xf2, 0x46, 0xeb, 0xbb, 0x88, 0x07, 0xd9, 0x44, 0xfa,
2561 0x9f, 0xbd, 0x5a, 0xd0, 0xa9, 0xdb, 0x3f, 0x02, 0x4f, 0xb3, 0x0b, 0x81, 2504 0xd4, 0x45, 0x59, 0x9d, 0xba, 0x60, 0x53, 0x17, 0x69, 0xc3, 0xff, 0x80,
2562 0x1d, 0x10, 0x37, 0xf1, 0x42, 0x37, 0xec, 0xef, 0x01, 0x27, 0xde, 0x35, 2505 0x9c, 0xd4, 0x92, 0x4a, 0x8d, 0xbe, 0x8b, 0xb8, 0x58, 0x17, 0xec, 0xb5,
2563 0x06, 0x81, 0xeb, 0x7b, 0x8a, 0x17, 0xb7, 0x3b, 0xd9, 0xab, 0x08, 0x49, 2506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f,
2600 0xe4, 0x45, 0xf4, 0x74, 0x86, 0xf4, 0x4d, 0x86, 0xe3, 0x44, 0x48, 0x43, 2543 0xbf, 0x40, 0xf9, 0xed, 0x43, 0x8e, 0x6f, 0x07, 0xba, 0x69, 0x6d, 0xec,
2601 0x2b, 0xbe, 0x4e, 0xe0, 0x42, 0xac, 0xcf, 0x79, 0x21, 0x1e, 0xfa, 0x11, 2544 0x99, 0x9f, 0xeb, 0x82, 0xac, 0xb8, 0x6f, 0xbb, 0x1c, 0x83, 0xdd, 0xe7,
2602 0xd0, 0x3a, 0x99, 0x96, 0x15, 0x8f, 0x74, 0x6c, 0x91, 0x6a, 0x8a, 0xfd, 2545 0xaa, 0xdc, 0xff, 0x18, 0xf4, 0xe8, 0x2d, 0xb5, 0x7f, 0x7e, 0xa9, 0x2f,
2603 0x03, 0xd0, 0x37, 0xe2, 0xd9, 0xc4, 0x7c, 0x66, 0x1d, 0x8f, 0x1f, 0x6c, 2546 0x5c, 0xcf, 0xb5, 0x5d, 0x5b, 0xd6, 0xb6, 0xca, 0xa1, 0x8a, 0x75, 0x8d,
2604 0x54, 0xc0, 0x63, 0xf2, 0x97, 0xeb, 0x10, 0x23, 0x3e, 0x47, 0xf9, 0xed, 2547 0xf5, 0xbf, 0x8f, 0xf5, 0xba, 0x9c, 0x1e, 0xe5, 0x7a, 0xe2, 0x01, 0x5c,
2605 0x46, 0x2e, 0x6f, 0x07, 0xba, 0x69, 0xad, 0xed, 0x59, 0x3a, 0xde, 0x0d, 2548 0x35, 0xf1, 0x29, 0x78, 0xe2, 0xaa, 0xde, 0xcf, 0x55, 0x5b, 0x25, 0x57,
2606 0x59, 0x71, 0xdf, 0x0e, 0x99, 0x84, 0xdd, 0x17, 0xeb, 0xdc, 0x7f, 0x12, 2549 0x89, 0x70, 0x11, 0xcf, 0x47, 0xa8, 0x87, 0xbf, 0xaa, 0x70, 0x4d, 0x2a,
2607 0x7a, 0x74, 0x51, 0xed, 0x5f, 0x5a, 0xe9, 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e3, 0x58, 0x55, 0xd9, 0x9a,
2622 0xef, 0xa6, 0x3a, 0xfb, 0xa1, 0x15, 0xde, 0xbf, 0x66, 0x78, 0x47, 0x37, 2565 0x3b, 0xfc, 0x5f, 0xe6, 0x0d, 0xdc, 0x9f, 0xfe, 0x1a, 0x79, 0x82, 0x87,
2623 0x8c, 0xda, 0x5b, 0x1e, 0x5a, 0xb1, 0xe5, 0x6b, 0x8d, 0x61, 0x79, 0xb8, 2566 0x3c, 0xc1, 0x43, 0x9e, 0xe0, 0x21, 0x4f, 0xf0, 0x90, 0x27, 0x78, 0xc8,
2624 0x91, 0xb5, 0xee, 0x81, 0x0f, 0x28, 0xaf, 0xde, 0xcb, 0x6e, 0x4b, 0xd2, 2567 0x13, 0x3c, 0xe4, 0x09, 0x1e, 0xf2, 0x04, 0xc4, 0xee, 0xa0, 0x5e, 0x18,
2625 0x7f, 0x99, 0xc8, 0x3d, 0xdb, 0xec, 0x20, 0x17, 0xa9, 0xb2, 0x36, 0x3b, 2568 0x43, 0xfe, 0x0b, 0xff, 0xe5, 0xdd, 0x06, 0x3e, 0xf1, 0xfe, 0x92, 0x31,
2626 0x9e, 0xe5, 0x7d, 0x8d, 0x55, 0x97, 0x8d, 0xf9, 0xca, 0xff, 0x65, 0xae, 2569 0x87, 0xb1, 0x99, 0x73, 0xab, 0xdb, 0x5c, 0xca, 0x4d, 0xf9, 0xbe, 0x3b,
2627 0xc2, 0xfd, 0xe9, 0xaf, 0x91, 0x9b, 0x78, 0xc8, 0x4d, 0x3c, 0xe4, 0x26, 2570 0x31, 0x37, 0x1e, 0xe6, 0x23, 0x84, 0x89, 0x62, 0x37, 0xe1, 0xe4, 0xa0,
2628 0x1e, 0x72, 0x13, 0x0f, 0xb9, 0x89, 0x87, 0xdc, 0xc4, 0x43, 0x6e, 0xe2, 2571 0xeb, 0x68, 0xb0, 0x31, 0xe6, 0x2b, 0x41, 0xcc, 0x0a, 0x72, 0xe5, 0xb7,
2629 0x21, 0x37, 0x41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x6f, 0x36, 0x31, 0x44, 2579 0x88, 0x97, 0xfe, 0x75, 0x65, 0x2a, 0x57, 0x5d, 0x51, 0x3a, 0x75, 0xb4,
2637 0x99, 0xdf, 0xf7, 0x31, 0xf9, 0x72, 0xc4, 0xdf, 0xe0, 0xbe, 0x4f, 0x5f, 2580 0x96, 0x47, 0x7d, 0xd4, 0xd3, 0x2b, 0xed, 0x26, 0x6a, 0xab, 0x08, 0x37,
2638 0x22, 0xff, 0x44, 0x7a, 0xcf, 0x80, 0xe1, 0x67, 0x12, 0x92, 0x3c, 0xb9, 2581 0x71, 0xfe, 0x32, 0xae, 0x6a, 0x9e, 0x73, 0xeb, 0xf2, 0x84, 0xac, 0xb9,
2639 0x05, 0x73, 0x96, 0xf4, 0xa9, 0x3b, 0x23, 0x88, 0xf2, 0xcc, 0x7f, 0x40, 2582 0xcf, 0xca, 0x54, 0xa9, 0x92, 0x4e, 0xb2, 0x56, 0xce, 0x5a, 0x2b, 0x53,
2640 0x5e, 0xb6, 0xe8, 0x67, 0x78, 0xb3, 0x40, 0xbc, 0xf4, 0xaf, 0xf5, 0x99, 2583 0x27, 0x81, 0x63, 0x11, 0xb9, 0x81, 0xa1, 0xf6, 0x5e, 0x99, 0x9a, 0xae,
2641 0x62, 0xbd, 0xae, 0x74, 0xea, 0x60, 0xa3, 0x84, 0x3c, 0xca, 0xe8, 0x93, 2584 0x04, 0xf7, 0x59, 0x01, 0x0d, 0x8c, 0x57, 0xed, 0x62, 0x2c, 0x04, 0xf7,
2642 0x0e, 0x13, 0xb5, 0x54, 0x84, 0x9b, 0x38, 0xdf, 0x4c, 0xaa, 0x1a, 0xe7, 2585 0x5a, 0xba, 0x5a, 0xcb, 0x75, 0x5c, 0x6f, 0x62, 0x1d, 0xe5, 0x36, 0x8c,
2643 0xcc, 0xaa, 0x3c, 0x21, 0x6b, 0xee, 0x53, 0x9f, 0xa9, 0x2e, 0x64, 0xd3, 2586 0xb5, 0x94, 0x1d, 0x69, 0x58, 0x99, 0x2a, 0x56, 0x1b, 0x69, 0x20, 0x1e,
2644 0xac, 0x71, 0x0b, 0x56, 0x7d, 0xe6, 0x49, 0xe0, 0x58, 0x46, 0x6e, 0x60, 2587 0xe2, 0x8d, 0xce, 0xc3, 0xb3, 0xc4, 0x45, 0x3f, 0xe3, 0xfb, 0x85, 0x91,
2645 0xa8, 0xbd, 0xeb, 0x33, 0xb3, 0x0b, 0xc1, 0xbd, 0x55, 0x40, 0x03, 0xe3, 2588 0xfe, 0x30, 0xef, 0x3a, 0x89, 0xfc, 0xce, 0x0c, 0xf4, 0x5c, 0x8d, 0xbf,
2646 0x55, 0x87, 0x18, 0x4b, 0xc1, 0xfd, 0x95, 0xae, 0x60, 0x09, 0x47, 0x78, 2589 0xa3, 0xe2, 0x54, 0x4a, 0xe7, 0x3c, 0x9f, 0x78, 0x37, 0xba, 0x80, 0x39,
2647 0x13, 0x70, 0x94, 0xdb, 0x30, 0x60, 0x29, 0x3b, 0xd2, 0x50, 0x9f, 0xa9, 2590 0x8c, 0x17, 0x23, 0x58, 0x3d, 0x84, 0xed, 0x6c, 0xe0, 0x67, 0x4b, 0xb8,
2648 0xd4, 0x5b, 0x69, 0x20, 0x1e, 0xe2, 0x8d, 0xce, 0xc3, 0xb3, 0x24, 0x45, 2591 0x1f, 0x69, 0xe2, 0x39, 0x2f, 0x61, 0x2f, 0xd2, 0x45, 0x98, 0x38, 0x68,
2649 0x3f, 0xe9, 0xfb, 0xe5, 0xd1, 0x81, 0xb0, 0xae, 0x44, 0x1d, 0x79, 0xcc, 2592 0x83, 0x2c, 0xbd, 0xff, 0x2d, 0xef, 0x1b, 0xcf, 0x44, 0x9e, 0x9a, 0x58,
2650 0x0c, 0xf4, 0x5c, 0x8d, 0xff, 0x58, 0xc5, 0xa9, 0x8c, 0xce, 0x79, 0x3e, 2593 0x43, 0x78, 0xe2, 0x88, 0xd6, 0xe0, 0xc5, 0xb9, 0x60, 0x9d, 0xbe, 0x7e,
2651 0xf1, 0x2e, 0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0xde, 0x79, 0x75, 0xb5, 0xde, 0x59, 0x9e, 0x67, 0xbd, 0xf3, 2623 0xe6, 0xff, 0xd3, 0x8e, 0xad, 0x45, 0x13, 0xfb, 0x1b, 0x3b, 0x82, 0xfa,
2681 0xca, 0xba, 0x7a, 0xe7, 0xca, 0xd3, 0x97, 0xd6, 0xd5, 0x3b, 0x57, 0x9e, 2624 0xac, 0x71, 0xbe, 0xab, 0x61, 0xfe, 0x8a, 0xfa, 0xce, 0x5a, 0x28, 0xb7,
2682 0x7e, 0x29, 0x1c, 0x4b, 0xa8, 0x0f, 0x21, 0xad, 0x96, 0x83, 0x67, 0x4f, 2625 0xfd, 0x0a, 0x1e, 0x58, 0x96, 0x86, 0x98, 0xe7, 0x7d, 0xe4, 0xf3, 0xfb,
2683 0x98, 0x73, 0x34, 0xfb, 0xd6, 0xff, 0xdf, 0x74, 0xca, 0x96, 0x35, 0xb1, 2626 0x9f, 0xab, 0xb7, 0xab, 0x6f, 0x72, 0xae, 0xca, 0xb7, 0x61, 0xe7, 0x23,
2684 0xff, 0x68, 0x6b, 0x50, 0x23, 0xb5, 0xce, 0x77, 0xb7, 0xcc, 0x5f, 0x56, 2627 0xa5, 0x1d, 0x81, 0x2f, 0x60, 0x3f, 0xa1, 0x05, 0xfe, 0xfd, 0x8f, 0x81,
2685 0xdf, 0x4b, 0xcb, 0xb5, 0xcd, 0xef, 0xc2, 0x03, 0xcb, 0xca, 0x10, 0xf3, 2628 0x07, 0xbc, 0xf6, 0x1a, 0x6b, 0x38, 0x2b, 0xbc, 0x4b, 0xb9, 0x32, 0xc5,
2686 0xbc, 0x0f, 0x7c, 0x7e, 0xf3, 0x73, 0xf5, 0x0e, 0xf5, 0xcd, 0xcd, 0x55, 2629 0xdc, 0xba, 0xa4, 0x70, 0xb3, 0xd6, 0x63, 0xdd, 0x17, 0xc5, 0x80, 0x08,
2687 0xf9, 0x36, 0xec, 0x7c, 0xf4, 0xd1, 0xad, 0x81, 0x2f, 0x60, 0x3f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30,
2702 0x7a, 0xe8, 0x03, 0xd2, 0x17, 0x70, 0xe6, 0x29, 0xd4, 0x5f, 0x87, 0x83, 2645 0x42, 0x59, 0xf3, 0x79, 0x2d, 0xde, 0x45, 0x67, 0xfa, 0xf3, 0xf0, 0x4c,
2703 0x7b, 0xb4, 0x70, 0x9f, 0x1b, 0xb5, 0x20, 0x6f, 0xce, 0x69, 0x95, 0xf0, 2646 0xd9, 0xb0, 0x9e, 0x8e, 0xce, 0x14, 0x93, 0x77, 0x67, 0x2d, 0xac, 0xfd,
2704 0x0e, 0xf0, 0x2b, 0xf0, 0x17, 0x86, 0x4e, 0xd8, 0x77, 0x80, 0x5b, 0x93, 2647 0x1c, 0xf8, 0x91, 0x97, 0xa5, 0x7a, 0xea, 0x33, 0xf0, 0x94, 0x1b, 0x78,
2705 0xa5, 0xa3, 0x86, 0xba, 0x3b, 0x2d, 0x8f, 0x52, 0xd6, 0x7c, 0x7e, 0x14, 2648 0x63, 0x6e, 0x91, 0x61, 0x71, 0xa3, 0x86, 0x1f, 0x4f, 0xc2, 0x0e, 0xbf,
2706 0xef, 0xa2, 0x33, 0xfd, 0x4d, 0x78, 0xa6, 0xd1, 0xb0, 0x6e, 0x8f, 0xce, 2649 0xd1, 0x1b, 0xdd, 0x0d, 0x1b, 0xb6, 0xcf, 0xba, 0x07, 0x8d, 0xf3, 0xfd,
2707 0x94, 0x90, 0xd7, 0xe7, 0x2d, 0xc0, 0x8e, 0x80, 0x1f, 0x25, 0x59, 0x69, 2650 0xb0, 0xc5, 0x14, 0xec, 0x93, 0x39, 0x53, 0x9e, 0xb5, 0x0a, 0xed, 0xc9,
2708 0x66, 0x3e, 0x05, 0x4f, 0xad, 0x85, 0x37, 0xe6, 0x06, 0x19, 0x46, 0x75, 2651 0x72, 0x8d, 0xb4, 0x75, 0x4c, 0x86, 0x51, 0xef, 0xf0, 0xfc, 0x19, 0x59,
2709 0x0f, 0x78, 0x30, 0x91, 0x86, 0x1d, 0xde, 0xd7, 0x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, 0x85, 0x74, 0x88, 0xf2, 0x9f, 0x2a, 0x6e, 2674 0x0f, 0xd9, 0x2e, 0xf0, 0xfb, 0x63, 0x22, 0xa8, 0x31, 0x83, 0xfa, 0x2b,
2732 0x29, 0x7c, 0xc6, 0x06, 0x5f, 0xf0, 0xa4, 0x7a, 0x9e, 0x37, 0xe8, 0x9b, 2675 0x45, 0x5f, 0x88, 0xb6, 0xa4, 0xfc, 0x64, 0x5e, 0x7d, 0x6f, 0x8c, 0x03,
2733 0x18, 0xff, 0xa8, 0xc3, 0xdd, 0xf0, 0x7f, 0xd0, 0x41, 0xd8, 0x71, 0x71, 2676 0xc6, 0xa7, 0xef, 0x6c, 0xf8, 0x9b, 0x89, 0x1f, 0x64, 0x83, 0xbf, 0x99,
2734 0x91, 0xf7, 0x13, 0x43, 0xea, 0x4e, 0xab, 0x04, 0xd9, 0x2e, 0xf1, 0x3b, 2677 0x08, 0xbf, 0xfd, 0x56, 0x83, 0x3c, 0xe2, 0xe1, 0x9a, 0x29, 0x13, 0xb5,
2735 0x63, 0x2a, 0xc8, 0x27, 0x83, 0xfa, 0x2b, 0x43, 0x5f, 0x88, 0xf6, 0xb8, 2678 0xe8, 0x6f, 0x28, 0x28, 0x07, 0xf8, 0xe6, 0x5a, 0x94, 0x3b, 0xf8, 0x41,
2736 0xf2, 0x93, 0x25, 0xf5, 0x5d, 0x31, 0x89, 0x35, 0x3e, 0x9e, 0xad, 0x7f, 2679 0x4d, 0xb3, 0x49, 0x96, 0x4b, 0x61, 0x4e, 0xc4, 0x1a, 0x80, 0x3c, 0xc4,
2737 0x27, 0xf1, 0xa3, 0x42, 0xf0, 0x77, 0x12, 0xe1, 0x37, 0xde, 0x7a, 0x90, 2680 0x78, 0x31, 0xaa, 0x2f, 0x07, 0x20, 0x3f, 0xf0, 0x1c, 0x74, 0xbd, 0x3b,
2738 0x47, 0x3c, 0xd8, 0x30, 0x65, 0xaa, 0x11, 0xfd, 0xdd, 0x04, 0xe5, 0x60, 2681 0x1b, 0xd4, 0xb9, 0x25, 0xfa, 0xc5, 0xfe, 0xa8, 0xee, 0xdd, 0x25, 0xa5,
2739 0x4b, 0xb9, 0x11, 0xe5, 0x0e, 0x7e, 0x50, 0xd3, 0xac, 0x93, 0xe5, 0xe3, 2682 0x63, 0x7c, 0x1f, 0x93, 0x77, 0x66, 0x63, 0xea, 0x7d, 0x41, 0x62, 0xe1,
2740 0x61, 0x4e, 0xc4, 0x1a, 0x80, 0x3c, 0xc4, 0x78, 0x39, 0x90, 0xdf, 0x92, 2683 0x7b, 0x8e, 0xe3, 0x52, 0x50, 0xef, 0xab, 0x21, 0x3e, 0xd4, 0x69, 0x5f,
2741 0xbe, 0x03, 0xf2, 0x03, 0xcf, 0x3d, 0x13, 0xb6, 0x94, 0x0e, 0xe3, 0xba, 2684 0x89, 0xc6, 0xa6, 0x76, 0xbc, 0x1e, 0xac, 0x9b, 0xac, 0x57, 0xe5, 0xf1,
2742 0xc5, 0x1a, 0x33, 0xac, 0x7b, 0xb7, 0x4b, 0x75, 0x92, 0xef, 0x13, 0xf2, 2685 0xfa, 0x2a, 0xce, 0xaf, 0x49, 0x6e, 0xbc, 0x28, 0xbb, 0x6d, 0x4b, 0xc5,
2743 0xda, 0xfc, 0x40, 0x70, 0x4f, 0x24, 0x89, 0xf0, 0x3d, 0xc7, 0x49, 0x29, 2686 0x7d, 0x37, 0x4e, 0x1d, 0xa3, 0x7e, 0x8d, 0xa9, 0xba, 0xb3, 0x88, 0x7c,
2744 0xab, 0xf7, 0x77, 0x86, 0xf8, 0x50, 0xa7, 0xdd, 0x19, 0x8d, 0xd3, 0x90, 2687 0xa1, 0x30, 0xc2, 0x6f, 0x3c, 0xbf, 0xba, 0xab, 0x50, 0x4e, 0x5b, 0x59,
2745 0x63, 0x00, 0x37, 0x8d, 0x58, 0xf6, 0x55, 0xc4, 0xb1, 0x69, 0xf0, 0xbd, 2688 0xf9, 0xd0, 0x77, 0x4d, 0x8e, 0x45, 0x47, 0x3d, 0x74, 0xd7, 0xc3, 0xb5,
2746 0x38, 0x51, 0x91, 0x6b, 0x6d, 0x4b, 0xc5, 0x7d, 0x37, 0x49, 0x1d, 0xa3, 2689 0x0b, 0x77, 0x05, 0x67, 0xc5, 0xfb, 0x1a, 0x61, 0x0d, 0xf5, 0x6d, 0xf6,
2747 0x7e, 0x11, 0xa6, 0x07, 0xb9, 0x2a, 0xce, 0x3b, 0x2a, 0x53, 0x46, 0xfe, 2690 0x5f, 0x6f, 0x35, 0x65, 0xed, 0x56, 0xdf, 0xbf, 0xdf, 0xb1, 0xc4, 0x0d,
2748 0xdd, 0xdb, 0xca, 0xb5, 0xac, 0x55, 0x90, 0xf7, 0x7d, 0xd7, 0xe4, 0xf8, 2691 0x6b, 0x57, 0x4b, 0xd5, 0xae, 0xed, 0x2a, 0x07, 0x71, 0x47, 0x52, 0x5a,
2749 0xfc, 0x6d, 0x0f, 0x06, 0x77, 0xfe, 0xba, 0x9e, 0xbf, 0x78, 0x5b, 0x39, 2692 0x1e, 0xf6, 0x7a, 0xc6, 0x43, 0x9d, 0xa3, 0xa7, 0x0f, 0xae, 0xea, 0x16,
2750 0xe8, 0xe3, 0xcc, 0xef, 0x86, 0x7d, 0xc2, 0x19, 0xea, 0x7b, 0xec, 0x4f, 2693 0x62, 0x6e, 0x3a, 0x35, 0x27, 0x6e, 0x2f, 0xbf, 0x37, 0xcf, 0x38, 0x84,
2751 0x6e, 0x32, 0xe5, 0xc2, 0x4d, 0xbe, 0x7f, 0x0f, 0xbf, 0x09, 0x85, 0x75, 2694 0xd9, 0x19, 0xdc, 0x75, 0xdd, 0x34, 0xae, 0xfc, 0xac, 0x48, 0x18, 0x7b,
2752 0xac, 0xa5, 0xea, 0xd8, 0x0e, 0x95, 0x8f, 0xb8, 0xa3, 0x19, 0xad, 0x04, 2695 0x6e, 0x6a, 0xb4, 0x89, 0xc6, 0xdc, 0x92, 0xb6, 0x20, 0x13, 0x26, 0x68,
2753 0xdb, 0x3d, 0xe9, 0xa1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7d, 0x79, 0xd6, 2703 0xba, 0x20, 0xcf, 0x63, 0x6d, 0xb5, 0x79, 0x0d, 0xf2, 0xb5, 0x0c, 0xfd,
2761 0x9b, 0x08, 0x73, 0xb6, 0xc7, 0x56, 0x73, 0x36, 0xfe, 0xcd, 0xcb, 0xb9, 2704 0x19, 0xed, 0x22, 0x11, 0xd4, 0x8b, 0x99, 0xf3, 0xf7, 0xba, 0x88, 0xbf,
2762 0xa6, 0xa2, 0xa5, 0x52, 0x91, 0x20, 0xe7, 0x15, 0x9d, 0xf9, 0x4d, 0x94, 2705 0x85, 0x9a, 0x8a, 0xc1, 0xbc, 0x17, 0xbc, 0x97, 0x7f, 0xb7, 0x00, 0x39,
2763 0xf3, 0x7e, 0xf4, 0xf7, 0x90, 0x00, 0x8e, 0xf9, 0x1e, 0xe1, 0x2a, 0x9a, 2706 0xf0, 0xdd, 0x7d, 0xac, 0x27, 0x0a, 0xb5, 0xa4, 0x14, 0x17, 0xa3, 0xfc,
2764 0x6e, 0x13, 0x2e, 0xc8, 0xf9, 0x58, 0x67, 0xad, 0x87, 0xe1, 0x77, 0x37, 2707 0x07, 0xeb, 0xbc, 0x7d, 0x5a, 0xbe, 0x42, 0xd9, 0xea, 0x32, 0x9d, 0x00,
2765 0xfa, 0xb6, 0xe0, 0x9b, 0x4f, 0xf0, 0x7d, 0xa9, 0x76, 0x87, 0x8b, 0x58, 2708 0x53, 0xec, 0xc6, 0xbc, 0xee, 0x4d, 0x55, 0x23, 0xad, 0xd4, 0x49, 0xcf,
2766 0x5c, 0x6e, 0xa8, 0x78, 0x8c, 0x71, 0xe3, 0x0e, 0xfe, 0xad, 0x02, 0x64, 2709 0x7e, 0xd0, 0x16, 0xdd, 0xe3, 0x8a, 0x18, 0xb3, 0x09, 0xd1, 0x67, 0x91,
2767 0xc0, 0x77, 0x5f, 0x66, 0x6d, 0x51, 0x6e, 0x20, 0x2f, 0x5a, 0x8e, 0x72, 2710 0xd3, 0xda, 0x43, 0xea, 0x6f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 0xba, 0xda, 0x05, 0x42, 0xe2, 0x3a, 2725 0xcc, 0x63, 0x14, 0x3c, 0xc8, 0xa6, 0x4e, 0x42, 0x55, 0x94, 0x74, 0x5b,
2783 0xdd, 0x24, 0xb4, 0x72, 0xd5, 0x2a, 0x42, 0x60, 0x37, 0x8e, 0xfa, 0xd2, 2726 0x27, 0xee, 0xb8, 0x40, 0x5c, 0x80, 0x6a, 0x39, 0x69, 0xe9, 0x86, 0x3d,
2784 0x46, 0x55, 0xdb, 0x37, 0xaf, 0x16, 0xec, 0x38, 0xcd, 0xac, 0x17, 0x37, 2727 0xa7, 0x5b, 0xba, 0x00, 0x57, 0x9e, 0xe3, 0xa4, 0x4d, 0xe7, 0xcc, 0x1a,
2785 0x38, 0xf4, 0x71, 0xb3, 0x2c, 0x0e, 0x90, 0x75, 0x56, 0x6e, 0xf2, 0x90, 2728 0x03, 0x69, 0x70, 0x41, 0x23, 0x33, 0x6d, 0xe3, 0x66, 0x37, 0x48, 0x5c,
2786 0x3e, 0x19, 0x6d, 0xa2, 0x24, 0x55, 0xa5, 0xbc, 0x54, 0x7d, 0xab, 0x5a, 2729 0x57, 0x29, 0x83, 0x02, 0x6b, 0x2b, 0xb8, 0xe1, 0xef, 0xe2, 0xf0, 0x3c,
2787 0x0b, 0x27, 0xc4, 0x0f, 0xa9, 0xad, 0xf6, 0xa5, 0x77, 0x4d, 0xbf, 0xef, 2730 0xdf, 0x39, 0x76, 0xd3, 0xc0, 0x44, 0x24, 0xeb, 0x7c, 0xe7, 0x3b, 0xdf,
2788 0xcc, 0x2c, 0xc6, 0xa4, 0x51, 0x91, 0x56, 0x73, 0xe6, 0xcc, 0xb9, 0x9f, 2731 0xff, 0xf7, 0xbe, 0xcf, 0xfb, 0x9b, 0x6e, 0xb9, 0x08, 0x3a, 0xce, 0x8d,
2789 0xff, 0xf2, 0xfd, 0x17, 0x3e, 0x67, 0x67, 0xba, 0xc2, 0xbd, 0xcd, 0x95, 2732 0xb5, 0xfa, 0x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, 0x0d, 0xae,
2826 0x9b, 0xde, 0x55, 0x43, 0x68, 0x6f, 0xe7, 0xdf, 0x53, 0xc4, 0x79, 0x79, 2769 0xb1, 0x8d, 0x31, 0x38, 0xbf, 0xce, 0x06, 0x8d, 0xb0, 0x8e, 0xf4, 0x9d,
2827 0xbf, 0x15, 0xb8, 0x7c, 0x1c, 0x78, 0x28, 0x53, 0xbf, 0x20, 0x8d, 0x91, 2770 0x04, 0x4f, 0x26, 0x29, 0x37, 0x31, 0xde, 0x18, 0xc6, 0x63, 0xb9, 0x13,
2828 0x28, 0xda, 0x10, 0xaf, 0x68, 0x59, 0x22, 0x59, 0x8f, 0x39, 0x5a, 0xcc, 2771 0xe3, 0x5d, 0x90, 0x94, 0xd3, 0x18, 0x73, 0x0a, 0x6d, 0x88, 0x33, 0x53,
2829 0x97, 0xc2, 0x1a, 0xa7, 0x74, 0x2e, 0x57, 0x1f, 0xcf, 0x9c, 0x58, 0x3e, 2772 0xd0, 0x1f, 0x86, 0xd4, 0xec, 0x7a, 0x18, 0xf2, 0xbb, 0x4f, 0x66, 0xcd,
2830 0xa8, 0xb3, 0x41, 0x23, 0xac, 0x23, 0x7d, 0xa7, 0x35, 0xa6, 0x82, 0x0e, 2773 0x23, 0x07, 0xf6, 0x98, 0xd5, 0xf6, 0x81, 0x61, 0x8c, 0xf9, 0x6b, 0xea,
2831 0xc5, 0x78, 0xc3, 0x92, 0xd1, 0xe5, 0x2e, 0x8c, 0x77, 0x41, 0x32, 0x6e, 2774 0x3c, 0xb0, 0x26, 0xf6, 0xc7, 0x0f, 0xb6, 0x71, 0x6a, 0x7d, 0x0d, 0x38,
2832 0x73, 0xcc, 0x51, 0xb4, 0xa1, 0x9c, 0x19, 0x05, 0x96, 0xf8, 0x58, 0x8d, 2775 0xb5, 0xf6, 0x61, 0xca, 0x39, 0x2b, 0x33, 0x61, 0xae, 0x89, 0xf5, 0x61,
2833 0x2d, 0xc6, 0xa0, 0xcb, 0xe3, 0x32, 0x66, 0xee, 0xd9, 0xb1, 0xc7, 0xbc, 2776 0xac, 0x99, 0x7e, 0xac, 0x67, 0x81, 0x43, 0x47, 0xfc, 0x3a, 0xb6, 0x15,
2834 0xb6, 0x15, 0x0c, 0x63, 0x38, 0x5c, 0x53, 0xd7, 0x8e, 0x35, 0xb1, 0x3f, 2777 0x23, 0x85, 0xb3, 0xf7, 0xec, 0x5a, 0xd6, 0x7d, 0x56, 0x52, 0x6b, 0x19,
2835 0x7e, 0xb0, 0x93, 0x33, 0x8b, 0x0b, 0x90, 0x53, 0x0b, 0x1f, 0x66, 0xdc, 2778 0x99, 0xd7, 0xfd, 0x78, 0x86, 0x83, 0x5a, 0xf7, 0x20, 0xaf, 0xc6, 0x7a,
2836 0x67, 0x25, 0x1b, 0x6b, 0xd3, 0xb6, 0x4d, 0x05, 0xf7, 0x92, 0xf5, 0xe8, 2779 0x70, 0x96, 0x89, 0x07, 0x36, 0x70, 0xb4, 0x47, 0xcb, 0xcc, 0x7e, 0x8f,
2837 0xd3, 0xfa, 0x0e, 0xe4, 0xd0, 0x9e, 0xb0, 0x8e, 0x6d, 0xc5, 0xc8, 0xe0, 2780 0x67, 0xf1, 0xad, 0x87, 0x77, 0xd4, 0x26, 0xb1, 0x6f, 0x40, 0x46, 0xe6,
2838 0xec, 0x03, 0x1b, 0x97, 0x75, 0x5f, 0x96, 0xcc, 0x42, 0x4e, 0x26, 0x74, 2781 0x1b, 0xf5, 0x21, 0xf9, 0x24, 0xdf, 0xd1, 0xcf, 0x38, 0xcb, 0xdd, 0xbc,
2839 0x3f, 0x9e, 0xe1, 0x41, 0x8d, 0x43, 0xc8, 0xab, 0x03, 0xbd, 0x38, 0xcb, 2782 0x29, 0x1f, 0xe7, 0x75, 0x2c, 0x74, 0x31, 0x20, 0xd6, 0x79, 0xcf, 0x3e,
2840 0xd4, 0x03, 0x7b, 0x38, 0xd9, 0x4b, 0x2e, 0xfa, 0x4f, 0xc8, 0xb3, 0xf8, 2783 0x1f, 0x59, 0x5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0xa9, 0x8e,
2848 0x36, 0x84, 0xe3, 0x5b, 0x93, 0xcb, 0x2a, 0x95, 0x1c, 0x54, 0x56, 0xba, 2791 0xfb, 0xef, 0x53, 0xc0, 0xcc, 0xe6, 0x78, 0x67, 0x36, 0x95, 0x29, 0x2f,
2849 0x80, 0x5f, 0x8b, 0xd2, 0x71, 0xcc, 0x44, 0x52, 0x81, 0x77, 0xb1, 0x27, 2792 0xe5, 0x13, 0xd1, 0x65, 0x65, 0x65, 0x30, 0x66, 0x66, 0x56, 0x11, 0x37,
2850 0xfb, 0xa8, 0xef, 0x4f, 0xda, 0xac, 0x4f, 0x99, 0x51, 0x45, 0xdf, 0x4b, 2793 0x12, 0x66, 0x87, 0xa2, 0x4f, 0xb4, 0x5d, 0xef, 0x3b, 0x8d, 0xfe, 0x09,
2851 0xa7, 0x8e, 0x77, 0x5e, 0x3e, 0x90, 0x32, 0x8f, 0xaa, 0xfd, 0xe1, 0xfb, 2794 0xd5, 0xe2, 0xaf, 0x87, 0xf7, 0xf5, 0xe3, 0x7e, 0x8f, 0x67, 0x88, 0x39,
2852 0x28, 0x64, 0xe6, 0xf6, 0x78, 0x67, 0x96, 0x95, 0x29, 0x2f, 0x79, 0xa9, 2795 0xa3, 0xc0, 0x4c, 0xe6, 0x9a, 0xe9, 0xdc, 0x86, 0x64, 0x6c, 0x62, 0x54,
2853 0xe4, 0xac, 0xb2, 0x72, 0x18, 0x33, 0x37, 0xa6, 0x28, 0x37, 0x52, 0x66, 2796 0x63, 0xe8, 0xfd, 0x53, 0x7f, 0x47, 0x1d, 0xca, 0x25, 0xd6, 0xc5, 0x7d,
2854 0xa7, 0xa2, 0x7f, 0xb4, 0x5d, 0xef, 0x7b, 0x12, 0xfd, 0x53, 0xaa, 0x25, 2797 0x7e, 0x1b, 0xd5, 0x3a, 0xf3, 0xfd, 0x53, 0x59, 0x9d, 0xc7, 0x58, 0x57,
2855 0x5c, 0x0f, 0xef, 0xeb, 0x4a, 0x5f, 0xc0, 0x33, 0x94, 0x39, 0xfd, 0xc6, 2798 0x31, 0x7f, 0xdf, 0xcd, 0x3b, 0x8b, 0xa6, 0x9c, 0x47, 0x38, 0xce, 0x5a,
2856 0xcc, 0x02, 0xf3, 0xcb, 0x74, 0x5e, 0x43, 0x7a, 0xe0, 0x18, 0xdf, 0x0d, 2799 0x60, 0xba, 0x5d, 0x98, 0x23, 0x3a, 0x57, 0x6c, 0xd0, 0x06, 0xfd, 0x01,
2857 0xb9, 0x7f, 0xe2, 0x6f, 0xa8, 0x43, 0xb9, 0xcc, 0x3a, 0x27, 0xe4, 0xb7, 2800 0xcc, 0x17, 0x68, 0xc4, 0xbd, 0x2f, 0x88, 0x31, 0x11, 0x3c, 0x40, 0x27,
2858 0x23, 0x1a, 0x3f, 0xdf, 0x3f, 0x91, 0xd7, 0xb9, 0x8b, 0x0d, 0x35, 0x10, 2801 0xd0, 0x35, 0xa1, 0xa3, 0x56, 0x30, 0x4e, 0x6e, 0x5d, 0xb2, 0x5e, 0x7f,
2859 0xee, 0x7b, 0xfb, 0xce, 0x92, 0x19, 0xf7, 0x4b, 0x1c, 0x67, 0x21, 0x72, 2802 0x09, 0x32, 0x27, 0x35, 0x57, 0xf9, 0xb4, 0x31, 0x38, 0x37, 0xe6, 0xc0,
2860 0xb2, 0x5d, 0x98, 0x23, 0x3a, 0x5e, 0x6a, 0xd2, 0x06, 0x7d, 0x03, 0xcc, 2803 0xfb, 0xfd, 0x53, 0xa4, 0x4f, 0x9e, 0x4d, 0x54, 0xcd, 0x6d, 0x70, 0x3d,
2861 0x15, 0x68, 0xc6, 0xdd, 0x2f, 0x88, 0x71, 0xac, 0x63, 0x07, 0x9d, 0x00, 2804 0x83, 0x32, 0xbf, 0x3e, 0x24, 0xcb, 0xf8, 0xad, 0xae, 0x7b, 0xf7, 0xb6,
2862 0x77, 0x02, 0xaf, 0x56, 0x31, 0x4e, 0x61, 0x51, 0xf2, 0x41, 0x7f, 0xe9, 2805 0x0d, 0xdd, 0x7a, 0x3e, 0x6f, 0x6a, 0x7e, 0x5d, 0x76, 0x18, 0x33, 0x01,
2863 0x60, 0x4e, 0x6a, 0xa1, 0xfa, 0x45, 0x63, 0x04, 0x3a, 0x70, 0x1c, 0xef, 2806 0xaf, 0xe8, 0x9c, 0x2a, 0xf6, 0x65, 0x5e, 0xe1, 0x10, 0xe5, 0xa3, 0x53,
2864 0xf7, 0x4f, 0x90, 0x3e, 0x79, 0x36, 0x49, 0x35, 0xbe, 0xc4, 0xf5, 0x1c, 2807 0x87, 0x5c, 0xdd, 0xae, 0x51, 0x4f, 0x65, 0xbd, 0x35, 0x15, 0x0d, 0x74,
2865 0x94, 0x89, 0x45, 0x60, 0x23, 0xfc, 0xe6, 0x17, 0x83, 0x7b, 0xbb, 0x0e, 2808 0xc9, 0x2a, 0xf0, 0xae, 0x0c, 0xd9, 0x99, 0x7b, 0x25, 0x24, 0xcb, 0x79,
2866 0x9c, 0x3d, 0xe1, 0x99, 0x9a, 0x5f, 0x67, 0x5d, 0xc6, 0x4f, 0xc0, 0x2b, 2809 0x1d, 0x4f, 0x8e, 0xfe, 0x5e, 0x39, 0x52, 0xad, 0x4d, 0xca, 0x6e, 0x2d,
2867 0x3a, 0x8f, 0x8a, 0x7d, 0x99, 0x4b, 0x78, 0x88, 0xfa, 0xd1, 0x6d, 0x48, 2810 0xae, 0xbf, 0x51, 0xae, 0xe5, 0x5e, 0x37, 0xe4, 0xf9, 0x51, 0x9d, 0x57,
2868 0x0c, 0x6d, 0x89, 0x59, 0x59, 0x6f, 0x8d, 0x26, 0x23, 0xdd, 0x32, 0x0f, 2811 0x17, 0x2f, 0x4b, 0xef, 0x00, 0x75, 0x9e, 0x2d, 0x9d, 0x63, 0x07, 0xec,
2869 0x79, 0x57, 0x81, 0xee, 0x2c, 0x5c, 0x89, 0xca, 0xac, 0xa7, 0xe3, 0xd9, 2812 0x80, 0xce, 0xf1, 0x33, 0xe8, 0x1c, 0xef, 0x40, 0xe7, 0xf8, 0x69, 0x11,
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70, 0x94, 0xf2, 0xa3, 0x43, 0x96, 2820 0xbb, 0xd0, 0xae, 0x81, 0x5d, 0xc3, 0x5e, 0xcc, 0x5b, 0xfd, 0x05, 0x6d,
2878 0x8b, 0xab, 0x5a, 0x0e, 0x2d, 0x17, 0x59, 0x8e, 0x88, 0xce, 0x21, 0x9b, 2821 0x30, 0x47, 0xb1, 0x4b, 0xb6, 0x21, 0x43, 0xea, 0xf1, 0x2e, 0xad, 0xfb,
2879 0xda, 0x90, 0x8a, 0x5b, 0x47, 0xfd, 0x3e, 0xed, 0x0f, 0x0a, 0xfc, 0xf3, 2822 0xd5, 0xe3, 0x43, 0x3a, 0x17, 0x97, 0xe3, 0xe4, 0x0a, 0xb6, 0xac, 0x14,
2880 0x94, 0x97, 0x7f, 0x0a, 0xef, 0x5e, 0xe9, 0xdc, 0xba, 0x19, 0xb3, 0x1b, 2823 0xac, 0x68, 0x16, 0xf4, 0xb7, 0x0b, 0x5b, 0xed, 0x3a, 0xee, 0x60, 0x07,
2881 0xed, 0x9a, 0xb2, 0x6b, 0x30, 0x88, 0xb9, 0xab, 0xdb, 0x68, 0x83, 0x39, 2824 0x67, 0x70, 0xa3, 0x46, 0x39, 0x7f, 0x57, 0x63, 0xef, 0x66, 0xed, 0x4f,
2882 0x80, 0x19, 0xaf, 0x43, 0x87, 0x34, 0x9c, 0x6e, 0x8d, 0xfd, 0x1a, 0xce, 2825 0x18, 0xc7, 0x3a, 0x93, 0x94, 0x3f, 0xf6, 0x13, 0x03, 0xe9, 0x8f, 0x9a,
2883 0x21, 0x9d, 0x77, 0xcb, 0x71, 0x0a, 0x45, 0x5b, 0xe6, 0x8a, 0x56, 0x32, 2826 0xd1, 0xfd, 0xbd, 0x7e, 0xd7, 0xd1, 0x76, 0xa7, 0x46, 0x3c, 0x16, 0xb9,
2884 0x0f, 0xfa, 0xbb, 0x01, 0xbb, 0x6d, 0x15, 0x77, 0xb0, 0x86, 0x33, 0x58, 2827 0x94, 0xb7, 0x21, 0x4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 0x27, 2849 0xe4, 0x69, 0x94, 0x03, 0xa8, 0x8b, 0xfa, 0x65, 0x03, 0xe5, 0x45, 0x94,
2907 0x12, 0x38, 0xdb, 0x56, 0xcd, 0x0f, 0x0d, 0xe8, 0xef, 0x86, 0xf6, 0x29, 2850 0x5b, 0xf0, 0x64, 0x9b, 0x11, 0xe8, 0x15, 0x78, 0xbe, 0x81, 0xf1, 0xc6,
2908 0x06, 0xb1, 0x8b, 0x86, 0xc9, 0x76, 0xa7, 0xd0, 0xaf, 0x5d, 0x32, 0x57, 2851 0xb1, 0xe6, 0x8c, 0x29, 0x1f, 0x9d, 0xa2, 0x2c, 0x19, 0x53, 0xcc, 0x4b,
2909 0xdb, 0xb4, 0x5c, 0x7d, 0xb8, 0x2e, 0x0d, 0x1c, 0xf2, 0x04, 0xca, 0x11, 2852 0x5e, 0xb6, 0xf1, 0xac, 0x0e, 0xab, 0x99, 0x35, 0x96, 0xf1, 0x2c, 0x79,
2910 0xd4, 0x25, 0xc3, 0xb2, 0x81, 0xf2, 0x34, 0xca, 0x2d, 0x78, 0xb2, 0xcd, 2853 0xdf, 0x1f, 0xc2, 0x24, 0xf4, 0x49, 0x5d, 0xf5, 0x30, 0xe9, 0xa3, 0x26,
2911 0x61, 0xe0, 0x0a, 0x3c, 0x5f, 0xc3, 0x78, 0x23, 0x58, 0x73, 0xce, 0x94, 2854 0x26, 0xb1, 0xae, 0x5d, 0x66, 0xaf, 0x90, 0xd7, 0x4d, 0xd0, 0x5b, 0x87,
2912 0x8f, 0x4e, 0x50, 0x97, 0x38, 0x06, 0x73, 0x91, 0x67, 0x6d, 0x3c, 0x6b, 2855 0xcc, 0x5c, 0x0d, 0x6b, 0x7d, 0xb4, 0x0c, 0x5a, 0xdc, 0x06, 0x5d, 0x6d,
2913 0x45, 0x95, 0x5d, 0x60, 0x19, 0xcf, 0x72, 0xf0, 0xfd, 0x21, 0x99, 0x84, 2856 0x82, 0xa6, 0x52, 0x05, 0x6b, 0x6a, 0x51, 0x45, 0xb5, 0x2f, 0xe0, 0x09,
2914 0x3e, 0x99, 0x6b, 0x81, 0x4c, 0xfa, 0x68, 0x5b, 0x26, 0xb1, 0xae, 0x5d, 2857 0xd0, 0x6b, 0xf0, 0x15, 0xea, 0xa2, 0xe4, 0xe5, 0x38, 0x68, 0x4f, 0xdc,
2915 0xc6, 0xae, 0x92, 0xd7, 0x4d, 0xd0, 0x5b, 0xa7, 0x64, 0xaf, 0xc5, 0x34, 2858 0xa0, 0x6d, 0xa7, 0xe3, 0xca, 0x06, 0x0d, 0x82, 0x2e, 0x0b, 0x1e, 0x4f,
2916 0x1e, 0xad, 0x80, 0x16, 0xaf, 0x83, 0xae, 0x96, 0x41, 0x53, 0x99, 0xa2, 2859 0xbf, 0xa7, 0x34, 0xae, 0x4e, 0xdd, 0x96, 0x44, 0xf2, 0xb6, 0x58, 0xc0,
2917 0x35, 0x3a, 0xad, 0x92, 0xda, 0x2f, 0xf0, 0x38, 0xe8, 0xb5, 0xe3, 0x0a, 2860 0x02, 0xcb, 0xf9, 0x50, 0x1c, 0x8c, 0x39, 0x29, 0xd7, 0x30, 0x8f, 0x01,
2918 0xb1, 0x28, 0x79, 0xd9, 0x01, 0xed, 0x89, 0xdf, 0x61, 0xdb, 0x93, 0x8e, 2861 0xfe, 0x1e, 0x3d, 0xa1, 0xf9, 0x7b, 0x4a, 0x02, 0x87, 0x79, 0x1c, 0xf4,
2919 0xb2, 0x41, 0x83, 0xa0, 0xcb, 0x62, 0xc0, 0xd3, 0xef, 0x29, 0x2d, 0x57, 2862 0x06, 0x0c, 0xf2, 0x78, 0x3a, 0xe9, 0xd3, 0xe8, 0xd7, 0xc1, 0xbf, 0x16,
2920 0x47, 0xef, 0x48, 0x2a, 0x7d, 0x47, 0x2c, 0xc8, 0x02, 0xcb, 0xfd, 0x50, 2863 0x2c, 0xb1, 0xb0, 0xac, 0x82, 0xff, 0xb7, 0xf1, 0xfd, 0x66, 0x6d, 0x44,
2921 0x5c, 0x8c, 0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x6f,
2943 0x4c, 0x29, 0x83, 0x8e, 0xca, 0x90, 0x4f, 0x65, 0xd0, 0x14, 0x31, 0x50, 2886 0x15, 0xc7, 0x80, 0x49, 0x02, 0x8c, 0x72, 0x40, 0x1b, 0x53, 0x72, 0xbd,
2944 0x19, 0xf2, 0xad, 0x5c, 0xb7, 0x9c, 0x2a, 0xf6, 0x4c, 0x9d, 0xbd, 0x02, 2887 0x38, 0x2d, 0x3b, 0x90, 0x4f, 0x37, 0x36, 0x62, 0xd0, 0xa7, 0x23, 0xb2,
2945 0x3a, 0xba, 0x5e, 0xe7, 0xfd, 0xeb, 0x35, 0x9b, 0xd4, 0x83, 0xb7, 0xb6, 2888 0xf2, 0xda, 0xa8, 0xbc, 0xb9, 0xa1, 0x64, 0x09, 0xf4, 0x9b, 0xdb, 0xa4,
2946 0xef, 0xfe, 0xef, 0xb8, 0xfb, 0x43, 0x72, 0x03, 0x76, 0xcb, 0x9b, 0xa5, 2889 0xdf, 0x1d, 0xf4, 0x5c, 0xea, 0xd0, 0x71, 0xfa, 0xd9, 0x8a, 0xe7, 0x7f,
2947 0x61, 0xc8, 0x24, 0x21, 0x5e, 0x04, 0x6d, 0x8c, 0xca, 0x6a, 0xe9, 0xa4, 2890 0x9f, 0xab, 0x74, 0xca, 0x7c, 0xc5, 0x94, 0xc7, 0x2b, 0xdd, 0xf2, 0xe5,
2948 0xac, 0x41, 0x3f, 0xad, 0x2f, 0x0d, 0x00, 0x4f, 0x43, 0x8e, 0xbe, 0x72, 2891 0x4a, 0x58, 0x4e, 0xc3, 0x0e, 0xfc, 0x4a, 0x65, 0x50, 0x9e, 0xac, 0x0c,
2949 0x44, 0xde, 0x58, 0x52, 0x32, 0x63, 0x43, 0xbf, 0x2c, 0xd3, 0x07, 0x0f, 2892 0xc9, 0x57, 0xab, 0x51, 0xf9, 0x5a, 0xd5, 0x96, 0x4c, 0x35, 0x2e, 0xe9,
2950 0x7a, 0x2e, 0x77, 0xea, 0x98, 0xfd, 0x58,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0x43, 0xf3, 0x73, 2922 0x00, 0x00 };
2980 0xd3, 0xc7, 0xf0, 0xdb, 0x7e, 0xda, 0xb6, 0x94, 0x1b, 0x97, 0x02, 0xbf, 2923
2981 0x91, 0xb6, 0xa1, 0x21, 0x2b, 0x50, 0x47, 0x5e, 0x05, 0x9f, 0x6c, 0xb7, 2924static const u32 bnx2_RXP_b09FwData[(0x0/4) + 1] = { 0x0 };
2982 0xe5, 0xdf, 0x7f, 0x01, 0x99, 0xe7, 0xd3, 0x46, 0x40, 0x67, 0x00, 0x00, 2925static const u32 bnx2_RXP_b09FwRodata[(0x278/4) + 1] = {
2983 0x00 }; 2926 0x08004050, 0x08003f50, 0x08003ff4, 0x0800400c, 0x08004024, 0x08004044,
2984static u32 bnx2_RXP_b09FwData[(0x0/4) + 1] = { 0x0 }; 2927 0x08004050, 0x08004050, 0x08003f58, 0x00000000, 0x08004a0c, 0x08004a44,
2985static u32 bnx2_RXP_b09FwRodata[(0x278/4) + 1] = { 2928 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004a7c, 0x08004c40,
2986 0x08003fa4, 0x08003ea4, 0x08003f48, 0x08003f60, 0x08003f78, 0x08003f98, 2929 0x08004b88, 0x08004bc0, 0x08004c40, 0x08004b10, 0x08004c40, 0x08004c40,
2987 0x08003fa4, 0x08003fa4, 0x08003eac, 0x00000000, 0x080049d4, 0x08004a0c, 2930 0x08004bc0, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2988 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004a44, 0x08004c08, 2931 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c00,
2989 0x08004b50, 0x08004b88, 0x08004c08, 0x08004ad8, 0x08004c08, 0x08004c08, 2932 0x08004c40, 0x08004c00, 0x08004b88, 0x08004c40, 0x08004c40, 0x08004c00,
2990 0x08004b88, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2933 0x08004c00, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2991 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004bc8, 2934 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2992 0x08004c08, 0x08004bc8, 0x08004b50, 0x08004c08, 0x08004c08, 0x08004bc8, 2935 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2993 0x08004bc8, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2936 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2994 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2937 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2995 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2938 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2996 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2939 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2997 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2940 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2998 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2941 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
2999 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2942 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
3000 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2943 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
3001 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2944 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
3002 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2945 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
3003 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2946 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
3004 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2947 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
3005 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2948 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40, 0x08004c40,
3006 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2949 0x08004aec, 0x00000000, 0x08006058, 0x08006070, 0x08006070, 0x08006070,
3007 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2950 0x08006058, 0x08006070, 0x08006070, 0x08006070, 0x08006058, 0x08006070,
3008 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 2951 0x08006070, 0x08006070, 0x08006058, 0x08006070, 0x08006070, 0x08006070,
3009 0x08004ab4, 0x00000000, 0x0800602c, 0x08006044, 0x08006044, 0x08006044, 2952 0x08006064, 0x00000000, 0x00000000 };
3010 0x0800602c, 0x08006044, 0x08006044, 0x08006044, 0x0800602c, 0x08006044, 2953static const u32 bnx2_RXP_b09FwBss[(0x13dc/4) + 1] = { 0x0 };
3011 0x08006044, 0x08006044, 0x0800602c, 0x08006044, 0x08006044, 0x08006044, 2954static const u32 bnx2_RXP_b09FwSbss[(0x20/4) + 1] = { 0x0 };
3012 0x08006038, 0x00000000, 0x00000000 };
3013static u32 bnx2_RXP_b09FwBss[(0x13dc/4) + 1] = { 0x0 };
3014static u32 bnx2_RXP_b09FwSbss[(0x2c/4) + 1] = { 0x0 };
3015 2955
3016static struct fw_info bnx2_rxp_fw_09 = { 2956static struct fw_info bnx2_rxp_fw_09 = {
3017 .ver_major = 0x1, 2957 .ver_major = 0x3,
3018 .ver_minor = 0x0, 2958 .ver_minor = 0x4,
3019 .ver_fix = 0x0, 2959 .ver_fix = 0x3,
3020 2960
3021 .start_addr = 0x08003184, 2961 .start_addr = 0x08003184,
3022 2962
3023 .text_addr = 0x08000000, 2963 .text_addr = 0x08000000,
3024 .text_len = 0x673c, 2964 .text_len = 0x6768,
3025 .text_index = 0x0, 2965 .text_index = 0x0,
3026 .gz_text = bnx2_RXP_b09FwText, 2966 .gz_text = bnx2_RXP_b09FwText,
3027 .gz_text_len = sizeof(bnx2_RXP_b09FwText), 2967 .gz_text_len = sizeof(bnx2_RXP_b09FwText),
3028 2968
3029 .data_addr = 0x080069e0, 2969 .data_addr = 0x08006a00,
3030 .data_len = 0x0, 2970 .data_len = 0x0,
3031 .data_index = 0x0, 2971 .data_index = 0x0,
3032 .data = bnx2_RXP_b09FwData, 2972 .data = bnx2_RXP_b09FwData,
3033 2973
3034 .sbss_addr = 0x080069e0, 2974 .sbss_addr = 0x08006a00,
3035 .sbss_len = 0x2c, 2975 .sbss_len = 0x20,
3036 .sbss_index = 0x0, 2976 .sbss_index = 0x0,
3037 .sbss = bnx2_RXP_b09FwSbss, 2977 .sbss = bnx2_RXP_b09FwSbss,
3038 2978
3039 .bss_addr = 0x08006a10, 2979 .bss_addr = 0x08006a20,
3040 .bss_len = 0x13dc, 2980 .bss_len = 0x13dc,
3041 .bss_index = 0x0, 2981 .bss_index = 0x0,
3042 .bss = bnx2_RXP_b09FwBss, 2982 .bss = bnx2_RXP_b09FwBss,
3043 2983
3044 .rodata_addr = 0x08006740, 2984 .rodata_addr = 0x08006768,
3045 .rodata_len = 0x278, 2985 .rodata_len = 0x278,
3046 .rodata_index = 0x0, 2986 .rodata_index = 0x0,
3047 .rodata = bnx2_RXP_b09FwRodata, 2987 .rodata = bnx2_RXP_b09FwRodata,
3048}; 2988};
3049 2989
3050static u8 bnx2_TPAT_b09FwText[] = { 2990static u8 bnx2_TPAT_b09FwText[] = {
3051 0x1f, 0x8b, 0x08, 0x08, 0xdb, 0xfd, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65, 2991 0x1f, 0x8b, 0x08, 0x00, 0x0e, 0x34, 0xe7, 0x45, 0x00, 0x03, 0xcd, 0x58,
3052 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x58, 0x5d, 0x6c, 2992 0x5d, 0x68, 0x1c, 0xd7, 0x15, 0x3e, 0xf3, 0xb7, 0x3b, 0x52, 0x24, 0xeb,
3053 0x1c, 0x57, 0x15, 0x3e, 0xf3, 0xbb, 0x13, 0x77, 0xed, 0xbd, 0x49, 0x97, 2993 0x5a, 0xd9, 0xa6, 0xeb, 0xa0, 0x34, 0x33, 0xda, 0x91, 0xac, 0x22, 0x13,
3054 0x6a, 0x13, 0xb9, 0x74, 0xc6, 0x1e, 0x3b, 0x8b, 0x1c, 0x35, 0x93, 0xb0, 2994 0x4f, 0x9d, 0x25, 0x16, 0x65, 0x21, 0x93, 0xd9, 0x91, 0xac, 0x98, 0x3c,
3055 0x24, 0x16, 0x5a, 0xd1, 0xc9, 0xcc, 0xae, 0x6b, 0xe5, 0x29, 0x86, 0xbc, 2995 0x28, 0xc5, 0x90, 0x87, 0x52, 0x50, 0x57, 0x32, 0x09, 0x79, 0x69, 0xda,
3056 0xf1, 0xb2, 0xac, 0xed, 0x46, 0x54, 0x48, 0x4d, 0x51, 0x84, 0x22, 0x81, 2996 0xc6, 0x90, 0x3e, 0x79, 0x3b, 0x2b, 0xc7, 0x0e, 0x6c, 0xbc, 0x8d, 0x52,
3057 0x94, 0x65, 0x76, 0x53, 0x40, 0x5a, 0x65, 0xc1, 0xa0, 0x04, 0x21, 0x84, 2997 0xe4, 0x52, 0xfa, 0x60, 0xd6, 0xb1, 0x05, 0xcd, 0x46, 0x93, 0xd4, 0x7e,
3058 0x22, 0x9b, 0x66, 0x91, 0x58, 0x3c, 0x4d, 0xe9, 0x6b, 0x94, 0xbc, 0x90, 2998 0x35, 0x36, 0x4e, 0x93, 0xa7, 0x42, 0x9f, 0x52, 0xf4, 0x18, 0xd2, 0x12,
3059 0x96, 0x17, 0x9e, 0x4b, 0x9e, 0xac, 0x02, 0x12, 0x0f, 0xa8, 0x8a, 0x78, 2999 0xda, 0x52, 0x8a, 0x69, 0xa1, 0x09, 0x8d, 0xeb, 0xdb, 0xef, 0xdc, 0x99,
3060 0x40, 0x15, 0x0d, 0x1e, 0xbe, 0x33, 0x3f, 0x9b, 0x5d, 0xd7, 0x29, 0x79, 3000 0x91, 0x57, 0xb6, 0xec, 0xa4, 0x25, 0x85, 0x0a, 0x56, 0x77, 0xe6, 0xce,
3061 0xa8, 0x84, 0xa5, 0xf1, 0xcc, 0xfd, 0x39, 0xf7, 0xe7, 0x7c, 0xdf, 0x77, 3001 0x3d, 0xe7, 0x9e, 0x7b, 0xee, 0x77, 0xbe, 0x73, 0xee, 0x2d, 0xeb, 0x34,
3062 0xee, 0xb9, 0x5b, 0x92, 0x69, 0x82, 0xd2, 0xbf, 0x49, 0x3c, 0x97, 0xbe, 3002 0x48, 0xd9, 0xdf, 0x30, 0x7e, 0x2f, 0x7e, 0xf7, 0x85, 0x17, 0xab, 0x8f,
3063 0x71, 0xf1, 0xd2, 0xe2, 0x8b, 0x27, 0x4d, 0x3a, 0x71, 0xe2, 0x45, 0xe9, 3003 0x3c, 0xea, 0x10, 0x3d, 0xfa, 0x88, 0x66, 0x98, 0x06, 0x7d, 0x09, 0x7f,
3064 0x19, 0x43, 0xa6, 0xcf, 0xe0, 0x4f, 0x21, 0x12, 0xd9, 0xf8, 0xfc, 0x90, 3004 0x50, 0x22, 0x72, 0xfd, 0xfc, 0x23, 0x5b, 0xaf, 0x9d, 0x72, 0x42, 0x8f,
3065 0x21, 0x57, 0x6f, 0x4e, 0x7b, 0x36, 0x19, 0x4a, 0xd5, 0x79, 0x61, 0xd5, 3005 0x6c, 0xa3, 0x26, 0xbe, 0xbe, 0xe4, 0x11, 0x05, 0xbd, 0x69, 0xa7, 0x4e,
3066 0x26, 0x72, 0x07, 0x0b, 0xa6, 0x4f, 0xff, 0x89, 0x5a, 0x45, 0x95, 0xb8, 3006 0xff, 0x92, 0xcd, 0x92, 0x49, 0xdc, 0xff, 0x50, 0xed, 0xc6, 0xfe, 0xcb,
3067 0xfe, 0xf9, 0xea, 0xa3, 0xe3, 0x77, 0x4e, 0x5b, 0x0f, 0x6f, 0x2a, 0x64, 3007 0x07, 0xdd, 0xeb, 0x67, 0x0d, 0xb2, 0x45, 0x6d, 0xd1, 0x16, 0x93, 0x64,
3068 0x88, 0x6a, 0xc3, 0x10, 0xf3, 0x64, 0x4c, 0xc3, 0xe6, 0x97, 0x47, 0x57, 3008 0x8f, 0xd5, 0x9a, 0xce, 0x2f, 0xf6, 0x1e, 0x28, 0xd0, 0xae, 0x5c, 0x97,
3069 0x34, 0x9a, 0xca, 0xc6, 0x12, 0x14, 0xf4, 0x0c, 0xaa, 0x77, 0x31, 0x8e, 3009 0xa0, 0xb8, 0x43, 0x4d, 0xab, 0x66, 0x53, 0xd4, 0x7e, 0x49, 0x0b, 0x3b,
3070 0x7d, 0x59, 0xf2, 0x43, 0x55, 0xf2, 0x6f, 0x18, 0x24, 0x57, 0x5d, 0xc9, 3010 0x9e, 0x98, 0x85, 0x8e, 0xa0, 0x04, 0xfd, 0x1e, 0xde, 0x13, 0x53, 0x8b,
3071 0x0b, 0x6d, 0xb4, 0x49, 0xe4, 0x39, 0x39, 0x72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0xd6, 0xd9, 0x12, 0x06, 0xf0, 0x6e, 0x9c, 0x8f, 0xa2, 0x37, 3033 0xa8, 0x60, 0x83, 0xe7, 0x02, 0xf0, 0x11, 0xcf, 0xe8, 0xd4, 0x2c, 0x17,
3094 0x9d, 0x28, 0xd2, 0xab, 0x76, 0xf9, 0x16, 0x2d, 0x94, 0x34, 0x9a, 0x17, 3034 0xc9, 0xf5, 0x8f, 0xa2, 0xf7, 0xd7, 0x6d, 0x83, 0xea, 0xec, 0x2b, 0xdf,
3095 0x78, 0xc3, 0x8f, 0x36, 0x7c, 0xa5, 0x65, 0xeb, 0xc9, 0x78, 0x86, 0xbf, 3035 0xcc, 0x64, 0x18, 0x1b, 0x1f, 0x64, 0x76, 0x0a, 0x5a, 0x3c, 0x22, 0xe5,
3096 0xcb, 0x12, 0x96, 0x42, 0x1f, 0x74, 0xdf, 0x63, 0x7f, 0x94, 0x97, 0x62, 3036 0x8a, 0x2f, 0xa5, 0x55, 0xf3, 0x9c, 0x13, 0x34, 0x5d, 0x36, 0x69, 0x52,
3097 0x9b, 0x28, 0xda, 0x5c, 0xfc, 0x34, 0x9b, 0xef, 0xa7, 0x36, 0x51, 0x54, 3037 0xa0, 0x85, 0x8f, 0xbd, 0x72, 0x83, 0x2c, 0x60, 0xa1, 0x1f, 0xff, 0xfc,
3098 0xaf, 0xf0, 0xbc, 0x16, 0xf6, 0xcc, 0x5c, 0x25, 0xaa, 0x0f, 0x1c, 0xa3, 3038 0xf7, 0xa6, 0x86, 0x25, 0xd0, 0xb5, 0x36, 0xeb, 0x98, 0x70, 0x66, 0x95,
3099 0xd9, 0xc5, 0xfa, 0x6c, 0xbc, 0x07, 0x25, 0xec, 0xc1, 0x2a, 0x9b, 0x92, 3039 0x8c, 0x94, 0xf1, 0xcc, 0xbd, 0x64, 0x2e, 0x65, 0x32, 0x52, 0x46, 0x55,
3100 0x41, 0x81, 0x1d, 0xbd, 0x00, 0x7e, 0xb8, 0xbe, 0x6d, 0xbd, 0xef, 0x2b, 3040 0x81, 0x3d, 0x6f, 0x0a, 0xd8, 0x87, 0x75, 0x31, 0xc6, 0x89, 0xa2, 0x9e,
3101 0x05, 0xda, 0x72, 0xf2, 0xd4, 0x09, 0x4b, 0x14, 0x84, 0x1d, 0xf2, 0x42, 3041 0x6f, 0x37, 0xda, 0xb0, 0xd1, 0x43, 0xdb, 0x13, 0xf0, 0x0f, 0x51, 0x0b,
3102 0x19, 0x73, 0x14, 0x68, 0xd3, 0x7e, 0x18, 0xd5, 0x1d, 0x07, 0x7e, 0x21, 3042 0x63, 0xf5, 0xea, 0x7d, 0x8c, 0x0d, 0xec, 0xef, 0x82, 0x1d, 0xb5, 0xdd,
3103 0xb6, 0x2b, 0xd5, 0x69, 0x1a, 0xed, 0x0b, 0x62, 0x8d, 0x1c, 0x60, 0x21, 3043 0xf2, 0x29, 0x5a, 0xb0, 0xeb, 0xbd, 0xe9, 0xf2, 0x32, 0x3d, 0xc4, 0x73,
3104 0xc3, 0x37, 0xb3, 0xf1, 0x77, 0x10, 0x3a, 0x68, 0xa7, 0x96, 0x5c, 0xb1, 3044 0xd8, 0x56, 0xed, 0x88, 0xdd, 0x55, 0x72, 0x88, 0xc4, 0x41, 0x3c, 0xf7,
3105 0x44, 0x40, 0x56, 0xc9, 0x53, 0x48, 0xc8, 0x55, 0x81, 0x3e, 0x2d, 0xaa, 3045 0x88, 0xe2, 0x36, 0x69, 0xa1, 0x7f, 0x1f, 0xaf, 0x15, 0x72, 0xf3, 0x99,
3106 0x85, 0x06, 0xed, 0x28, 0x97, 0x63, 0x7e, 0xb7, 0x7b, 0x3b, 0xd1, 0x9d, 3046 0xdc, 0x7c, 0x26, 0x37, 0x92, 0xc9, 0x3d, 0xd5, 0x27, 0xf7, 0x14, 0xcb,
3107 0xa3, 0x25, 0xba, 0x1b, 0x16, 0xe9, 0x76, 0x48, 0x72, 0xd3, 0x01, 0x37, 3047 0x61, 0x6c, 0x90, 0x8d, 0x0d, 0xb2, 0xb1, 0x66, 0x36, 0x36, 0xca, 0xc6,
3108 0x8a, 0x82, 0xde, 0x0a, 0x47, 0xf7, 0xf2, 0x1b, 0xec, 0x25, 0x38, 0xa2, 3048 0xa2, 0xed, 0x8d, 0xc1, 0x36, 0x77, 0xca, 0xd1, 0x6c, 0x8a, 0x3d, 0xf9,
3109 0x40, 0x83, 0xab, 0xce, 0x3d, 0x30, 0xc8, 0x02, 0x46, 0x2d, 0xec, 0x3d, 3049 0x70, 0xe8, 0x53, 0x50, 0xf7, 0xdc, 0xcd, 0xba, 0x31, 0x42, 0xe7, 0xfc,
3110 0x7b, 0xf3, 0xbe, 0x76, 0xa6, 0x57, 0x6d, 0xeb, 0x87, 0x3e, 0xa3, 0x76, 3050 0x21, 0x5a, 0x49, 0xc6, 0x28, 0x4e, 0x56, 0x28, 0x4c, 0x74, 0xc8, 0x8e,
3111 0x4d, 0x43, 0xed, 0x5e, 0x7f, 0x0c, 0x30, 0x86, 0xa0, 0xab, 0xd0, 0x93, 3051 0x50, 0xd7, 0xbb, 0x2e, 0x67, 0x7d, 0x1f, 0x7b, 0x66, 0xb3, 0x5c, 0x79,
3112 0x0c, 0xbf, 0xcc, 0x6c, 0x1b, 0xd4, 0xef, 0xe6, 0xc8, 0xdc, 0x54, 0xa9, 3052 0x96, 0x1c, 0x7c, 0x9f, 0x16, 0xcb, 0xe4, 0x03, 0x2b, 0x3a, 0xf6, 0xad,
3113 0xd9, 0x2b, 0x92, 0x33, 0x6f, 0x99, 0x24, 0xcb, 0x45, 0x99, 0x54, 0x9a, 3053 0xa2, 0x9e, 0xe3, 0xc4, 0xe7, 0x35, 0x37, 0xf5, 0xaa, 0x2b, 0x62, 0x72,
3114 0xd9, 0x8c, 0x68, 0x09, 0xeb, 0xb8, 0x6f, 0xff, 0x48, 0xa7, 0xa9, 0xc0, 3054 0xcb, 0xa1, 0x41, 0x42, 0xaf, 0xc1, 0x4f, 0x49, 0x93, 0xa2, 0xc4, 0xa6,
3115 0xd1, 0x89, 0xfb, 0x18, 0x34, 0x73, 0xcb, 0x90, 0xfc, 0x1e, 0xef, 0x83, 3055 0x0f, 0x8d, 0x97, 0x54, 0x8c, 0xc6, 0x9d, 0x4d, 0x79, 0x79, 0xaf, 0x43,
3116 0x7d, 0x6e, 0xa4, 0x3e, 0x57, 0x25, 0xef, 0x46, 0x8e, 0x66, 0x37, 0xfe, 3056 0x57, 0x30, 0xcf, 0xc5, 0xa4, 0x4c, 0xbf, 0x4a, 0x4a, 0xf4, 0x4e, 0x42,
3117 0x11, 0x79, 0x36, 0x7c, 0x0d, 0x9e, 0xaf, 0x56, 0xbe, 0xa0, 0xd0, 0x04, 3057 0x7a, 0xe8, 0x03, 0xc3, 0x25, 0x41, 0x6f, 0x27, 0xfd, 0x3e, 0xff, 0x88,
3118 0xea, 0x36, 0xb9, 0xed, 0x61, 0x5a, 0xcf, 0x63, 0x44, 0x91, 0xe7, 0x3c, 3058 0x7d, 0x6e, 0xdf, 0x5f, 0x23, 0x7b, 0xb4, 0xc6, 0x38, 0x4b, 0x39, 0xa0,
3119 0x4b, 0x1e, 0xf3, 0xff, 0x3c, 0xdb, 0xe4, 0x68, 0x66, 0x83, 0x75, 0x83, 3059 0x9e, 0x72, 0x80, 0xc2, 0x52, 0xab, 0x13, 0x3f, 0x68, 0x80, 0x7f, 0x96,
3120 0xf7, 0x26, 0x97, 0x79, 0x6d, 0x07, 0xa8, 0x89, 0x1d, 0x35, 0xcb, 0x45, 3060 0xfc, 0x60, 0xb7, 0xa1, 0xf6, 0xa3, 0x89, 0x3d, 0xcc, 0x5b, 0xde, 0x9b,
3121 0xf8, 0x41, 0x8e, 0x35, 0xd2, 0xc4, 0x8e, 0x65, 0x7b, 0x02, 0x6f, 0x9e, 3061 0xab, 0xce, 0x92, 0xe7, 0x9e, 0xaa, 0x33, 0x6a, 0x4f, 0x5b, 0x39, 0x2e,
3122 0xef, 0xac, 0x92, 0xf0, 0x9d, 0xe3, 0x46, 0x9e, 0x7c, 0xe0, 0xab, 0x62, 3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9b, 0xc6, 0x2f, 0xd8, 0x5a, 0xbd, 0xc3,
3130 0x37, 0x70, 0x14, 0xd8, 0x25, 0x38, 0x71, 0xbf, 0xa5, 0x6e, 0x44, 0xed, 3070 0x3e, 0x63, 0xfc, 0xd9, 0x19, 0xfe, 0x4c, 0x2d, 0x3c, 0x53, 0xc4, 0x5c,
3131 0x78, 0xae, 0x2b, 0x3c, 0x17, 0x62, 0x92, 0xbd, 0xf8, 0x07, 0x70, 0xa3, 3071 0x7f, 0x91, 0xa1, 0x27, 0xb1, 0x0f, 0x3a, 0x2d, 0x55, 0x7f, 0x04, 0xfb,
3132 0x49, 0x79, 0x9a, 0xdf, 0xce, 0xd3, 0x85, 0x41, 0x9e, 0x66, 0xae, 0xe9, 3072 0xd0, 0xd7, 0xe5, 0x6f, 0xd7, 0xb3, 0x7e, 0xd6, 0x01, 0x7e, 0xf0, 0xef,
3133 0xf0, 0x43, 0x14, 0x75, 0x2a, 0xac, 0x51, 0xe0, 0x6d, 0x73, 0x3f, 0xab, 3073 0xa7, 0x90, 0xb9, 0xe0, 0x08, 0xcb, 0x14, 0x69, 0x7c, 0x95, 0xf9, 0x05,
3134 0xa4, 0xc8, 0xbc, 0x0e, 0xb4, 0x6f, 0x13, 0xad, 0x0d, 0x74, 0xf8, 0x4d, 3074 0x6d, 0x97, 0xdf, 0x79, 0x6d, 0x03, 0xd4, 0x80, 0x57, 0x1a, 0x53, 0x25,
3135 0x1d, 0x19, 0x5b, 0xa6, 0x97, 0x7f, 0x46, 0xf4, 0xf2, 0x80, 0x6d, 0x79, 3075 0xd8, 0xa5, 0x2b, 0xbe, 0x68, 0x80, 0x3f, 0x74, 0x6f, 0x10, 0x2d, 0xcf,
3136 0xfc, 0xc4, 0xa6, 0x89, 0x3d, 0xcb, 0xc0, 0xfc, 0xc2, 0x40, 0x46, 0xbc, 3076 0xf7, 0x73, 0x23, 0x8f, 0xa9, 0xb8, 0x33, 0x44, 0x75, 0xe0, 0xd7, 0x84,
3137 0x40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, 0xdc, 0x82, 0x66, 0xb7, 0xa9, 0xa5, 3084 0xf4, 0x5b, 0xd8, 0x53, 0x20, 0xaf, 0x6b, 0xd2, 0x1b, 0x6d, 0xf6, 0x85,
3145 0xa4, 0xf1, 0xcb, 0x1f, 0xc6, 0xaf, 0x52, 0xcc, 0x83, 0x20, 0x14, 0xb0, 3085 0x4d, 0x95, 0x35, 0x29, 0x4f, 0xfa, 0xbc, 0x27, 0xbf, 0x83, 0x5f, 0x08,
3146 0x61, 0xfd, 0x66, 0x7a, 0x65, 0xec, 0xc8, 0xf5, 0xa0, 0x65, 0x4f, 0x89, 3086 0x2b, 0x9c, 0x98, 0xf9, 0x08, 0xfb, 0xb3, 0xde, 0xe3, 0xbd, 0xb1, 0x94,
3147 0xa2, 0x55, 0xa7, 0x40, 0x4d, 0xe0, 0xee, 0x42, 0xc3, 0x4d, 0x68, 0xd8, 3087 0x4f, 0xbc, 0xd5, 0x29, 0xec, 0xeb, 0x54, 0x66, 0x23, 0xef, 0x97, 0x49,
3148 0x1f, 0xd1, 0xb0, 0xff, 0x3f, 0x35, 0x0c, 0x7d, 0x42, 0x23, 0xb7, 0xc1, 3088 0x2b, 0x55, 0x9d, 0xce, 0x57, 0x3f, 0x93, 0xba, 0xc7, 0xfc, 0x5a, 0x80,
3149 0xa9, 0xb7, 0x7a, 0xfb, 0xe9, 0x99, 0xb5, 0xcc, 0x9a, 0x36, 0xe9, 0xce, 3089 0x6f, 0x31, 0xae, 0x8b, 0x71, 0x49, 0x01, 0x3e, 0xfc, 0x07, 0x78, 0x45,
3150 0xd1, 0xa7, 0xd5, 0x74, 0x49, 0x7e, 0x4a, 0x4d, 0xb7, 0x58, 0xd3, 0x2a, 3090 0xca, 0xf3, 0x55, 0xf4, 0xaf, 0x1e, 0x87, 0xad, 0x06, 0x64, 0x53, 0x8c,
3151 0x6b, 0xba, 0xb8, 0x57, 0xd3, 0xd3, 0x18, 0x23, 0xd1, 0xe6, 0x19, 0xb5, 3091 0xb1, 0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ef, 0xf1, 0x61, 0x7c,
3159 0xe9, 0xd7, 0xed, 0xd2, 0x85, 0x38, 0x06, 0xcf, 0x8a, 0x25, 0x62, 0x0d, 3099 0x1f, 0x46, 0x1e, 0xc8, 0xf2, 0x84, 0xe0, 0x3c, 0xb1, 0x1b, 0x71, 0x30,
3160 0xf2, 0xb9, 0x88, 0xf6, 0x41, 0x8e, 0x94, 0x58, 0xf7, 0x13, 0xa9, 0xee, 3100 0x00, 0xee, 0xdf, 0x63, 0x6e, 0xcf, 0x13, 0x18, 0x57, 0xda, 0x83, 0xbc,
3161 0x9f, 0x87, 0xaf, 0x26, 0x50, 0x66, 0xed, 0x1f, 0x4e, 0xb5, 0x3f, 0x85, 3101 0x70, 0x3f, 0xfa, 0x59, 0xd7, 0x28, 0xda, 0x01, 0xbc, 0xef, 0xc1, 0xd8,
3162 0x37, 0xd7, 0xad, 0xa8, 0x09, 0x87, 0xc0, 0xc7, 0x0d, 0xc6, 0x37, 0x8f, 3102 0xfe, 0x1c, 0x91, 0xcb, 0xdd, 0x2d, 0x3f, 0x20, 0x26, 0x56, 0x11, 0x2b,
3163 0x58, 0xc7, 0xf3, 0xff, 0x33, 0x5a, 0xb5, 0x19, 0x63, 0xdb, 0xfc, 0x01, 3103 0x6b, 0x9c, 0x27, 0x38, 0x16, 0x79, 0x4f, 0x8b, 0xe0, 0x6f, 0x1b, 0x3a,
3164 0xcd, 0x41, 0x7f, 0xa8, 0xdf, 0xe6, 0xbe, 0x6c, 0x93, 0xf5, 0x15, 0x69, 3104 0x78, 0x6f, 0x8b, 0xd8, 0x43, 0xce, 0x71, 0x82, 0x2a, 0x1b, 0x3b, 0xe5,
3165 0xdf, 0x0f, 0xf7, 0xf4, 0x45, 0xfd, 0x36, 0xf7, 0x63, 0x7d, 0x1c, 0x22, 3105 0x0f, 0x5e, 0x0f, 0x38, 0xec, 0x34, 0xaf, 0xc5, 0x15, 0x0d, 0xf0, 0x59,
3166 0xe5, 0x3a, 0x9f, 0xdb, 0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 3113 0xfa, 0xfe, 0xde, 0x7b, 0x73, 0xdd, 0x09, 0x70, 0x9d, 0xf5, 0xf9, 0x5c,
3174 0x3c, 0x37, 0x72, 0x11, 0x3e, 0x17, 0xa2, 0xe8, 0x15, 0x07, 0xed, 0x59, 3114 0xd7, 0x64, 0xae, 0x33, 0x81, 0xbd, 0x26, 0x78, 0x40, 0x5f, 0xed, 0x9f,
3175 0x4e, 0x12, 0x63, 0x9f, 0xc3, 0xd9, 0xcb, 0x78, 0x20, 0x0f, 0xb4, 0x67, 3115 0xe7, 0x24, 0xe6, 0xe1, 0x3e, 0x33, 0xcb, 0xa5, 0x3a, 0x75, 0x81, 0x7b,
3176 0xa1, 0x07, 0x8e, 0x05, 0xbb, 0xd1, 0x96, 0xed, 0xa1, 0xae, 0x06, 0xff, 3116 0xc3, 0xe3, 0x79, 0x60, 0x73, 0x92, 0x72, 0xd1, 0x13, 0x66, 0x89, 0xac,
3177 0x33, 0x26, 0xcb, 0xd2, 0x52, 0xdf, 0x60, 0x3b, 0xe8, 0x6d, 0xbf, 0x5c, 3117 0x49, 0xe0, 0x61, 0x75, 0x88, 0x8c, 0xd3, 0xb7, 0xf0, 0x8e, 0x7a, 0x00,
3178 0x4c, 0x87, 0xae, 0x1e, 0xe3, 0xc4, 0x3c, 0x6a, 0x8e, 0xe0, 0xd4, 0x88, 3118 0x71, 0x8e, 0x7f, 0x1b, 0xb9, 0x8e, 0x41, 0x70, 0x8d, 0x49, 0x85, 0x55,
3179 0x71, 0xda, 0x19, 0xe2, 0xd4, 0x4c, 0x71, 0x6a, 0xc6, 0x38, 0x3d, 0x48, 3119 0x0b, 0xef, 0xda, 0xb6, 0x71, 0x87, 0x90, 0x6f, 0x8c, 0x9a, 0x3b, 0xf3,
3180 0x71, 0xfa, 0xf3, 0x13, 0x70, 0xda, 0x79, 0x0a, 0x9c, 0x0c, 0xda, 0xb2, 3120 0x7b, 0x7e, 0xee, 0xf1, 0x98, 0x41, 0xd2, 0xd7, 0x5c,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0x5c, 0xcf, 0xe1, 0x3d, 0x21, 0xcf, 0xb5, 0x47, 0x63, 0xd1, 3128 0x74, 0xb1, 0xbc, 0x57, 0x7e, 0x76, 0x4b, 0x9e, 0x79, 0x6d, 0xa2, 0xcc,
3189 0x07, 0x88, 0x45, 0x5c, 0xc7, 0xfd, 0x54, 0xa9, 0x06, 0xcd, 0x2b, 0xc8, 3129 0xfc, 0xc5, 0x76, 0x18, 0x8a, 0x4b, 0x07, 0x33, 0x2e, 0xad, 0x60, 0x3f,
3190 0xe1, 0xfd, 0x61, 0x0e, 0x9f, 0xf8, 0xe1, 0x6a, 0x9a, 0xc3, 0x6f, 0xd9, 3130 0x07, 0x55, 0x5c, 0xea, 0xde, 0xc3, 0x19, 0x9f, 0xee, 0x46, 0xcb, 0x7d,
3191 0x9c, 0xc3, 0x9f, 0xd0, 0x68, 0x62, 0x39, 0xc5, 0x93, 0x79, 0x3d, 0x89, 3131 0x37, 0xb2, 0x38, 0x31, 0x61, 0x2f, 0xeb, 0x1d, 0x24, 0x03, 0x76, 0x45,
3192 0xb6, 0xb3, 0x31, 0xee, 0x6d, 0xc4, 0xf2, 0x55, 0xf8, 0xa0, 0x19, 0xf3, 3132 0x6a, 0x4d, 0x7f, 0x93, 0x4b, 0x1e, 0x73, 0x04, 0xe3, 0x53, 0x71, 0x29,
3193 0x13, 0x79, 0x57, 0xca, 0x5d, 0xe4, 0xbb, 0xe4, 0x87, 0x09, 0x4f, 0x3f, 3133 0xfa, 0x27, 0x60, 0x33, 0xf3, 0x02, 0xcb, 0xb1, 0xfc, 0x4e, 0x72, 0x7f,
3194 0xdb, 0x5c, 0xec, 0xef, 0x88, 0xd9, 0x46, 0x43, 0xc5, 0x1d, 0xe0, 0x6e, 3134 0x85, 0x9c, 0xd8, 0x41, 0x0e, 0x7d, 0x1b, 0x2c, 0xc3, 0xdc, 0x30, 0x8a,
3195 0x18, 0xc7, 0xea, 0x73, 0x41, 0x97, 0x5a, 0x47, 0xaa, 0x57, 0x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7d, 0x03, 0xcf, 0xe0, 0xcc, 0xea, 0xc4,
3232 0x4f, 0x38, 0xf6, 0x32, 0x9f, 0xf6, 0xcb, 0x15, 0xb3, 0x3e, 0x1c, 0x93, 3172 0xc0, 0xd5, 0xcb, 0x89, 0x45, 0xad, 0x12, 0xdf, 0x51, 0x30, 0x57, 0x96,
3233 0x58, 0xef, 0x1c, 0xcb, 0x92, 0xdc, 0xec, 0x6e, 0x98, 0xe9, 0xe2, 0x55, 3173 0xa1, 0xe3, 0x99, 0x42, 0x8a, 0xcb, 0x32, 0xf4, 0x70, 0xcc, 0x10, 0xe6,
3234 0xcc, 0x83, 0x72, 0x6f, 0x3f, 0x5d, 0x18, 0xa9, 0x2e, 0x26, 0x13, 0x9b, 3174 0x63, 0xff, 0xe5, 0x58, 0x2b, 0xf7, 0xd5, 0xee, 0x85, 0xec, 0xbc, 0x4a,
3235 0xde, 0xa8, 0x36, 0x5e, 0xd5, 0xc7, 0xb5, 0x91, 0x8d, 0x93, 0x69, 0x23, 3175 0xca, 0x07, 0xec, 0xdf, 0xd0, 0x7b, 0xbe, 0x90, 0xdf, 0xc7, 0xb4, 0x10,
3236 0x19, 0x73, 0x47, 0x29, 0xe1, 0x0c, 0x2c, 0x23, 0x1e, 0x09, 0xbe, 0xa3, 3176 0xf3, 0x8d, 0x7d, 0x8c, 0x43, 0x0d, 0x78, 0xc3, 0x98, 0x84, 0xfb, 0x90,
3237 0x21, 0x5e, 0x54, 0xf3, 0xb8, 0xa7, 0x14, 0x78, 0xec, 0x76, 0xf8, 0x2c, 3177 0x57, 0xf6, 0x21, 0x37, 0x97, 0x8a, 0xaa, 0x6d, 0x26, 0xc7, 0xb2, 0xf1,
3238 0x35, 0x8a, 0x8c, 0x0b, 0xaf, 0xff, 0x61, 0x7c, 0x7f, 0xc0, 0xba, 0x0b, 3178 0xba, 0x1a, 0xc7, 0x39, 0x21, 0x4e, 0xd4, 0x59, 0x41, 0x8b, 0x3a, 0xe4,
3239 0x01, 0xff,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, 0x38, 0x07, 0xe3, 0x79, 0x0b, 0x1f, 0x8c, 0xd5, 0xcf,
3254 0x3f, 0x6f, 0x53, 0x12, 0x3b, 0x6a, 0xce, 0x39, 0xac, 0x05, 0x98, 0x88, 3194 0xc7, 0xa8, 0xf5, 0x05, 0x31, 0xfa, 0x46, 0x9b, 0xb9, 0x22, 0xc5, 0x68,
3255 0x06, 0x30, 0x9e, 0x47, 0xac, 0xb2, 0xcc, 0x93, 0x72, 0xf2, 0x5b, 0xd5, 3195 0xe3, 0x0e, 0x8c, 0xa2, 0x06, 0x2a, 0xe5, 0xf8, 0xe4, 0x78, 0xc9, 0xf1,
3256 0x1a, 0xc6, 0x56, 0x4e, 0x72, 0x2e, 0xf9, 0x51, 0xb4, 0x36, 0x88, 0xcf, 3196 0x99, 0x3f, 0xf3, 0xfd, 0x08, 0x38, 0x38, 0xe3, 0xb6, 0x18, 0xdc, 0x16,
3257 0x44, 0x87, 0xb9, 0xe6, 0x87, 0x07, 0x65, 0x7e, 0xbb, 0x21, 0x7f, 0xeb, 3197 0xa9, 0x1c, 0xe7, 0x96, 0x23, 0x4a, 0xe3, 0x78, 0x19, 0x71, 0x1c, 0x19,
3258 0x98, 0xc7, 0x7c, 0x02, 0x0f, 0x8b, 0xa2, 0x76, 0xc3, 0x14, 0xf5, 0x9e, 3198 0x9c, 0xf3, 0x38, 0x86, 0x59, 0x8e, 0xe3, 0x98, 0xe5, 0x46, 0x32, 0x39,
3259 0x29, 0x96, 0x7a, 0x32, 0x54, 0x52, 0xc8, 0xd1, 0x14, 0xe7, 0x08, 0x3a, 3199 0xb4, 0x88, 0xe7, 0x28, 0x8b, 0xe7, 0x16, 0x78, 0x37, 0xca, 0xe2, 0xb9,
3260 0xd1, 0x73, 0x58, 0xcb, 0x2d, 0x53, 0xf8, 0xc8, 0xa3, 0xbe, 0xad, 0x58, 3200 0x85, 0x18, 0x5e, 0xc9, 0xe2, 0xb9, 0x95, 0xc5, 0x33, 0xdf, 0xdb, 0x19,
3261 0x62, 0x85, 0x76, 0xb1, 0xc7, 0x47, 0x51, 0x72, 0xa7, 0x35, 0x45, 0x6d, 3201 0x55, 0x95, 0x8b, 0x9d, 0x3a, 0x78, 0x6d, 0x45, 0xe9, 0x6c, 0x62, 0x9d,
3262 0x38, 0xf7, 0x23, 0xcc, 0xcd, 0x6b, 0x62, 0x2d, 0xf3, 0x79, 0xb6, 0x2c, 3202 0xb0, 0xb1, 0x93, 0xc7, 0xc5, 0x1d, 0xf7, 0x5b, 0x58, 0xcf, 0xad, 0xbc,
3263 0x9d, 0x83, 0x8f, 0xce, 0xf7, 0x77, 0x11, 0x43, 0xf9, 0x3c, 0xcb, 0x23, 3203 0x32, 0x8b, 0xbc, 0x72, 0x0e, 0x79, 0xa5, 0xdb, 0x77, 0xbf, 0x75, 0x56,
3264 0xe6, 0x59, 0x26, 0x5f, 0xf6, 0xef, 0x62, 0xff, 0xef, 0xf4, 0x80, 0x0f, 3204 0xe5, 0x95, 0x27, 0x8b, 0x79, 0x5e, 0xe9, 0x66, 0x79, 0xa5, 0xab, 0xf2,
3265 0x72, 0xc7, 0xb7, 0x87, 0x79, 0x1a, 0x63, 0x58, 0x06, 0x17, 0xd9, 0x3e, 3205 0xca, 0x13, 0x45, 0xce, 0x2b, 0x31, 0x05, 0xc5, 0xfe, 0xbc, 0x12, 0x6f,
3266 0x8a, 0x82, 0xc5, 0x38, 0x47, 0xc1, 0x5a, 0xe6, 0xca, 0xb7, 0x90, 0xa7, 3206 0xcb, 0x2b, 0xb9, 0x2c, 0xf7, 0xef, 0x94, 0x57, 0x72, 0x9f, 0x71, 0x6e,
3267 0xd7, 0x69, 0xa1, 0x5c, 0x8f, 0xdf, 0x11, 0x72, 0x12, 0xfe, 0x5d, 0xc0, 3207 0xb1, 0x72, 0x5e, 0xbd, 0x2d, 0x9f, 0xe4, 0x63, 0xd8, 0x56, 0xe6, 0x25,
3268 0x12, 0x4d, 0x7c, 0xd7, 0xd2, 0xef, 0x80, 0x73, 0xf8, 0x45, 0x1e, 0x83, 3208 0xe6, 0xe0, 0xb4, 0xae, 0xbf, 0x92, 0xe4, 0xb1, 0x74, 0x0c, 0xf3, 0xe0,
3269 0x73, 0x79, 0xd6, 0xe1, 0x7f, 0x01, 0x17, 0xc6, 0xf1, 0xb2, 0x84, 0x14, 3209 0xbd, 0xb3, 0x53, 0x2c, 0xd9, 0x59, 0x2c, 0x0d, 0xa7, 0x32, 0x9d, 0xfe,
3270 0x00, 0x00, 0x00 }; 3210 0x78, 0x3a, 0x56, 0xdc, 0x1e, 0x4f, 0xb9, 0x9e, 0x3c, 0x9e, 0x52, 0x9d,
3271static u32 bnx2_TPAT_b09FwData[(0x0/4) + 1] = { 0x0 }; 3211 0x1f, 0x1a, 0x65, 0xae, 0x07, 0x70, 0x96, 0x76, 0xfd, 0x39, 0xf4, 0x5e,
3272static u32 bnx2_TPAT_b09FwRodata[(0x0/4) + 1] = { 0x0 }; 3212 0xe8, 0x4d, 0xa3, 0xae, 0x36, 0xe9, 0x6a, 0xce, 0x37, 0xea, 0xbe, 0x07,
3273static u32 bnx2_TPAT_b09FwBss[(0x250/4) + 1] = { 0x0 }; 3213 0x6d, 0x2f, 0xb7, 0xb5, 0xb8, 0xf5, 0xad, 0x8b, 0xda, 0xfa, 0x7d, 0xf0,
3274static u32 bnx2_TPAT_b09FwSbss[(0x34/4) + 1] = { 0x0 }; 3214 0xc8, 0x79, 0xf5, 0xfd, 0x33, 0x79, 0xb5, 0x84, 0x33, 0xb0, 0x97, 0x8f,
3215 0x7b, 0x1d, 0xf3, 0xb9, 0xe2, 0x2c, 0x9e, 0x5e, 0xee, 0xdd, 0x82, 0xf9,
3216 0x8a, 0xc7, 0x7d, 0xff, 0x44, 0x0e, 0x41, 0x5d, 0xbe, 0x35, 0x96, 0xcf,
3217 0x38, 0x1e, 0xd6, 0xec, 0xd0, 0xa5, 0x6d, 0xe7, 0x9c, 0xf4, 0x7c, 0x83,
3218 0x75, 0xa3, 0x3e, 0xe1, 0x3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xc1,
3233 0x1a, 0x6f, 0xc8, 0xf4, 0xde, 0xc5, 0x11, 0xd1, 0xd6, 0xdc, 0x37, 0x30,
3234 0x37, 0xdb, 0xc4, 0x31, 0xca, 0xf9, 0x72, 0x5e, 0x5b, 0x80, 0x8f, 0x8e,
3235 0xac, 0x6b, 0xe0, 0x35, 0xce, 0x97, 0x23, 0xd9, 0xfd, 0x12, 0xf6, 0x07,
3236 0xeb, 0xbf, 0x74, 0x47, 0xad, 0x99, 0xd7, 0x94, 0xe9, 0xdd, 0x69, 0x3c,
3237 0xc3, 0xf3, 0x13, 0x6c, 0x99, 0x98, 0xba, 0xa0, 0xce, 0x3d, 0xd3, 0xa8,
3238 0xf1, 0xb8, 0x95, 0xa8, 0x83, 0xf8, 0xae, 0x8b, 0x6b, 0x27, 0x89, 0xf8,
3239 0x4f, 0x9f, 0x63, 0x3e, 0x13, 0xcd, 0xb0, 0x0e, 0x3e, 0x1b, 0x71, 0xfc,
3240 0xfc, 0x1b, 0x2f, 0xf3, 0x0a, 0xbd, 0x68, 0x18, 0x00, 0x00, 0x00 };
3241
3242static const u32 bnx2_TPAT_b09FwData[(0x0/4) + 1] = { 0x0 };
3243static const u32 bnx2_TPAT_b09FwRodata[(0x0/4) + 1] = { 0x0 };
3244static const u32 bnx2_TPAT_b09FwBss[(0x850/4) + 1] = { 0x0 };
3245static const u32 bnx2_TPAT_b09FwSbss[(0x2c/4) + 1] = { 0x0 };
3275 3246
3276static struct fw_info bnx2_tpat_fw_09 = { 3247static struct fw_info bnx2_tpat_fw_09 = {
3277 .ver_major = 0x1, 3248 .ver_major = 0x3,
3278 .ver_minor = 0x0, 3249 .ver_minor = 0x4,
3279 .ver_fix = 0x0, 3250 .ver_fix = 0x3,
3280 3251
3281 .start_addr = 0x08000860, 3252 .start_addr = 0x08000860,
3282 3253
3283 .text_addr = 0x08000800, 3254 .text_addr = 0x08000800,
3284 .text_len = 0x1480, 3255 .text_len = 0x1864,
3285 .text_index = 0x0, 3256 .text_index = 0x0,
3286 .gz_text = bnx2_TPAT_b09FwText, 3257 .gz_text = bnx2_TPAT_b09FwText,
3287 .gz_text_len = sizeof(bnx2_TPAT_b09FwText), 3258 .gz_text_len = sizeof(bnx2_TPAT_b09FwText),
3288 3259
3289 .data_addr = 0x08001ca0, 3260 .data_addr = 0x08002080,
3290 .data_len = 0x0, 3261 .data_len = 0x0,
3291 .data_index = 0x0, 3262 .data_index = 0x0,
3292 .data = bnx2_TPAT_b09FwData, 3263 .data = bnx2_TPAT_b09FwData,
3293 3264
3294 .sbss_addr = 0x08001ca0, 3265 .sbss_addr = 0x08002088,
3295 .sbss_len = 0x34, 3266 .sbss_len = 0x2c,
3296 .sbss_index = 0x0, 3267 .sbss_index = 0x0,
3297 .sbss = bnx2_TPAT_b09FwSbss, 3268 .sbss = bnx2_TPAT_b09FwSbss,
3298 3269
3299 .bss_addr = 0x08001ce0, 3270 .bss_addr = 0x080020c0,
3300 .bss_len = 0x250, 3271 .bss_len = 0x850,
3301 .bss_index = 0x0, 3272 .bss_index = 0x0,
3302 .bss = bnx2_TPAT_b09FwBss, 3273 .bss = bnx2_TPAT_b09FwBss,
3303 3274
@@ -3308,732 +3279,769 @@ static struct fw_info bnx2_tpat_fw_09 = {
3308}; 3279};
3309 3280
3310static u8 bnx2_TXP_b09FwText[] = { 3281static u8 bnx2_TXP_b09FwText[] = {
3311 0x1f, 0x8b, 0x08, 0x08, 0x51, 0xfe, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65, 3282 0x1f, 0x8b, 0x08, 0x00, 0x0e, 0x34, 0xe7, 0x45, 0x00, 0x03, 0xcd, 0x7c,
3312 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xcd, 0x7b, 0x7f, 0x70, 3283 0x6f, 0x70, 0x5b, 0xd7, 0x95, 0xdf, 0x79, 0xef, 0x81, 0x24, 0x48, 0xd1,
3313 0x1b, 0xe7, 0x99, 0xde, 0xbb, 0x0b, 0x80, 0x04, 0x29, 0x8a, 0x5a, 0x31, 3284 0xd4, 0x13, 0x17, 0x56, 0x60, 0x87, 0x71, 0x00, 0xf1, 0x81, 0x66, 0x42,
3314 0x30, 0x83, 0x38, 0xb4, 0x8d, 0x15, 0x17, 0x34, 0x6d, 0xf2, 0x1c, 0x58, 3285 0xae, 0x04, 0x2b, 0x4c, 0xc2, 0x6d, 0xd1, 0xf8, 0x05, 0x00, 0x29, 0x48,
3315 0xe5, 0xf9, 0xd8, 0x06, 0xb5, 0xd7, 0xc0, 0x92, 0xa2, 0x63, 0x26, 0x47, 3286 0xd1, 0x6c, 0x68, 0x95, 0x49, 0x94, 0x54, 0xe3, 0x62, 0x41, 0x52, 0xf1,
3316 0xbb, 0xcc, 0x9d, 0x92, 0x51, 0x7d, 0x28, 0x48, 0x29, 0x6e, 0xe3, 0xb4, 3287 0xb6, 0xce, 0x54, 0x9b, 0x78, 0x5a, 0x4d, 0xeb, 0xad, 0x11, 0x90, 0xfa,
3317 0xaa, 0xe3, 0x3f, 0x34, 0x4d, 0x5b, 0xc3, 0x00, 0x25, 0xcb, 0x2e, 0x44, 3288 0xe7, 0x85, 0x04, 0xda, 0x62, 0x44, 0x7f, 0xc8, 0x07, 0x18, 0x80, 0x24,
3318 0xd0, 0x16, 0x63, 0xa5, 0x33, 0x37, 0x53, 0x18, 0x80, 0x28, 0xe7, 0xba, 3289 0x6f, 0xf2, 0x44, 0x28, 0x9b, 0x7f, 0xfd, 0xd0, 0xac, 0x50, 0x4a, 0xd6,
3319 0x24, 0xdc, 0xe4, 0x2e, 0xe9, 0x1f, 0xc9, 0x99, 0xa5, 0x6c, 0xc5, 0x6d, 3290 0xba, 0x9b, 0xb4, 0xa3, 0xed, 0x66, 0x67, 0x3b, 0xd3, 0x2f, 0x1c, 0x49,
3320 0xae, 0x33, 0xbe, 0x3f, 0xda, 0xa6, 0x37, 0xd7, 0x19, 0x8d, 0xfc, 0x23, 3291 0xf6, 0x7a, 0x77, 0x67, 0x36, 0xda, 0x6e, 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0x2c, 0x05, 0x25, 0x19, 0x7f, 0xab, 0xe9, 0x3e,
3343 0x92, 0xa9, 0x44, 0x25, 0x93, 0x7a, 0xaf, 0xe5, 0x3d, 0x13, 0xc5, 0xbe, 3314 0x13, 0xc4, 0x98, 0x81, 0x9e, 0xb1, 0x52, 0xb3, 0x99, 0x8e, 0x83, 0x7e,
3344 0xe1, 0xde, 0x89, 0x4a, 0xab, 0xe5, 0xa4, 0xb0, 0x47, 0x2a, 0x78, 0x36, 3315 0xdc, 0x7f, 0xb6, 0x4d, 0xca, 0x21, 0xbb, 0x3c, 0x1b, 0xff, 0x6f, 0xba,
3345 0x22, 0xd5, 0x98, 0x5d, 0x2d, 0xa5, 0x4c, 0xdd, 0xd3, 0x09, 0x79, 0xe4, 3316 0xab, 0x13, 0xce, 0x91, 0xd7, 0xb6, 0xe8, 0x56, 0x5e, 0x72, 0x21, 0x29,
3346 0xb5, 0x2d, 0xba, 0xf5, 0xdb, 0x92, 0x8f, 0x49, 0xb5, 0x98, 0xba, 0x4b, 3317 0x17, 0xe2, 0x9f, 0x92, 0x13, 0xf1, 0x30, 0xe6, 0x17, 0x94, 0x63, 0x71,
3347 0x9e, 0x4e, 0x19, 0x72, 0x12, 0xeb, 0x3d, 0x95, 0x82, 0x1c, 0xad, 0x63, 3318 0xc8, 0xd1, 0x3a, 0xac, 0x25, 0xeb, 0xd1, 0x48, 0x56, 0x9e, 0x97, 0xe4,
3348 0x5a, 0xa6, 0x69, 0xc6, 0x45, 0x7b, 0x5a, 0x32, 0x67, 0x06, 0x8d, 0xac, 3319 0x62, 0xbf, 0x99, 0x16, 0x8c, 0x6d, 0x35, 0x3f, 0x9a, 0x8c, 0x63, 0xbc,
3349 0x60, 0x6f, 0xab, 0x75, 0x4b, 0x26, 0x85, 0xfd, 0x46, 0xff, 0x67, 0xcb, 3320 0xe1, 0xff, 0xd5, 0xb4, 0x43, 0xd1, 0x6c, 0x59, 0x06, 0xa5, 0x50, 0xea,
3350 0x8e, 0x99, 0xb9, 0xaa, 0x0c, 0x48, 0xb1, 0x32, 0x98, 0xfa, 0x13, 0xd1, 3321 0x8f, 0xff, 0x4c, 0x34, 0x09, 0x5a, 0x62, 0x4f, 0x59, 0x26, 0xe4, 0x16,
3351 0xa4, 0xd3, 0xa2, 0x7c, 0x5a, 0x72, 0x3f, 0xf6, 0xcd, 0x58, 0x18, 0x6f, 3322 0x1d, 0x4c, 0x19, 0x4d, 0xd9, 0x83, 0xf1, 0x93, 0x16, 0xee, 0xd7, 0x65,
3352 0x8a, 0xad, 0x27, 0x23, 0xf2, 0x0f, 0x0c, 0x33, 0x91, 0x09, 0xf5, 0x4b, 3323 0xb3, 0x6e, 0xb5, 0x4b, 0xc1, 0x94, 0x50, 0x97, 0x3c, 0x22, 0x85, 0xd3,
3353 0xf1, 0x74, 0x27, 0xe8, 0xb4, 0xfb, 0x74, 0xcc, 0x3d, 0x30, 0x26, 0xb1, 3324 0x68, 0x8f, 0xdb, 0xbd, 0x3a, 0x9e, 0xc9, 0x8c, 0xb0, 0x4d, 0x34, 0x23,
3354 0x5d, 0x22, 0x5a, 0x28, 0x9d, 0xc4, 0xba, 0x22, 0x45, 0x77, 0x00, 0xcf, 3325 0x11, 0x33, 0x53, 0xe0, 0xa8, 0xe2, 0x0c, 0x62, 0xfc, 0x98, 0xdd, 0xa9,
3355 0x26, 0xc7, 0x7f, 0x2a, 0x7b, 0x24, 0xb1, 0x37, 0x2c, 0x25, 0xb7, 0x1b, 3326 0x99, 0xb2, 0x62, 0x06, 0xa4, 0xea, 0xc4, 0xec, 0xb0, 0xd6, 0x2e, 0xc7,
3356 0x72, 0x34, 0xa0, 0x83, 0xe4, 0xf8, 0x5f, 0x40, 0x29, 0xba, 0x95, 0x8c, 3327 0x62, 0x5d, 0x90, 0x69, 0x18, 0xb4, 0xe5, 0x9b, 0x7a, 0x22, 0x16, 0xce,
3357 0x1f, 0x93, 0x9c, 0x96, 0x6d, 0x76, 0x48, 0x29, 0x19, 0x95, 0x05, 0xd0, 3328 0x41, 0x51, 0x3a, 0x64, 0x35, 0x07, 0x7e, 0xe6, 0xe2, 0x59, 0x2d, 0x55,
3358 0xb1, 0x90, 0xfa, 0xa2, 0x96, 0x39, 0x77, 0x50, 0xcb, 0x9e, 0xc3, 0xbc, 3329 0xff, 0x8a, 0x96, 0x3c, 0xbf, 0x5f, 0xdb, 0x75, 0x1e, 0x7d, 0xea, 0xe7,
3359 0x66, 0xdd, 0xb7, 0x35, 0x03, 0xeb, 0xe8, 0x52, 0x4c, 0x1e, 0xc4, 0xbd, 3330 0x3c, 0xbb, 0x0b, 0x83, 0x37, 0x1d, 0xcf, 0xb2, 0x1d, 0x3c, 0x2b, 0xde,
3360 0xa8, 0xcc, 0x61, 0xde, 0x1c, 0x78, 0x2a, 0x35, 0xf7, 0xc8, 0xfa, 0x6c, 3331 0xd1, 0x06, 0x5d, 0x36, 0x26, 0x43, 0x3d, 0x49, 0xa5, 0x4b, 0xf2, 0xa6,
3361 0xac, 0x37, 0x03, 0x1d, 0x16, 0x71, 0xff, 0xb7, 0x67, 0x34, 0x31, 0x2c, 3332 0x4b, 0x6e, 0x42, 0x93, 0x5e, 0xcb, 0x96, 0xe0, 0x27, 0xa1, 0xcf, 0x45,
3362 0x5b, 0x7e, 0x3c, 0x06, 0x1d, 0x9e, 0x81, 0xfe, 0xce, 0xc4, 0xe5, 0x78, 3333 0xe8, 0x72, 0x31, 0x22, 0x47, 0x4a, 0x12, 0xd2, 0x85, 0x63, 0x65, 0xf5,
3363 0x45, 0x62, 0xba, 0x24, 0xe3, 0x79, 0x79, 0x41, 0xea, 0x2e, 0xf5, 0x0f, 3334 0xaa, 0x43, 0x7b, 0x80, 0x6e, 0xa1, 0xfb, 0x82, 0xc3, 0x67, 0xa1, 0xc3,
3364 0x7d, 0x42, 0xdf, 0x45, 0x97, 0xcf, 0x41, 0x6f, 0x15, 0x07, 0xf2, 0x98, 3335 0x52, 0x1a, 0xf2, 0xc9, 0x60, 0xec, 0x7d, 0xda, 0x9e, 0xea, 0xa4, 0x96,
3365 0x02, 0x0d, 0x0f, 0x6a, 0xf7, 0xd7, 0x67, 0xb5, 0x03, 0xcd, 0x1f, 0x6b, 3336 0x81, 0x9d, 0x14, 0x4e, 0x0f, 0x41, 0x77, 0xd1, 0xc8, 0x8a, 0x6c, 0x96,
3366 0xd2, 0x7d, 0x4c, 0xfb, 0x5c, 0xf3, 0x88, 0xe6, 0xcb, 0x1e, 0xba, 0x8b, 3337 0x82, 0x65, 0x45, 0xbe, 0x2c, 0xdd, 0x72, 0x6c, 0xd1, 0x92, 0x23, 0x8b,
3367 0x8a, 0x3d, 0x13, 0x95, 0x95, 0xa6, 0xa7, 0xbb, 0x1a, 0xec, 0xd3, 0x36, 3338 0x21, 0xc9, 0x9b, 0x51, 0xb3, 0x26, 0x7d, 0xd9, 0x4d, 0x89, 0x1e, 0x79,
3368 0x6c, 0xe8, 0xe1, 0x6f, 0x6f, 0xce, 0x59, 0x69, 0xc6, 0x64, 0x01, 0xb4, 3339 0xfe, 0x74, 0x34, 0x53, 0x96, 0x7e, 0xfb, 0x75, 0xdc, 0xcf, 0x9d, 0xa4,
3369 0x1d, 0x6f, 0x72, 0xfe, 0xef, 0x41, 0x3f, 0x51, 0x71, 0x6f, 0xed, 0x91, 3340 0x4e, 0x25, 0x9f, 0x8a, 0x1b, 0x92, 0x85, 0x4d, 0x18, 0xd6, 0x1f, 0x81,
3370 0x1c, 0xc6, 0x8b, 0x67, 0xc4, 0xce, 0xa4, 0x74, 0x3c, 0xd3, 0x2b, 0x21, 3341 0xff, 0xe6, 0x73, 0xc9, 0x78, 0x34, 0x2c, 0xa2, 0x4b, 0xea, 0x0b, 0xfd,
3371 0xab, 0x1f, 0x9f, 0x6e, 0x99, 0xab, 0x77, 0xda, 0x21, 0x2b, 0x26, 0x73, 3342 0xe6, 0x6e, 0x89, 0x9a, 0x19, 0xca, 0x3f, 0x3e, 0x04, 0x3d, 0xfc, 0x77,
3372 0x4d, 0xca, 0x10, 0x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d, 0x00, 0x5f, 0xba, 0x64, 0xab, 0x8a, 0xb7, 0x08,
3387 0x5d, 0x56, 0x14, 0xb6, 0x40, 0x5a, 0xc6, 0xb1, 0x7e, 0xab, 0xf5, 0xd9, 3358 0x6d, 0xc0, 0x9d, 0x47, 0x9f, 0xcc, 0x2e, 0x76, 0xf7, 0xa4, 0x17, 0xd9,
3388 0x94, 0x47, 0x53, 0xf1, 0x8c, 0x8d, 0x67, 0xc3, 0x90, 0xbb, 0xf9, 0x70, 3359 0x9e, 0x0c, 0x1b, 0x98, 0xe7, 0x54, 0x5c, 0x1a, 0x73, 0x71, 0xbd, 0x3f,
3389 0x42, 0xed, 0x3f, 0xee, 0xef, 0x6f, 0xc8, 0x1c, 0xe8, 0x2e, 0x56, 0x42, 3360 0x00, 0xbe, 0xa6, 0xb1, 0xe0, 0x30, 0x0f, 0x8f, 0xc7, 0x06, 0xee, 0xf7,
3390 0x92, 0x35, 0xb8, 0xc6, 0x9f, 0x71, 0x3c, 0xe7, 0xad, 0x05, 0xbb, 0x3d, 3361 0xca, 0xd4, 0x79, 0xf6, 0xe5, 0x18, 0x85, 0x2d, 0xba, 0x24, 0xc0, 0x1b,
3391 0x35, 0x68, 0xdc, 0x07, 0x5f, 0xa2, 0x8f, 0x15, 0x57, 0x29, 0x63, 0xac, 3362 0x3e, 0x56, 0x14, 0xf7, 0x3b, 0x31, 0x4e, 0x37, 0x6c, 0x27, 0x83, 0x31,
3392 0x33, 0x46, 0x19, 0x1b, 0x8a, 0xc6, 0xcc, 0x19, 0xda, 0x91, 0x0c, 0x84, 3363 0x9b, 0x8f, 0x27, 0xe3, 0xbd, 0x92, 0x5d, 0xed, 0x2b, 0xb0, 0x3b, 0xf6,
3393 0x84, 0x76, 0x8e, 0x98, 0x01, 0xbb, 0x2a, 0xf9, 0x76, 0x95, 0x77, 0xa9, 3364 0x1f, 0x5c, 0xd7, 0x17, 0xf2, 0x3d, 0x0f, 0x9a, 0x8b, 0x9d, 0x90, 0x21,
3394 0xff, 0xbb, 0x7d, 0xff, 0xd4, 0x65, 0x28, 0x49, 0x7b, 0x7f, 0x5a, 0xb2, 3365 0xdb, 0x75, 0xf0, 0xdc, 0x01, 0x1e, 0x82, 0x98, 0x4f, 0x3f, 0xd6, 0x43,
3395 0xf0, 0xf1, 0x39, 0xec, 0x54, 0x07, 0x4f, 0xb5, 0xca, 0x20, 0x64, 0x15, 3366 0x07, 0xe8, 0x6f, 0xc2, 0x9c, 0x3a, 0x65, 0xfa, 0x74, 0x2f, 0x74, 0x61,
3396 0xf8, 0x1d, 0xf4, 0x3b, 0xfa, 0x6e, 0x2b, 0x88, 0x05, 0xc5, 0x0a, 0x7d, 3367 0xa2, 0x6f, 0x50, 0x9e, 0x2f, 0x45, 0x61, 0x03, 0xec, 0x0f, 0x1d, 0x2c,
3397 0xa6, 0x68, 0xe8, 0x52, 0xc0, 0x07, 0x76, 0x63, 0x99, 0xc3, 0x99, 0x90, 3368 0x46, 0xc3, 0x55, 0xb1, 0x65, 0x2e, 0xde, 0x01, 0xfb, 0x6a, 0x36, 0x67,
3398 0x39, 0x93, 0x03, 0x6d, 0xb0, 0x7b, 0xc9, 0xdc, 0x49, 0x7b, 0xc6, 0x9c, 3369 0x60, 0x1f, 0xdf, 0x51, 0xfe, 0x62, 0xc8, 0x1c, 0xd3, 0x24, 0xdf, 0x91,
3399 0xa6, 0xec, 0x0f, 0xfc, 0xac, 0xe6, 0x52, 0x4f, 0xdd, 0xd8, 0x37, 0xa0, 3370 0x38, 0x0c, 0x7e, 0xa2, 0x4f, 0x89, 0xf0, 0x7a, 0x87, 0xc6, 0x35, 0x0b,
3400 0x29, 0x8c, 0x31, 0xae, 0x13, 0x85, 0xcd, 0x07, 0x36, 0x43, 0xfb, 0x33, 3371 0x39, 0x72, 0x6c, 0xf8, 0xa4, 0xad, 0x90, 0x21, 0xfd, 0x56, 0x1f, 0xec,
3401 0xed, 0x75, 0xe9, 0x90, 0xe1, 0x24, 0x62, 0xd9, 0x19, 0x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 0x79, 3401 0x53, 0xe7, 0xb6, 0xab, 0x73, 0xea, 0xba, 0x53, 0x66, 0xd4, 0xb8, 0x4d,
3431 0xce, 0xd6, 0x75, 0x6b, 0x4b, 0x26, 0x0b, 0x6d, 0x32, 0x29, 0xb9, 0x94, 3402 0x09, 0x3c, 0x26, 0xf0, 0x2a, 0xf2, 0x59, 0x23, 0x11, 0x05, 0x3d, 0x1d,
3432 0x11, 0xe7, 0xd3, 0x97, 0x5d, 0xe8, 0x3d, 0x90, 0xcb, 0x34, 0x68, 0xe8, 3403 0xe3, 0x53, 0x5f, 0x31, 0xf0, 0x20, 0xd0, 0x6f, 0xb7, 0xf2, 0x45, 0xbb,
3433 0x24, 0xef, 0x3e, 0x1f, 0x5c, 0xbf, 0xcf, 0x5f, 0xff, 0xd3, 0x58, 0x93, 3404 0xa0, 0xf7, 0x65, 0xe7, 0xfe, 0x74, 0x95, 0x69, 0xd1, 0xd5, 0x9e, 0x35,
3434 0xbe, 0xbb, 0xd3, 0xbe, 0xdc, 0x93, 0xb9, 0xf4, 0xd7, 0xf1, 0x83, 0x5a, 3405 0xba, 0xea, 0x90, 0xe1, 0x98, 0xaf, 0xa3, 0xcd, 0x92, 0x8c, 0x51, 0x67,
3435 0x02, 0x31, 0xfa, 0x45, 0xf8, 0xda, 0xc5, 0x50, 0x5c, 0xbe, 0x7f, 0xeb, 3406 0xf7, 0xa3, 0xab, 0x7f, 0xaa, 0xff, 0xfd, 0xe8, 0xea, 0xb7, 0xee, 0xa1,
3436 0x6b, 0xa8, 0x2f, 0xa4, 0x70, 0x63, 0xba, 0x95, 0x08, 0xa7, 0xdf, 0x6b, 3407 0xab, 0x7f, 0xb5, 0x4e, 0x57, 0x96, 0xf9, 0x82, 0x46, 0xda, 0x8c, 0x1f,
3437 0x2d, 0x8c, 0x21, 0x7e, 0xa6, 0xcd, 0x78, 0x26, 0x34, 0x2a, 0x2f, 0x35, 3408 0xf4, 0x47, 0xcd, 0x8f, 0x4e, 0x31, 0x7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7f, 0xd9, 0x29, 0xbd, 0xdf, 0x5e, 0x37, 0x86, 0xfe, 0xbb, 0x5f, 0x0f, 3416 0x8c, 0xfb, 0x16, 0x73, 0x9e, 0x7c, 0x20, 0xd1, 0x25, 0xf9, 0x2d, 0x5c,
3446 0xa1, 0xc6, 0xea, 0x57, 0x8b, 0xe7, 0xb4, 0xf4, 0xa8, 0x93, 0x70, 0x37, 3417 0x8f, 0xf4, 0x73, 0xf4, 0x5d, 0xed, 0x1e, 0xdf, 0x7e, 0x8e, 0xa4, 0x78,
3447 0x70, 0x5f, 0xa2, 0xfd, 0xd6, 0xcf, 0x51, 0x85, 0xc8, 0xee, 0x98, 0xc5, 3418 0x33, 0x30, 0x65, 0xf4, 0x41, 0x3e, 0x54, 0xe2, 0x3c, 0xde, 0xf2, 0xec,
3448 0x9a, 0x6b, 0x26, 0xfb, 0x79, 0xfc, 0xff, 0x58, 0x5a, 0xf6, 0xf4, 0xe1, 3419 0x89, 0xb9, 0x82, 0xb4, 0xb9, 0xbe, 0x61, 0x2f, 0x72, 0x01, 0xda, 0x81,
3449 0xff, 0xde, 0x34, 0x4c, 0x2a, 0xcd, 0x98, 0xac, 0xb5, 0xc5, 0x64, 0xd1, 3420 0xaf, 0x73, 0xea, 0x9b, 0x39, 0x82, 0x44, 0x74, 0x8b, 0x39, 0x82, 0x98,
3450 0x1c, 0xe4, 0xdf, 0x05, 0xf0, 0xe4, 0x40, 0x1e, 0xbf, 0xd3, 0x8c, 0x6a, 3421 0x46, 0x62, 0x9f, 0x66, 0x43, 0xf7, 0x36, 0x74, 0x6f, 0x43, 0xf7, 0x36,
3451 0xd9, 0xd3, 0xfd, 0x52, 0xaa, 0x33, 0xaf, 0x71, 0x5e, 0xd4, 0xaf, 0x7b, 3422 0x74, 0x9f, 0xac, 0x1f, 0xc6, 0x3d, 0x95, 0x87, 0x80, 0x17, 0x97, 0x7e,
3452 0x78, 0xdd, 0x81, 0x6b, 0x41, 0xae, 0xf9, 0x94, 0x48, 0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8, 0xf5,
3467 0x0e, 0x70, 0x6e, 0x67, 0x3a, 0x76, 0xd3, 0x8f, 0xf1, 0xbf, 0x23, 0xfd, 3438 0x60, 0xb0, 0x56, 0xbc, 0x85, 0x7e, 0xcd, 0xe6, 0xa1, 0xf8, 0x6f, 0xed,
3468 0xce, 0x4d, 0x17, 0x2c, 0xae, 0x3b, 0x75, 0xd3, 0x59, 0xb5, 0x46, 0x18, 3439 0x30, 0xff, 0x81, 0x85, 0x35, 0xdd, 0xf9, 0x25, 0x23, 0xb1, 0x49, 0x66,
3469 0xf1, 0x8c, 0xf3, 0x2e, 0xdf, 0xc4, 0x67, 0x9f, 0x44, 0x1c, 0x3f, 0xe1, 3440 0x43, 0xdf, 0x6f, 0x98, 0x03, 0x7d, 0x59, 0x3d, 0x11, 0x94, 0x74, 0x91,
3470 0x42, 0x97, 0xee, 0x8b, 0x4e, 0x1e, 0x9f, 0x39, 0xd2, 0x54, 0xe1, 0x7d, 3441 0x6b, 0x2a, 0x24, 0xb3, 0x55, 0x28, 0xff, 0x3c, 0xd7, 0x85, 0x3c, 0x3b,
3471 0xe3, 0xe6, 0x8c, 0x15, 0x56, 0xf9, 0xf6, 0x4b, 0x98, 0x73, 0x04, 0x73, 3442 0x17, 0xef, 0x86, 0xed, 0xff, 0x9a, 0xe1, 0xae, 0x03, 0x18, 0x50, 0x75,
3472 0x0e, 0xbb, 0x01, 0x3f, 0xea, 0xbe, 0x93, 0xc5, 0xfd, 0xc3, 0x65, 0xc3, 3443 0x50, 0xf2, 0xe0, 0x37, 0x5f, 0x7f, 0xcb, 0xc3, 0x0e, 0xf0, 0x2a, 0x5b,
3473 0x71, 0xca, 0xe6, 0x38, 0x6a, 0x8e, 0xf8, 0x71, 0xe4, 0xe3, 0x1c, 0x72, 3444 0x21, 0xf8, 0xc4, 0x70, 0xda, 0x76, 0xfe, 0x30, 0x88, 0xb6, 0xe0, 0x56,
3474 0xa0, 0x2d, 0xe6, 0x70, 0x41, 0xd2, 0x5d, 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 0x4c, 0x95, 0xd8, 0x0f, 0x3c, 0x0b, 0xea, 0x30, 3467 0x67, 0x97, 0x30, 0xf7, 0x68, 0x9c, 0x89, 0x65, 0x5b, 0x82, 0xeb, 0xe1,
3497 0x7d, 0x55, 0x20, 0x01, 0x33, 0x7e, 0x44, 0x06, 0xe3, 0x5f, 0x92, 0x5f, 3468 0xcd, 0x08, 0x30, 0xe2, 0x6e, 0xe0, 0xbe, 0xdd, 0x67, 0xd5, 0xfa, 0x78,
3498 0xb6, 0x90, 0xef, 0x91, 0xeb, 0x7b, 0x24, 0xac, 0xd6, 0x89, 0x07, 0x7b, 3469 0x33, 0xea, 0x61, 0xf7, 0x6d, 0xc0, 0xee, 0x78, 0x3e, 0x00, 0x4c, 0xc8,
3499 0xd2, 0x46, 0xb7, 0xed, 0xeb, 0x9c, 0xb9, 0xd6, 0xba, 0x70, 0xfe, 0xd5, 3470 0xf6, 0x2b, 0x66, 0x12, 0x7a, 0xaa, 0x3a, 0xf6, 0xee, 0x02, 0x3e, 0x73,
3500 0xf8, 0x55, 0xeb, 0xfe, 0x85, 0xbf, 0xae, 0x81, 0x75, 0x07, 0xb0, 0x26, 3471 0xaa, 0xef, 0xad, 0x08, 0xfb, 0x76, 0x24, 0x12, 0xd1, 0x3f, 0xc3, 0x77,
3501 0x79, 0x34, 0xbb, 0x26, 0x4e, 0x8b, 0xdd, 0x09, 0xfa, 0x9c, 0xe4, 0x8d, 3472 0x7b, 0x22, 0xbc, 0xed, 0xaa, 0x45, 0xba, 0x87, 0xa2, 0x67, 0x15, 0x8d,
3502 0xc0, 0x86, 0xfd, 0x72, 0x62, 0x99, 0xf1, 0x42, 0xfa, 0xf1, 0x19, 0x8d, 3473 0x80, 0x14, 0xd4, 0xb3, 0x91, 0x6d, 0x7c, 0xf6, 0x18, 0x62, 0xf6, 0x51,
3503 0x48, 0x72, 0xf8, 0x1c, 0xea, 0xae, 0x09, 0xb5, 0x86, 0x57, 0x93, 0xe9, 3474 0xc7, 0x94, 0x23, 0x4e, 0x76, 0x77, 0x0e, 0x1f, 0x62, 0xd5, 0x4b, 0x25,
3504 0xab, 0x29, 0xd4, 0xc4, 0x3f, 0x05, 0x3d, 0xac, 0x15, 0xc8, 0x73, 0x18, 3475 0xde, 0x1f, 0xc5, 0xfd, 0x80, 0x30, 0x97, 0xfc, 0x2a, 0xfa, 0x1c, 0x44,
3505 0xfc, 0xa6, 0x50, 0x8b, 0x11, 0x47, 0xb5, 0x1e, 0xcf, 0xa4, 0xf0, 0xfd, 3476 0x9f, 0x19, 0xc7, 0xd7, 0x05, 0xef, 0x37, 0x32, 0x29, 0xdc, 0x9f, 0x29,
3506 0x5c, 0xa2, 0x2b, 0x8b, 0x98, 0x08, 0xff, 0xbe, 0x39, 0xa4, 0x72, 0x18, 3477 0x36, 0x32, 0xe9, 0x22, 0xf3, 0xd6, 0xa1, 0xf0, 0x11, 0xc8, 0x33, 0x8b,
3507 0xf5, 0x32, 0xda, 0x45, 0x3c, 0x83, 0xe7, 0xa1, 0x27, 0xca, 0x68, 0xbc, 3478 0x5c, 0xcd, 0x96, 0xe8, 0x60, 0x5e, 0x9e, 0xee, 0x1c, 0x07, 0x4e, 0x3a,
3508 0xcb, 0xa9, 0x50, 0x46, 0x02, 0x7a, 0x2c, 0xd8, 0x64, 0x58, 0x61, 0x29, 3479 0x87, 0x1c, 0xc2, 0x9e, 0x8c, 0xc6, 0xcb, 0xf2, 0xe1, 0xce, 0xe4, 0x69,
3509 0x7d, 0xd5, 0xc6, 0xbc, 0xb7, 0x42, 0xac, 0x77, 0x33, 0x16, 0xbf, 0x23, 3480 0xe4, 0x0b, 0xf1, 0xed, 0x90, 0x61, 0x23, 0xa3, 0xc7, 0x04, 0xb6, 0x1e,
3510 0xe6, 0xac, 0x4e, 0x61, 0x2e, 0xbf, 0xdf, 0x85, 0x75, 0x07, 0x87, 0x8b, 3481 0x87, 0x5f, 0x1e, 0xd1, 0x53, 0xc5, 0x7e, 0x73, 0x56, 0x1e, 0x95, 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, 0x8e, 0xc9, 0x77, 0x9b, 0x29, 0xe4, 3489 0x32, 0xee, 0x0c, 0x88, 0x5d, 0xa3, 0x1c, 0xa2, 0xf0, 0x4a, 0x0f, 0x77,
3519 0xc0, 0x51, 0xe4, 0xc0, 0x61, 0xe4, 0x40, 0x0b, 0x39, 0x30, 0x81, 0x1c, 3490 0xa5, 0x16, 0xa3, 0x76, 0x1e, 0x14, 0x8d, 0x0b, 0x7d, 0x5d, 0x49, 0xe4,
3520 0x38, 0x80, 0x1c, 0x18, 0x47, 0x9c, 0x14, 0x39, 0xa1, 0xf2, 0x6d, 0x2c, 3491 0x39, 0xfa, 0x85, 0x48, 0x57, 0x0a, 0x36, 0x6b, 0x5c, 0x78, 0xa8, 0x2b,
3521 0x0a, 0xcc, 0x1d, 0xb5, 0x9b, 0x0e, 0x78, 0x99, 0xc1, 0x5e, 0xb3, 0xe0, 3492 0x7d, 0x9a, 0x7c, 0x19, 0xc8, 0x73, 0x3e, 0x0a, 0x9c, 0xdf, 0x94, 0xdf,
3522 0xeb, 0x50, 0xd7, 0x44, 0x65, 0x1c, 0x31, 0xd7, 0x42, 0x3c, 0x4a, 0x20, 3493 0x45, 0x2e, 0x5b, 0x18, 0x44, 0x0e, 0x80, 0xd5, 0xaf, 0x83, 0xef, 0xbc,
3523 0xdf, 0x8c, 0x01, 0x6b, 0x89, 0x6c, 0x2c, 0x25, 0x10, 0x13, 0x5b, 0xe2, 3494 0x29, 0xc1, 0xae, 0xc4, 0xab, 0xe0, 0x6f, 0x18, 0xb2, 0xd9, 0x84, 0x3e,
3524 0x00, 0x13, 0x97, 0x8c, 0x14, 0x9e, 0xdd, 0xab, 0xec, 0x33, 0x94, 0xbe, 3495 0x06, 0xda, 0x07, 0x58, 0x13, 0x68, 0x69, 0xb7, 0xba, 0x10, 0x4f, 0x11,
3525 0x3b, 0x2c, 0xdd, 0xa3, 0x92, 0x2f, 0x9f, 0xc4, 0x58, 0x1c, 0xeb, 0x75, 3496 0xbb, 0x24, 0x98, 0x1c, 0xe9, 0x06, 0xfd, 0x2b, 0x01, 0xe6, 0x82, 0xc1,
3526 0x21, 0x2f, 0x31, 0x2e, 0x30, 0x06, 0x2c, 0x39, 0xbf, 0x6b, 0xd1, 0xd7, 3497 0xd8, 0x6a, 0xfb, 0x37, 0xdd, 0xf6, 0x41, 0xf0, 0xc2, 0xe7, 0x88, 0x09,
3527 0xba, 0xb5, 0xcc, 0xe9, 0x82, 0x30, 0x96, 0x23, 0x0f, 0xc0, 0x1e, 0x38, 3498 0x24, 0x38, 0x35, 0x62, 0x82, 0x07, 0xf6, 0x0d, 0xa9, 0xbe, 0xe9, 0x45,
3528 0x36, 0x89, 0xe7, 0xf8, 0xfd, 0x2f, 0xfd, 0x98, 0xf9, 0xb1, 0x4e, 0x81, 3499 0xda, 0x40, 0x23, 0x53, 0xb1, 0x1e, 0x91, 0xd4, 0xc2, 0x56, 0x19, 0x5f,
3529 0xd1, 0xbe, 0xc4, 0x9c, 0x67, 0x61, 0x3d, 0xb7, 0xdd, 0x4f, 0x9f, 0x47, 3500 0xe8, 0x95, 0x5d, 0x0b, 0xc4, 0x30, 0xac, 0x69, 0x60, 0x2a, 0xc0, 0x18,
3530 0xad, 0x14, 0xdc, 0x27, 0xae, 0x66, 0x3f, 0xe1, 0x24, 0x68, 0x1e, 0x04, 3501 0xfa, 0x05, 0xe6, 0x76, 0xd1, 0xf0, 0x41, 0xe9, 0x0f, 0x7f, 0x15, 0xeb,
3531 0xbe, 0x47, 0x6d, 0x75, 0xb0, 0x8a, 0xef, 0xed, 0xf3, 0x5d, 0xcc, 0x57, 3502 0x60, 0xca, 0x8a, 0x45, 0x66, 0xb1, 0xc6, 0x02, 0x8a, 0x4e, 0xd8, 0x1f,
3532 0x63, 0x51, 0x23, 0x6d, 0xb1, 0x9e, 0x43, 0xac, 0x3c, 0x86, 0xb8, 0x68, 3503 0x93, 0x36, 0xba, 0x66, 0xdc, 0xf4, 0xe2, 0xbd, 0xe8, 0x62, 0xe1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x22, 0x70, 0x0d, 0xe4, 0x99, 0x59, 0x24, 0xee, 3511 0xc5, 0xea, 0x4c, 0x96, 0x14, 0xdf, 0x9d, 0xa9, 0x12, 0x65, 0x14, 0xef,
3541 0xda, 0x05, 0x39, 0x45, 0x60, 0x23, 0xd4, 0xfd, 0x20, 0x9e, 0x6d, 0xc9, 3512 0x4c, 0x97, 0x28, 0x23, 0x01, 0x3f, 0x71, 0xd8, 0x64, 0x40, 0x22, 0x5b,
3542 0x57, 0x53, 0xb4, 0x87, 0xc7, 0x20, 0x4b, 0xac, 0x15, 0x0e, 0xf8, 0xf9, 3513 0xa8, 0xc7, 0x43, 0xe8, 0xf7, 0x57, 0x01, 0xe2, 0xb8, 0xa4, 0xc5, 0xdf,
3543 0x9a, 0xcc, 0x2d, 0x51, 0x7e, 0x71, 0xd4, 0x96, 0xdc, 0x5b, 0xa2, 0x5d, 3514 0xf0, 0xb5, 0x17, 0x0e, 0xa3, 0x2f, 0x7f, 0x6f, 0x07, 0xdd, 0xfe, 0xc1,
3544 0xe9, 0xab, 0xeb, 0x46, 0xdb, 0xd9, 0x58, 0xc4, 0xfa, 0x43, 0xc4, 0xd8, 3515 0x82, 0xb4, 0x0f, 0xce, 0xc0, 0x4f, 0xe8, 0x23, 0xc0, 0x91, 0xca, 0xce,
3545 0x88, 0xd5, 0x65, 0xf6, 0x06, 0x58, 0x53, 0x1d, 0x80, 0x4e, 0xa6, 0x15, 3516 0x9b, 0xc0, 0xd8, 0x3b, 0x30, 0x1f, 0xac, 0x8d, 0x98, 0x25, 0xd3, 0xf3,
3546 0xe6, 0xce, 0xd4, 0x53, 0x62, 0x9d, 0x62, 0xac, 0x92, 0x44, 0xc8, 0x22, 3517 0x94, 0xab, 0x7c, 0x08, 0x73, 0xc0, 0xfc, 0x63, 0xf0, 0x2d, 0x9c, 0x03,
3547 0xbe, 0x17, 0x43, 0x4f, 0xcf, 0xe2, 0x1e, 0xe5, 0xc9, 0x5a, 0x1f, 0xf7, 3518 0xc7, 0x16, 0xe4, 0x36, 0x4b, 0x92, 0x9b, 0x0f, 0x2a, 0x2c, 0x6b, 0x9b,
3548 0x57, 0xff, 0xa3, 0xd2, 0x49, 0x08, 0xba, 0xcb, 0xef, 0x67, 0x11, 0x22, 3519 0x1c, 0x5f, 0xd3, 0xf4, 0x44, 0x17, 0x74, 0xcc, 0xb9, 0xcd, 0x81, 0xb7,
3549 0x4b, 0xa1, 0x34, 0x62, 0xe0, 0x18, 0x79, 0x50, 0x7b, 0xa3, 0x9e, 0xa4, 3520 0x67, 0x10, 0xff, 0xa2, 0x0a, 0x43, 0x19, 0x17, 0xb8, 0x56, 0x46, 0xb1,
3550 0xdf, 0x81, 0x67, 0xd8, 0x46, 0x5b, 0x5d, 0xa9, 0xfe, 0x4a, 0x95, 0x08, 3521 0x4e, 0xc8, 0xbf, 0x67, 0x7b, 0x5a, 0x03, 0x3e, 0x45, 0xf9, 0x7f, 0xe4,
3551 0x6c, 0x59, 0x0a, 0x91, 0x34, 0x78, 0x1a, 0xc3, 0x77, 0x38, 0xff, 0x09, 3522 0xea, 0x09, 0xf8, 0x91, 0x51, 0xf9, 0x7d, 0xf8, 0x92, 0x1f, 0xd7, 0xe3,
3552 0xe8, 0xf3, 0x2c, 0x9e, 0x5f, 0x00, 0x5f, 0x1b, 0x65, 0xd2, 0x9d, 0x4c, 3523 0xc8, 0x1b, 0x86, 0x91, 0x37, 0x0c, 0x22, 0x6f, 0xb0, 0x90, 0x37, 0x44,
3553 0x1c, 0x57, 0xbe, 0x8b, 0x6b, 0x97, 0xb5, 0xcc, 0xd7, 0xe4, 0xbc, 0xe2, 3524 0x90, 0x37, 0xf4, 0x21, 0x6f, 0x08, 0x23, 0x3e, 0x88, 0x1c, 0xad, 0xe7,
3554 0xef, 0x13, 0xac, 0x9d, 0xa1, 0xa7, 0xeb, 0xe1, 0x6f, 0xf2, 0x3a, 0xf9, 3525 0x61, 0x63, 0x0d, 0xf8, 0x41, 0x33, 0x68, 0xd7, 0x43, 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f, 0x0f, 0x70, 0xde, 0x3c, 0xe5,
3577 0xf8, 0x3e, 0xe0, 0x7f, 0xe7, 0x7d, 0x89, 0xde, 0x9c, 0x36, 0xab, 0x05, 3548 0x17, 0x46, 0x6e, 0xce, 0xb1, 0x25, 0xd8, 0x99, 0x58, 0x9f, 0x77, 0xdf,
3578 0x31, 0xb1, 0x27, 0x74, 0x6e, 0xc5, 0xa5, 0xd8, 0x30, 0x5f, 0x20, 0x66, 3549 0xca, 0x2c, 0x9f, 0x02, 0xfd, 0x01, 0xd6, 0xde, 0xe0, 0xb3, 0x8b, 0xac,
3579 0xd4, 0x29, 0x83, 0x35, 0xca, 0x89, 0xfd, 0x27, 0xd4, 0x7f, 0xb5, 0xe7, 3550 0x1d, 0x32, 0x27, 0xdd, 0x05, 0x3d, 0xed, 0x55, 0xb5, 0xb8, 0x64, 0x35,
3580 0x21, 0x8f, 0xa8, 0xec, 0xb5, 0x0e, 0x22, 0xa6, 0x80, 0xfe, 0xca, 0x18, 3551 0x2e, 0xd6, 0x49, 0xfa, 0x2c, 0x89, 0x18, 0xd6, 0x7e, 0xe4, 0xaf, 0x62,
3581 0x78, 0x63, 0x8f, 0x66, 0x10, 0xf9, 0x2b, 0x04, 0x21, 0xa0, 0x96, 0x5a, 3552 0xea, 0x89, 0x49, 0xdc, 0xa3, 0x3c, 0x35, 0xe4, 0x1c, 0xb8, 0x7f, 0x61,
3582 0x0b, 0xc9, 0xbd, 0xe1, 0x11, 0xa3, 0x28, 0x8f, 0x46, 0x58, 0x36, 0x17, 3553 0x45, 0xe9, 0xc4, 0x80, 0xee, 0x72, 0x3b, 0x99, 0x84, 0xc9, 0xbc, 0x91,
3583 0xd6, 0x98, 0x07, 0xc2, 0xb2, 0xb0, 0x26, 0x72, 0x69, 0x91, 0x71, 0x45, 3554 0x80, 0x2f, 0x1c, 0xe1, 0x1c, 0xd4, 0xd8, 0xc8, 0xc7, 0xb9, 0xfe, 0x30,
3584 0xfd, 0x41, 0xe6, 0x86, 0x33, 0x8f, 0x3c, 0x5b, 0x5a, 0x62, 0x8c, 0x61, 3555 0x67, 0xd8, 0x55, 0x4b, 0x5e, 0xae, 0xfe, 0x66, 0x4b, 0x47, 0x60, 0xd3,
3585 0x9c, 0xb8, 0x01, 0xba, 0x48, 0x7e, 0xe3, 0xab, 0xc8, 0x49, 0xa5, 0xf2, 3556 0x92, 0x6f, 0x43, 0x3e, 0x90, 0x1c, 0xc1, 0x6f, 0x38, 0x81, 0xa3, 0xd0,
3586 0x20, 0x62, 0xa6, 0xac, 0xeb, 0x90, 0x29, 0x72, 0x19, 0x6b, 0xd4, 0x1d, 3557 0xe7, 0xd9, 0x11, 0xd6, 0x3f, 0x5f, 0x02, 0xb6, 0x27, 0xdf, 0xb1, 0xc8,
3587 0xfa, 0x32, 0x41, 0x4f, 0x26, 0x2a, 0xc5, 0x45, 0xf6, 0x63, 0xa2, 0xa0, 3558 0x11, 0xb5, 0x86, 0x71, 0xed, 0x30, 0x97, 0xdb, 0x24, 0x97, 0xd5, 0xfc,
3588 0x85, 0x35, 0x76, 0x48, 0xd5, 0x3f, 0x37, 0xa8, 0xd8, 0xca, 0xff, 0xe1, 3559 0x1e, 0x22, 0xf6, 0x80, 0x9e, 0xee, 0x67, 0x7e, 0xe3, 0xf7, 0x39, 0x3f,
3589 0xb6, 0x7d, 0x93, 0x27, 0xf7, 0xe9, 0x8c, 0x63, 0x37, 0x8b, 0x3d, 0x63, 3560 0x97, 0x3e, 0x63, 0x57, 0xd2, 0x8a, 0x48, 0xaa, 0x78, 0xa9, 0x19, 0xb0,
3590 0x77, 0x1d, 0xa8, 0x74, 0x48, 0xb5, 0x8f, 0x76, 0x49, 0xfd, 0xbf, 0xa0, 3561 0x2c, 0x60, 0x67, 0x57, 0x8f, 0x29, 0x27, 0x08, 0x3e, 0x58, 0x6b, 0xdb,
3591 0x62, 0xed, 0x02, 0x78, 0x2a, 0x2e, 0x12, 0xe3, 0x86, 0x31, 0x2f, 0xe6, 3562 0xa9, 0x74, 0x09, 0x3e, 0x68, 0x3b, 0xf9, 0x60, 0x62, 0xb3, 0x9c, 0x9b,
3592 0xcf, 0xa3, 0x5c, 0xff, 0x89, 0xcc, 0xed, 0x7f, 0x17, 0x74, 0x79, 0x71, 3563 0xef, 0x91, 0xca, 0xfc, 0xcf, 0xa5, 0x3a, 0xdf, 0x25, 0xe7, 0xe7, 0x9b,
3593 0x2d, 0xbf, 0x1f, 0xf1, 0x76, 0x46, 0x97, 0x3b, 0xef, 0x1a, 0xc7, 0xb3, 3564 0x72, 0x35, 0xae, 0x7c, 0x93, 0xd5, 0xae, 0xd6, 0xb5, 0x3c, 0xec, 0xd6,
3594 0xcc, 0x81, 0xef, 0xf8, 0x78, 0x92, 0x63, 0xec, 0x61, 0x81, 0xbe, 0x15, 3565 0x61, 0x62, 0xa3, 0xd7, 0xe5, 0x79, 0x39, 0x57, 0x76, 0x79, 0xcf, 0xb4,
3595 0x03, 0xff, 0xfb, 0xa4, 0xb0, 0x12, 0x85, 0x1c, 0x90, 0x4b, 0x6b, 0xde, 3566 0xf0, 0x7e, 0x15, 0xb6, 0xf6, 0xaa, 0x45, 0xfe, 0x47, 0xa4, 0x52, 0x24,
3596 0x5a, 0xac, 0x77, 0x4f, 0x42, 0x47, 0xfa, 0xa9, 0xa8, 0x44, 0x4e, 0xf5, 3567 0xef, 0xfb, 0x14, 0xef, 0xbb, 0x56, 0x79, 0x97, 0xac, 0x61, 0x91, 0xff,
3597 0x49, 0xf8, 0xeb, 0xdd, 0xd2, 0xf1, 0xf5, 0x21, 0x09, 0x7d, 0xdd, 0x64, 3568 0x8d, 0x78, 0xef, 0x90, 0xec, 0x56, 0xf2, 0x1f, 0xc1, 0xb3, 0xef, 0xb4,
3598 0x4e, 0x4f, 0x9c, 0x80, 0xbe, 0xe6, 0x65, 0x5c, 0x9e, 0x44, 0xde, 0x62, 3569 0xbf, 0x8a, 0x73, 0xad, 0xb9, 0x5c, 0x6c, 0x53, 0x3c, 0x1b, 0x89, 0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 0xa3, 0x3c, 0xdb, 0x9e, 0x68, 0x8b, 3577 0x67, 0x9d, 0x6f, 0xe3, 0xe3, 0x8e, 0x37, 0x56, 0xe7, 0x98, 0x6b, 0xe7,
3607 0x75, 0x0b, 0x95, 0x7b, 0xa0, 0x43, 0xd4, 0xf2, 0x16, 0xe2, 0x9c, 0x81, 3578 0x54, 0x70, 0x1a, 0xc8, 0xdf, 0x2d, 0xd0, 0xe5, 0xb8, 0x79, 0x31, 0x12,
3608 0x5c, 0x6e, 0xf1, 0xda, 0xeb, 0xe1, 0xe5, 0x63, 0x31, 0x75, 0x5d, 0xac, 3579 0x06, 0xc6, 0x65, 0x5b, 0x37, 0x7c, 0x4c, 0x04, 0x3e, 0x6b, 0x18, 0xbe,
3609 0x7a, 0x18, 0xdc, 0x5b, 0x9f, 0x75, 0x07, 0x62, 0x4c, 0x93, 0x74, 0x70, 3580 0x9f, 0x6b, 0x99, 0x7e, 0xde, 0xe7, 0x7d, 0x18, 0x34, 0xe9, 0x7f, 0x87,
3610 0xdf, 0x01, 0x09, 0x3d, 0x17, 0x93, 0xf0, 0x73, 0xb4, 0x3f, 0x33, 0xe1, 3581 0x31, 0x67, 0xe6, 0xd8, 0xf4, 0x9f, 0x88, 0x27, 0xb5, 0x70, 0x57, 0xf2,
3611 0x40, 0x7e, 0x0b, 0x16, 0x31, 0xd0, 0x0a, 0xb0, 0xc5, 0xcd, 0xa2, 0xaf, 3582 0xb4, 0x5b, 0x1b, 0x74, 0x7f, 0xf3, 0xbe, 0x04, 0x1f, 0x49, 0x44, 0xcb,
3612 0x0c, 0xc0, 0x77, 0xcc, 0x78, 0x55, 0x92, 0x12, 0xaa, 0x45, 0xe5, 0xad, 3583 0x79, 0xe4, 0x7e, 0x29, 0xac, 0xd1, 0xa4, 0x85, 0x3c, 0xbb, 0x16, 0x7d,
3613 0x45, 0x33, 0x41, 0x7b, 0x39, 0x6b, 0x61, 0xbc, 0xd9, 0x75, 0x79, 0x5d, 3584 0x85, 0x98, 0x5b, 0xa7, 0x0c, 0x96, 0x28, 0x27, 0xd6, 0xa9, 0x4c, 0xc9,
3614 0x51, 0xc1, 0xb1, 0x2f, 0x87, 0x80, 0x19, 0x86, 0x6d, 0xbd, 0x47, 0x5e, 3585 0x57, 0xbe, 0x0b, 0x79, 0x04, 0x65, 0x8b, 0x95, 0x85, 0x4f, 0x01, 0xff,
3615 0x87, 0xbe, 0x73, 0x6a, 0xec, 0x66, 0xac, 0x0b, 0x1a, 0x9e, 0x33, 0xc1, 3586 0x98, 0xfb, 0x5c, 0x89, 0xb5, 0xc8, 0x7e, 0xc4, 0x31, 0x03, 0x42, 0x40,
3616 0x03, 0xd7, 0xfd, 0x1e, 0xd6, 0x54, 0xf8, 0xca, 0xd9, 0x60, 0x4d, 0xba, 3587 0x4e, 0xb5, 0x64, 0xc8, 0x67, 0x03, 0x43, 0xc8, 0x01, 0x9f, 0x45, 0xdf,
3617 0x48, 0xdb, 0xed, 0x83, 0xdd, 0xe1, 0xba, 0xd9, 0x21, 0xb9, 0xd9, 0x84, 3588 0x80, 0xe4, 0x97, 0x18, 0x0f, 0x02, 0x32, 0xb7, 0x24, 0x72, 0xfd, 0x14,
3618 0xe8, 0x8b, 0x9f, 0x91, 0xc1, 0xfd, 0xba, 0xc7, 0x8f, 0xe2, 0x91, 0x63, 3589 0xfd, 0x8a, 0xfa, 0x83, 0xcc, 0x1b, 0x99, 0x69, 0x62, 0xed, 0x79, 0xfa,
3619 0xec, 0xc7, 0xdd, 0xae, 0xfc, 0x51, 0x5f, 0x83, 0xcd, 0x3c, 0x48, 0x1d, 3590 0x18, 0xfa, 0x89, 0x07, 0xa1, 0x8b, 0xd8, 0x4b, 0xdf, 0x40, 0x6c, 0x9a,
3620 0x23, 0xf7, 0x23, 0x8f, 0x31, 0x8e, 0x85, 0x90, 0xc7, 0xb2, 0x4d, 0x4f, 3591 0x2d, 0xf6, 0xc3, 0x67, 0x4a, 0x43, 0x87, 0x4c, 0x11, 0xd3, 0x98, 0x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 0xa7, 0x84, 0x56, 0x5c, 0x32, 0xb5, 0x12, 3599 0xcf, 0x32, 0x16, 0xde, 0xf2, 0xf0, 0x38, 0xdb, 0x58, 0xa3, 0x45, 0x9e,
3629 0x62, 0xf6, 0x64, 0x8a, 0x39, 0xbe, 0x53, 0xf5, 0x4d, 0xd9, 0xaf, 0xc9, 3600 0x7e, 0xce, 0xc4, 0x77, 0xaf, 0xe4, 0xcf, 0x05, 0x21, 0x07, 0xe4, 0xc4,
3630 0x2b, 0xbc, 0xb0, 0x4f, 0x2b, 0x56, 0x19, 0xe7, 0x0b, 0xf1, 0x0e, 0x21, 3601 0x15, 0x97, 0x16, 0xf3, 0xde, 0xe3, 0xd0, 0x91, 0x7e, 0x32, 0x28, 0x6d,
3631 0x0e, 0x11, 0xad, 0x66, 0x51, 0x27, 0x9a, 0x9c, 0x57, 0xbd, 0x58, 0x11, 3602 0x27, 0x7b, 0x25, 0xf0, 0xad, 0x2e, 0x69, 0xff, 0xd6, 0x80, 0x18, 0xdf,
3632 0xc7, 0x3d, 0x42, 0x19, 0x68, 0xf5, 0xea, 0x3e, 0xad, 0x50, 0x0d, 0xc9, 3603 0x62, 0x2d, 0x29, 0x1a, 0x39, 0xaa, 0xea, 0x58, 0x69, 0x39, 0x86, 0xf8,
3633 0xc5, 0x18, 0xe9, 0x4e, 0xa8, 0xfa, 0x7d, 0xbf, 0xb2, 0xb5, 0x1e, 0xe4, 3604 0xa5, 0x23, 0x16, 0x2b, 0x3b, 0x35, 0xb7, 0x8a, 0x81, 0xc4, 0x55, 0x7f,
3634 0x12, 0xd8, 0x4c, 0xea, 0x93, 0xd8, 0x57, 0x8d, 0xc1, 0xa6, 0xa8, 0x7b, 3605 0xc1, 0x96, 0xaf, 0xef, 0xfc, 0x85, 0xaa, 0xa3, 0x26, 0x47, 0x70, 0xfd,
3635 0xea, 0x5d, 0xc5, 0x48, 0x5f, 0xf7, 0x3b, 0xe5, 0x4c, 0xd0, 0x51, 0x26, 3606 0x72, 0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 0x3b, 3628 0x39, 0x98, 0x67, 0x45, 0xc3, 0xbb, 0x30, 0x1f, 0xfd, 0x31, 0xfa, 0x03,
3658 0xfc, 0x1c, 0xd1, 0xe0, 0xb9, 0x00, 0x72, 0x44, 0x83, 0xe7, 0x18, 0x23, 3629 0x5d, 0xd9, 0x6e, 0x0e, 0x3e, 0xba, 0x50, 0xa7, 0xde, 0x86, 0xb9, 0x7f,
3659 0xf1, 0x10, 0x30, 0x61, 0x48, 0xe2, 0xc2, 0x5e, 0xef, 0xdc, 0x18, 0xd6, 3630 0x66, 0x32, 0x5f, 0xb3, 0xc3, 0xae, 0xbc, 0x0b, 0x68, 0x9b, 0x85, 0xef,
3660 0x1a, 0x1d, 0x84, 0x27, 0x75, 0xa8, 0xbe, 0xd6, 0x71, 0xd5, 0x6f, 0x40, 3631 0x4f, 0x39, 0x6d, 0xb2, 0x32, 0x69, 0x43, 0xf7, 0x5f, 0x02, 0x5f, 0x07,
3661 0x5c, 0xa8, 0x06, 0xb5, 0x5b, 0x52, 0x26, 0x96, 0x88, 0x33, 0x65, 0xaf, 3632 0x3a, 0x59, 0x23, 0x58, 0x99, 0x4c, 0xe3, 0xfa, 0x80, 0xca, 0xd1, 0x8c,
3662 0x9e, 0x86, 0x0e, 0x5c, 0x62, 0xc3, 0xcd, 0xbe, 0xf4, 0x70, 0x1d, 0x7b, 3633 0xc7, 0x6c, 0xd0, 0xd8, 0xca, 0x75, 0xe4, 0xe9, 0x29, 0xae, 0x17, 0xe6,
3663 0x16, 0x2d, 0x8f, 0xbe, 0xe3, 0xee, 0xd6, 0x33, 0x07, 0x10, 0x9f, 0xa7, 3634 0x1f, 0xd3, 0x67, 0xe1, 0xb3, 0xc7, 0xe3, 0x8c, 0xf1, 0xdc, 0x4b, 0xe8,
3664 0xca, 0x09, 0x99, 0x2c, 0x7b, 0x98, 0x00, 0xf5, 0xcf, 0x55, 0xfd, 0x51, 3635 0x00, 0x1f, 0xdd, 0x0a, 0x57, 0xe8, 0xd6, 0x4e, 0xbd, 0x50, 0xa6, 0x9f,
3665 0x9b, 0x7a, 0x80, 0xfe, 0x36, 0x6d, 0x23, 0x71, 0x3e, 0x45, 0x19, 0x53, 3636 0xcf, 0x87, 0xdb, 0x85, 0x78, 0xc4, 0xd4, 0x2b, 0x16, 0x75, 0xa2, 0xc9,
3666 0xff, 0xd3, 0xaa, 0x67, 0x7d, 0xa0, 0xee, 0xf5, 0xe5, 0x27, 0x95, 0x2d, 3637 0x65, 0xb5, 0xef, 0x20, 0x92, 0x76, 0x0e, 0x61, 0xac, 0xb8, 0x5e, 0x2d,
3667 0x84, 0x19, 0x67, 0xa8, 0x3f, 0xcf, 0x87, 0x61, 0x17, 0x79, 0x37, 0x90, 3638 0xef, 0xd4, 0xf3, 0x65, 0x43, 0x56, 0x42, 0xe4, 0x3b, 0xa2, 0xf2, 0xf8,
3668 0x4b, 0x3b, 0x1e, 0xf9, 0xbc, 0x26, 0xd6, 0x4e, 0xe3, 0xb9, 0xb6, 0xf1, 3639 0x9d, 0xca, 0xd6, 0x8a, 0x88, 0x25, 0xb0, 0x99, 0xf8, 0x87, 0x31, 0xae,
3669 0xcd, 0xfb, 0x3e, 0xbd, 0x88, 0x7d, 0x9b, 0x3d, 0x06, 0xc6, 0xa9, 0xad, 3640 0x6a, 0x83, 0x4d, 0x51, 0xf7, 0xd4, 0xbb, 0xf2, 0x91, 0x9e, 0xee, 0x37,
3670 0xf1, 0x10, 0xea, 0x87, 0xb0, 0xba, 0x8f, 0x18, 0xde, 0x88, 0x49, 0xb6, 3641 0x8a, 0x99, 0x45, 0xf8, 0x5f, 0xd6, 0x2f, 0x3a, 0xbc, 0x5a, 0xe3, 0x4b,
3671 0x61, 0x89, 0x53, 0xe5, 0x3c, 0xf6, 0x2d, 0x18, 0x8f, 0x9e, 0x90, 0xec, 3642 0x5e, 0x3e, 0xf4, 0x8c, 0x30, 0x4f, 0x99, 0x2b, 0x91, 0x97, 0x22, 0xfc,
3672 0x52, 0xaf, 0xe4, 0x62, 0x66, 0xca, 0x96, 0xbf, 0x27, 0x1b, 0xcb, 0x85, 3643 0xe1, 0x46, 0xb6, 0x44, 0x39, 0xba, 0x3e, 0xe5, 0x10, 0xec, 0x42, 0x5f,
3673 0x04, 0xcf, 0x0d, 0x0b, 0x33, 0x1a, 0x9e, 0x7b, 0x18, 0xd7, 0xa4, 0xd9, 3644 0x32, 0x3d, 0x1b, 0xe0, 0xdf, 0x28, 0xee, 0x31, 0x06, 0xe0, 0xbb, 0xde,
3674 0x92, 0xc3, 0x65, 0xe6, 0x9d, 0x91, 0x78, 0x03, 0xf7, 0x72, 0xb3, 0xec, 3645 0x86, 0xf5, 0xbe, 0x17, 0x32, 0xa2, 0x6e, 0xa0, 0xbf, 0x25, 0xee, 0xbb,
3675 0xd5, 0x54, 0x61, 0x93, 0x66, 0xa2, 0x8a, 0x78, 0xf0, 0x72, 0x99, 0xfb, 3646 0x42, 0x7f, 0x4b, 0x57, 0xde, 0xb6, 0x7b, 0xe9, 0xf3, 0x46, 0xe4, 0x18,
3676 0x01, 0x1b, 0x95, 0xd9, 0xcf, 0x09, 0xee, 0x3f, 0x01, 0x1c, 0x88, 0x58, 3647 0xfc, 0xe8, 0xd1, 0x45, 0xf2, 0x93, 0xf6, 0x70, 0xd9, 0x30, 0x64, 0x42,
3677 0x1d, 0xf3, 0xe7, 0x28, 0x5e, 0x6d, 0x23, 0x2c, 0x81, 0xae, 0x3b, 0x65, 3648 0x1f, 0x3f, 0x2c, 0x6f, 0xd4, 0x7e, 0xa0, 0x70, 0xe0, 0xb6, 0x9d, 0x0d,
3678 0xdd, 0x8f, 0xbb, 0xb5, 0xb2, 0xd7, 0x47, 0x39, 0x4b, 0x7a, 0xdc, 0xff, 3649 0x99, 0x86, 0x7f, 0x98, 0x71, 0x20, 0x7f, 0x33, 0x82, 0xf5, 0x19, 0x56,
3679 0xd5, 0x5a, 0x8f, 0xa1, 0x16, 0xda, 0xe4, 0xf5, 0x8f, 0xb9, 0x8f, 0x81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7, 0x63, 0x73, 0x99, 0xf8, 0x5b, 0x0a, 0x9b, 0xef, 3672 0x71, 0xca, 0x98, 0xfa, 0xdf, 0xab, 0xf6, 0x29, 0x76, 0x55, 0xdd, 0xbd,
3702 0x42, 0x6d, 0x4e, 0xec, 0x4d, 0x1c, 0x43, 0x0c, 0x41, 0x7c, 0xce, 0x7e, 3673 0xa4, 0x71, 0x65, 0x0b, 0x01, 0xfa, 0x19, 0xd0, 0x89, 0xbb, 0x6b, 0x18,
3703 0x01, 0xeb, 0x19, 0xe6, 0x46, 0xd6, 0x37, 0x31, 0x7c, 0xf8, 0xbe, 0x41, 3674 0x76, 0x91, 0x73, 0x7c, 0xb9, 0xb4, 0xe2, 0x91, 0x2f, 0x6a, 0x62, 0x6d,
3704 0x80, 0xd1, 0x3b, 0xfc, 0xf8, 0xce, 0xba, 0x28, 0xc0, 0x2a, 0x77, 0x75, 3675 0xd4, 0xfe, 0x1b, 0x2d, 0xed, 0xab, 0xf7, 0x3d, 0x7e, 0xe1, 0xfb, 0x56,
3705 0x7b, 0xb5, 0xd1, 0x2e, 0xcd, 0xab, 0x3f, 0x13, 0xfe, 0x9c, 0xf0, 0x26, 3676 0x6b, 0x0d, 0xf4, 0x53, 0x77, 0xdb, 0x81, 0xdd, 0x24, 0xa0, 0xee, 0xc3,
3706 0x16, 0x0e, 0x6f, 0x62, 0xe1, 0x6d, 0xe7, 0x30, 0xa2, 0xde, 0x6d, 0x50, 3677 0x87, 0xd7, 0x42, 0x92, 0xaa, 0x59, 0x92, 0x2e, 0xb3, 0x1f, 0xeb, 0x17,
3707 0xe7, 0x39, 0x3c, 0xdf, 0x11, 0x4d, 0x4f, 0xf3, 0x8c, 0x07, 0x38, 0xc7, 3678 0xf4, 0x47, 0x7f, 0x22, 0x29, 0xe4, 0xab, 0xd9, 0x50, 0x34, 0x6e, 0xcb,
3708 0xe2, 0x99, 0x0f, 0x7d, 0xe9, 0x41, 0x2d, 0x5b, 0x37, 0x10, 0xef, 0x99, 3679 0x7f, 0x96, 0xe5, 0x85, 0x7c, 0x84, 0xe7, 0x0a, 0xf2, 0x13, 0x1a, 0x9e,
3709 0x7f, 0x90, 0x6b, 0xcb, 0xc1, 0xd9, 0x62, 0xa0, 0x27, 0xca, 0x8e, 0x63, 3680 0xfb, 0x19, 0xae, 0xc9, 0xb3, 0x25, 0x33, 0x45, 0xc6, 0x9d, 0xa1, 0x70,
3710 0x7f, 0xaa, 0xa1, 0xe6, 0x4d, 0x45, 0xac, 0x43, 0xa0, 0x65, 0x0a, 0xff, 3681 0x0d, 0xf7, 0xb2, 0x93, 0xac, 0xd9, 0x7c, 0x07, 0x36, 0x19, 0x8d, 0x94,
3711 0x03, 0x99, 0xde, 0xa3, 0x72, 0x5f, 0x27, 0x6c, 0xf6, 0x78, 0x85, 0xd8, 3682 0xa1, 0xef, 0x2b, 0x45, 0x8e, 0x07, 0x6c, 0x54, 0x64, 0x5d, 0xc7, 0xbf,
3712 0xf5, 0x71, 0x69, 0xf8, 0xf8, 0x75, 0x65, 0xc9, 0xc3, 0xae, 0xe1, 0xed, 3683 0xff, 0x27, 0xc0, 0x81, 0xf0, 0xd5, 0x21, 0xaf, 0x8f, 0x9a, 0xab, 0x6d,
3713 0xd8, 0x35, 0xb5, 0x21, 0x1e, 0x8d, 0x07, 0x76, 0xa4, 0xd1, 0x70, 0x5e, 3684 0x06, 0x60, 0xe3, 0x0d, 0xcf, 0xdf, 0x56, 0x8a, 0x6e, 0x1d, 0xe5, 0x2c,
3714 0x19, 0x22, 0x66, 0x25, 0x9d, 0xcc, 0x3d, 0xd3, 0x88, 0x81, 0xcc, 0x39, 3685 0xf9, 0x70, 0xfe, 0x77, 0xb3, 0x11, 0x42, 0x0e, 0xb4, 0x3a, 0xc7, 0xab,
3715 0xcc, 0x37, 0xc4, 0xa5, 0xd7, 0xa2, 0x4f, 0x8d, 0x1d, 0xed, 0xb0, 0xa2, 3686 0xa4, 0x6f, 0xc2, 0xdd, 0xca, 0x51, 0xc7, 0x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54, 0x82, 0xde, 0x3a, 0xeb, 0xc6, 0xe0, 0xbd, 0x8c, 3723 0x2d, 0x57, 0xe6, 0x27, 0xc1, 0xdf, 0x73, 0x32, 0x17, 0xcf, 0xc3, 0x8f,
3753 0xc1, 0xc4, 0x71, 0xa1, 0xad, 0x90, 0x3e, 0xae, 0xdb, 0x23, 0x73, 0x0a, 3724 0x70, 0xcf, 0x83, 0xb8, 0xad, 0xdf, 0xfb, 0x9e, 0xd6, 0xcf, 0x5a, 0x51,
3754 0x17, 0xc1, 0xa6, 0x92, 0xd7, 0xc6, 0xc6, 0xb5, 0xc5, 0x00, 0x1b, 0xc7, 3725 0xe2, 0x46, 0xa9, 0x16, 0xe9, 0x83, 0xb9, 0x67, 0xc8, 0xbd, 0x61, 0xda,
3755 0x14, 0x36, 0xae, 0xad, 0x05, 0xd8, 0x38, 0x73, 0x0d, 0x6c, 0xfc, 0xdf, 3726 0x0f, 0xeb, 0x27, 0xc8, 0x5d, 0x99, 0xc3, 0x9e, 0xe2, 0xf8, 0x6b, 0x75,
3756 0xba, 0xbc, 0xf8, 0x1f, 0x95, 0x82, 0xc2, 0xc6, 0xd7, 0x7a, 0xc7, 0x86, 3727 0xb2, 0xec, 0x10, 0x7f, 0x35, 0x32, 0x8d, 0x25, 0xe2, 0xc7, 0xf7, 0x8b,
3757 0xf7, 0xba, 0x89, 0x03, 0xc4, 0x3b, 0x17, 0xef, 0xbb, 0x86, 0xaf, 0x05, 3728 0x25, 0xa9, 0x07, 0xe2, 0xc9, 0xfb, 0xc1, 0x91, 0xd1, 0x79, 0x60, 0xc8,
3758 0x78, 0x99, 0xb9, 0xbe, 0x5f, 0x66, 0x9e, 0xdb, 0xc2, 0xcb, 0x1e, 0x26, 3729 0x57, 0x1a, 0x7a, 0x2b, 0x8e, 0x74, 0x31, 0x64, 0x72, 0x29, 0x0b, 0x9a,
3759 0x36, 0x13, 0x47, 0x55, 0x2e, 0x04, 0x3e, 0x68, 0xb2, 0xef, 0x7d, 0x48, 3730 0x71, 0x85, 0x95, 0x91, 0xc7, 0xc1, 0xed, 0xf5, 0xe3, 0xd9, 0x7e, 0xe4,
3760 0xd9, 0x6e, 0xa9, 0x32, 0xab, 0x70, 0x59, 0x1e, 0xb5, 0x6d, 0x51, 0xe1, 3731 0xe4, 0x2e, 0x66, 0x4c, 0x01, 0x33, 0xfe, 0x06, 0x30, 0xe3, 0xac, 0x74,
3761 0x60, 0x62, 0xe0, 0x2e, 0x91, 0xbe, 0x20, 0x17, 0x05, 0x18, 0x33, 0xec, 3732 0x76, 0x11, 0x33, 0xda, 0x1e, 0x66, 0x4c, 0xc3, 0x9e, 0x73, 0x6b, 0xec,
3762 0xc7, 0x67, 0x9e, 0x29, 0xbc, 0x1d, 0xca, 0x10, 0x03, 0xbb, 0x41, 0x8d, 3733 0x59, 0x53, 0xb5, 0x28, 0xde, 0xcb, 0x01, 0xf3, 0xa5, 0x4e, 0x45, 0xef,
3763 0x40, 0x39, 0x0f, 0x23, 0x76, 0x19, 0xbe, 0xac, 0x3c, 0x9f, 0xdd, 0xb7, 3734 0x03, 0x27, 0x6a, 0x12, 0x52, 0xe7, 0x52, 0x02, 0x2d, 0x34, 0x7d, 0x3c,
3764 0xff, 0x87, 0xef, 0xdb, 0x06, 0xe3, 0x5a, 0x80, 0x11, 0x51, 0x03, 0x55, 3735 0xb8, 0x4d, 0xe1, 0xbc, 0xdd, 0xa5, 0x4d, 0xc8, 0x51, 0x14, 0xee, 0xf3,
3765 0xc6, 0xd5, 0xbb, 0x0e, 0x1e, 0x46, 0xf4, 0xf0, 0x61, 0xd6, 0x9d, 0x01, 3736 0xf6, 0x4b, 0x03, 0xeb, 0xf6, 0x90, 0x03, 0x2d, 0x7b, 0xc8, 0x77, 0xf1,
3766 0x4e, 0x9e, 0x95, 0x09, 0xe0, 0xf3, 0xf5, 0xdf, 0x65, 0xef, 0x29, 0xc0, 3737 0x21, 0x9e, 0xf3, 0x6a, 0x7d, 0x6d, 0xf0, 0x05, 0xff, 0x13, 0x3c, 0x71,
3767 0x44, 0x36, 0xfe, 0xb7, 0xf7, 0xa2, 0x78, 0xdd, 0xa1, 0xce, 0xfe, 0xce, 3738 0x7d, 0x71, 0x2d, 0x68, 0xee, 0x7a, 0x59, 0x83, 0x13, 0xff, 0x7a, 0x1d,
3768 0x0f, 0x45, 0xdb, 0xc6, 0xff, 0x3e, 0xe2, 0x37, 0xea, 0xa1, 0x0a, 0x73, 3739 0x4e, 0x44, 0xec, 0x3a, 0x17, 0x92, 0x24, 0x30, 0xa2, 0xbd, 0x44, 0x5a,
3769 0x1d, 0xb1, 0xd0, 0x6f, 0x40, 0x07, 0x63, 0xd7, 0xc0, 0x42, 0x57, 0xe7, 3740 0x5c, 0xd3, 0xc3, 0xd2, 0x8e, 0xf9, 0x75, 0x9c, 0xea, 0x05, 0x36, 0xea,
3770 0x26, 0xe6, 0xcb, 0xad, 0xbc, 0xe4, 0x6c, 0xe6, 0x25, 0xee, 0xf1, 0xeb, 3741 0x92, 0x20, 0x30, 0x52, 0x9b, 0xc2, 0x48, 0x03, 0xc4, 0x32, 0x83, 0x33,
3771 0x72, 0x27, 0xc7, 0x6c, 0x23, 0x62, 0x4d, 0xe1, 0x33, 0x8f, 0x7c, 0xbd, 3742 0xc0, 0x36, 0xb5, 0x55, 0x9c, 0x14, 0x8d, 0xff, 0x01, 0xf4, 0xf2, 0x94,
3772 0x3d, 0x37, 0xcd, 0x5d, 0x47, 0x6e, 0x9a, 0x50, 0xb9, 0x89, 0xf4, 0xa2, 3743 0xf2, 0x3d, 0x69, 0x39, 0x01, 0x5f, 0xda, 0xbe, 0x04, 0x7c, 0x77, 0xce,
3773 0x9e, 0x83, 0x4c, 0xbe, 0x0b, 0x59, 0x7e, 0x07, 0xb4, 0xff, 0x11, 0xf8, 3744 0xc5, 0x4f, 0x6d, 0xeb, 0xf0, 0xd3, 0xc1, 0x0d, 0xf1, 0x93, 0xaa, 0xdf,
3774 0xf9, 0x43, 0x60, 0xac, 0x6f, 0x03, 0x63, 0x7d, 0xab, 0xd2, 0xfe, 0x0e, 3745 0x8f, 0x52, 0x26, 0x37, 0x1c, 0xb7, 0x7e, 0x7f, 0xdd, 0x71, 0xeb, 0xf7,
3775 0xc3, 0xb8, 0xb0, 0x0e, 0xf4, 0xea, 0x66, 0x0f, 0xc3, 0x1f, 0x86, 0x57, 3746 0x37, 0x9c, 0xd6, 0xfa, 0xfd, 0x47, 0xa4, 0x60, 0x46, 0xed, 0x15, 0x59,
3776 0x35, 0xca, 0x86, 0x33, 0x57, 0x1e, 0x31, 0xe6, 0xbd, 0xf3, 0xd2, 0x44, 3747 0x57, 0xbf, 0x9f, 0x60, 0x3d, 0xdc, 0xe9, 0x72, 0xeb, 0xf4, 0x5d, 0x5e,
3777 0x4e, 0xd2, 0x88, 0x11, 0xcc, 0x15, 0xea, 0x3a, 0xce, 0x7e, 0x25, 0xb1, 3748 0xfd, 0x3e, 0x2a, 0x85, 0x35, 0xed, 0xa6, 0xbc, 0x69, 0xf9, 0xf5, 0xfb,
3778 0x42, 0x5d, 0xd5, 0x93, 0x43, 0x52, 0x6d, 0x78, 0xf8, 0x6a, 0xe1, 0x8c, 3749 0xef, 0xa2, 0xad, 0x1b, 0x63, 0xac, 0xad, 0xdd, 0x5f, 0x77, 0x58, 0xbb,
3779 0xb7, 0xc6, 0x9c, 0x8f, 0xaf, 0xf2, 0x3e, 0xbe, 0xca, 0x35, 0x36, 0x12, 3750 0x0f, 0xb1, 0x9f, 0x57, 0xbb, 0x67, 0x3f, 0xe4, 0xf2, 0x0e, 0xeb, 0xf6,
3780 0xac, 0xcf, 0x17, 0x52, 0xdb, 0x31, 0xd5, 0x61, 0x1f, 0x53, 0xcd, 0xff, 3751 0x8f, 0x40, 0x16, 0x5b, 0x21, 0x87, 0x5e, 0x69, 0x3f, 0x13, 0x66, 0x1f,
3781 0x15, 0x31, 0x15, 0xf7, 0xca, 0xe3, 0x99, 0xc9, 0xa5, 0x84, 0x1c, 0x80, 3752 0x55, 0xaf,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 0x7f, 0xe4, 0x88, 0xd0, 0x56, 0xc8,
3789 0x33, 0xfa, 0xd1, 0x8c, 0x95, 0x98, 0x28, 0xba, 0x89, 0x09, 0x0f, 0x7f, 3760 0x1f, 0xe9, 0x76, 0xcb, 0x94, 0xc2, 0x47, 0xb0, 0xa9, 0xd8, 0xbd, 0x31,
3790 0xfc, 0xea, 0x6f, 0x66, 0xac, 0x29, 0xbe, 0xc3, 0x00, 0xf9, 0xfe, 0xf9, 3761 0x72, 0xe5, 0x94, 0x8f, 0x91, 0x43, 0x0a, 0x23, 0x57, 0x96, 0x7c, 0x8c,
3791 0xdd, 0x73, 0x0a, 0x7b, 0x04, 0x98, 0x23, 0x67, 0x73, 0xff, 0x92, 0x9b, 3762 0x9c, 0xbc, 0x07, 0x46, 0x6e, 0x76, 0xb9, 0x71, 0x20, 0x28, 0x79, 0x85,
3792 0x9a, 0xa8, 0xe1, 0xe3, 0x61, 0x9b, 0xef, 0xd9, 0x1e, 0xb6, 0x59, 0xfa, 3763 0x91, 0xef, 0x75, 0x96, 0x8c, 0xf7, 0xba, 0x88, 0x07, 0xc4, 0x3d, 0x5f,
3793 0xeb, 0xd4, 0xbb, 0x87, 0x6b, 0x1e, 0x4e, 0xd3, 0xaf, 0xeb, 0xc0, 0x1c, 3764 0xd0, 0x7b, 0x8f, 0xb5, 0xe6, 0xe3, 0x66, 0xc6, 0xfe, 0xad, 0x32, 0x71,
3794 0x35, 0xf8, 0x64, 0xa1, 0x69, 0xab, 0xcf, 0xf1, 0x8a, 0x6d, 0x46, 0x20, 3765 0xe6, 0x2e, 0x6e, 0x76, 0xb1, 0x71, 0x34, 0x72, 0x48, 0xc5, 0x44, 0xe0,
3795 0x1f, 0xf6, 0x58, 0x4f, 0xd1, 0x0b, 0x5d, 0xd3, 0x28, 0x13, 0x81, 0xba, 3766 0x84, 0x3a, 0xeb, 0xdf, 0xc4, 0xbe, 0x8c, 0x39, 0x01, 0x85, 0xcf, 0x72,
3796 0x66, 0xfc, 0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 0xfd, 0x0c, 0x56, 0x57, 0xad, 0xd8, 0xc8, 0x4c,
3811 0x32, 0xa9, 0x4b, 0x7e, 0x8c, 0x38, 0xd6, 0x56, 0xb9, 0xa8, 0x51, 0xb6, 3782 0x15, 0x87, 0xcc, 0x69, 0x77, 0x1f, 0x35, 0x92, 0x95, 0xa7, 0x3b, 0x53,
3812 0x3f, 0xc1, 0xda, 0xf0, 0x75, 0x61, 0x5e, 0xbb, 0x07, 0xf3, 0x06, 0x10, 3783 0x8b, 0x8c, 0x19, 0xea, 0x3a, 0xcc, 0xfa, 0x25, 0xb1, 0x43, 0x55, 0xe5,
3813 0x7f, 0x71, 0xaf, 0x09, 0x5e, 0x4e, 0x93, 0x57, 0x3e, 0x83, 0xda, 0xb6, 3784 0x99, 0x03, 0x52, 0xae, 0xb9, 0x78, 0x6b, 0x6e, 0xd1, 0xa5, 0x31, 0xe5,
3814 0xfa, 0x49, 0xbd, 0xb8, 0xe4, 0xd7, 0x44, 0xaa, 0x76, 0x48, 0x48, 0x7d, 3785 0xe1, 0xad, 0x9c, 0x87, 0xb7, 0xb2, 0xb5, 0xe5, 0x48, 0x00, 0xfd, 0xe7,
3815 0xf3, 0xcc, 0xc9, 0xeb, 0x93, 0xd4, 0xdd, 0x00, 0x3b, 0xf4, 0x60, 0x0e, 3786 0xe2, 0x6b, 0x31, 0xd6, 0x8c, 0x87, 0xb1, 0xa6, 0x3f, 0x20, 0xc6, 0xe2,
3816 0xeb, 0x08, 0xc8, 0xc8, 0x3b, 0x27, 0x53, 0x67, 0x64, 0x45, 0xf7, 0x93, 3787 0x58, 0x39, 0x3c, 0x33, 0x3e, 0x1f, 0x91, 0x5d, 0x90, 0xf3, 0x58, 0x91,
3817 0x7a, 0x69, 0x29, 0x83, 0x71, 0xf6, 0xa4, 0xf1, 0xbd, 0xaa, 0x2b, 0xec, 3788 0xfa, 0xe2, 0x19, 0xb2, 0xf7, 0xd2, 0x19, 0xf5, 0xe5, 0xea, 0x2a, 0x10,
3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 0xb2, 0xae, 0x7a, 0x60, 0xad, 3796 0x37, 0x87, 0x9c, 0x0f, 0xa4, 0xa6, 0x14, 0x36, 0xf1, 0x31, 0xc9, 0xed,
3826 0xd6, 0x64, 0x8a, 0xb1, 0xa7, 0x43, 0x36, 0x14, 0xd6, 0xf2, 0x7a, 0xe3, 3797 0x34, 0xc7, 0x9f, 0x75, 0x56, 0x80, 0x7d, 0x56, 0x3c, 0xec, 0x73, 0x60,
3827 0x1b, 0xb3, 0x9e, 0x6f, 0x84, 0x94, 0xbd, 0xff, 0x1b, 0xd0, 0x71, 0x0c, 3798 0xcc, 0xc5, 0x3e, 0xc1, 0xcf, 0x50, 0xff, 0x2e, 0xee, 0x59, 0xb1, 0x93,
3828 0x36, 0x1b, 0x51, 0x73, 0x42, 0xe9, 0x4e, 0x7f, 0x8e, 0xc2, 0x66, 0x6d, 3799 0x18, 0xa7, 0x0a, 0x4c, 0x52, 0x71, 0x0e, 0x48, 0xbe, 0xbe, 0x57, 0x7d,
3829 0x73, 0xc6, 0xc7, 0x33, 0x96, 0xf1, 0xa9, 0x8c, 0x35, 0x36, 0xe1, 0xf5, 3800 0x8e, 0x94, 0xec, 0x68, 0x1b, 0xe4, 0xc4, 0xda, 0xeb, 0x49, 0xae, 0x4a,
3830 0x53, 0x4c, 0xc3, 0xd6, 0x2e, 0xb6, 0x82, 0xf7, 0x4d, 0xa6, 0xe0, 0x4f, 3801 0x27, 0x6a, 0x16, 0xf1, 0x9d, 0x75, 0xa2, 0xe1, 0xdf, 0xf1, 0xae, 0x9f,
3831 0x2f, 0x6d, 0x62, 0x63, 0x18, 0xe7, 0xf3, 0x0b, 0xd0, 0x6b, 0x58, 0x3a, 3802 0xf7, 0xae, 0x4f, 0x78, 0xd7, 0xc7, 0x11, 0x87, 0x8f, 0xa9, 0x58, 0xca,
3832 0x4e, 0xb5, 0xee, 0x99, 0x4b, 0x8d, 0x24, 0x8e, 0x08, 0xdf, 0x30, 0x62, 3803 0x76, 0xb6, 0x41, 0xc9, 0x0e, 0x68, 0x01, 0x7b, 0x9c, 0x1d, 0xfe, 0x8b,
3833 0xfd, 0x6c, 0x82, 0xda, 0x05, 0xe4, 0xc3, 0x2b, 0xc4, 0x08, 0xc3, 0xe7, 3804 0x66, 0x59, 0xe9, 0x98, 0xf4, 0x27, 0xf0, 0x39, 0x8e, 0xcf, 0x34, 0x3e,
3834 0xe5, 0xca, 0x3d, 0x99, 0xd4, 0x7e, 0xad, 0x36, 0x8b, 0xea, 0xe4, 0xf9, 3805 0xfb, 0xf1, 0xc9, 0xe3, 0xb3, 0x2a, 0x53, 0x2d, 0x55, 0x9a, 0x84, 0x8d,
3835 0x29, 0xe6, 0xd3, 0xa3, 0xec, 0x7d, 0x86, 0x4e, 0xbd, 0xad, 0x39, 0x65, 3806 0x0c, 0x4a, 0xaa, 0xfe, 0x12, 0xf4, 0xf8, 0x1c, 0x74, 0x7b, 0x58, 0x0a,
3836 0xf5, 0x8e, 0x39, 0xf4, 0xd2, 0xd2, 0xe6, 0x21, 0x37, 0x3c, 0x3f, 0xc3, 3807 0xd5, 0x3f, 0x95, 0xd9, 0x79, 0x4d, 0xba, 0x2c, 0xe8, 0xb4, 0x0a, 0x5b,
3837 0x04, 0xa8, 0x5b, 0x83, 0x09, 0x47, 0x72, 0xec, 0x71, 0x49, 0x7e, 0x59, 3808 0x9e, 0x77, 0xf7, 0x13, 0x3b, 0x13, 0x7b, 0xd1, 0xb7, 0x29, 0x4f, 0xc5,
3838 0xf6, 0x65, 0x10, 0x47, 0xed, 0x99, 0x0e, 0x99, 0x6f, 0x18, 0xce, 0xe0, 3809 0x9f, 0x13, 0xfd, 0xb1, 0x39, 0xf4, 0x13, 0xbd, 0x30, 0xfc, 0x31, 0xb5,
3839 0xe2, 0x51, 0xac, 0x31, 0x87, 0xb5, 0xa6, 0x51, 0x83, 0xcc, 0x22, 0x27, 3810 0x6f, 0x56, 0x8d, 0xbb, 0x32, 0xde, 0x65, 0xd9, 0x51, 0xe8, 0x7c, 0xf0,
3840 0x53, 0xae, 0x8c, 0xd5, 0x0f, 0x43, 0x46, 0x37, 0xf1, 0xcc, 0x78, 0x3c, 3811 0x18, 0x68, 0x27, 0xd5, 0xd9, 0xd8, 0x8c, 0x1c, 0x3d, 0xbd, 0xbc, 0xc5,
3841 0x27, 0xe6, 0x4c, 0x41, 0xad, 0xfb, 0x9e, 0x96, 0x1f, 0xfd, 0x18, 0x72, 3812 0xf5, 0xad, 0x51, 0xf3, 0x26, 0xf5, 0x8e, 0x79, 0xd8, 0xf0, 0x85, 0x19,
3842 0x5a, 0x58, 0x0e, 0x24, 0x45, 0x9f, 0x4e, 0x86, 0xdf, 0x9f, 0xb3, 0x38, 3813 0xd8, 0xfb, 0x41, 0x27, 0xa0, 0x8d, 0x21, 0xde, 0x8c, 0x39, 0x37, 0x55,
3843 0x16, 0xe5, 0x98, 0x8e, 0xb1, 0xf0, 0xe7, 0x92, 0x51, 0x3d, 0x93, 0x34, 3814 0xbc, 0x81, 0xef, 0xca, 0xc4, 0x4e, 0x86, 0x70, 0xcd, 0xb3, 0x45, 0x88,
3844 0xc7, 0xd9, 0xef, 0x0d, 0x59, 0x73, 0x12, 0x7a, 0xbe, 0xb7, 0x47, 0xba, 3815 0x8b, 0xea, 0x6c, 0xe5, 0x32, 0xf0, 0x8d, 0xa6, 0xea, 0x80, 0xb3, 0xab,
3845 0xa7, 0xa5, 0x77, 0xd5, 0x1c, 0x7f, 0x1d, 0xb4, 0x84, 0x55, 0x6c, 0x9f, 3816 0xfb, 0x43, 0x86, 0xf2, 0x5b, 0xb1, 0x98, 0x2e, 0xb9, 0x11, 0xe2, 0xdc,
3846 0x13, 0xdd, 0x1f, 0xef, 0xd9, 0x1c, 0x0f, 0xfb, 0xe3, 0xd3, 0xd2, 0xbd, 3817 0xbd, 0x2a, 0x36, 0xd5, 0x8a, 0xf6, 0x43, 0xcc, 0x15, 0x6f, 0x08, 0xe3,
3847 0x3a, 0x62, 0xbc, 0x29, 0x87, 0xb1, 0x66, 0x48, 0x2e, 0xa1, 0xa6, 0xb1, 3818 0xdc, 0xe3, 0xe8, 0xd7, 0x07, 0x7f, 0x8c, 0x7b, 0x75, 0xda, 0x27, 0xe7,
3848 0x86, 0xe6, 0xe0, 0x73, 0x0f, 0x91, 0x96, 0x83, 0xc0, 0x14, 0xf0, 0x09, 3819 0xca, 0x67, 0xa6, 0xa5, 0x5a, 0x1e, 0xc5, 0x7c, 0xbd, 0x1c, 0x49, 0xe5,
3849 0xd4, 0xd9, 0xd6, 0x27, 0xe5, 0x4b, 0x46, 0x97, 0xe4, 0x55, 0x4d, 0x1b, 3820 0x12, 0x11, 0xd8, 0xa3, 0xbf, 0x17, 0xe5, 0xd6, 0x4f, 0xaa, 0x8e, 0x8f,
3850 0xf6, 0x7a, 0xa5, 0xb0, 0xf3, 0x5b, 0x87, 0xa6, 0x77, 0x7b, 0xfd, 0x00, 3821 0x29, 0xba, 0xd1, 0x87, 0x79, 0x05, 0x64, 0xe4, 0xee, 0x9f, 0xa9, 0xbd,
3851 0x9e, 0x67, 0x8c, 0x62, 0xec, 0x4a, 0x6b, 0xc5, 0xe2, 0x18, 0xef, 0x5d, 3822 0xb3, 0x82, 0x33, 0x0a, 0x39, 0x25, 0xd1, 0xce, 0x5a, 0x35, 0x7e, 0x97,
3852 0x69, 0xd5, 0xad, 0x11, 0x23, 0xab, 0x45, 0xfd, 0x73, 0xed, 0x79, 0xc5, 3823 0x75, 0x55, 0x13, 0x58, 0x31, 0x66, 0xa4, 0x56, 0x6e, 0x82, 0x5f, 0xc4,
3853 0x7b, 0xa1, 0x3a, 0x68, 0xd4, 0xe4, 0x16, 0x2d, 0x7b, 0x03, 0xf2, 0x83, 3824 0xdc, 0x2d, 0x33, 0x52, 0x29, 0x4f, 0xcb, 0x2b, 0xe5, 0x9f, 0x77, 0x03,
3854 0xfb, 0x19, 0xcc, 0xbd, 0xd2, 0xca, 0x58, 0xf3, 0xaa, 0x7f, 0x5f, 0x93, 3825 0x53, 0x41,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90, 0x37, 0x2a, 0x05, 0x3c, 0x49, 0x9f, 0xf5, 0x72, 0xe0, 3840 0x51, 0xad, 0x32, 0x89, 0xac, 0xe5, 0xe5, 0x49, 0xc6, 0xd9, 0x43, 0x22,
3870 0x9c, 0x7a, 0xcf, 0xfc, 0x24, 0xea, 0x64, 0xd8, 0x6e, 0x79, 0x70, 0x78, 3841 0xc0, 0x97, 0x27, 0x47, 0x24, 0x5d, 0x54, 0xef, 0xa9, 0xf0, 0x9c, 0xad,
3871 0x05, 0xcf, 0xbc, 0xa0, 0x70, 0xa8, 0x2b, 0x0d, 0xf8, 0x40, 0xe2, 0xf9, 3842 0x36, 0x0d, 0xf9, 0xe1, 0xf9, 0x09, 0x06, 0x46, 0xdd, 0xea, 0x8f, 0xa4,
3872 0x3d, 0xb2, 0xfb, 0x01, 0xda, 0x22, 0x32, 0xfd, 0x6d, 0x11, 0xf5, 0xee, 3843 0xe5, 0x69, 0xd6, 0xc0, 0x24, 0xb7, 0x20, 0xdb, 0x92, 0xf0, 0xab, 0xf6,
3873 0xbd, 0x6e, 0x75, 0x8a, 0xec, 0xa5, 0xdd, 0x34, 0x61, 0x63, 0x73, 0xde, 3844 0x44, 0xbb, 0x4c, 0xd7, 0x1a, 0x99, 0xfe, 0x53, 0xcf, 0x82, 0xc6, 0x14,
3874 0x99, 0xd6, 0xb6, 0x6b, 0x73, 0xe6, 0xa2, 0xac, 0x2a, 0xfb, 0xbb, 0x7d, 3845 0x68, 0xed, 0x45, 0x6e, 0x92, 0x45, 0xac, 0xa6, 0x7c, 0xe9, 0xbb, 0x9f,
3875 0xd5, 0xfb, 0x3f, 0xba, 0x8a, 0x72, 0x38, 0x39, 0x2d, 0x77, 0xac, 0x7a, 3846 0x81, 0x8c, 0x3e, 0xc2, 0x3d, 0xe5, 0xd1, 0xac, 0x44, 0x27, 0xf2, 0x8a,
3876 0xf6, 0x56, 0x5a, 0x3a, 0xaa, 0xe4, 0x3a, 0xa7, 0xe4, 0xda, 0x92, 0xc3, 3847 0xee, 0x5b, 0x5a, 0x6e, 0xf8, 0x57, 0x10, 0xeb, 0x02, 0xb2, 0x2b, 0x26,
3877 0x29, 0xca, 0x9c, 0xbc, 0xf0, 0xbd, 0x40, 0x4f, 0x16, 0xf7, 0xfb, 0xf6, 3848 0xfa, 0xde, 0x58, 0xe0, 0xed, 0x29, 0x8b, 0x6d, 0x41, 0xb6, 0xe9, 0x68,
3878 0x33, 0xf8, 0x0c, 0x7f, 0x57, 0x42, 0xd9, 0xb0, 0xee, 0xbe, 0x7f, 0x37, 3849 0x0b, 0xfc, 0x7a, 0x2c, 0xa8, 0x27, 0x63, 0xd1, 0x51, 0x9e, 0x8f, 0x36,
3879 0xcf, 0x59, 0xf7, 0xad, 0x92, 0xcf, 0x1b, 0xb7, 0xf1, 0xf9, 0x14, 0x62, 3850 0xac, 0x29, 0xee, 0x4d, 0x3c, 0x20, 0x5d, 0x7b, 0xa5, 0xe7, 0x42, 0x74,
3880 0xea, 0xd0, 0x90, 0xc7, 0xeb, 0xab, 0x4b, 0x1f, 0xce, 0xeb, 0x37, 0x37, 3851 0xf4, 0x06, 0x78, 0x09, 0x28, 0x5f, 0x3f, 0x25, 0xba, 0xd7, 0xde, 0xbd,
3881 0x79, 0x0d, 0x49, 0x43, 0xd5, 0xaf, 0x5d, 0xbd, 0xd2, 0x8d, 0xa8, 0x07, 3852 0xda, 0x1e, 0xf0, 0xda, 0xf7, 0x4a, 0xd7, 0x85, 0x21, 0xf3, 0x75, 0x99,
3882 0x7b, 0xf8, 0x09, 0xf6, 0x9a, 0x12, 0xd2, 0xe0, 0xed, 0xb7, 0xe1, 0x92, 3853 0x01, 0x4d, 0x43, 0xae, 0x23, 0xd7, 0xb1, 0x06, 0xa6, 0x60, 0x8b, 0x4f,
3883 0x96, 0x80, 0x76, 0xd2, 0x73, 0x9f, 0xaf, 0x2f, 0xee, 0x7f, 0x74, 0xc7, 3854 0x92, 0x97, 0xfd, 0xc0, 0x1a, 0x58, 0x1b, 0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0xba, 0x32, 0xf9, 0x9c, 0x67, 0x47,
3913 0x71, 0x6d, 0x38, 0xa9, 0xa1, 0xff, 0x84, 0xf5, 0xd9, 0x77, 0x61, 0xcc, 3884 0xfd, 0x2f, 0xf0, 0x3d, 0x35, 0xca, 0x88, 0x7c, 0xcf, 0xf4, 0x70, 0x3f,
3914 0x1f, 0xc7, 0x7c, 0x8e, 0xf5, 0x49, 0x69, 0x59, 0x6c, 0xf6, 0x99, 0x6a, 3885 0x76, 0xdb, 0x05, 0xce, 0xb7, 0x6f, 0xcd, 0x7c, 0x4f, 0xc0, 0xc7, 0x0e,
3915 0xc2, 0x77, 0x31, 0x72, 0xb2, 0xd8, 0x18, 0x8c, 0x9f, 0xd7, 0x1c, 0xf5, 3886 0x0c, 0xb8, 0x73, 0x7e, 0x6d, 0xfe, 0xfd, 0xcf, 0xf9, 0x77, 0x57, 0xe7,
3916 0xce, 0x46, 0x72, 0x88, 0x7d, 0xb7, 0x3e, 0x69, 0x2c, 0x4b, 0x22, 0x94, 3887 0x6c, 0x48, 0x55, 0xe5, 0xb9, 0xb1, 0xcd, 0xd2, 0x95, 0x93, 0x06, 0xec,
3917 0x7e, 0x48, 0xdc, 0x86, 0x87, 0xb9, 0x17, 0x34, 0xf6, 0xdf, 0x6c, 0x69, 3888 0xe3, 0xcf, 0x85, 0x67, 0xc6, 0xc9, 0x8b, 0x3b, 0xee, 0xb2, 0x43, 0x9e,
3918 0x6c, 0x9f, 0x63, 0x84, 0xd2, 0x87, 0xe4, 0x0f, 0xfc, 0x39, 0x8e, 0x9a, 3889 0xfc, 0x39, 0x90, 0xaf, 0x29, 0x4f, 0x7f, 0xe4, 0xe3, 0xd9, 0x0d, 0xef,
3919 0xf3, 0x1f, 0x76, 0xf3, 0xec, 0xab, 0xe1, 0xf6, 0x82, 0x06, 0xd2, 0x76, 3890 0x5d, 0x97, 0x46, 0x66, 0x10, 0x6d, 0xba, 0xd2, 0xe1, 0x98, 0xb7, 0xde,
3920 0x63, 0xfb, 0xbe, 0x89, 0xad, 0x7d, 0xb9, 0x27, 0x6a, 0x98, 0xbd, 0x36, 3891 0xf6, 0x8a, 0xae, 0x74, 0x98, 0x5c, 0xd5, 0xe1, 0x0d, 0xe8, 0xb0, 0x2a,
3921 0xf6, 0x7d, 0x15, 0xcf, 0x3c, 0x04, 0x3a, 0xae, 0x84, 0x74, 0xeb, 0x21, 3892 0x9f, 0xc6, 0x9c, 0xb0, 0xbe, 0x5f, 0x18, 0x32, 0x67, 0x64, 0xab, 0xd2,
3922 0x29, 0x36, 0xae, 0xde, 0xa3, 0x9d, 0x06, 0x3e, 0xc3, 0xf5, 0xb9, 0xcf, 3893 0xbf, 0x35, 0x00, 0x9f, 0xea, 0xe9, 0xb2, 0xfd, 0x3e, 0x74, 0xf9, 0xba,
3923 0x21, 0xd0, 0x77, 0x45, 0xd3, 0xad, 0x43, 0x90, 0xa5, 0xb7, 0x47, 0xe8, 3894 0x28, 0x7d, 0xaa, 0x73, 0x44, 0x55, 0x45, 0x87, 0xbe, 0x8d, 0x73, 0x6b,
3924 0x39, 0xd3, 0xf8, 0xa1, 0x0c, 0x89, 0xbe, 0xa2, 0x29, 0xf9, 0xeb, 0xb5, 3895 0x57, 0x3e, 0x81, 0x3c, 0xaa, 0xb3, 0x01, 0x13, 0xae, 0x7e, 0xd5, 0x9a,
3925 0x51, 0x38, 0xc4, 0x94, 0x74, 0xaf, 0xcd, 0x4a, 0x68, 0x8d, 0x3d, 0x00, 3896 0xf7, 0xf4, 0x9b, 0x9d, 0xa0, 0x0e, 0x7f, 0xad, 0xc7, 0xd5, 0x67, 0x87,
3926 0xda, 0x22, 0xf5, 0xb8, 0x0b, 0x7e, 0x2c, 0x76, 0xd8, 0x22, 0xde, 0x67, 3897 0xea, 0x73, 0x2a, 0x36, 0xaa, 0xd6, 0xbb, 0x35, 0xf0, 0xe9, 0x1e, 0xea,
3927 0x1f, 0x77, 0xb5, 0x57, 0x7a, 0x89, 0xf7, 0x59, 0x0f, 0x1c, 0xc4, 0x7f, 3898 0xf4, 0x79, 0xc7, 0xfd, 0x2e, 0x22, 0xce, 0x9d, 0x72, 0xde, 0x4b, 0xaf,
3928 0xd6, 0x04, 0x2f, 0xb5, 0x32, 0xa9, 0x77, 0x54, 0xde, 0xcc, 0x37, 0x78, 3899 0xae, 0x4e, 0xc7, 0xc4, 0x5d, 0x57, 0xeb, 0xf5, 0xa9, 0x5f, 0x08, 0x28,
3929 0xdf, 0x4c, 0x88, 0xf0, 0x1e, 0xe3, 0x43, 0x9f, 0x44, 0xbe, 0x3e, 0x8c, 3900 0x1b, 0x1e, 0x83, 0x0c, 0x8f, 0x97, 0x1e, 0xf4, 0xec, 0xde, 0x9d, 0xf3,
3930 0x98, 0x90, 0x03, 0x76, 0xc6, 0xba, 0xa7, 0x86, 0x24, 0xec, 0xbd, 0xeb, 3901 0xc0, 0xfb, 0x9c, 0xf3, 0x91, 0x62, 0xbf, 0xf9, 0x26, 0xee, 0x8d, 0x63,
3931 0xa0, 0xfa, 0x25, 0x6f, 0x2d, 0x9b, 0xfe, 0xef, 0x53, 0x64, 0xdf, 0xf9, 3902 0xce, 0x33, 0xd2, 0x26, 0x29, 0x6f, 0xce, 0x91, 0xd5, 0x39, 0xfb, 0x3c,
3932 0x14, 0x7b, 0x9a, 0x03, 0xb0, 0x53, 0xd6, 0x23, 0xa2, 0x6f, 0xa0, 0xde, 3903 0xba, 0xfd, 0x52, 0xcc, 0x63, 0x1d, 0xfa, 0xaf, 0x7f, 0xab, 0xde, 0x37,
3933 0xbc, 0xd4, 0x88, 0xf6, 0xf2, 0x7d, 0xcb, 0xd7, 0x5d, 0x5c, 0x13, 0xbb, 3904 0xb9, 0x59, 0xa4, 0xdf, 0x06, 0x56, 0x0a, 0xf5, 0xca, 0xf5, 0x5a, 0x44,
3934 0xc7, 0x14, 0x56, 0xf4, 0xef, 0xf1, 0x3b, 0xea, 0xa0, 0x6d, 0x98, 0x32, 3905 0xae, 0x13, 0x83, 0x8c, 0xe0, 0xdb, 0x99, 0xf3, 0x62, 0x78, 0x50, 0x5e,
3935 0x01, 0x4c, 0xc9, 0x3a, 0x69, 0xca, 0x7f, 0xe7, 0xcd, 0x70, 0x4e, 0x6c, 3906 0x2f, 0x6e, 0xc4, 0xc7, 0xb0, 0xdc, 0x28, 0xfa, 0xbc, 0x10, 0x0b, 0x33,
3936 0xab, 0x95, 0x86, 0x65, 0x03, 0x38, 0x6b, 0xdd, 0xb5, 0x10, 0x07, 0xdf, 3907 0x5f, 0x98, 0x92, 0x37, 0xe6, 0xfb, 0xa5, 0x31, 0x81, 0xb8, 0x3f, 0x40,
3937 0xd6, 0xea, 0x65, 0xf5, 0xbb, 0x34, 0xed, 0x01, 0x60, 0xac, 0x44, 0x9f, 3908 0x99, 0x0c, 0x99, 0x7b, 0xd4, 0x7b, 0x48, 0x77, 0x9a, 0x97, 0x2d, 0xd0,
3938 0xaa, 0x75, 0x4e, 0x3e, 0x20, 0x9e, 0xbd, 0xc3, 0xca, 0x54, 0xcc, 0x5a, 3909 0x5f, 0x68, 0xca, 0x41, 0xee, 0x67, 0xf3, 0x77, 0xed, 0x21, 0x69, 0x30,
3939 0xaf, 0x7a, 0xb5, 0xc5, 0x46, 0x75, 0x4a, 0xfe, 0xd4, 0x5d, 0x50, 0xbd, 3910 0xa7, 0x18, 0xe8, 0x95, 0xca, 0x02, 0xf2, 0xf9, 0x22, 0xe9, 0x53, 0x6e,
3940 0xd2, 0x25, 0xd4, 0x1b, 0xe1, 0x45, 0x55, 0x6b, 0xb5, 0xe1, 0x54, 0xc4, 3911 0x7b, 0xd5, 0xef, 0x71, 0x8c, 0xf7, 0x39, 0xbe, 0x1f, 0x10, 0xa2, 0x6e,
3941 0xb7, 0x67, 0x8f, 0xc0, 0x07, 0x4d, 0xf5, 0x6e, 0x81, 0xbe, 0xd2, 0x6a, 3912 0xee, 0x34, 0x97, 0x2d, 0xee, 0x67, 0x4e, 0x49, 0x0d, 0xfa, 0xfb, 0xe7,
3942 0x65, 0x11, 0x2f, 0x74, 0xcb, 0x32, 0x8a, 0xc8, 0x73, 0x59, 0xf5, 0x7e, 3913 0x31, 0xee, 0xb7, 0xe7, 0xd4, 0xf9, 0xdb, 0x4a, 0x6d, 0x02, 0xb9, 0xc3,
3943 0x0a, 0xfd, 0xf7, 0xf7, 0x54, 0x1c, 0x96, 0x1a, 0x64, 0xf3, 0x5c, 0x02, 3914 0x9d, 0xe6, 0x9c, 0x75, 0x56, 0xe9, 0xad, 0x56, 0x7e, 0xc2, 0x6b, 0xe7,
3944 0xeb, 0x68, 0xca, 0x3e, 0x43, 0x4a, 0x0f, 0x0f, 0x28, 0xec, 0x1a, 0x5a, 3915 0x35, 0xef, 0x35, 0x32, 0xdb, 0x06, 0x98, 0xaf, 0x3e, 0x81, 0x7c, 0x81,
3945 0x41, 0x80, 0x5a, 0x1b, 0x12, 0x59, 0x81, 0xbf, 0xc2, 0x77, 0xc3, 0x6b, 3916 0xb9, 0xea, 0x04, 0xf0, 0x1a, 0x65, 0x12, 0x91, 0xd9, 0x22, 0x69, 0x49,
3946 0xd4, 0x01, 0x65, 0x3b, 0x2b, 0x11, 0xc8, 0x9e, 0x58, 0x22, 0xb4, 0x48, 3917 0x68, 0x13, 0xf2, 0xfb, 0x9c, 0x8c, 0x83, 0x9f, 0x08, 0x72, 0x7b, 0xc6,
3947 0x19, 0xc7, 0x61, 0x17, 0x5c, 0x07, 0x32, 0xe6, 0xbb, 0x2c, 0xcb, 0x1d, 3918 0x87, 0x47, 0x65, 0x39, 0xe4, 0xc6, 0x01, 0x9e, 0xfb, 0x5a, 0x46, 0x6c,
3948 0xf2, 0x4c, 0xc3, 0xf4, 0xdf, 0x3d, 0x7f, 0x89, 0xef, 0xa3, 0xeb, 0x73, 3919 0x58, 0x5e, 0x8d, 0x0d, 0x5b, 0x71, 0xdd, 0xc8, 0xc4, 0x07, 0xfe, 0x06,
3949 0x63, 0x03, 0xc4, 0x4f, 0x52, 0x6a, 0x00, 0x63, 0x9c, 0x66, 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66, 0x8c, 0x4c, 0xbd, 0x91, 3942 0x67, 0xe7, 0x1a, 0x99, 0xa3, 0x6b, 0x72, 0xaa, 0x41, 0x55, 0xef, 0x6d,
3972 0x43, 0xbd, 0xc3, 0xf9, 0x77, 0x40, 0x8f, 0x85, 0x4c, 0xad, 0x51, 0xc8, 3943 0x38, 0x16, 0xfc, 0xe3, 0x08, 0xec, 0x93, 0x6b, 0xa0, 0xa9, 0x3d, 0x01,
3973 0x9c, 0xe5, 0x79, 0x0e, 0xe6, 0xd5, 0x1a, 0x3d, 0x90, 0x7b, 0x8f, 0xea, 3944 0x6c, 0x16, 0xe9, 0x55, 0x39, 0xd1, 0xf1, 0x27, 0xc4, 0xb5, 0x77, 0x58,
3974 0x8b, 0xbc, 0x5c, 0x8e, 0x31, 0x06, 0xc1, 0xd6, 0x63, 0x18, 0x8b, 0xab, 3945 0x99, 0xf2, 0x65, 0x8d, 0xb2, 0x9b, 0x83, 0x2c, 0x97, 0x33, 0xf2, 0x47,
3975 0xdf, 0x68, 0xd5, 0xdd, 0x65, 0xf8, 0x74, 0x02, 0xe3, 0xd5, 0xae, 0x49, 3946 0xce, 0x15, 0x55, 0x6b, 0x9d, 0x47, 0x5e, 0x12, 0x38, 0xa5, 0x72, 0xb2,
3976 0x85, 0x47, 0x2d, 0x59, 0x71, 0x7f, 0xa5, 0x15, 0xcb, 0x97, 0xb5, 0x52, 3947 0x16, 0x7c, 0x0b, 0xbf, 0xf7, 0xe2, 0xd7, 0xb1, 0x16, 0xa3, 0xea, 0x8c,
3977 0x79, 0x18, 0x73, 0x46, 0xf9, 0x5b, 0x9f, 0x3d, 0xc0, 0x49, 0x53, 0xd5, 3948 0x82, 0x7e, 0xae, 0xd9, 0x4c, 0xc1, 0x7f, 0xe8, 0x96, 0x65, 0x16, 0x10,
3978 0x1d, 0x69, 0x4a, 0x80, 0x26, 0xbd, 0x8d, 0xa6, 0x04, 0xe8, 0x41, 0xcc, 3949 0x0f, 0x53, 0xea, 0x9c, 0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0x72, 0x0e, 0xf7, 0x1f, 0xc2, 0xf5, 0xbc, 3964 0x3f, 0x7a, 0x5e, 0xf8, 0x4e, 0xd6, 0xed, 0x26, 0xf3, 0xa5, 0xab, 0xf0,
3994 0x96, 0x6d, 0xe6, 0x70, 0xfd, 0x30, 0xae, 0x27, 0x48, 0x9b, 0xf3, 0x8a, 3965 0x7b, 0x99, 0x58, 0x06, 0x36, 0x94, 0x0f, 0x77, 0x80, 0xe7, 0xdf, 0xc4,
3995 0x35, 0xa5, 0xd9, 0x58, 0xcb, 0x3e, 0x37, 0x89, 0x4f, 0xfb, 0x7a, 0xbc, 3966 0xbd, 0x9c, 0xc3, 0x71, 0xa2, 0xf1, 0x15, 0x29, 0x44, 0x02, 0x32, 0x14,
3996 0x07, 0x3d, 0x95, 0x79, 0x3e, 0x96, 0x04, 0x4d, 0x0f, 0x6a, 0x4e, 0xbd, 3967 0xb9, 0x22, 0x9b, 0xe1, 0xc9, 0x34, 0x79, 0xdd, 0x8a, 0x8e, 0x8a, 0xa6,
3997 0x1b, 0x6b, 0x0c, 0xe1, 0x79, 0xda, 0x54, 0xfb, 0x39, 0xd4, 0x6d, 0xaa, 3968 0xe8, 0x0d, 0xee, 0x86, 0x0d, 0xde, 0x84, 0xbf, 0x6b, 0xf7, 0x72, 0xfd,
3998 0x67, 0x14, 0x4a, 0xa7, 0x81, 0x77, 0x1f, 0x41, 0xde, 0xd7, 0xc4, 0xb1, 3969 0x54, 0x91, 0x18, 0xea, 0x59, 0x75, 0xb6, 0xe0, 0xaa, 0xc5, 0x3a, 0x20,
3999 0x1e, 0x97, 0x62, 0x2a, 0x2d, 0x0b, 0xf5, 0x90, 0x64, 0x63, 0x05, 0x7c, 3970 0xdf, 0xc5, 0xfe, 0x1f, 0x6a, 0x8c, 0xbb, 0x7b, 0x77, 0xac, 0x43, 0x93,
4000 0x2f, 0x48, 0x66, 0x1c, 0xf7, 0xeb, 0xb4, 0x05, 0xce, 0x2b, 0x49, 0xb1, 3971 0x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, 0x71, 0xff, 0x49, 0x5c, 0x4f, 0x6b, 0xa9, 0x7a,
4030 0xaa, 0xce, 0xbd, 0xbc, 0x7e, 0xf5, 0xbc, 0x04, 0xbf, 0xd7, 0x8d, 0xfa, 4001 0x16, 0xd7, 0x4f, 0xe1, 0x7a, 0xca, 0x64, 0x9e, 0xf2, 0xaa, 0x95, 0xd1,
4031 0x39, 0x8e, 0xef, 0x95, 0xf0, 0xb7, 0xa7, 0x8c, 0x01, 0xa8, 0x6b, 0x66, 4002 0x6c, 0xd0, 0xb2, 0xcf, 0x8f, 0xe3, 0xd3, 0x4a, 0x8f, 0xf7, 0xa0, 0xa7,
4032 0x0a, 0x58, 0xaf, 0xd5, 0xf2, 0xfa, 0xd9, 0x2d, 0xd8, 0x7d, 0x84, 0xbf, 4003 0x22, 0xf7, 0xda, 0x62, 0xe0, 0x69, 0x9f, 0x96, 0xae, 0x76, 0x81, 0xc6,
4033 0x65, 0xc0, 0xdf, 0x23, 0xb0, 0x13, 0xf8, 0xc1, 0xe6, 0x38, 0xaf, 0x59, 4004 0x00, 0x9e, 0xa7, 0x4d, 0xed, 0xf7, 0xc6, 0x67, 0xcd, 0xe9, 0x63, 0xaa,
4034 0x4b, 0x04, 0xd7, 0x4c, 0x58, 0xff, 0x1b, 0xed, 0xcc, 0xfa, 0xa1, 0x98, 4005 0xe6, 0x64, 0x24, 0x32, 0xc0, 0xc9, 0x87, 0x91, 0x07, 0x68, 0x92, 0xb6,
4035 0x41, 0x00, 0x00, 0x00 }; 4006 0x9e, 0x93, 0x42, 0x1c, 0x7e, 0xa5, 0x6a, 0x48, 0x2a, 0x94, 0xc7, 0xef,
4036static u32 bnx2_TXP_b09FwData[(0xd0/4) + 1] = { 4007 0xbc, 0x24, 0x47, 0x71, 0xbf, 0x4a, 0x5b, 0x60, 0xbf, 0x3f, 0x95, 0x42,
4008 0x99, 0xb8, 0x9f, 0x75, 0x26, 0xd6, 0xa6, 0x58, 0x5f, 0xca, 0x41, 0x06,
4009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f, 0xf9, 0xfd, 0xe4, 0x16, 0xe9, 0xca,
4024 0x98, 0x86, 0xc5, 0xd8, 0xf0, 0xb8, 0xb7, 0x3f, 0xf0, 0x7f, 0x43, 0xce,
4025 0xae, 0x2c, 0x02, 0x09, 0x99, 0xf5, 0xde, 0xbf, 0xde, 0xc0, 0x1e, 0xd6,
4026 0xef, 0x35, 0x37, 0x32, 0x67, 0xad, 0xbb, 0xf3, 0xae, 0x6c, 0x30, 0xef,
4027 0x8a, 0x37, 0xef, 0xea, 0x7d, 0xf2, 0x5b, 0x99, 0xb7, 0x31, 0x67, 0xda,
4028 0xdc, 0x46, 0xf6, 0x28, 0xea, 0xdd, 0xb0, 0x15, 0x23, 0x18, 0xb4, 0x9d,
4029 0x7b, 0xd5, 0x50, 0x99, 0x57, 0xbb, 0x76, 0x79, 0x16, 0xb1, 0xb0, 0x5c,
4030 0x76, 0x73, 0xec, 0xb2, 0xc3, 0x5a, 0xf6, 0xbb, 0xf1, 0xc0, 0x77, 0xb9,
4031 0xbe, 0xa8, 0xce, 0xbb, 0xcc, 0x3a, 0x6e, 0xdd, 0xab, 0x5c, 0x6e, 0x8d,
4032 0xa9, 0x0f, 0x32, 0x9e, 0x0e, 0xe6, 0x65, 0x82, 0xef, 0x94, 0xe3, 0xfa,
4033 0x11, 0xb9, 0xb2, 0xa0, 0xf6, 0xac, 0xbc, 0xbd, 0x21, 0xee, 0xf9, 0xa8,
4034 0xfd, 0x6f, 0xf8, 0xb5, 0x49, 0xe5, 0xd7, 0x97, 0x17, 0xd4, 0x3d, 0x17,
4035 0x2b, 0x39, 0x13, 0xf0, 0xfb, 0xc8, 0x25, 0xac, 0x07, 0xa4, 0x80, 0x9c,
4036 0xfb, 0xac, 0x75, 0x78, 0x0b, 0x71, 0x0e, 0x69, 0x2d, 0x83, 0xd6, 0xe5,
4037 0x05, 0xd9, 0xc2, 0x33, 0x25, 0x65, 0xb5, 0xcf, 0xe6, 0xd6, 0xc5, 0xa7,
4038 0xc5, 0xff, 0x7f, 0x1d, 0x41, 0x2f, 0x16, 0xf2, 0x5c, 0x0b, 0xdf, 0x73,
4039 0xa6, 0xaf, 0x40, 0x1e, 0x34, 0xc1, 0x7d, 0x9c, 0x66, 0xd3, 0xad, 0x9b,
4040 0x37, 0xb1, 0x2e, 0xda, 0xf8, 0x0e, 0x05, 0xfe, 0x0e, 0xc3, 0x7e, 0xb0,
4041 0x4e, 0x56, 0xdb, 0x79, 0xcd, 0xdc, 0xc3, 0xbf, 0x66, 0x60, 0xfb, 0x3f,
4042 0xe8, 0xf3, 0x49, 0x14, 0x38, 0x46, 0x00, 0x00, 0x00 };
4043
4044static const u32 bnx2_TXP_b09FwData[(0xd0/4) + 1] = {
4037 0x00000000, 0x00000014, 0x00000014, 0x00000014, 0x00000014, 0x00000010, 4045 0x00000000, 0x00000014, 0x00000014, 0x00000014, 0x00000014, 0x00000010,
4038 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 4046 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000010,
4039 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x00008002, 0x00000000, 4047 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x00008002, 0x00000000,
@@ -4043,42 +4051,42 @@ static u32 bnx2_TXP_b09FwData[(0xd0/4) + 1] = {
4043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 4051 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
4044 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 4052 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
4045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; 4053 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
4046static u32 bnx2_TXP_b09FwRodata[(0x30/4) + 1] = { 4054static const u32 bnx2_TXP_b09FwRodata[(0x30/4) + 1] = {
4047 0x08003be8, 0x08003c14, 0x08003c5c, 0x08003c5c, 0x08003ae8, 0x08003b14, 4055 0x08004060, 0x0800408c, 0x080040d4, 0x080040d4, 0x08003f60, 0x08003f8c,
4048 0x08003b14, 0x08003c5c, 0x08003c5c, 0x08003c5c, 0x08003b7c, 0x00000000, 4056 0x08003f8c, 0x080040d4, 0x080040d4, 0x080040d4, 0x08003ff4, 0x00000000,
4049 0x00000000 }; 4057 0x00000000 };
4050static u32 bnx2_TXP_b09FwBss[(0xa20/4) + 1] = { 0x0 }; 4058static const u32 bnx2_TXP_b09FwBss[(0xa20/4) + 1] = { 0x0 };
4051static u32 bnx2_TXP_b09FwSbss[(0x80/4) + 1] = { 0x0 }; 4059static const u32 bnx2_TXP_b09FwSbss[(0x8c/4) + 1] = { 0x0 };
4052 4060
4053static struct fw_info bnx2_txp_fw_09 = { 4061static struct fw_info bnx2_txp_fw_09 = {
4054 .ver_major = 0x1, 4062 .ver_major = 0x3,
4055 .ver_minor = 0x0, 4063 .ver_minor = 0x4,
4056 .ver_fix = 0x0, 4064 .ver_fix = 0x3,
4057 4065
4058 .start_addr = 0x08000060, 4066 .start_addr = 0x08000060,
4059 4067
4060 .text_addr = 0x08000000, 4068 .text_addr = 0x08000000,
4061 .text_len = 0x4194, 4069 .text_len = 0x4634,
4062 .text_index = 0x0, 4070 .text_index = 0x0,
4063 .gz_text = bnx2_TXP_b09FwText, 4071 .gz_text = bnx2_TXP_b09FwText,
4064 .gz_text_len = sizeof(bnx2_TXP_b09FwText), 4072 .gz_text_len = sizeof(bnx2_TXP_b09FwText),
4065 4073
4066 .data_addr = 0x080041e0, 4074 .data_addr = 0x08004680,
4067 .data_len = 0xd0, 4075 .data_len = 0xd0,
4068 .data_index = 0x0, 4076 .data_index = 0x0,
4069 .data = bnx2_TXP_b09FwData, 4077 .data = bnx2_TXP_b09FwData,
4070 4078
4071 .sbss_addr = 0x080042b0, 4079 .sbss_addr = 0x08004750,
4072 .sbss_len = 0x80, 4080 .sbss_len = 0x8c,
4073 .sbss_index = 0x0, 4081 .sbss_index = 0x0,
4074 .sbss = bnx2_TXP_b09FwSbss, 4082 .sbss = bnx2_TXP_b09FwSbss,
4075 4083
4076 .bss_addr = 0x08004330, 4084 .bss_addr = 0x080047e0,
4077 .bss_len = 0xa20, 4085 .bss_len = 0xa20,
4078 .bss_index = 0x0, 4086 .bss_index = 0x0,
4079 .bss = bnx2_TXP_b09FwBss, 4087 .bss = bnx2_TXP_b09FwBss,
4080 4088
4081 .rodata_addr = 0x08004198, 4089 .rodata_addr = 0x08004638,
4082 .rodata_len = 0x30, 4090 .rodata_len = 0x30,
4083 .rodata_index = 0x0, 4091 .rodata_index = 0x0,
4084 .rodata = bnx2_TXP_b09FwRodata, 4092 .rodata = bnx2_TXP_b09FwRodata,
diff --git a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c
index e824d5d231af..88efe9731bab 100644
--- a/drivers/net/fec_8xx/fec_main.c
+++ b/drivers/net/fec_8xx/fec_main.c
@@ -19,7 +19,6 @@
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/pci.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/netdevice.h> 24#include <linux/netdevice.h>
diff --git a/drivers/net/fec_8xx/fec_mii.c b/drivers/net/fec_8xx/fec_mii.c
index e79700abf7b6..b3fa0d6a159c 100644
--- a/drivers/net/fec_8xx/fec_mii.c
+++ b/drivers/net/fec_8xx/fec_mii.c
@@ -19,7 +19,6 @@
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/pci.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/netdevice.h> 24#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index e2ddd617493a..a4a2a0ea43d3 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -24,7 +24,6 @@
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/pci.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/netdevice.h> 29#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index 8545e84fc9a0..5603121132cd 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index cdcfb96f360f..04b4f80a1cde 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index 65925b5a224f..d0f28981b55a 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c
index f91447837fd4..d3840108ffbd 100644
--- a/drivers/net/fs_enet/mii-bitbang.c
+++ b/drivers/net/fs_enet/mii-bitbang.c
@@ -22,7 +22,6 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/pci.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
28#include <linux/netdevice.h> 27#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index 235b177fb9ac..0a563a83016f 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index 3d82d46f4998..50035ebd4f52 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -27,7 +27,6 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/pci.h>
31#include <linux/netdevice.h> 30#include <linux/netdevice.h>
32#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
33#include <linux/skbuff.h> 32#include <linux/skbuff.h>
diff --git a/drivers/net/ixgb/ixgb_osdep.h b/drivers/net/ixgb/ixgb_osdep.h
index 8434d752fd81..9e04a6b3ae0d 100644
--- a/drivers/net/ixgb/ixgb_osdep.h
+++ b/drivers/net/ixgb/ixgb_osdep.h
@@ -34,7 +34,6 @@
34#define _IXGB_OSDEP_H_ 34#define _IXGB_OSDEP_H_
35 35
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/pci.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <asm/io.h> 38#include <asm/io.h>
40#include <linux/interrupt.h> 39#include <linux/interrupt.h>
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index d34afb52ea7f..75f6f441e876 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -88,6 +88,23 @@ static unsigned short known_revisions[] =
88 0xffff /* end of list */ 88 0xffff /* end of list */
89}; 89};
90 90
91static int jazzsonic_open(struct net_device* dev)
92{
93 if (request_irq(dev->irq, &sonic_interrupt, IRQF_DISABLED, "sonic", dev)) {
94 printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq);
95 return -EAGAIN;
96 }
97 return sonic_open(dev);
98}
99
100static int jazzsonic_close(struct net_device* dev)
101{
102 int err;
103 err = sonic_close(dev);
104 free_irq(dev->irq, dev);
105 return err;
106}
107
91static int __init sonic_probe1(struct net_device *dev) 108static int __init sonic_probe1(struct net_device *dev)
92{ 109{
93 static unsigned version_printed; 110 static unsigned version_printed;
@@ -169,8 +186,8 @@ static int __init sonic_probe1(struct net_device *dev)
169 lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS 186 lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
170 * SONIC_BUS_SCALE(lp->dma_bitmode)); 187 * SONIC_BUS_SCALE(lp->dma_bitmode));
171 188
172 dev->open = sonic_open; 189 dev->open = jazzsonic_open;
173 dev->stop = sonic_close; 190 dev->stop = jazzsonic_close;
174 dev->hard_start_xmit = sonic_send_packet; 191 dev->hard_start_xmit = sonic_send_packet;
175 dev->get_stats = sonic_get_stats; 192 dev->get_stats = sonic_get_stats;
176 dev->set_multicast_list = &sonic_multicast_list; 193 dev->set_multicast_list = &sonic_multicast_list;
@@ -260,8 +277,6 @@ MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
260module_param(sonic_debug, int, 0); 277module_param(sonic_debug, int, 0);
261MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)"); 278MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
262 279
263#define SONIC_IRQ_FLAG IRQF_DISABLED
264
265#include "sonic.c" 280#include "sonic.c"
266 281
267static int __devexit jazz_sonic_device_remove (struct platform_device *pdev) 282static int __devexit jazz_sonic_device_remove (struct platform_device *pdev)
@@ -269,11 +284,11 @@ static int __devexit jazz_sonic_device_remove (struct platform_device *pdev)
269 struct net_device *dev = platform_get_drvdata(pdev); 284 struct net_device *dev = platform_get_drvdata(pdev);
270 struct sonic_local* lp = netdev_priv(dev); 285 struct sonic_local* lp = netdev_priv(dev);
271 286
272 unregister_netdev (dev); 287 unregister_netdev(dev);
273 dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), 288 dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
274 lp->descriptors, lp->descriptors_laddr); 289 lp->descriptors, lp->descriptors_laddr);
275 release_region (dev->base_addr, SONIC_MEM_SIZE); 290 release_region (dev->base_addr, SONIC_MEM_SIZE);
276 free_netdev (dev); 291 free_netdev(dev);
277 292
278 return 0; 293 return 0;
279} 294}
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index 0edcd125fd61..6b49fc4bd1a1 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -81,7 +81,6 @@
81#include <linux/etherdevice.h> 81#include <linux/etherdevice.h>
82#include <linux/skbuff.h> 82#include <linux/skbuff.h>
83#include <linux/init.h> 83#include <linux/init.h>
84#include <linux/pci.h>
85#include <linux/types.h> 84#include <linux/types.h>
86#include <linux/bitops.h> 85#include <linux/bitops.h>
87 86
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index a12bb64e3694..90b0c3ed4bb6 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -14,6 +14,8 @@
14/* 2001-05-15: support for Cabletron ported from old daynaport driver 14/* 2001-05-15: support for Cabletron ported from old daynaport driver
15 * and fixed access to Sonic Sys card which masquerades as a Farallon 15 * and fixed access to Sonic Sys card which masquerades as a Farallon
16 * by rayk@knightsmanor.org */ 16 * by rayk@knightsmanor.org */
17/* 2002-12-30: Try to support more cards, some clues from NetBSD driver */
18/* 2003-12-26: Make sure Asante cards always work. */
17 19
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -61,25 +63,21 @@ static char version[] =
61#define DAYNA_8390_BASE 0x80000 63#define DAYNA_8390_BASE 0x80000
62#define DAYNA_8390_MEM 0x00000 64#define DAYNA_8390_MEM 0x00000
63 65
64#define KINETICS_8390_BASE 0x80000
65#define KINETICS_8390_MEM 0x00000
66
67#define CABLETRON_8390_BASE 0x90000 66#define CABLETRON_8390_BASE 0x90000
68#define CABLETRON_8390_MEM 0x00000 67#define CABLETRON_8390_MEM 0x00000
69 68
69#define INTERLAN_8390_BASE 0xE0000
70#define INTERLAN_8390_MEM 0xD0000
71
70enum mac8390_type { 72enum mac8390_type {
71 MAC8390_NONE = -1, 73 MAC8390_NONE = -1,
72 MAC8390_APPLE, 74 MAC8390_APPLE,
73 MAC8390_ASANTE, 75 MAC8390_ASANTE,
74 MAC8390_FARALLON, /* Apple, Asante, and Farallon are all compatible */ 76 MAC8390_FARALLON,
75 MAC8390_CABLETRON, 77 MAC8390_CABLETRON,
76 MAC8390_DAYNA, 78 MAC8390_DAYNA,
77 MAC8390_INTERLAN, 79 MAC8390_INTERLAN,
78 MAC8390_KINETICS, 80 MAC8390_KINETICS,
79 MAC8390_FOCUS,
80 MAC8390_SONICSYS,
81 MAC8390_DAYNA2,
82 MAC8390_DAYNA3,
83}; 81};
84 82
85static const char * cardname[] = { 83static const char * cardname[] = {
@@ -90,10 +88,6 @@ static const char * cardname[] = {
90 "dayna", 88 "dayna",
91 "interlan", 89 "interlan",
92 "kinetics", 90 "kinetics",
93 "focus",
94 "sonic systems",
95 "dayna2",
96 "dayna_lc",
97}; 91};
98 92
99static int word16[] = { 93static int word16[] = {
@@ -104,10 +98,6 @@ static int word16[] = {
104 0, /* dayna */ 98 0, /* dayna */
105 1, /* interlan */ 99 1, /* interlan */
106 0, /* kinetics */ 100 0, /* kinetics */
107 1, /* focus (??) */
108 1, /* sonic systems */
109 1, /* dayna2 */
110 1, /* dayna-lc */
111}; 101};
112 102
113/* on which cards do we use NuBus resources? */ 103/* on which cards do we use NuBus resources? */
@@ -119,10 +109,12 @@ static int useresources[] = {
119 0, /* dayna */ 109 0, /* dayna */
120 0, /* interlan */ 110 0, /* interlan */
121 0, /* kinetics */ 111 0, /* kinetics */
122 0, /* focus (??) */ 112};
123 1, /* sonic systems */ 113
124 1, /* dayna2 */ 114enum mac8390_access {
125 1, /* dayna-lc */ 115 ACCESS_UNKNOWN = 0,
116 ACCESS_32,
117 ACCESS_16,
126}; 118};
127 119
128extern enum mac8390_type mac8390_ident(struct nubus_dev * dev); 120extern enum mac8390_type mac8390_ident(struct nubus_dev * dev);
@@ -134,8 +126,9 @@ static int mac8390_initdev(struct net_device * dev, struct nubus_dev * ndev,
134static int mac8390_open(struct net_device * dev); 126static int mac8390_open(struct net_device * dev);
135static int mac8390_close(struct net_device * dev); 127static int mac8390_close(struct net_device * dev);
136static void mac8390_no_reset(struct net_device *dev); 128static void mac8390_no_reset(struct net_device *dev);
129static void interlan_reset(struct net_device *dev);
137 130
138/* Sane (32-bit chunk memory read/write) - Apple/Asante/Farallon do this*/ 131/* Sane (32-bit chunk memory read/write) - Some Farallon and Apple do this*/
139static void sane_get_8390_hdr(struct net_device *dev, 132static void sane_get_8390_hdr(struct net_device *dev,
140 struct e8390_pkt_hdr *hdr, int ring_page); 133 struct e8390_pkt_hdr *hdr, int ring_page);
141static void sane_block_input(struct net_device * dev, int count, 134static void sane_block_input(struct net_device * dev, int count,
@@ -172,23 +165,93 @@ static void word_memcpy_fromcard(void *tp, const void *fp, int count);
172 165
173enum mac8390_type __init mac8390_ident(struct nubus_dev * dev) 166enum mac8390_type __init mac8390_ident(struct nubus_dev * dev)
174{ 167{
175 if (dev->dr_sw == NUBUS_DRSW_ASANTE) 168 switch (dev->dr_sw) {
176 return MAC8390_ASANTE; 169 case NUBUS_DRSW_3COM:
177 if (dev->dr_sw == NUBUS_DRSW_FARALLON) 170 switch (dev->dr_hw) {
178 return MAC8390_FARALLON; 171 case NUBUS_DRHW_APPLE_SONIC_NB:
179 if (dev->dr_sw == NUBUS_DRSW_KINETICS) 172 case NUBUS_DRHW_APPLE_SONIC_LC:
180 return MAC8390_KINETICS; 173 case NUBUS_DRHW_SONNET:
181 if (dev->dr_sw == NUBUS_DRSW_DAYNA) 174 return MAC8390_NONE;
182 return MAC8390_DAYNA; 175 break;
183 if (dev->dr_sw == NUBUS_DRSW_DAYNA2) 176 default:
184 return MAC8390_DAYNA2; 177 return MAC8390_APPLE;
185 if (dev->dr_sw == NUBUS_DRSW_DAYNA_LC) 178 break;
186 return MAC8390_DAYNA3; 179 }
187 if (dev->dr_hw == NUBUS_DRHW_CABLETRON) 180 break;
188 return MAC8390_CABLETRON; 181
182 case NUBUS_DRSW_APPLE:
183 switch (dev->dr_hw) {
184 case NUBUS_DRHW_ASANTE_LC:
185 return MAC8390_NONE;
186 break;
187 case NUBUS_DRHW_CABLETRON:
188 return MAC8390_CABLETRON;
189 break;
190 default:
191 return MAC8390_APPLE;
192 break;
193 }
194 break;
195
196 case NUBUS_DRSW_ASANTE:
197 return MAC8390_ASANTE;
198 break;
199
200 case NUBUS_DRSW_TECHWORKS:
201 case NUBUS_DRSW_DAYNA2:
202 case NUBUS_DRSW_DAYNA_LC:
203 if (dev->dr_hw == NUBUS_DRHW_CABLETRON)
204 return MAC8390_CABLETRON;
205 else
206 return MAC8390_APPLE;
207 break;
208
209 case NUBUS_DRSW_FARALLON:
210 return MAC8390_FARALLON;
211 break;
212
213 case NUBUS_DRSW_KINETICS:
214 switch (dev->dr_hw) {
215 case NUBUS_DRHW_INTERLAN:
216 return MAC8390_INTERLAN;
217 break;
218 default:
219 return MAC8390_KINETICS;
220 break;
221 }
222 break;
223
224 case NUBUS_DRSW_DAYNA:
225 // These correspond to Dayna Sonic cards
226 // which use the macsonic driver
227 if (dev->dr_hw == NUBUS_DRHW_SMC9194 ||
228 dev->dr_hw == NUBUS_DRHW_INTERLAN )
229 return MAC8390_NONE;
230 else
231 return MAC8390_DAYNA;
232 break;
233 }
189 return MAC8390_NONE; 234 return MAC8390_NONE;
190} 235}
191 236
237enum mac8390_access __init mac8390_testio(volatile unsigned long membase)
238{
239 unsigned long outdata = 0xA5A0B5B0;
240 unsigned long indata = 0x00000000;
241 /* Try writing 32 bits */
242 memcpy((char *)membase, (char *)&outdata, 4);
243 /* Now compare them */
244 if (memcmp((char *)&outdata, (char *)membase, 4) == 0)
245 return ACCESS_32;
246 /* Write 16 bit output */
247 word_memcpy_tocard((char *)membase, (char *)&outdata, 4);
248 /* Now read it back */
249 word_memcpy_fromcard((char *)&indata, (char *)membase, 4);
250 if (outdata == indata)
251 return ACCESS_16;
252 return ACCESS_UNKNOWN;
253}
254
192int __init mac8390_memsize(unsigned long membase) 255int __init mac8390_memsize(unsigned long membase)
193{ 256{
194 unsigned long flags; 257 unsigned long flags;
@@ -287,14 +350,6 @@ struct net_device * __init mac8390_probe(int unit)
287 continue; 350 continue;
288 } else { 351 } else {
289 nubus_get_rsrc_mem(dev->dev_addr, &ent, 6); 352 nubus_get_rsrc_mem(dev->dev_addr, &ent, 6);
290 /* Some Sonic Sys cards masquerade as Farallon */
291 if (cardtype == MAC8390_FARALLON &&
292 dev->dev_addr[0] == 0x0 &&
293 dev->dev_addr[1] == 0x40 &&
294 dev->dev_addr[2] == 0x10) {
295 /* This is really Sonic Sys card */
296 cardtype = MAC8390_SONICSYS;
297 }
298 } 353 }
299 354
300 if (useresources[cardtype] == 1) { 355 if (useresources[cardtype] == 1) {
@@ -334,6 +389,17 @@ struct net_device * __init mac8390_probe(int unit)
334 dev->mem_start + 389 dev->mem_start +
335 mac8390_memsize(dev->mem_start); 390 mac8390_memsize(dev->mem_start);
336 break; 391 break;
392 case MAC8390_INTERLAN:
393 dev->base_addr =
394 (int)(ndev->board->slot_addr +
395 INTERLAN_8390_BASE);
396 dev->mem_start =
397 (int)(ndev->board->slot_addr +
398 INTERLAN_8390_MEM);
399 dev->mem_end =
400 dev->mem_start +
401 mac8390_memsize(dev->mem_start);
402 break;
337 case MAC8390_CABLETRON: 403 case MAC8390_CABLETRON:
338 dev->base_addr = 404 dev->base_addr =
339 (int)(ndev->board->slot_addr + 405 (int)(ndev->board->slot_addr +
@@ -356,8 +422,8 @@ struct net_device * __init mac8390_probe(int unit)
356 422
357 default: 423 default:
358 printk(KERN_ERR "Card type %s is" 424 printk(KERN_ERR "Card type %s is"
359 " unsupported, sorry\n", 425 " unsupported, sorry\n",
360 cardname[cardtype]); 426 ndev->board->name);
361 continue; 427 continue;
362 } 428 }
363 } 429 }
@@ -438,7 +504,7 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
438 24, 26, 28, 30 504 24, 26, 28, 30
439 }; 505 };
440 506
441 int access_bitmode; 507 int access_bitmode = 0;
442 508
443 /* Now fill in our stuff */ 509 /* Now fill in our stuff */
444 dev->open = &mac8390_open; 510 dev->open = &mac8390_open;
@@ -468,29 +534,47 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
468 534
469 /* Fill in model-specific information and functions */ 535 /* Fill in model-specific information and functions */
470 switch(type) { 536 switch(type) {
471 case MAC8390_SONICSYS:
472 /* 16 bit card, register map is reversed */
473 ei_status.reset_8390 = &mac8390_no_reset;
474 ei_status.block_input = &slow_sane_block_input;
475 ei_status.block_output = &slow_sane_block_output;
476 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
477 ei_status.reg_offset = back4_offsets;
478 access_bitmode = 0;
479 break;
480 case MAC8390_FARALLON: 537 case MAC8390_FARALLON:
481 case MAC8390_APPLE: 538 case MAC8390_APPLE:
539 switch(mac8390_testio(dev->mem_start)) {
540 case ACCESS_UNKNOWN:
541 printk("Don't know how to access card memory!\n");
542 return -ENODEV;
543 break;
544
545 case ACCESS_16:
546 /* 16 bit card, register map is reversed */
547 ei_status.reset_8390 = &mac8390_no_reset;
548 ei_status.block_input = &slow_sane_block_input;
549 ei_status.block_output = &slow_sane_block_output;
550 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
551 ei_status.reg_offset = back4_offsets;
552 break;
553
554 case ACCESS_32:
555 /* 32 bit card, register map is reversed */
556 ei_status.reset_8390 = &mac8390_no_reset;
557 ei_status.block_input = &sane_block_input;
558 ei_status.block_output = &sane_block_output;
559 ei_status.get_8390_hdr = &sane_get_8390_hdr;
560 ei_status.reg_offset = back4_offsets;
561 access_bitmode = 1;
562 break;
563 }
564 break;
565
482 case MAC8390_ASANTE: 566 case MAC8390_ASANTE:
483 case MAC8390_DAYNA2: 567 /* Some Asante cards pass the 32 bit test
484 case MAC8390_DAYNA3: 568 * but overwrite system memory when run at 32 bit.
485 /* 32 bit card, register map is reversed */ 569 * so we run them all at 16 bit.
486 /* sane */ 570 */
487 ei_status.reset_8390 = &mac8390_no_reset; 571 ei_status.reset_8390 = &mac8390_no_reset;
488 ei_status.block_input = &sane_block_input; 572 ei_status.block_input = &slow_sane_block_input;
489 ei_status.block_output = &sane_block_output; 573 ei_status.block_output = &slow_sane_block_output;
490 ei_status.get_8390_hdr = &sane_get_8390_hdr; 574 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
491 ei_status.reg_offset = back4_offsets; 575 ei_status.reg_offset = back4_offsets;
492 access_bitmode = 1;
493 break; 576 break;
577
494 case MAC8390_CABLETRON: 578 case MAC8390_CABLETRON:
495 /* 16 bit card, register map is short forward */ 579 /* 16 bit card, register map is short forward */
496 ei_status.reset_8390 = &mac8390_no_reset; 580 ei_status.reset_8390 = &mac8390_no_reset;
@@ -498,21 +582,30 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
498 ei_status.block_output = &slow_sane_block_output; 582 ei_status.block_output = &slow_sane_block_output;
499 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr; 583 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
500 ei_status.reg_offset = fwrd2_offsets; 584 ei_status.reg_offset = fwrd2_offsets;
501 access_bitmode = 0;
502 break; 585 break;
586
503 case MAC8390_DAYNA: 587 case MAC8390_DAYNA:
504 case MAC8390_KINETICS: 588 case MAC8390_KINETICS:
505 /* 16 bit memory */ 589 /* 16 bit memory, register map is forward */
506 /* dayna and similar */ 590 /* dayna and similar */
507 ei_status.reset_8390 = &mac8390_no_reset; 591 ei_status.reset_8390 = &mac8390_no_reset;
508 ei_status.block_input = &dayna_block_input; 592 ei_status.block_input = &dayna_block_input;
509 ei_status.block_output = &dayna_block_output; 593 ei_status.block_output = &dayna_block_output;
510 ei_status.get_8390_hdr = &dayna_get_8390_hdr; 594 ei_status.get_8390_hdr = &dayna_get_8390_hdr;
511 ei_status.reg_offset = fwrd4_offsets; 595 ei_status.reg_offset = fwrd4_offsets;
512 access_bitmode = 0;
513 break; 596 break;
597
598 case MAC8390_INTERLAN:
599 /* 16 bit memory, register map is forward */
600 ei_status.reset_8390 = &interlan_reset;
601 ei_status.block_input = &slow_sane_block_input;
602 ei_status.block_output = &slow_sane_block_output;
603 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
604 ei_status.reg_offset = fwrd4_offsets;
605 break;
606
514 default: 607 default:
515 printk(KERN_ERR "Card type %s is unsupported, sorry\n", cardname[type]); 608 printk(KERN_ERR "Card type %s is unsupported, sorry\n", ndev->board->name);
516 return -ENODEV; 609 return -ENODEV;
517 } 610 }
518 611
@@ -530,9 +623,9 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
530 printk(":"); 623 printk(":");
531 } 624 }
532 } 625 }
533 printk(" IRQ %d, shared memory at %#lx-%#lx, %d-bit access.\n", 626 printk(" IRQ %d, %d KB shared memory at %#lx, %d-bit access.\n",
534 dev->irq, dev->mem_start, dev->mem_end-1, 627 dev->irq, (int)((dev->mem_end - dev->mem_start)/0x1000) * 4,
535 access_bitmode?32:16); 628 dev->mem_start, access_bitmode?32:16);
536 return 0; 629 return 0;
537} 630}
538 631
@@ -561,6 +654,18 @@ static void mac8390_no_reset(struct net_device *dev)
561 return; 654 return;
562} 655}
563 656
657static void interlan_reset(struct net_device *dev)
658{
659 unsigned char *target=nubus_slot_addr(IRQ2SLOT(dev->irq));
660 if (ei_debug > 1)
661 printk("Need to reset the NS8390 t=%lu...", jiffies);
662 ei_status.txing = 0;
663 target[0xC0000] = 0;
664 if (ei_debug > 1)
665 printk("reset complete\n");
666 return;
667}
668
564/* dayna_memcpy_fromio/dayna_memcpy_toio */ 669/* dayna_memcpy_fromio/dayna_memcpy_toio */
565/* directly from daynaport.c by Alan Cox */ 670/* directly from daynaport.c by Alan Cox */
566static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from, int count) 671static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from, int count)
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
index 90e695d53266..26a3b45a4a34 100644
--- a/drivers/net/mac89x0.c
+++ b/drivers/net/mac89x0.c
@@ -128,7 +128,7 @@ struct net_local {
128extern void reset_chip(struct net_device *dev); 128extern void reset_chip(struct net_device *dev);
129#endif 129#endif
130static int net_open(struct net_device *dev); 130static int net_open(struct net_device *dev);
131static int net_send_packet(struct sk_buff *skb, struct net_device *dev); 131static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
132static irqreturn_t net_interrupt(int irq, void *dev_id); 132static irqreturn_t net_interrupt(int irq, void *dev_id);
133static void set_multicast_list(struct net_device *dev); 133static void set_multicast_list(struct net_device *dev);
134static void net_rx(struct net_device *dev); 134static void net_rx(struct net_device *dev);
@@ -374,56 +374,39 @@ net_open(struct net_device *dev)
374static int 374static int
375net_send_packet(struct sk_buff *skb, struct net_device *dev) 375net_send_packet(struct sk_buff *skb, struct net_device *dev)
376{ 376{
377 if (dev->tbusy) { 377 struct net_local *lp = netdev_priv(dev);
378 /* If we get here, some higher level has decided we are broken. 378 unsigned long flags;
379 There should really be a "kick me" function call instead. */
380 int tickssofar = jiffies - dev->trans_start;
381 if (tickssofar < 5)
382 return 1;
383 if (net_debug > 0) printk("%s: transmit timed out, %s?\n", dev->name,
384 tx_done(dev) ? "IRQ conflict" : "network cable problem");
385 /* Try to restart the adaptor. */
386 dev->tbusy=0;
387 dev->trans_start = jiffies;
388 }
389
390 /* Block a timer-based transmit from overlapping. This could better be
391 done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
392 if (test_and_set_bit(0, (void*)&dev->tbusy) != 0)
393 printk("%s: Transmitter access conflict.\n", dev->name);
394 else {
395 struct net_local *lp = netdev_priv(dev);
396 unsigned long flags;
397
398 if (net_debug > 3)
399 printk("%s: sent %d byte packet of type %x\n",
400 dev->name, skb->len,
401 (skb->data[ETH_ALEN+ETH_ALEN] << 8)
402 | skb->data[ETH_ALEN+ETH_ALEN+1]);
403
404 /* keep the upload from being interrupted, since we
405 ask the chip to start transmitting before the
406 whole packet has been completely uploaded. */
407 local_irq_save(flags);
408 379
409 /* initiate a transmit sequence */ 380 if (net_debug > 3)
410 writereg(dev, PP_TxCMD, lp->send_cmd); 381 printk("%s: sent %d byte packet of type %x\n",
411 writereg(dev, PP_TxLength, skb->len); 382 dev->name, skb->len,
383 (skb->data[ETH_ALEN+ETH_ALEN] << 8)
384 | skb->data[ETH_ALEN+ETH_ALEN+1]);
412 385
413 /* Test to see if the chip has allocated memory for the packet */ 386 /* keep the upload from being interrupted, since we
414 if ((readreg(dev, PP_BusST) & READY_FOR_TX_NOW) == 0) { 387 ask the chip to start transmitting before the
415 /* Gasp! It hasn't. But that shouldn't happen since 388 whole packet has been completely uploaded. */
416 we're waiting for TxOk, so return 1 and requeue this packet. */ 389 local_irq_save(flags);
417 local_irq_restore(flags); 390 netif_stop_queue(dev);
418 return 1;
419 }
420 391
421 /* Write the contents of the packet */ 392 /* initiate a transmit sequence */
422 memcpy_toio(dev->mem_start + PP_TxFrame, skb->data, skb->len+1); 393 writereg(dev, PP_TxCMD, lp->send_cmd);
394 writereg(dev, PP_TxLength, skb->len);
423 395
396 /* Test to see if the chip has allocated memory for the packet */
397 if ((readreg(dev, PP_BusST) & READY_FOR_TX_NOW) == 0) {
398 /* Gasp! It hasn't. But that shouldn't happen since
399 we're waiting for TxOk, so return 1 and requeue this packet. */
424 local_irq_restore(flags); 400 local_irq_restore(flags);
425 dev->trans_start = jiffies; 401 return 1;
426 } 402 }
403
404 /* Write the contents of the packet */
405 skb_copy_from_linear_data(skb, (void *)(dev->mem_start + PP_TxFrame),
406 skb->len+1);
407
408 local_irq_restore(flags);
409 dev->trans_start = jiffies;
427 dev_kfree_skb (skb); 410 dev_kfree_skb (skb);
428 411
429 return 0; 412 return 0;
@@ -441,9 +424,6 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
441 printk ("net_interrupt(): irq %d for unknown device.\n", irq); 424 printk ("net_interrupt(): irq %d for unknown device.\n", irq);
442 return IRQ_NONE; 425 return IRQ_NONE;
443 } 426 }
444 if (dev->interrupt)
445 printk("%s: Re-entering the interrupt handler.\n", dev->name);
446 dev->interrupt = 1;
447 427
448 ioaddr = dev->base_addr; 428 ioaddr = dev->base_addr;
449 lp = netdev_priv(dev); 429 lp = netdev_priv(dev);
@@ -464,8 +444,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
464 break; 444 break;
465 case ISQ_TRANSMITTER_EVENT: 445 case ISQ_TRANSMITTER_EVENT:
466 lp->stats.tx_packets++; 446 lp->stats.tx_packets++;
467 dev->tbusy = 0; 447 netif_wake_queue(dev);
468 mark_bh(NET_BH); /* Inform upper layers. */
469 if ((status & TX_OK) == 0) lp->stats.tx_errors++; 448 if ((status & TX_OK) == 0) lp->stats.tx_errors++;
470 if (status & TX_LOST_CRS) lp->stats.tx_carrier_errors++; 449 if (status & TX_LOST_CRS) lp->stats.tx_carrier_errors++;
471 if (status & TX_SQE_ERROR) lp->stats.tx_heartbeat_errors++; 450 if (status & TX_SQE_ERROR) lp->stats.tx_heartbeat_errors++;
@@ -479,8 +458,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
479 That shouldn't happen since we only ever 458 That shouldn't happen since we only ever
480 load one packet. Shrug. Do the right 459 load one packet. Shrug. Do the right
481 thing anyway. */ 460 thing anyway. */
482 dev->tbusy = 0; 461 netif_wake_queue(dev);
483 mark_bh(NET_BH); /* Inform upper layers. */
484 } 462 }
485 if (status & TX_UNDERRUN) { 463 if (status & TX_UNDERRUN) {
486 if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); 464 if (net_debug > 0) printk("%s: transmit underrun\n", dev->name);
@@ -497,7 +475,6 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
497 break; 475 break;
498 } 476 }
499 } 477 }
500 dev->interrupt = 0;
501 return IRQ_HANDLED; 478 return IRQ_HANDLED;
502} 479}
503 480
@@ -531,7 +508,8 @@ net_rx(struct net_device *dev)
531 } 508 }
532 skb_put(skb, length); 509 skb_put(skb, length);
533 510
534 memcpy_fromio(skb->data, dev->mem_start + PP_RxFrame, length); 511 skb_copy_to_linear_data(skb, (void *)(dev->mem_start + PP_RxFrame),
512 length);
535 513
536 if (net_debug > 3)printk("%s: received %d byte packet of type %x\n", 514 if (net_debug > 3)printk("%s: received %d byte packet of type %x\n",
537 dev->name, length, 515 dev->name, length,
@@ -610,8 +588,6 @@ static void set_multicast_list(struct net_device *dev)
610static int set_mac_address(struct net_device *dev, void *addr) 588static int set_mac_address(struct net_device *dev, void *addr)
611{ 589{
612 int i; 590 int i;
613 if (dev->start)
614 return -EBUSY;
615 printk("%s: Setting MAC address to ", dev->name); 591 printk("%s: Setting MAC address to ", dev->name);
616 for (i = 0; i < 6; i++) 592 for (i = 0; i < 6; i++)
617 printk(" %2.2x", dev->dev_addr[i] = ((unsigned char *)addr)[i]); 593 printk(" %2.2x", dev->dev_addr[i] = ((unsigned char *)addr)[i]);
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 27911c07558d..fef3193121f9 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -12,6 +12,11 @@
12 * Copyright (C) 1998 Alan Cox <alan@redhat.com> 12 * Copyright (C) 1998 Alan Cox <alan@redhat.com>
13 * 13 *
14 * Modified heavily by Joshua M. Thompson based on Dave Huang's NetBSD driver 14 * Modified heavily by Joshua M. Thompson based on Dave Huang's NetBSD driver
15 *
16 * Copyright (C) 2007 Finn Thain
17 *
18 * Converted to DMA API, converted to unified driver model,
19 * sync'd some routines with mace.c and fixed various bugs.
15 */ 20 */
16 21
17 22
@@ -23,8 +28,9 @@
23#include <linux/string.h> 28#include <linux/string.h>
24#include <linux/crc32.h> 29#include <linux/crc32.h>
25#include <linux/bitrev.h> 30#include <linux/bitrev.h>
31#include <linux/dma-mapping.h>
32#include <linux/platform_device.h>
26#include <asm/io.h> 33#include <asm/io.h>
27#include <asm/pgtable.h>
28#include <asm/irq.h> 34#include <asm/irq.h>
29#include <asm/macintosh.h> 35#include <asm/macintosh.h>
30#include <asm/macints.h> 36#include <asm/macints.h>
@@ -32,13 +38,20 @@
32#include <asm/page.h> 38#include <asm/page.h>
33#include "mace.h" 39#include "mace.h"
34 40
35#define N_TX_RING 1 41static char mac_mace_string[] = "macmace";
36#define N_RX_RING 8 42static struct platform_device *mac_mace_device;
37#define N_RX_PAGES ((N_RX_RING * 0x0800 + PAGE_SIZE - 1) / PAGE_SIZE) 43
44#define N_TX_BUFF_ORDER 0
45#define N_TX_RING (1 << N_TX_BUFF_ORDER)
46#define N_RX_BUFF_ORDER 3
47#define N_RX_RING (1 << N_RX_BUFF_ORDER)
48
38#define TX_TIMEOUT HZ 49#define TX_TIMEOUT HZ
39 50
40/* Bits in transmit DMA status */ 51#define MACE_BUFF_SIZE 0x800
41#define TX_DMA_ERR 0x80 52
53/* Chip rev needs workaround on HW & multicast addr change */
54#define BROKEN_ADDRCHG_REV 0x0941
42 55
43/* The MACE is simply wired down on a Mac68K box */ 56/* The MACE is simply wired down on a Mac68K box */
44 57
@@ -47,40 +60,46 @@
47 60
48struct mace_data { 61struct mace_data {
49 volatile struct mace *mace; 62 volatile struct mace *mace;
50 volatile unsigned char *tx_ring; 63 unsigned char *tx_ring;
51 volatile unsigned char *tx_ring_phys; 64 dma_addr_t tx_ring_phys;
52 volatile unsigned char *rx_ring; 65 unsigned char *rx_ring;
53 volatile unsigned char *rx_ring_phys; 66 dma_addr_t rx_ring_phys;
54 int dma_intr; 67 int dma_intr;
55 struct net_device_stats stats; 68 struct net_device_stats stats;
56 int rx_slot, rx_tail; 69 int rx_slot, rx_tail;
57 int tx_slot, tx_sloti, tx_count; 70 int tx_slot, tx_sloti, tx_count;
71 int chipid;
72 struct device *device;
58}; 73};
59 74
60struct mace_frame { 75struct mace_frame {
61 u16 len; 76 u8 rcvcnt;
62 u16 status; 77 u8 pad1;
63 u16 rntpc; 78 u8 rcvsts;
64 u16 rcvcc; 79 u8 pad2;
65 u32 pad1; 80 u8 rntpc;
66 u32 pad2; 81 u8 pad3;
82 u8 rcvcc;
83 u8 pad4;
84 u32 pad5;
85 u32 pad6;
67 u8 data[1]; 86 u8 data[1];
68 /* And frame continues.. */ 87 /* And frame continues.. */
69}; 88};
70 89
71#define PRIV_BYTES sizeof(struct mace_data) 90#define PRIV_BYTES sizeof(struct mace_data)
72 91
73extern void psc_debug_dump(void);
74
75static int mace_open(struct net_device *dev); 92static int mace_open(struct net_device *dev);
76static int mace_close(struct net_device *dev); 93static int mace_close(struct net_device *dev);
77static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev); 94static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev);
78static struct net_device_stats *mace_stats(struct net_device *dev); 95static struct net_device_stats *mace_stats(struct net_device *dev);
79static void mace_set_multicast(struct net_device *dev); 96static void mace_set_multicast(struct net_device *dev);
80static int mace_set_address(struct net_device *dev, void *addr); 97static int mace_set_address(struct net_device *dev, void *addr);
98static void mace_reset(struct net_device *dev);
81static irqreturn_t mace_interrupt(int irq, void *dev_id); 99static irqreturn_t mace_interrupt(int irq, void *dev_id);
82static irqreturn_t mace_dma_intr(int irq, void *dev_id); 100static irqreturn_t mace_dma_intr(int irq, void *dev_id);
83static void mace_tx_timeout(struct net_device *dev); 101static void mace_tx_timeout(struct net_device *dev);
102static void __mace_set_address(struct net_device *dev, void *addr);
84 103
85/* 104/*
86 * Load a receive DMA channel with a base address and ring length 105 * Load a receive DMA channel with a base address and ring length
@@ -88,7 +107,7 @@ static void mace_tx_timeout(struct net_device *dev);
88 107
89static void mace_load_rxdma_base(struct net_device *dev, int set) 108static void mace_load_rxdma_base(struct net_device *dev, int set)
90{ 109{
91 struct mace_data *mp = (struct mace_data *) dev->priv; 110 struct mace_data *mp = netdev_priv(dev);
92 111
93 psc_write_word(PSC_ENETRD_CMD + set, 0x0100); 112 psc_write_word(PSC_ENETRD_CMD + set, 0x0100);
94 psc_write_long(PSC_ENETRD_ADDR + set, (u32) mp->rx_ring_phys); 113 psc_write_long(PSC_ENETRD_ADDR + set, (u32) mp->rx_ring_phys);
@@ -103,7 +122,7 @@ static void mace_load_rxdma_base(struct net_device *dev, int set)
103 122
104static void mace_rxdma_reset(struct net_device *dev) 123static void mace_rxdma_reset(struct net_device *dev)
105{ 124{
106 struct mace_data *mp = (struct mace_data *) dev->priv; 125 struct mace_data *mp = netdev_priv(dev);
107 volatile struct mace *mace = mp->mace; 126 volatile struct mace *mace = mp->mace;
108 u8 maccc = mace->maccc; 127 u8 maccc = mace->maccc;
109 128
@@ -130,7 +149,7 @@ static void mace_rxdma_reset(struct net_device *dev)
130 149
131static void mace_txdma_reset(struct net_device *dev) 150static void mace_txdma_reset(struct net_device *dev)
132{ 151{
133 struct mace_data *mp = (struct mace_data *) dev->priv; 152 struct mace_data *mp = netdev_priv(dev);
134 volatile struct mace *mace = mp->mace; 153 volatile struct mace *mace = mp->mace;
135 u8 maccc; 154 u8 maccc;
136 155
@@ -168,7 +187,7 @@ static void mace_dma_off(struct net_device *dev)
168 * model of Macintrash has a MACE (AV macintoshes) 187 * model of Macintrash has a MACE (AV macintoshes)
169 */ 188 */
170 189
171struct net_device *mace_probe(int unit) 190static int __devinit mace_probe(struct platform_device *pdev)
172{ 191{
173 int j; 192 int j;
174 struct mace_data *mp; 193 struct mace_data *mp;
@@ -179,24 +198,28 @@ struct net_device *mace_probe(int unit)
179 int err; 198 int err;
180 199
181 if (found || macintosh_config->ether_type != MAC_ETHER_MACE) 200 if (found || macintosh_config->ether_type != MAC_ETHER_MACE)
182 return ERR_PTR(-ENODEV); 201 return -ENODEV;
183 202
184 found = 1; /* prevent 'finding' one on every device probe */ 203 found = 1; /* prevent 'finding' one on every device probe */
185 204
186 dev = alloc_etherdev(PRIV_BYTES); 205 dev = alloc_etherdev(PRIV_BYTES);
187 if (!dev) 206 if (!dev)
188 return ERR_PTR(-ENOMEM); 207 return -ENOMEM;
189 208
190 if (unit >= 0) 209 mp = netdev_priv(dev);
191 sprintf(dev->name, "eth%d", unit); 210
211 mp->device = &pdev->dev;
212 SET_NETDEV_DEV(dev, &pdev->dev);
213 SET_MODULE_OWNER(dev);
192 214
193 mp = (struct mace_data *) dev->priv;
194 dev->base_addr = (u32)MACE_BASE; 215 dev->base_addr = (u32)MACE_BASE;
195 mp->mace = (volatile struct mace *) MACE_BASE; 216 mp->mace = (volatile struct mace *) MACE_BASE;
196 217
197 dev->irq = IRQ_MAC_MACE; 218 dev->irq = IRQ_MAC_MACE;
198 mp->dma_intr = IRQ_MAC_MACE_DMA; 219 mp->dma_intr = IRQ_MAC_MACE_DMA;
199 220
221 mp->chipid = mp->mace->chipid_hi << 8 | mp->mace->chipid_lo;
222
200 /* 223 /*
201 * The PROM contains 8 bytes which total 0xFF when XOR'd 224 * The PROM contains 8 bytes which total 0xFF when XOR'd
202 * together. Due to the usual peculiar apple brain damage 225 * together. Due to the usual peculiar apple brain damage
@@ -217,7 +240,7 @@ struct net_device *mace_probe(int unit)
217 240
218 if (checksum != 0xFF) { 241 if (checksum != 0xFF) {
219 free_netdev(dev); 242 free_netdev(dev);
220 return ERR_PTR(-ENODEV); 243 return -ENODEV;
221 } 244 }
222 245
223 memset(&mp->stats, 0, sizeof(mp->stats)); 246 memset(&mp->stats, 0, sizeof(mp->stats));
@@ -237,22 +260,98 @@ struct net_device *mace_probe(int unit)
237 260
238 err = register_netdev(dev); 261 err = register_netdev(dev);
239 if (!err) 262 if (!err)
240 return dev; 263 return 0;
241 264
242 free_netdev(dev); 265 free_netdev(dev);
243 return ERR_PTR(err); 266 return err;
267}
268
269/*
270 * Reset the chip.
271 */
272
273static void mace_reset(struct net_device *dev)
274{
275 struct mace_data *mp = netdev_priv(dev);
276 volatile struct mace *mb = mp->mace;
277 int i;
278
279 /* soft-reset the chip */
280 i = 200;
281 while (--i) {
282 mb->biucc = SWRST;
283 if (mb->biucc & SWRST) {
284 udelay(10);
285 continue;
286 }
287 break;
288 }
289 if (!i) {
290 printk(KERN_ERR "macmace: cannot reset chip!\n");
291 return;
292 }
293
294 mb->maccc = 0; /* turn off tx, rx */
295 mb->imr = 0xFF; /* disable all intrs for now */
296 i = mb->ir;
297
298 mb->biucc = XMTSP_64;
299 mb->utr = RTRD;
300 mb->fifocc = XMTFW_8 | RCVFW_64 | XMTFWU | RCVFWU;
301
302 mb->xmtfc = AUTO_PAD_XMIT; /* auto-pad short frames */
303 mb->rcvfc = 0;
304
305 /* load up the hardware address */
306 __mace_set_address(dev, dev->dev_addr);
307
308 /* clear the multicast filter */
309 if (mp->chipid == BROKEN_ADDRCHG_REV)
310 mb->iac = LOGADDR;
311 else {
312 mb->iac = ADDRCHG | LOGADDR;
313 while ((mb->iac & ADDRCHG) != 0)
314 ;
315 }
316 for (i = 0; i < 8; ++i)
317 mb->ladrf = 0;
318
319 /* done changing address */
320 if (mp->chipid != BROKEN_ADDRCHG_REV)
321 mb->iac = 0;
322
323 mb->plscc = PORTSEL_AUI;
244} 324}
245 325
246/* 326/*
247 * Load the address on a mace controller. 327 * Load the address on a mace controller.
248 */ 328 */
249 329
250static int mace_set_address(struct net_device *dev, void *addr) 330static void __mace_set_address(struct net_device *dev, void *addr)
251{ 331{
252 unsigned char *p = addr; 332 struct mace_data *mp = netdev_priv(dev);
253 struct mace_data *mp = (struct mace_data *) dev->priv;
254 volatile struct mace *mb = mp->mace; 333 volatile struct mace *mb = mp->mace;
334 unsigned char *p = addr;
255 int i; 335 int i;
336
337 /* load up the hardware address */
338 if (mp->chipid == BROKEN_ADDRCHG_REV)
339 mb->iac = PHYADDR;
340 else {
341 mb->iac = ADDRCHG | PHYADDR;
342 while ((mb->iac & ADDRCHG) != 0)
343 ;
344 }
345 for (i = 0; i < 6; ++i)
346 mb->padr = dev->dev_addr[i] = p[i];
347 if (mp->chipid != BROKEN_ADDRCHG_REV)
348 mb->iac = 0;
349}
350
351static int mace_set_address(struct net_device *dev, void *addr)
352{
353 struct mace_data *mp = netdev_priv(dev);
354 volatile struct mace *mb = mp->mace;
256 unsigned long flags; 355 unsigned long flags;
257 u8 maccc; 356 u8 maccc;
258 357
@@ -260,15 +359,10 @@ static int mace_set_address(struct net_device *dev, void *addr)
260 359
261 maccc = mb->maccc; 360 maccc = mb->maccc;
262 361
263 /* load up the hardware address */ 362 __mace_set_address(dev, addr);
264 mb->iac = ADDRCHG | PHYADDR;
265 while ((mb->iac & ADDRCHG) != 0);
266
267 for (i = 0; i < 6; ++i) {
268 mb->padr = dev->dev_addr[i] = p[i];
269 }
270 363
271 mb->maccc = maccc; 364 mb->maccc = maccc;
365
272 local_irq_restore(flags); 366 local_irq_restore(flags);
273 367
274 return 0; 368 return 0;
@@ -281,31 +375,11 @@ static int mace_set_address(struct net_device *dev, void *addr)
281 375
282static int mace_open(struct net_device *dev) 376static int mace_open(struct net_device *dev)
283{ 377{
284 struct mace_data *mp = (struct mace_data *) dev->priv; 378 struct mace_data *mp = netdev_priv(dev);
285 volatile struct mace *mb = mp->mace; 379 volatile struct mace *mb = mp->mace;
286#if 0
287 int i;
288 380
289 i = 200; 381 /* reset the chip */
290 while (--i) { 382 mace_reset(dev);
291 mb->biucc = SWRST;
292 if (mb->biucc & SWRST) {
293 udelay(10);
294 continue;
295 }
296 break;
297 }
298 if (!i) {
299 printk(KERN_ERR "%s: software reset failed!!\n", dev->name);
300 return -EAGAIN;
301 }
302#endif
303
304 mb->biucc = XMTSP_64;
305 mb->fifocc = XMTFW_16 | RCVFW_64 | XMTFWU | RCVFWU | XMTBRST | RCVBRST;
306 mb->xmtfc = AUTO_PAD_XMIT;
307 mb->plscc = PORTSEL_AUI;
308 /* mb->utr = RTRD; */
309 383
310 if (request_irq(dev->irq, mace_interrupt, 0, dev->name, dev)) { 384 if (request_irq(dev->irq, mace_interrupt, 0, dev->name, dev)) {
311 printk(KERN_ERR "%s: can't get irq %d\n", dev->name, dev->irq); 385 printk(KERN_ERR "%s: can't get irq %d\n", dev->name, dev->irq);
@@ -319,25 +393,21 @@ static int mace_open(struct net_device *dev)
319 393
320 /* Allocate the DMA ring buffers */ 394 /* Allocate the DMA ring buffers */
321 395
322 mp->rx_ring = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, N_RX_PAGES); 396 mp->tx_ring = dma_alloc_coherent(mp->device,
323 mp->tx_ring = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, 0); 397 N_TX_RING * MACE_BUFF_SIZE,
324 398 &mp->tx_ring_phys, GFP_KERNEL);
325 if (mp->tx_ring==NULL || mp->rx_ring==NULL) { 399 if (mp->tx_ring == NULL) {
326 if (mp->rx_ring) free_pages((u32) mp->rx_ring, N_RX_PAGES); 400 printk(KERN_ERR "%s: unable to allocate DMA tx buffers\n", dev->name);
327 if (mp->tx_ring) free_pages((u32) mp->tx_ring, 0); 401 goto out1;
328 free_irq(dev->irq, dev);
329 free_irq(mp->dma_intr, dev);
330 printk(KERN_ERR "%s: unable to allocate DMA buffers\n", dev->name);
331 return -ENOMEM;
332 } 402 }
333 403
334 mp->rx_ring_phys = (unsigned char *) virt_to_bus((void *)mp->rx_ring); 404 mp->rx_ring = dma_alloc_coherent(mp->device,
335 mp->tx_ring_phys = (unsigned char *) virt_to_bus((void *)mp->tx_ring); 405 N_RX_RING * MACE_BUFF_SIZE,
336 406 &mp->rx_ring_phys, GFP_KERNEL);
337 /* We want the Rx buffer to be uncached and the Tx buffer to be writethrough */ 407 if (mp->rx_ring == NULL) {
338 408 printk(KERN_ERR "%s: unable to allocate DMA rx buffers\n", dev->name);
339 kernel_set_cachemode((void *)mp->rx_ring, N_RX_PAGES * PAGE_SIZE, IOMAP_NOCACHE_NONSER); 409 goto out2;
340 kernel_set_cachemode((void *)mp->tx_ring, PAGE_SIZE, IOMAP_WRITETHROUGH); 410 }
341 411
342 mace_dma_off(dev); 412 mace_dma_off(dev);
343 413
@@ -348,34 +418,22 @@ static int mace_open(struct net_device *dev)
348 psc_write_word(PSC_ENETWR_CTL, 0x0400); 418 psc_write_word(PSC_ENETWR_CTL, 0x0400);
349 psc_write_word(PSC_ENETRD_CTL, 0x0400); 419 psc_write_word(PSC_ENETRD_CTL, 0x0400);
350 420
351#if 0
352 /* load up the hardware address */
353
354 mb->iac = ADDRCHG | PHYADDR;
355
356 while ((mb->iac & ADDRCHG) != 0);
357
358 for (i = 0; i < 6; ++i)
359 mb->padr = dev->dev_addr[i];
360
361 /* clear the multicast filter */
362 mb->iac = ADDRCHG | LOGADDR;
363
364 while ((mb->iac & ADDRCHG) != 0);
365
366 for (i = 0; i < 8; ++i)
367 mb->ladrf = 0;
368
369 mb->plscc = PORTSEL_GPSI + ENPLSIO;
370
371 mb->maccc = ENXMT | ENRCV;
372 mb->imr = RCVINT;
373#endif
374
375 mace_rxdma_reset(dev); 421 mace_rxdma_reset(dev);
376 mace_txdma_reset(dev); 422 mace_txdma_reset(dev);
377 423
424 /* turn it on! */
425 mb->maccc = ENXMT | ENRCV;
426 /* enable all interrupts except receive interrupts */
427 mb->imr = RCVINT;
378 return 0; 428 return 0;
429
430out2:
431 dma_free_coherent(mp->device, N_TX_RING * MACE_BUFF_SIZE,
432 mp->tx_ring, mp->tx_ring_phys);
433out1:
434 free_irq(dev->irq, dev);
435 free_irq(mp->dma_intr, dev);
436 return -ENOMEM;
379} 437}
380 438
381/* 439/*
@@ -384,19 +442,13 @@ static int mace_open(struct net_device *dev)
384 442
385static int mace_close(struct net_device *dev) 443static int mace_close(struct net_device *dev)
386{ 444{
387 struct mace_data *mp = (struct mace_data *) dev->priv; 445 struct mace_data *mp = netdev_priv(dev);
388 volatile struct mace *mb = mp->mace; 446 volatile struct mace *mb = mp->mace;
389 447
390 mb->maccc = 0; /* disable rx and tx */ 448 mb->maccc = 0; /* disable rx and tx */
391 mb->imr = 0xFF; /* disable all irqs */ 449 mb->imr = 0xFF; /* disable all irqs */
392 mace_dma_off(dev); /* disable rx and tx dma */ 450 mace_dma_off(dev); /* disable rx and tx dma */
393 451
394 free_irq(dev->irq, dev);
395 free_irq(IRQ_MAC_MACE_DMA, dev);
396
397 free_pages((u32) mp->rx_ring, N_RX_PAGES);
398 free_pages((u32) mp->tx_ring, 0);
399
400 return 0; 452 return 0;
401} 453}
402 454
@@ -406,15 +458,20 @@ static int mace_close(struct net_device *dev)
406 458
407static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev) 459static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
408{ 460{
409 struct mace_data *mp = (struct mace_data *) dev->priv; 461 struct mace_data *mp = netdev_priv(dev);
462 unsigned long flags;
410 463
411 /* Stop the queue if the buffer is full */ 464 /* Stop the queue since there's only the one buffer */
412 465
466 local_irq_save(flags);
467 netif_stop_queue(dev);
413 if (!mp->tx_count) { 468 if (!mp->tx_count) {
414 netif_stop_queue(dev); 469 printk(KERN_ERR "macmace: tx queue running but no free buffers.\n");
415 return 1; 470 local_irq_restore(flags);
471 return NETDEV_TX_BUSY;
416 } 472 }
417 mp->tx_count--; 473 mp->tx_count--;
474 local_irq_restore(flags);
418 475
419 mp->stats.tx_packets++; 476 mp->stats.tx_packets++;
420 mp->stats.tx_bytes += skb->len; 477 mp->stats.tx_bytes += skb->len;
@@ -432,23 +489,26 @@ static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
432 489
433 dev_kfree_skb(skb); 490 dev_kfree_skb(skb);
434 491
435 return 0; 492 dev->trans_start = jiffies;
493 return NETDEV_TX_OK;
436} 494}
437 495
438static struct net_device_stats *mace_stats(struct net_device *dev) 496static struct net_device_stats *mace_stats(struct net_device *dev)
439{ 497{
440 struct mace_data *p = (struct mace_data *) dev->priv; 498 struct mace_data *mp = netdev_priv(dev);
441 return &p->stats; 499 return &mp->stats;
442} 500}
443 501
444static void mace_set_multicast(struct net_device *dev) 502static void mace_set_multicast(struct net_device *dev)
445{ 503{
446 struct mace_data *mp = (struct mace_data *) dev->priv; 504 struct mace_data *mp = netdev_priv(dev);
447 volatile struct mace *mb = mp->mace; 505 volatile struct mace *mb = mp->mace;
448 int i, j; 506 int i, j;
449 u32 crc; 507 u32 crc;
450 u8 maccc; 508 u8 maccc;
509 unsigned long flags;
451 510
511 local_irq_save(flags);
452 maccc = mb->maccc; 512 maccc = mb->maccc;
453 mb->maccc &= ~PROM; 513 mb->maccc &= ~PROM;
454 514
@@ -473,116 +533,122 @@ static void mace_set_multicast(struct net_device *dev)
473 } 533 }
474 } 534 }
475 535
476 mb->iac = ADDRCHG | LOGADDR; 536 if (mp->chipid == BROKEN_ADDRCHG_REV)
477 while (mb->iac & ADDRCHG); 537 mb->iac = LOGADDR;
478 538 else {
479 for (i = 0; i < 8; ++i) { 539 mb->iac = ADDRCHG | LOGADDR;
480 mb->ladrf = multicast_filter[i]; 540 while ((mb->iac & ADDRCHG) != 0)
541 ;
481 } 542 }
543 for (i = 0; i < 8; ++i)
544 mb->ladrf = multicast_filter[i];
545 if (mp->chipid != BROKEN_ADDRCHG_REV)
546 mb->iac = 0;
482 } 547 }
483 548
484 mb->maccc = maccc; 549 mb->maccc = maccc;
550 local_irq_restore(flags);
485} 551}
486 552
487/*
488 * Miscellaneous interrupts are handled here. We may end up
489 * having to bash the chip on the head for bad errors
490 */
491
492static void mace_handle_misc_intrs(struct mace_data *mp, int intr) 553static void mace_handle_misc_intrs(struct mace_data *mp, int intr)
493{ 554{
494 volatile struct mace *mb = mp->mace; 555 volatile struct mace *mb = mp->mace;
495 static int mace_babbles, mace_jabbers; 556 static int mace_babbles, mace_jabbers;
496 557
497 if (intr & MPCO) { 558 if (intr & MPCO)
498 mp->stats.rx_missed_errors += 256; 559 mp->stats.rx_missed_errors += 256;
499 } 560 mp->stats.rx_missed_errors += mb->mpc; /* reading clears it */
500 mp->stats.rx_missed_errors += mb->mpc; /* reading clears it */ 561 if (intr & RNTPCO)
501
502 if (intr & RNTPCO) {
503 mp->stats.rx_length_errors += 256; 562 mp->stats.rx_length_errors += 256;
504 } 563 mp->stats.rx_length_errors += mb->rntpc; /* reading clears it */
505 mp->stats.rx_length_errors += mb->rntpc; /* reading clears it */ 564 if (intr & CERR)
506
507 if (intr & CERR) {
508 ++mp->stats.tx_heartbeat_errors; 565 ++mp->stats.tx_heartbeat_errors;
509 } 566 if (intr & BABBLE)
510 if (intr & BABBLE) { 567 if (mace_babbles++ < 4)
511 if (mace_babbles++ < 4) { 568 printk(KERN_DEBUG "macmace: babbling transmitter\n");
512 printk(KERN_DEBUG "mace: babbling transmitter\n"); 569 if (intr & JABBER)
513 } 570 if (mace_jabbers++ < 4)
514 } 571 printk(KERN_DEBUG "macmace: jabbering transceiver\n");
515 if (intr & JABBER) {
516 if (mace_jabbers++ < 4) {
517 printk(KERN_DEBUG "mace: jabbering transceiver\n");
518 }
519 }
520} 572}
521 573
522/* 574static irqreturn_t mace_interrupt(int irq, void *dev_id)
523 * A transmit error has occurred. (We kick the transmit side from
524 * the DMA completion)
525 */
526
527static void mace_xmit_error(struct net_device *dev)
528{ 575{
529 struct mace_data *mp = (struct mace_data *) dev->priv; 576 struct net_device *dev = (struct net_device *) dev_id;
577 struct mace_data *mp = netdev_priv(dev);
530 volatile struct mace *mb = mp->mace; 578 volatile struct mace *mb = mp->mace;
531 u8 xmtfs, xmtrc; 579 int intr, fs;
580 unsigned int flags;
532 581
533 xmtfs = mb->xmtfs; 582 /* don't want the dma interrupt handler to fire */
534 xmtrc = mb->xmtrc; 583 local_irq_save(flags);
535 584
536 if (xmtfs & XMTSV) { 585 intr = mb->ir; /* read interrupt register */
537 if (xmtfs & UFLO) { 586 mace_handle_misc_intrs(mp, intr);
538 printk("%s: DMA underrun.\n", dev->name); 587
539 mp->stats.tx_errors++; 588 if (intr & XMTINT) {
540 mp->stats.tx_fifo_errors++; 589 fs = mb->xmtfs;
541 mace_txdma_reset(dev); 590 if ((fs & XMTSV) == 0) {
591 printk(KERN_ERR "macmace: xmtfs not valid! (fs=%x)\n", fs);
592 mace_reset(dev);
593 /*
594 * XXX mace likes to hang the machine after a xmtfs error.
595 * This is hard to reproduce, reseting *may* help
596 */
542 } 597 }
543 if (xmtfs & RTRY) { 598 /* dma should have finished */
544 mp->stats.collisions++; 599 if (!mp->tx_count) {
600 printk(KERN_DEBUG "macmace: tx ring ran out? (fs=%x)\n", fs);
601 }
602 /* Update stats */
603 if (fs & (UFLO|LCOL|LCAR|RTRY)) {
604 ++mp->stats.tx_errors;
605 if (fs & LCAR)
606 ++mp->stats.tx_carrier_errors;
607 else if (fs & (UFLO|LCOL|RTRY)) {
608 ++mp->stats.tx_aborted_errors;
609 if (mb->xmtfs & UFLO) {
610 printk(KERN_ERR "%s: DMA underrun.\n", dev->name);
611 mp->stats.tx_fifo_errors++;
612 mace_txdma_reset(dev);
613 }
614 }
545 } 615 }
546 } 616 }
547}
548 617
549/* 618 if (mp->tx_count)
550 * A receive interrupt occurred. 619 netif_wake_queue(dev);
551 */
552 620
553static void mace_recv_interrupt(struct net_device *dev) 621 local_irq_restore(flags);
554{
555/* struct mace_data *mp = (struct mace_data *) dev->priv; */
556// volatile struct mace *mb = mp->mace;
557}
558 622
559/* 623 return IRQ_HANDLED;
560 * Process the chip interrupt 624}
561 */
562 625
563static irqreturn_t mace_interrupt(int irq, void *dev_id) 626static void mace_tx_timeout(struct net_device *dev)
564{ 627{
565 struct net_device *dev = (struct net_device *) dev_id; 628 struct mace_data *mp = netdev_priv(dev);
566 struct mace_data *mp = (struct mace_data *) dev->priv;
567 volatile struct mace *mb = mp->mace; 629 volatile struct mace *mb = mp->mace;
568 u8 ir; 630 unsigned long flags;
569 631
570 ir = mb->ir; 632 local_irq_save(flags);
571 mace_handle_misc_intrs(mp, ir);
572 633
573 if (ir & XMTINT) { 634 /* turn off both tx and rx and reset the chip */
574 mace_xmit_error(dev); 635 mb->maccc = 0;
575 } 636 printk(KERN_ERR "macmace: transmit timeout - resetting\n");
576 if (ir & RCVINT) { 637 mace_txdma_reset(dev);
577 mace_recv_interrupt(dev); 638 mace_reset(dev);
578 }
579 return IRQ_HANDLED;
580}
581 639
582static void mace_tx_timeout(struct net_device *dev) 640 /* restart rx dma */
583{ 641 mace_rxdma_reset(dev);
584/* struct mace_data *mp = (struct mace_data *) dev->priv; */ 642
585// volatile struct mace *mb = mp->mace; 643 mp->tx_count = N_TX_RING;
644 netif_wake_queue(dev);
645
646 /* turn it on! */
647 mb->maccc = ENXMT | ENRCV;
648 /* enable all interrupts except receive interrupts */
649 mb->imr = RCVINT;
650
651 local_irq_restore(flags);
586} 652}
587 653
588/* 654/*
@@ -591,40 +657,39 @@ static void mace_tx_timeout(struct net_device *dev)
591 657
592static void mace_dma_rx_frame(struct net_device *dev, struct mace_frame *mf) 658static void mace_dma_rx_frame(struct net_device *dev, struct mace_frame *mf)
593{ 659{
594 struct mace_data *mp = (struct mace_data *) dev->priv; 660 struct mace_data *mp = netdev_priv(dev);
595 struct sk_buff *skb; 661 struct sk_buff *skb;
662 unsigned int frame_status = mf->rcvsts;
596 663
597 if (mf->status & RS_OFLO) { 664 if (frame_status & (RS_OFLO | RS_CLSN | RS_FRAMERR | RS_FCSERR)) {
598 printk("%s: fifo overflow.\n", dev->name);
599 mp->stats.rx_errors++;
600 mp->stats.rx_fifo_errors++;
601 }
602 if (mf->status&(RS_CLSN|RS_FRAMERR|RS_FCSERR))
603 mp->stats.rx_errors++; 665 mp->stats.rx_errors++;
666 if (frame_status & RS_OFLO) {
667 printk(KERN_DEBUG "%s: fifo overflow.\n", dev->name);
668 mp->stats.rx_fifo_errors++;
669 }
670 if (frame_status & RS_CLSN)
671 mp->stats.collisions++;
672 if (frame_status & RS_FRAMERR)
673 mp->stats.rx_frame_errors++;
674 if (frame_status & RS_FCSERR)
675 mp->stats.rx_crc_errors++;
676 } else {
677 unsigned int frame_length = mf->rcvcnt + ((frame_status & 0x0F) << 8 );
604 678
605 if (mf->status&RS_CLSN) { 679 skb = dev_alloc_skb(frame_length + 2);
606 mp->stats.collisions++; 680 if (!skb) {
607 } 681 mp->stats.rx_dropped++;
608 if (mf->status&RS_FRAMERR) { 682 return;
609 mp->stats.rx_frame_errors++; 683 }
610 } 684 skb_reserve(skb, 2);
611 if (mf->status&RS_FCSERR) { 685 memcpy(skb_put(skb, frame_length), mf->data, frame_length);
612 mp->stats.rx_crc_errors++; 686
613 } 687 skb->protocol = eth_type_trans(skb, dev);
614 688 netif_rx(skb);
615 skb = dev_alloc_skb(mf->len+2); 689 dev->last_rx = jiffies;
616 if (!skb) { 690 mp->stats.rx_packets++;
617 mp->stats.rx_dropped++; 691 mp->stats.rx_bytes += frame_length;
618 return;
619 } 692 }
620 skb_reserve(skb,2);
621 memcpy(skb_put(skb, mf->len), mf->data, mf->len);
622
623 skb->protocol = eth_type_trans(skb, dev);
624 netif_rx(skb);
625 dev->last_rx = jiffies;
626 mp->stats.rx_packets++;
627 mp->stats.rx_bytes += mf->len;
628} 693}
629 694
630/* 695/*
@@ -634,7 +699,7 @@ static void mace_dma_rx_frame(struct net_device *dev, struct mace_frame *mf)
634static irqreturn_t mace_dma_intr(int irq, void *dev_id) 699static irqreturn_t mace_dma_intr(int irq, void *dev_id)
635{ 700{
636 struct net_device *dev = (struct net_device *) dev_id; 701 struct net_device *dev = (struct net_device *) dev_id;
637 struct mace_data *mp = (struct mace_data *) dev->priv; 702 struct mace_data *mp = netdev_priv(dev);
638 int left, head; 703 int left, head;
639 u16 status; 704 u16 status;
640 u32 baka; 705 u32 baka;
@@ -661,7 +726,8 @@ static irqreturn_t mace_dma_intr(int irq, void *dev_id)
661 /* Loop through the ring buffer and process new packages */ 726 /* Loop through the ring buffer and process new packages */
662 727
663 while (mp->rx_tail < head) { 728 while (mp->rx_tail < head) {
664 mace_dma_rx_frame(dev, (struct mace_frame *) (mp->rx_ring + (mp->rx_tail * 0x0800))); 729 mace_dma_rx_frame(dev, (struct mace_frame*) (mp->rx_ring
730 + (mp->rx_tail * MACE_BUFF_SIZE)));
665 mp->rx_tail++; 731 mp->rx_tail++;
666 } 732 }
667 733
@@ -688,9 +754,76 @@ static irqreturn_t mace_dma_intr(int irq, void *dev_id)
688 psc_write_word(PSC_ENETWR_CMD + mp->tx_sloti, 0x0100); 754 psc_write_word(PSC_ENETWR_CMD + mp->tx_sloti, 0x0100);
689 mp->tx_sloti ^= 0x10; 755 mp->tx_sloti ^= 0x10;
690 mp->tx_count++; 756 mp->tx_count++;
691 netif_wake_queue(dev);
692 } 757 }
693 return IRQ_HANDLED; 758 return IRQ_HANDLED;
694} 759}
695 760
696MODULE_LICENSE("GPL"); 761MODULE_LICENSE("GPL");
762MODULE_DESCRIPTION("Macintosh MACE ethernet driver");
763
764static int __devexit mac_mace_device_remove (struct platform_device *pdev)
765{
766 struct net_device *dev = platform_get_drvdata(pdev);
767 struct mace_data *mp = netdev_priv(dev);
768
769 unregister_netdev(dev);
770
771 free_irq(dev->irq, dev);
772 free_irq(IRQ_MAC_MACE_DMA, dev);
773
774 dma_free_coherent(mp->device, N_RX_RING * MACE_BUFF_SIZE,
775 mp->rx_ring, mp->rx_ring_phys);
776 dma_free_coherent(mp->device, N_TX_RING * MACE_BUFF_SIZE,
777 mp->tx_ring, mp->tx_ring_phys);
778
779 free_netdev(dev);
780
781 return 0;
782}
783
784static struct platform_driver mac_mace_driver = {
785 .probe = mace_probe,
786 .remove = __devexit_p(mac_mace_device_remove),
787 .driver = {
788 .name = mac_mace_string,
789 },
790};
791
792static int __init mac_mace_init_module(void)
793{
794 int err;
795
796 if ((err = platform_driver_register(&mac_mace_driver))) {
797 printk(KERN_ERR "Driver registration failed\n");
798 return err;
799 }
800
801 mac_mace_device = platform_device_alloc(mac_mace_string, 0);
802 if (!mac_mace_device)
803 goto out_unregister;
804
805 if (platform_device_add(mac_mace_device)) {
806 platform_device_put(mac_mace_device);
807 mac_mace_device = NULL;
808 }
809
810 return 0;
811
812out_unregister:
813 platform_driver_unregister(&mac_mace_driver);
814
815 return -ENOMEM;
816}
817
818static void __exit mac_mace_cleanup_module(void)
819{
820 platform_driver_unregister(&mac_mace_driver);
821
822 if (mac_mace_device) {
823 platform_device_unregister(mac_mace_device);
824 mac_mace_device = NULL;
825 }
826}
827
828module_init(mac_mace_init_module);
829module_exit(mac_mace_cleanup_module);
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index 8ca57a0a4c11..e9ecdbf352ae 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -130,6 +130,46 @@ static inline void bit_reverse_addr(unsigned char addr[6])
130 addr[i] = bitrev8(addr[i]); 130 addr[i] = bitrev8(addr[i]);
131} 131}
132 132
133static irqreturn_t macsonic_interrupt(int irq, void *dev_id)
134{
135 irqreturn_t result;
136 unsigned long flags;
137
138 local_irq_save(flags);
139 result = sonic_interrupt(irq, dev_id);
140 local_irq_restore(flags);
141 return result;
142}
143
144static int macsonic_open(struct net_device* dev)
145{
146 if (request_irq(dev->irq, &sonic_interrupt, IRQ_FLG_FAST, "sonic", dev)) {
147 printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq);
148 return -EAGAIN;
149 }
150 /* Under the A/UX interrupt scheme, the onboard SONIC interrupt comes
151 * in at priority level 3. However, we sometimes get the level 2 inter-
152 * rupt as well, which must prevent re-entrance of the sonic handler.
153 */
154 if (dev->irq == IRQ_AUTO_3)
155 if (request_irq(IRQ_NUBUS_9, &macsonic_interrupt, IRQ_FLG_FAST, "sonic", dev)) {
156 printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, IRQ_NUBUS_9);
157 free_irq(dev->irq, dev);
158 return -EAGAIN;
159 }
160 return sonic_open(dev);
161}
162
163static int macsonic_close(struct net_device* dev)
164{
165 int err;
166 err = sonic_close(dev);
167 free_irq(dev->irq, dev);
168 if (dev->irq == IRQ_AUTO_3)
169 free_irq(IRQ_NUBUS_9, dev);
170 return err;
171}
172
133int __init macsonic_init(struct net_device* dev) 173int __init macsonic_init(struct net_device* dev)
134{ 174{
135 struct sonic_local* lp = netdev_priv(dev); 175 struct sonic_local* lp = netdev_priv(dev);
@@ -160,8 +200,8 @@ int __init macsonic_init(struct net_device* dev)
160 lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS 200 lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
161 * SONIC_BUS_SCALE(lp->dma_bitmode)); 201 * SONIC_BUS_SCALE(lp->dma_bitmode));
162 202
163 dev->open = sonic_open; 203 dev->open = macsonic_open;
164 dev->stop = sonic_close; 204 dev->stop = macsonic_close;
165 dev->hard_start_xmit = sonic_send_packet; 205 dev->hard_start_xmit = sonic_send_packet;
166 dev->get_stats = sonic_get_stats; 206 dev->get_stats = sonic_get_stats;
167 dev->set_multicast_list = &sonic_multicast_list; 207 dev->set_multicast_list = &sonic_multicast_list;
@@ -402,7 +442,7 @@ int __init macsonic_ident(struct nubus_dev* ndev)
402 ndev->dr_sw == NUBUS_DRSW_DAYNA) 442 ndev->dr_sw == NUBUS_DRSW_DAYNA)
403 return MACSONIC_DAYNA; 443 return MACSONIC_DAYNA;
404 444
405 if (ndev->dr_hw == NUBUS_DRHW_SONIC_LC && 445 if (ndev->dr_hw == NUBUS_DRHW_APPLE_SONIC_LC &&
406 ndev->dr_sw == 0) { /* huh? */ 446 ndev->dr_sw == 0) { /* huh? */
407 return MACSONIC_APPLE16; 447 return MACSONIC_APPLE16;
408 } 448 }
@@ -522,7 +562,7 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
522 return macsonic_init(dev); 562 return macsonic_init(dev);
523} 563}
524 564
525static int __init mac_sonic_probe(struct platform_device *device) 565static int __init mac_sonic_probe(struct platform_device *pdev)
526{ 566{
527 struct net_device *dev; 567 struct net_device *dev;
528 struct sonic_local *lp; 568 struct sonic_local *lp;
@@ -534,8 +574,8 @@ static int __init mac_sonic_probe(struct platform_device *device)
534 return -ENOMEM; 574 return -ENOMEM;
535 575
536 lp = netdev_priv(dev); 576 lp = netdev_priv(dev);
537 lp->device = &device->dev; 577 lp->device = &pdev->dev;
538 SET_NETDEV_DEV(dev, &device->dev); 578 SET_NETDEV_DEV(dev, &pdev->dev);
539 SET_MODULE_OWNER(dev); 579 SET_MODULE_OWNER(dev);
540 580
541 /* This will catch fatal stuff like -ENOMEM as well as success */ 581 /* This will catch fatal stuff like -ENOMEM as well as success */
@@ -572,19 +612,17 @@ MODULE_DESCRIPTION("Macintosh SONIC ethernet driver");
572module_param(sonic_debug, int, 0); 612module_param(sonic_debug, int, 0);
573MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)"); 613MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
574 614
575#define SONIC_IRQ_FLAG IRQ_FLG_FAST
576
577#include "sonic.c" 615#include "sonic.c"
578 616
579static int __devexit mac_sonic_device_remove (struct platform_device *device) 617static int __devexit mac_sonic_device_remove (struct platform_device *pdev)
580{ 618{
581 struct net_device *dev = platform_get_drvdata(device); 619 struct net_device *dev = platform_get_drvdata(pdev);
582 struct sonic_local* lp = netdev_priv(dev); 620 struct sonic_local* lp = netdev_priv(dev);
583 621
584 unregister_netdev (dev); 622 unregister_netdev(dev);
585 dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), 623 dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
586 lp->descriptors, lp->descriptors_laddr); 624 lp->descriptors, lp->descriptors_laddr);
587 free_netdev (dev); 625 free_netdev(dev);
588 626
589 return 0; 627 return 0;
590} 628}
@@ -607,9 +645,8 @@ static int __init mac_sonic_init_module(void)
607 } 645 }
608 646
609 mac_sonic_device = platform_device_alloc(mac_sonic_string, 0); 647 mac_sonic_device = platform_device_alloc(mac_sonic_string, 0);
610 if (!mac_sonic_device) { 648 if (!mac_sonic_device)
611 goto out_unregister; 649 goto out_unregister;
612 }
613 650
614 if (platform_device_add(mac_sonic_device)) { 651 if (platform_device_add(mac_sonic_device)) {
615 platform_device_put(mac_sonic_device); 652 platform_device_put(mac_sonic_device);
diff --git a/drivers/net/sonic.c b/drivers/net/sonic.c
index c6320c719931..8069f3e32d83 100644
--- a/drivers/net/sonic.c
+++ b/drivers/net/sonic.c
@@ -50,29 +50,6 @@ static int sonic_open(struct net_device *dev)
50 if (sonic_debug > 2) 50 if (sonic_debug > 2)
51 printk("sonic_open: initializing sonic driver.\n"); 51 printk("sonic_open: initializing sonic driver.\n");
52 52
53 /*
54 * We don't need to deal with auto-irq stuff since we
55 * hardwire the sonic interrupt.
56 */
57/*
58 * XXX Horrible work around: We install sonic_interrupt as fast interrupt.
59 * This means that during execution of the handler interrupt are disabled
60 * covering another bug otherwise corrupting data. This doesn't mean
61 * this glue works ok under all situations.
62 *
63 * Note (dhd): this also appears to prevent lockups on the Macintrash
64 * when more than one Ethernet card is installed (knock on wood)
65 *
66 * Note (fthain): whether the above is still true is anyones guess. Certainly
67 * the buffer handling algorithms will not tolerate re-entrance without some
68 * mutual exclusion added. Anyway, the memcpy has now been eliminated from the
69 * rx code to make this a faster "fast interrupt".
70 */
71 if (request_irq(dev->irq, &sonic_interrupt, SONIC_IRQ_FLAG, "sonic", dev)) {
72 printk(KERN_ERR "\n%s: unable to get IRQ %d .\n", dev->name, dev->irq);
73 return -EAGAIN;
74 }
75
76 for (i = 0; i < SONIC_NUM_RRS; i++) { 53 for (i = 0; i < SONIC_NUM_RRS; i++) {
77 struct sk_buff *skb = dev_alloc_skb(SONIC_RBSIZE + 2); 54 struct sk_buff *skb = dev_alloc_skb(SONIC_RBSIZE + 2);
78 if (skb == NULL) { 55 if (skb == NULL) {
@@ -169,8 +146,6 @@ static int sonic_close(struct net_device *dev)
169 } 146 }
170 } 147 }
171 148
172 free_irq(dev->irq, dev); /* release the IRQ */
173
174 return 0; 149 return 0;
175} 150}
176 151
@@ -178,8 +153,13 @@ static void sonic_tx_timeout(struct net_device *dev)
178{ 153{
179 struct sonic_local *lp = netdev_priv(dev); 154 struct sonic_local *lp = netdev_priv(dev);
180 int i; 155 int i;
181 /* Stop the interrupts for this */ 156 /*
157 * put the Sonic into software-reset mode and
158 * disable all interrupts before releasing DMA buffers
159 */
182 SONIC_WRITE(SONIC_IMR, 0); 160 SONIC_WRITE(SONIC_IMR, 0);
161 SONIC_WRITE(SONIC_ISR, 0x7fff);
162 SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
183 /* We could resend the original skbs. Easier to re-initialise. */ 163 /* We could resend the original skbs. Easier to re-initialise. */
184 for (i = 0; i < SONIC_NUM_TDS; i++) { 164 for (i = 0; i < SONIC_NUM_TDS; i++) {
185 if(lp->tx_laddr[i]) { 165 if(lp->tx_laddr[i]) {
diff --git a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
index 396c3d961f88..a123ea87893b 100644
--- a/drivers/net/sun3_82586.c
+++ b/drivers/net/sun3_82586.c
@@ -1023,10 +1023,11 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
1023 { 1023 {
1024 len = skb->len; 1024 len = skb->len;
1025 if (len < ETH_ZLEN) { 1025 if (len < ETH_ZLEN) {
1026 memset((char *)p->xmit_cbuffs[p->xmit_count], 0, ETH_ZLEN); 1026 memset((void *)p->xmit_cbuffs[p->xmit_count], 0,
1027 ETH_ZLEN);
1027 len = ETH_ZLEN; 1028 len = ETH_ZLEN;
1028 } 1029 }
1029 skb_copy_from_linear_data(skb, p->xmit_cbuffs[p->xmit_count], skb->len); 1030 skb_copy_from_linear_data(skb, (void *)p->xmit_cbuffs[p->xmit_count], skb->len);
1030 1031
1031#if (NUM_XMIT_BUFFS == 1) 1032#if (NUM_XMIT_BUFFS == 1)
1032# ifdef NO_NOPCOMMANDS 1033# ifdef NO_NOPCOMMANDS
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 9488f49ea569..59d6e74a4a5f 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -1300,9 +1300,11 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1300 msleep(1); 1300 msleep(1);
1301 } 1301 }
1302 } 1302 }
1303 tg3_write_mem(tp, NIC_SRAM_WOL_MBOX, WOL_SIGNATURE | 1303 if (tp->tg3_flags & TG3_FLAG_WOL_CAP)
1304 WOL_DRV_STATE_SHUTDOWN | 1304 tg3_write_mem(tp, NIC_SRAM_WOL_MBOX, WOL_SIGNATURE |
1305 WOL_DRV_WOL | WOL_SET_MAGIC_PKT); 1305 WOL_DRV_STATE_SHUTDOWN |
1306 WOL_DRV_WOL |
1307 WOL_SET_MAGIC_PKT);
1306 1308
1307 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps); 1309 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps);
1308 1310
@@ -2593,10 +2595,8 @@ static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
2593{ 2595{
2594 int current_link_up = 0; 2596 int current_link_up = 0;
2595 2597
2596 if (!(mac_status & MAC_STATUS_PCS_SYNCED)) { 2598 if (!(mac_status & MAC_STATUS_PCS_SYNCED))
2597 tp->tg3_flags &= ~TG3_FLAG_GOT_SERDES_FLOWCTL;
2598 goto out; 2599 goto out;
2599 }
2600 2600
2601 if (tp->link_config.autoneg == AUTONEG_ENABLE) { 2601 if (tp->link_config.autoneg == AUTONEG_ENABLE) {
2602 u32 flags; 2602 u32 flags;
@@ -2614,7 +2614,6 @@ static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
2614 2614
2615 tg3_setup_flow_control(tp, local_adv, remote_adv); 2615 tg3_setup_flow_control(tp, local_adv, remote_adv);
2616 2616
2617 tp->tg3_flags |= TG3_FLAG_GOT_SERDES_FLOWCTL;
2618 current_link_up = 1; 2617 current_link_up = 1;
2619 } 2618 }
2620 for (i = 0; i < 30; i++) { 2619 for (i = 0; i < 30; i++) {
@@ -2637,7 +2636,6 @@ static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
2637 } else { 2636 } else {
2638 /* Forcing 1000FD link up. */ 2637 /* Forcing 1000FD link up. */
2639 current_link_up = 1; 2638 current_link_up = 1;
2640 tp->tg3_flags |= TG3_FLAG_GOT_SERDES_FLOWCTL;
2641 2639
2642 tw32_f(MAC_MODE, (tp->mac_mode | MAC_MODE_SEND_CONFIGS)); 2640 tw32_f(MAC_MODE, (tp->mac_mode | MAC_MODE_SEND_CONFIGS));
2643 udelay(40); 2641 udelay(40);
@@ -3895,8 +3893,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3895 entry = tp->tx_prod; 3893 entry = tp->tx_prod;
3896 base_flags = 0; 3894 base_flags = 0;
3897 mss = 0; 3895 mss = 0;
3898 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 3896 if ((mss = skb_shinfo(skb)->gso_size) != 0) {
3899 (mss = skb_shinfo(skb)->gso_size) != 0) {
3900 int tcp_opt_len, ip_tcp_len; 3897 int tcp_opt_len, ip_tcp_len;
3901 3898
3902 if (skb_header_cloned(skb) && 3899 if (skb_header_cloned(skb) &&
@@ -4053,8 +4050,7 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
4053 if (skb->ip_summed == CHECKSUM_PARTIAL) 4050 if (skb->ip_summed == CHECKSUM_PARTIAL)
4054 base_flags |= TXD_FLAG_TCPUDP_CSUM; 4051 base_flags |= TXD_FLAG_TCPUDP_CSUM;
4055 mss = 0; 4052 mss = 0;
4056 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 4053 if ((mss = skb_shinfo(skb)->gso_size) != 0) {
4057 (mss = skb_shinfo(skb)->gso_size) != 0) {
4058 struct iphdr *iph; 4054 struct iphdr *iph;
4059 int tcp_opt_len, ip_tcp_len, hdr_len; 4055 int tcp_opt_len, ip_tcp_len, hdr_len;
4060 4056
@@ -5934,7 +5930,7 @@ static int tg3_load_tso_firmware(struct tg3 *tp)
5934 5930
5935 5931
5936/* tp->lock is held. */ 5932/* tp->lock is held. */
5937static void __tg3_set_mac_addr(struct tg3 *tp) 5933static void __tg3_set_mac_addr(struct tg3 *tp, int skip_mac_1)
5938{ 5934{
5939 u32 addr_high, addr_low; 5935 u32 addr_high, addr_low;
5940 int i; 5936 int i;
@@ -5946,6 +5942,8 @@ static void __tg3_set_mac_addr(struct tg3 *tp)
5946 (tp->dev->dev_addr[4] << 8) | 5942 (tp->dev->dev_addr[4] << 8) |
5947 (tp->dev->dev_addr[5] << 0)); 5943 (tp->dev->dev_addr[5] << 0));
5948 for (i = 0; i < 4; i++) { 5944 for (i = 0; i < 4; i++) {
5945 if (i == 1 && skip_mac_1)
5946 continue;
5949 tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high); 5947 tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high);
5950 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low); 5948 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
5951 } 5949 }
@@ -5972,7 +5970,7 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p)
5972{ 5970{
5973 struct tg3 *tp = netdev_priv(dev); 5971 struct tg3 *tp = netdev_priv(dev);
5974 struct sockaddr *addr = p; 5972 struct sockaddr *addr = p;
5975 int err = 0; 5973 int err = 0, skip_mac_1 = 0;
5976 5974
5977 if (!is_valid_ether_addr(addr->sa_data)) 5975 if (!is_valid_ether_addr(addr->sa_data))
5978 return -EINVAL; 5976 return -EINVAL;
@@ -5983,22 +5981,21 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p)
5983 return 0; 5981 return 0;
5984 5982
5985 if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) { 5983 if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
5986 /* Reset chip so that ASF can re-init any MAC addresses it 5984 u32 addr0_high, addr0_low, addr1_high, addr1_low;
5987 * needs.
5988 */
5989 tg3_netif_stop(tp);
5990 tg3_full_lock(tp, 1);
5991 5985
5992 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 5986 addr0_high = tr32(MAC_ADDR_0_HIGH);
5993 err = tg3_restart_hw(tp, 0); 5987 addr0_low = tr32(MAC_ADDR_0_LOW);
5994 if (!err) 5988 addr1_high = tr32(MAC_ADDR_1_HIGH);
5995 tg3_netif_start(tp); 5989 addr1_low = tr32(MAC_ADDR_1_LOW);
5996 tg3_full_unlock(tp); 5990
5997 } else { 5991 /* Skip MAC addr 1 if ASF is using it. */
5998 spin_lock_bh(&tp->lock); 5992 if ((addr0_high != addr1_high || addr0_low != addr1_low) &&
5999 __tg3_set_mac_addr(tp); 5993 !(addr1_high == 0 && addr1_low == 0))
6000 spin_unlock_bh(&tp->lock); 5994 skip_mac_1 = 1;
6001 } 5995 }
5996 spin_lock_bh(&tp->lock);
5997 __tg3_set_mac_addr(tp, skip_mac_1);
5998 spin_unlock_bh(&tp->lock);
6002 5999
6003 return err; 6000 return err;
6004} 6001}
@@ -6315,7 +6312,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6315 tp->rx_jumbo_ptr); 6312 tp->rx_jumbo_ptr);
6316 6313
6317 /* Initialize MAC address and backoff seed. */ 6314 /* Initialize MAC address and backoff seed. */
6318 __tg3_set_mac_addr(tp); 6315 __tg3_set_mac_addr(tp, 0);
6319 6316
6320 /* MTU + ethernet header + FCS + optional VLAN tag */ 6317 /* MTU + ethernet header + FCS + optional VLAN tag */
6321 tw32(MAC_RX_MTU_SIZE, tp->dev->mtu + ETH_HLEN + 8); 6318 tw32(MAC_RX_MTU_SIZE, tp->dev->mtu + ETH_HLEN + 8);
@@ -6346,8 +6343,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6346 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 6343 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
6347 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) { 6344 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) {
6348 if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE && 6345 if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE &&
6349 (tp->pci_chip_rev_id == CHIPREV_ID_5705_A1 || 6346 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
6350 tp->pci_chip_rev_id == CHIPREV_ID_5705_A2)) {
6351 rdmac_mode |= RDMAC_MODE_FIFO_SIZE_128; 6347 rdmac_mode |= RDMAC_MODE_FIFO_SIZE_128;
6352 } else if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) && 6348 } else if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) &&
6353 !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) { 6349 !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
@@ -6457,6 +6453,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6457 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) 6453 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
6458 gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL; 6454 gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL;
6459 6455
6456 tp->grc_local_ctrl &= ~gpio_mask;
6460 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; 6457 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
6461 6458
6462 /* GPIO1 must be driven high for eeprom write protect */ 6459 /* GPIO1 must be driven high for eeprom write protect */
@@ -7036,11 +7033,7 @@ static int tg3_open(struct net_device *dev)
7036 if (err) 7033 if (err)
7037 return err; 7034 return err;
7038 7035
7039 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 7036 if (tp->tg3_flags & TG3_FLAG_SUPPORT_MSI) {
7040 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) &&
7041 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX) &&
7042 !((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) &&
7043 (tp->pdev_peer == tp->pdev))) {
7044 /* All MSI supporting chips should support tagged 7037 /* All MSI supporting chips should support tagged
7045 * status. Assert that this is the case. 7038 * status. Assert that this is the case.
7046 */ 7039 */
@@ -7399,9 +7392,7 @@ static int tg3_close(struct net_device *dev)
7399 7392
7400 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 7393 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
7401 tg3_free_rings(tp); 7394 tg3_free_rings(tp);
7402 tp->tg3_flags &= 7395 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
7403 ~(TG3_FLAG_INIT_COMPLETE |
7404 TG3_FLAG_GOT_SERDES_FLOWCTL);
7405 7396
7406 tg3_full_unlock(tp); 7397 tg3_full_unlock(tp);
7407 7398
@@ -8036,7 +8027,10 @@ static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
8036{ 8027{
8037 struct tg3 *tp = netdev_priv(dev); 8028 struct tg3 *tp = netdev_priv(dev);
8038 8029
8039 wol->supported = WAKE_MAGIC; 8030 if (tp->tg3_flags & TG3_FLAG_WOL_CAP)
8031 wol->supported = WAKE_MAGIC;
8032 else
8033 wol->supported = 0;
8040 wol->wolopts = 0; 8034 wol->wolopts = 0;
8041 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) 8035 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)
8042 wol->wolopts = WAKE_MAGIC; 8036 wol->wolopts = WAKE_MAGIC;
@@ -8050,8 +8044,7 @@ static int tg3_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
8050 if (wol->wolopts & ~WAKE_MAGIC) 8044 if (wol->wolopts & ~WAKE_MAGIC)
8051 return -EINVAL; 8045 return -EINVAL;
8052 if ((wol->wolopts & WAKE_MAGIC) && 8046 if ((wol->wolopts & WAKE_MAGIC) &&
8053 tp->tg3_flags2 & TG3_FLG2_ANY_SERDES && 8047 !(tp->tg3_flags & TG3_FLAG_WOL_CAP))
8054 !(tp->tg3_flags & TG3_FLAG_SERDES_WOL_CAP))
8055 return -EINVAL; 8048 return -EINVAL;
8056 8049
8057 spin_lock_bh(&tp->lock); 8050 spin_lock_bh(&tp->lock);
@@ -9289,7 +9282,7 @@ static void __devinit tg3_get_nvram_size(struct tg3 *tp)
9289 return; 9282 return;
9290 } 9283 }
9291 } 9284 }
9292 tp->nvram_size = 0x20000; 9285 tp->nvram_size = 0x80000;
9293} 9286}
9294 9287
9295static void __devinit tg3_get_nvram_info(struct tg3 *tp) 9288static void __devinit tg3_get_nvram_info(struct tg3 *tp)
@@ -9408,33 +9401,31 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp)
9408 9401
9409static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp) 9402static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
9410{ 9403{
9411 u32 nvcfg1; 9404 u32 nvcfg1, protect = 0;
9412 9405
9413 nvcfg1 = tr32(NVRAM_CFG1); 9406 nvcfg1 = tr32(NVRAM_CFG1);
9414 9407
9415 /* NVRAM protection for TPM */ 9408 /* NVRAM protection for TPM */
9416 if (nvcfg1 & (1 << 27)) 9409 if (nvcfg1 & (1 << 27)) {
9417 tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM; 9410 tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
9411 protect = 1;
9412 }
9418 9413
9419 switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) { 9414 nvcfg1 &= NVRAM_CFG1_5752VENDOR_MASK;
9420 case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ: 9415 switch (nvcfg1) {
9421 case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ:
9422 tp->nvram_jedecnum = JEDEC_ATMEL;
9423 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
9424 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;
9425
9426 nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
9427 tw32(NVRAM_CFG1, nvcfg1);
9428 break;
9429 case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
9430 case FLASH_5755VENDOR_ATMEL_FLASH_1: 9416 case FLASH_5755VENDOR_ATMEL_FLASH_1:
9431 case FLASH_5755VENDOR_ATMEL_FLASH_2: 9417 case FLASH_5755VENDOR_ATMEL_FLASH_2:
9432 case FLASH_5755VENDOR_ATMEL_FLASH_3: 9418 case FLASH_5755VENDOR_ATMEL_FLASH_3:
9433 case FLASH_5755VENDOR_ATMEL_FLASH_4:
9434 tp->nvram_jedecnum = JEDEC_ATMEL; 9419 tp->nvram_jedecnum = JEDEC_ATMEL;
9435 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; 9420 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
9436 tp->tg3_flags2 |= TG3_FLG2_FLASH; 9421 tp->tg3_flags2 |= TG3_FLG2_FLASH;
9437 tp->nvram_pagesize = 264; 9422 tp->nvram_pagesize = 264;
9423 if (nvcfg1 == FLASH_5755VENDOR_ATMEL_FLASH_1)
9424 tp->nvram_size = (protect ? 0x3e200 : 0x80000);
9425 else if (nvcfg1 == FLASH_5755VENDOR_ATMEL_FLASH_2)
9426 tp->nvram_size = (protect ? 0x1f200 : 0x40000);
9427 else
9428 tp->nvram_size = (protect ? 0x1f200 : 0x20000);
9438 break; 9429 break;
9439 case FLASH_5752VENDOR_ST_M45PE10: 9430 case FLASH_5752VENDOR_ST_M45PE10:
9440 case FLASH_5752VENDOR_ST_M45PE20: 9431 case FLASH_5752VENDOR_ST_M45PE20:
@@ -9443,6 +9434,12 @@ static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
9443 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; 9434 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
9444 tp->tg3_flags2 |= TG3_FLG2_FLASH; 9435 tp->tg3_flags2 |= TG3_FLG2_FLASH;
9445 tp->nvram_pagesize = 256; 9436 tp->nvram_pagesize = 256;
9437 if (nvcfg1 == FLASH_5752VENDOR_ST_M45PE10)
9438 tp->nvram_size = (protect ? 0x10000 : 0x20000);
9439 else if (nvcfg1 == FLASH_5752VENDOR_ST_M45PE20)
9440 tp->nvram_size = (protect ? 0x10000 : 0x40000);
9441 else
9442 tp->nvram_size = (protect ? 0x20000 : 0x80000);
9446 break; 9443 break;
9447 } 9444 }
9448} 9445}
@@ -9518,6 +9515,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
9518 } 9515 }
9519 tg3_enable_nvram_access(tp); 9516 tg3_enable_nvram_access(tp);
9520 9517
9518 tp->nvram_size = 0;
9519
9521 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 9520 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
9522 tg3_get_5752_nvram_info(tp); 9521 tg3_get_5752_nvram_info(tp);
9523 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) 9522 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
@@ -9529,7 +9528,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
9529 else 9528 else
9530 tg3_get_nvram_info(tp); 9529 tg3_get_nvram_info(tp);
9531 9530
9532 tg3_get_nvram_size(tp); 9531 if (tp->nvram_size == 0)
9532 tg3_get_nvram_size(tp);
9533 9533
9534 tg3_disable_nvram_access(tp); 9534 tg3_disable_nvram_access(tp);
9535 tg3_nvram_unlock(tp); 9535 tg3_nvram_unlock(tp);
@@ -9996,8 +9996,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9996 tp->phy_id = PHY_ID_INVALID; 9996 tp->phy_id = PHY_ID_INVALID;
9997 tp->led_ctrl = LED_CTRL_MODE_PHY_1; 9997 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
9998 9998
9999 /* Assume an onboard device by default. */ 9999 /* Assume an onboard device and WOL capable by default. */
10000 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 10000 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT | TG3_FLAG_WOL_CAP;
10001 10001
10002 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 10002 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
10003 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) { 10003 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) {
@@ -10120,8 +10120,9 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10120 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) 10120 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
10121 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 10121 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
10122 } 10122 }
10123 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL) 10123 if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES &&
10124 tp->tg3_flags |= TG3_FLAG_SERDES_WOL_CAP; 10124 !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL))
10125 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP;
10125 10126
10126 if (cfg2 & (1 << 17)) 10127 if (cfg2 & (1 << 17))
10127 tp->tg3_flags2 |= TG3_FLG2_CAPACITIVE_COUPLING; 10128 tp->tg3_flags2 |= TG3_FLG2_CAPACITIVE_COUPLING;
@@ -10399,6 +10400,8 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
10399 } 10400 }
10400} 10401}
10401 10402
10403static struct pci_dev * __devinit tg3_find_peer(struct tg3 *);
10404
10402static int __devinit tg3_get_invariants(struct tg3 *tp) 10405static int __devinit tg3_get_invariants(struct tg3 *tp)
10403{ 10406{
10404 static struct pci_device_id write_reorder_chipsets[] = { 10407 static struct pci_device_id write_reorder_chipsets[] = {
@@ -10554,6 +10557,10 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10554 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff; 10557 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff;
10555 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff; 10558 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff;
10556 10559
10560 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10561 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
10562 tp->pdev_peer = tg3_find_peer(tp);
10563
10557 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || 10564 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
10558 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || 10565 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
10559 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || 10566 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
@@ -10567,6 +10574,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10567 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; 10574 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
10568 10575
10569 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { 10576 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
10577 tp->tg3_flags |= TG3_FLAG_SUPPORT_MSI;
10578 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_AX ||
10579 GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_BX ||
10580 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714 &&
10581 tp->pci_chip_rev_id <= CHIPREV_ID_5714_A2 &&
10582 tp->pdev_peer == tp->pdev))
10583 tp->tg3_flags &= ~TG3_FLAG_SUPPORT_MSI;
10584
10570 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || 10585 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
10571 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || 10586 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 ||
10572 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 10587 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
@@ -10668,17 +10683,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10668 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX) 10683 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX)
10669 tp->tg3_flags |= TG3_FLAG_TXD_MBOX_HWBUG; 10684 tp->tg3_flags |= TG3_FLAG_TXD_MBOX_HWBUG;
10670 10685
10671 /* Back to back register writes can cause problems on this chip,
10672 * the workaround is to read back all reg writes except those to
10673 * mailbox regs. See tg3_write_indirect_reg32().
10674 *
10675 * PCI Express 5750_A0 rev chips need this workaround too.
10676 */
10677 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
10678 ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) &&
10679 tp->pci_chip_rev_id == CHIPREV_ID_5750_A0))
10680 tp->tg3_flags |= TG3_FLAG_5701_REG_WRITE_BUG;
10681
10682 if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0) 10686 if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0)
10683 tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED; 10687 tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED;
10684 if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0) 10688 if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0)
@@ -10702,8 +10706,19 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10702 /* Various workaround register access methods */ 10706 /* Various workaround register access methods */
10703 if (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) 10707 if (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG)
10704 tp->write32 = tg3_write_indirect_reg32; 10708 tp->write32 = tg3_write_indirect_reg32;
10705 else if (tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) 10709 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
10710 ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) &&
10711 tp->pci_chip_rev_id == CHIPREV_ID_5750_A0)) {
10712 /*
10713 * Back to back register writes can cause problems on these
10714 * chips, the workaround is to read back all reg writes
10715 * except those to mailbox regs.
10716 *
10717 * See tg3_write_indirect_reg32().
10718 */
10706 tp->write32 = tg3_write_flush_reg32; 10719 tp->write32 = tg3_write_flush_reg32;
10720 }
10721
10707 10722
10708 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) || 10723 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) ||
10709 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) { 10724 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) {
@@ -11892,10 +11907,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11892 tp->rx_pending = 63; 11907 tp->rx_pending = 63;
11893 } 11908 }
11894 11909
11895 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
11896 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
11897 tp->pdev_peer = tg3_find_peer(tp);
11898
11899 err = tg3_get_device_address(tp); 11910 err = tg3_get_device_address(tp);
11900 if (err) { 11911 if (err) {
11901 printk(KERN_ERR PFX "Could not obtain valid ethernet address, " 11912 printk(KERN_ERR PFX "Could not obtain valid ethernet address, "
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index d515ed23841b..dcdfc084966c 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -131,6 +131,7 @@
131#define CHIPREV_ID_5752_A0_HW 0x5000 131#define CHIPREV_ID_5752_A0_HW 0x5000
132#define CHIPREV_ID_5752_A0 0x6000 132#define CHIPREV_ID_5752_A0 0x6000
133#define CHIPREV_ID_5752_A1 0x6001 133#define CHIPREV_ID_5752_A1 0x6001
134#define CHIPREV_ID_5714_A2 0x9002
134#define CHIPREV_ID_5906_A1 0xc001 135#define CHIPREV_ID_5906_A1 0xc001
135#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12) 136#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
136#define ASIC_REV_5700 0x07 137#define ASIC_REV_5700 0x07
@@ -2199,7 +2200,6 @@ struct tg3 {
2199#define TG3_FLAG_USE_LINKCHG_REG 0x00000008 2200#define TG3_FLAG_USE_LINKCHG_REG 0x00000008
2200#define TG3_FLAG_USE_MI_INTERRUPT 0x00000010 2201#define TG3_FLAG_USE_MI_INTERRUPT 0x00000010
2201#define TG3_FLAG_ENABLE_ASF 0x00000020 2202#define TG3_FLAG_ENABLE_ASF 0x00000020
2202#define TG3_FLAG_5701_REG_WRITE_BUG 0x00000040
2203#define TG3_FLAG_POLL_SERDES 0x00000080 2203#define TG3_FLAG_POLL_SERDES 0x00000080
2204#define TG3_FLAG_MBOX_WRITE_REORDER 0x00000100 2204#define TG3_FLAG_MBOX_WRITE_REORDER 0x00000100
2205#define TG3_FLAG_PCIX_TARGET_HWBUG 0x00000200 2205#define TG3_FLAG_PCIX_TARGET_HWBUG 0x00000200
@@ -2215,14 +2215,14 @@ struct tg3 {
2215#define TG3_FLAG_PCI_32BIT 0x00080000 2215#define TG3_FLAG_PCI_32BIT 0x00080000
2216#define TG3_FLAG_SRAM_USE_CONFIG 0x00100000 2216#define TG3_FLAG_SRAM_USE_CONFIG 0x00100000
2217#define TG3_FLAG_TX_RECOVERY_PENDING 0x00200000 2217#define TG3_FLAG_TX_RECOVERY_PENDING 0x00200000
2218#define TG3_FLAG_SERDES_WOL_CAP 0x00400000 2218#define TG3_FLAG_WOL_CAP 0x00400000
2219#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000 2219#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000
2220#define TG3_FLAG_10_100_ONLY 0x01000000 2220#define TG3_FLAG_10_100_ONLY 0x01000000
2221#define TG3_FLAG_PAUSE_AUTONEG 0x02000000 2221#define TG3_FLAG_PAUSE_AUTONEG 0x02000000
2222#define TG3_FLAG_IN_RESET_TASK 0x04000000 2222#define TG3_FLAG_IN_RESET_TASK 0x04000000
2223#define TG3_FLAG_40BIT_DMA_BUG 0x08000000 2223#define TG3_FLAG_40BIT_DMA_BUG 0x08000000
2224#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000 2224#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000
2225#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000 2225#define TG3_FLAG_SUPPORT_MSI 0x20000000
2226#define TG3_FLAG_CHIP_RESETTING 0x40000000 2226#define TG3_FLAG_CHIP_RESETTING 0x40000000
2227#define TG3_FLAG_INIT_COMPLETE 0x80000000 2227#define TG3_FLAG_INIT_COMPLETE 0x80000000
2228 u32 tg3_flags2; 2228 u32 tg3_flags2;
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index ed274d6909d0..f8f4d74f01f1 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -23,7 +23,6 @@ static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n";
23#include <linux/mca.h> 23#include <linux/mca.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/pci.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/netdevice.h> 27#include <linux/netdevice.h>
29#include <linux/trdevice.h> 28#include <linux/trdevice.h>
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 9bbea5c8acf4..58d7e5d452fa 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -41,7 +41,6 @@
41#include <linux/time.h> 41#include <linux/time.h>
42#include <linux/errno.h> 42#include <linux/errno.h>
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/pci.h>
45#include <linux/mca-legacy.h> 44#include <linux/mca-legacy.h>
46#include <linux/delay.h> 45#include <linux/delay.h>
47#include <linux/netdevice.h> 46#include <linux/netdevice.h>
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index 942b839ccc5b..6c400ccd38b4 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -14,7 +14,6 @@
14 14
15*/ 15*/
16 16
17#include <linux/pci.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include "tulip.h" 18#include "tulip.h"
20 19
diff --git a/drivers/net/tulip/pnic.c b/drivers/net/tulip/pnic.c
index 85a521e0d052..be82a2effee3 100644
--- a/drivers/net/tulip/pnic.c
+++ b/drivers/net/tulip/pnic.c
@@ -15,7 +15,6 @@
15*/ 15*/
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/pci.h>
19#include <linux/jiffies.h> 18#include <linux/jiffies.h>
20#include "tulip.h" 19#include "tulip.h"
21 20
diff --git a/drivers/net/tulip/pnic2.c b/drivers/net/tulip/pnic2.c
index c31be0e377a8..4e4a879c3fa5 100644
--- a/drivers/net/tulip/pnic2.c
+++ b/drivers/net/tulip/pnic2.c
@@ -76,7 +76,6 @@
76 76
77 77
78 78
79#include <linux/pci.h>
80#include "tulip.h" 79#include "tulip.h"
81#include <linux/delay.h> 80#include <linux/delay.h>
82 81
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
index df326fe1cc8f..d2c1f42109b0 100644
--- a/drivers/net/tulip/timer.c
+++ b/drivers/net/tulip/timer.c
@@ -14,7 +14,6 @@
14 14
15*/ 15*/
16 16
17#include <linux/pci.h>
18#include "tulip.h" 17#include "tulip.h"
19 18
20 19
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index c840d2e67b23..16f26a8364f0 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -22,6 +22,7 @@
22#include <linux/netdevice.h> 22#include <linux/netdevice.h>
23#include <linux/timer.h> 23#include <linux/timer.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/pci.h>
25#include <asm/io.h> 26#include <asm/io.h>
26#include <asm/irq.h> 27#include <asm/irq.h>
27 28
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index ae01555d24cf..574737b55f39 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -8,7 +8,6 @@
8#include <linux/ioport.h> 8#include <linux/ioport.h>
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/pci.h>
12#include <linux/in.h> 11#include <linux/in.h>
13#include <linux/if_arp.h> 12#include <linux/if_arp.h>
14#include <linux/netdevice.h> 13#include <linux/netdevice.h>
diff --git a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c
index 74876c0073e8..31e1799571ad 100644
--- a/drivers/net/wan/lmc/lmc_proto.c
+++ b/drivers/net/wan/lmc/lmc_proto.c
@@ -27,7 +27,6 @@
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/pci.h>
31#include <linux/in.h> 30#include <linux/in.h>
32#include <linux/if_arp.h> 31#include <linux/if_arp.h>
33#include <linux/netdevice.h> 32#include <linux/netdevice.h>
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 07dbdfbfc15d..e24a7b095dd6 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -38,7 +38,6 @@
38 38
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/pci.h>
42#include <linux/errno.h> 41#include <linux/errno.h>
43#include <linux/string.h> 42#include <linux/string.h>
44#include <linux/init.h> 43#include <linux/init.h>
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 2a299a0676a6..ef32a5c1e818 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -1971,8 +1971,7 @@ static struct net_device *get_strip_dev(struct strip *strip_info)
1971 sizeof(zero_address))) { 1971 sizeof(zero_address))) {
1972 struct net_device *dev; 1972 struct net_device *dev;
1973 read_lock_bh(&dev_base_lock); 1973 read_lock_bh(&dev_base_lock);
1974 dev = dev_base; 1974 for_each_netdev(dev) {
1975 while (dev) {
1976 if (dev->type == strip_info->dev->type && 1975 if (dev->type == strip_info->dev->type &&
1977 !memcmp(dev->dev_addr, 1976 !memcmp(dev->dev_addr,
1978 &strip_info->true_dev_addr, 1977 &strip_info->true_dev_addr,
@@ -1983,7 +1982,6 @@ static struct net_device *get_strip_dev(struct strip *strip_info)
1983 read_unlock_bh(&dev_base_lock); 1982 read_unlock_bh(&dev_base_lock);
1984 return (dev); 1983 return (dev);
1985 } 1984 }
1986 dev = dev->next;
1987 } 1985 }
1988 read_unlock_bh(&dev_base_lock); 1986 read_unlock_bh(&dev_base_lock);
1989 } 1987 }
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index 9bb4db552f3c..a68b3b3761a2 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -22,8 +22,6 @@
22#include <asm/hardware.h> 22#include <asm/hardware.h>
23#include <asm/parisc-device.h> 23#include <asm/parisc-device.h>
24 24
25#include <linux/pci.h>
26
27struct hppb_card { 25struct hppb_card {
28 unsigned long hpa; 26 unsigned long hpa;
29 struct resource mmio_region; 27 struct resource mmio_region;
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index 3df82fe9ce8c..98be2880757d 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -365,7 +365,7 @@ static __inline__ int led_get_net_activity(void)
365 * for reading should be OK */ 365 * for reading should be OK */
366 read_lock(&dev_base_lock); 366 read_lock(&dev_base_lock);
367 rcu_read_lock(); 367 rcu_read_lock();
368 for (dev = dev_base; dev; dev = dev->next) { 368 for_each_netdev(dev) {
369 struct net_device_stats *stats; 369 struct net_device_stats *stats;
370 struct in_device *in_dev = __in_dev_get_rcu(dev); 370 struct in_device *in_dev = __in_dev_get_rcu(dev);
371 if (!in_dev || !in_dev->ifa_list) 371 if (!in_dev || !in_dev->ifa_list)
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index ea1b7a63598e..815e445c3125 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -520,17 +520,17 @@ static struct pdcspath_entry *pdcspath_entries[] = {
520 520
521/** 521/**
522 * pdcs_size_read - Stable Storage size output. 522 * pdcs_size_read - Stable Storage size output.
523 * @entry: An allocated and populated subsytem struct. We don't use it tho. 523 * @kset: An allocated and populated struct kset. We don't use it tho.
524 * @buf: The output buffer to write to. 524 * @buf: The output buffer to write to.
525 */ 525 */
526static ssize_t 526static ssize_t
527pdcs_size_read(struct subsystem *entry, char *buf) 527pdcs_size_read(struct kset *kset, char *buf)
528{ 528{
529 char *out = buf; 529 char *out = buf;
530 530
531 if (!entry || !buf) 531 if (!kset || !buf)
532 return -EINVAL; 532 return -EINVAL;
533 533
534 /* show the size of the stable storage */ 534 /* show the size of the stable storage */
535 out += sprintf(out, "%ld\n", pdcs_size); 535 out += sprintf(out, "%ld\n", pdcs_size);
536 536
@@ -539,17 +539,17 @@ pdcs_size_read(struct subsystem *entry, char *buf)
539 539
540/** 540/**
541 * pdcs_auto_read - Stable Storage autoboot/search flag output. 541 * pdcs_auto_read - Stable Storage autoboot/search flag output.
542 * @entry: An allocated and populated subsytem struct. We don't use it tho. 542 * @kset: An allocated and populated struct kset. We don't use it tho.
543 * @buf: The output buffer to write to. 543 * @buf: The output buffer to write to.
544 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag 544 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
545 */ 545 */
546static ssize_t 546static ssize_t
547pdcs_auto_read(struct subsystem *entry, char *buf, int knob) 547pdcs_auto_read(struct kset *kset, char *buf, int knob)
548{ 548{
549 char *out = buf; 549 char *out = buf;
550 struct pdcspath_entry *pathentry; 550 struct pdcspath_entry *pathentry;
551 551
552 if (!entry || !buf) 552 if (!kset || !buf)
553 return -EINVAL; 553 return -EINVAL;
554 554
555 /* Current flags are stored in primary boot path entry */ 555 /* Current flags are stored in primary boot path entry */
@@ -565,40 +565,40 @@ pdcs_auto_read(struct subsystem *entry, char *buf, int knob)
565 565
566/** 566/**
567 * pdcs_autoboot_read - Stable Storage autoboot flag output. 567 * pdcs_autoboot_read - Stable Storage autoboot flag output.
568 * @entry: An allocated and populated subsytem struct. We don't use it tho. 568 * @kset: An allocated and populated struct kset. We don't use it tho.
569 * @buf: The output buffer to write to. 569 * @buf: The output buffer to write to.
570 */ 570 */
571static inline ssize_t 571static inline ssize_t
572pdcs_autoboot_read(struct subsystem *entry, char *buf) 572pdcs_autoboot_read(struct kset *kset, char *buf)
573{ 573{
574 return pdcs_auto_read(entry, buf, PF_AUTOBOOT); 574 return pdcs_auto_read(kset, buf, PF_AUTOBOOT);
575} 575}
576 576
577/** 577/**
578 * pdcs_autosearch_read - Stable Storage autoboot flag output. 578 * pdcs_autosearch_read - Stable Storage autoboot flag output.
579 * @entry: An allocated and populated subsytem struct. We don't use it tho. 579 * @kset: An allocated and populated struct kset. We don't use it tho.
580 * @buf: The output buffer to write to. 580 * @buf: The output buffer to write to.
581 */ 581 */
582static inline ssize_t 582static inline ssize_t
583pdcs_autosearch_read(struct subsystem *entry, char *buf) 583pdcs_autosearch_read(struct kset *kset, char *buf)
584{ 584{
585 return pdcs_auto_read(entry, buf, PF_AUTOSEARCH); 585 return pdcs_auto_read(kset, buf, PF_AUTOSEARCH);
586} 586}
587 587
588/** 588/**
589 * pdcs_timer_read - Stable Storage timer count output (in seconds). 589 * pdcs_timer_read - Stable Storage timer count output (in seconds).
590 * @entry: An allocated and populated subsytem struct. We don't use it tho. 590 * @kset: An allocated and populated struct kset. We don't use it tho.
591 * @buf: The output buffer to write to. 591 * @buf: The output buffer to write to.
592 * 592 *
593 * The value of the timer field correponds to a number of seconds in powers of 2. 593 * The value of the timer field correponds to a number of seconds in powers of 2.
594 */ 594 */
595static ssize_t 595static ssize_t
596pdcs_timer_read(struct subsystem *entry, char *buf) 596pdcs_timer_read(struct kset *kset, char *buf)
597{ 597{
598 char *out = buf; 598 char *out = buf;
599 struct pdcspath_entry *pathentry; 599 struct pdcspath_entry *pathentry;
600 600
601 if (!entry || !buf) 601 if (!kset || !buf)
602 return -EINVAL; 602 return -EINVAL;
603 603
604 /* Current flags are stored in primary boot path entry */ 604 /* Current flags are stored in primary boot path entry */
@@ -615,15 +615,15 @@ pdcs_timer_read(struct subsystem *entry, char *buf)
615 615
616/** 616/**
617 * pdcs_osid_read - Stable Storage OS ID register output. 617 * pdcs_osid_read - Stable Storage OS ID register output.
618 * @entry: An allocated and populated subsytem struct. We don't use it tho. 618 * @kset: An allocated and populated struct kset. We don't use it tho.
619 * @buf: The output buffer to write to. 619 * @buf: The output buffer to write to.
620 */ 620 */
621static ssize_t 621static ssize_t
622pdcs_osid_read(struct subsystem *entry, char *buf) 622pdcs_osid_read(struct kset *kset, char *buf)
623{ 623{
624 char *out = buf; 624 char *out = buf;
625 625
626 if (!entry || !buf) 626 if (!kset || !buf)
627 return -EINVAL; 627 return -EINVAL;
628 628
629 out += sprintf(out, "%s dependent data (0x%.4x)\n", 629 out += sprintf(out, "%s dependent data (0x%.4x)\n",
@@ -634,18 +634,18 @@ pdcs_osid_read(struct subsystem *entry, char *buf)
634 634
635/** 635/**
636 * pdcs_osdep1_read - Stable Storage OS-Dependent data area 1 output. 636 * pdcs_osdep1_read - Stable Storage OS-Dependent data area 1 output.
637 * @entry: An allocated and populated subsytem struct. We don't use it tho. 637 * @kset: An allocated and populated struct kset. We don't use it tho.
638 * @buf: The output buffer to write to. 638 * @buf: The output buffer to write to.
639 * 639 *
640 * This can hold 16 bytes of OS-Dependent data. 640 * This can hold 16 bytes of OS-Dependent data.
641 */ 641 */
642static ssize_t 642static ssize_t
643pdcs_osdep1_read(struct subsystem *entry, char *buf) 643pdcs_osdep1_read(struct kset *kset, char *buf)
644{ 644{
645 char *out = buf; 645 char *out = buf;
646 u32 result[4]; 646 u32 result[4];
647 647
648 if (!entry || !buf) 648 if (!kset || !buf)
649 return -EINVAL; 649 return -EINVAL;
650 650
651 if (pdc_stable_read(PDCS_ADDR_OSD1, &result, sizeof(result)) != PDC_OK) 651 if (pdc_stable_read(PDCS_ADDR_OSD1, &result, sizeof(result)) != PDC_OK)
@@ -661,18 +661,18 @@ pdcs_osdep1_read(struct subsystem *entry, char *buf)
661 661
662/** 662/**
663 * pdcs_diagnostic_read - Stable Storage Diagnostic register output. 663 * pdcs_diagnostic_read - Stable Storage Diagnostic register output.
664 * @entry: An allocated and populated subsytem struct. We don't use it tho. 664 * @kset: An allocated and populated struct kset. We don't use it tho.
665 * @buf: The output buffer to write to. 665 * @buf: The output buffer to write to.
666 * 666 *
667 * I have NFC how to interpret the content of that register ;-). 667 * I have NFC how to interpret the content of that register ;-).
668 */ 668 */
669static ssize_t 669static ssize_t
670pdcs_diagnostic_read(struct subsystem *entry, char *buf) 670pdcs_diagnostic_read(struct kset *kset, char *buf)
671{ 671{
672 char *out = buf; 672 char *out = buf;
673 u32 result; 673 u32 result;
674 674
675 if (!entry || !buf) 675 if (!kset || !buf)
676 return -EINVAL; 676 return -EINVAL;
677 677
678 /* get diagnostic */ 678 /* get diagnostic */
@@ -686,18 +686,18 @@ pdcs_diagnostic_read(struct subsystem *entry, char *buf)
686 686
687/** 687/**
688 * pdcs_fastsize_read - Stable Storage FastSize register output. 688 * pdcs_fastsize_read - Stable Storage FastSize register output.
689 * @entry: An allocated and populated subsytem struct. We don't use it tho. 689 * @kset: An allocated and populated struct kset. We don't use it tho.
690 * @buf: The output buffer to write to. 690 * @buf: The output buffer to write to.
691 * 691 *
692 * This register holds the amount of system RAM to be tested during boot sequence. 692 * This register holds the amount of system RAM to be tested during boot sequence.
693 */ 693 */
694static ssize_t 694static ssize_t
695pdcs_fastsize_read(struct subsystem *entry, char *buf) 695pdcs_fastsize_read(struct kset *kset, char *buf)
696{ 696{
697 char *out = buf; 697 char *out = buf;
698 u32 result; 698 u32 result;
699 699
700 if (!entry || !buf) 700 if (!kset || !buf)
701 return -EINVAL; 701 return -EINVAL;
702 702
703 /* get fast-size */ 703 /* get fast-size */
@@ -715,13 +715,13 @@ pdcs_fastsize_read(struct subsystem *entry, char *buf)
715 715
716/** 716/**
717 * pdcs_osdep2_read - Stable Storage OS-Dependent data area 2 output. 717 * pdcs_osdep2_read - Stable Storage OS-Dependent data area 2 output.
718 * @entry: An allocated and populated subsytem struct. We don't use it tho. 718 * @kset: An allocated and populated struct kset. We don't use it tho.
719 * @buf: The output buffer to write to. 719 * @buf: The output buffer to write to.
720 * 720 *
721 * This can hold pdcs_size - 224 bytes of OS-Dependent data, when available. 721 * This can hold pdcs_size - 224 bytes of OS-Dependent data, when available.
722 */ 722 */
723static ssize_t 723static ssize_t
724pdcs_osdep2_read(struct subsystem *entry, char *buf) 724pdcs_osdep2_read(struct kset *kset, char *buf)
725{ 725{
726 char *out = buf; 726 char *out = buf;
727 unsigned long size; 727 unsigned long size;
@@ -733,7 +733,7 @@ pdcs_osdep2_read(struct subsystem *entry, char *buf)
733 733
734 size = pdcs_size - 224; 734 size = pdcs_size - 224;
735 735
736 if (!entry || !buf) 736 if (!kset || !buf)
737 return -EINVAL; 737 return -EINVAL;
738 738
739 for (i=0; i<size; i+=4) { 739 for (i=0; i<size; i+=4) {
@@ -748,7 +748,7 @@ pdcs_osdep2_read(struct subsystem *entry, char *buf)
748 748
749/** 749/**
750 * pdcs_auto_write - This function handles autoboot/search flag modifying. 750 * pdcs_auto_write - This function handles autoboot/search flag modifying.
751 * @entry: An allocated and populated subsytem struct. We don't use it tho. 751 * @kset: An allocated and populated struct kset. We don't use it tho.
752 * @buf: The input buffer to read from. 752 * @buf: The input buffer to read from.
753 * @count: The number of bytes to be read. 753 * @count: The number of bytes to be read.
754 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag 754 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
@@ -758,7 +758,7 @@ pdcs_osdep2_read(struct subsystem *entry, char *buf)
758 * \"n\" (n == 0 or 1) to toggle AutoBoot Off or On 758 * \"n\" (n == 0 or 1) to toggle AutoBoot Off or On
759 */ 759 */
760static ssize_t 760static ssize_t
761pdcs_auto_write(struct subsystem *entry, const char *buf, size_t count, int knob) 761pdcs_auto_write(struct kset *kset, const char *buf, size_t count, int knob)
762{ 762{
763 struct pdcspath_entry *pathentry; 763 struct pdcspath_entry *pathentry;
764 unsigned char flags; 764 unsigned char flags;
@@ -768,7 +768,7 @@ pdcs_auto_write(struct subsystem *entry, const char *buf, size_t count, int knob
768 if (!capable(CAP_SYS_ADMIN)) 768 if (!capable(CAP_SYS_ADMIN))
769 return -EACCES; 769 return -EACCES;
770 770
771 if (!entry || !buf || !count) 771 if (!kset || !buf || !count)
772 return -EINVAL; 772 return -EINVAL;
773 773
774 /* We'll use a local copy of buf */ 774 /* We'll use a local copy of buf */
@@ -823,7 +823,7 @@ parse_error:
823 823
824/** 824/**
825 * pdcs_autoboot_write - This function handles autoboot flag modifying. 825 * pdcs_autoboot_write - This function handles autoboot flag modifying.
826 * @entry: An allocated and populated subsytem struct. We don't use it tho. 826 * @kset: An allocated and populated struct kset. We don't use it tho.
827 * @buf: The input buffer to read from. 827 * @buf: The input buffer to read from.
828 * @count: The number of bytes to be read. 828 * @count: The number of bytes to be read.
829 * 829 *
@@ -832,14 +832,14 @@ parse_error:
832 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On 832 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
833 */ 833 */
834static inline ssize_t 834static inline ssize_t
835pdcs_autoboot_write(struct subsystem *entry, const char *buf, size_t count) 835pdcs_autoboot_write(struct kset *kset, const char *buf, size_t count)
836{ 836{
837 return pdcs_auto_write(entry, buf, count, PF_AUTOBOOT); 837 return pdcs_auto_write(kset, buf, count, PF_AUTOBOOT);
838} 838}
839 839
840/** 840/**
841 * pdcs_autosearch_write - This function handles autosearch flag modifying. 841 * pdcs_autosearch_write - This function handles autosearch flag modifying.
842 * @entry: An allocated and populated subsytem struct. We don't use it tho. 842 * @kset: An allocated and populated struct kset. We don't use it tho.
843 * @buf: The input buffer to read from. 843 * @buf: The input buffer to read from.
844 * @count: The number of bytes to be read. 844 * @count: The number of bytes to be read.
845 * 845 *
@@ -848,14 +848,14 @@ pdcs_autoboot_write(struct subsystem *entry, const char *buf, size_t count)
848 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On 848 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
849 */ 849 */
850static inline ssize_t 850static inline ssize_t
851pdcs_autosearch_write(struct subsystem *entry, const char *buf, size_t count) 851pdcs_autosearch_write(struct kset *kset, const char *buf, size_t count)
852{ 852{
853 return pdcs_auto_write(entry, buf, count, PF_AUTOSEARCH); 853 return pdcs_auto_write(kset, buf, count, PF_AUTOSEARCH);
854} 854}
855 855
856/** 856/**
857 * pdcs_osdep1_write - Stable Storage OS-Dependent data area 1 input. 857 * pdcs_osdep1_write - Stable Storage OS-Dependent data area 1 input.
858 * @entry: An allocated and populated subsytem struct. We don't use it tho. 858 * @kset: An allocated and populated struct kset. We don't use it tho.
859 * @buf: The input buffer to read from. 859 * @buf: The input buffer to read from.
860 * @count: The number of bytes to be read. 860 * @count: The number of bytes to be read.
861 * 861 *
@@ -864,14 +864,14 @@ pdcs_autosearch_write(struct subsystem *entry, const char *buf, size_t count)
864 * its input buffer. 864 * its input buffer.
865 */ 865 */
866static ssize_t 866static ssize_t
867pdcs_osdep1_write(struct subsystem *entry, const char *buf, size_t count) 867pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count)
868{ 868{
869 u8 in[16]; 869 u8 in[16];
870 870
871 if (!capable(CAP_SYS_ADMIN)) 871 if (!capable(CAP_SYS_ADMIN))
872 return -EACCES; 872 return -EACCES;
873 873
874 if (!entry || !buf || !count) 874 if (!kset || !buf || !count)
875 return -EINVAL; 875 return -EINVAL;
876 876
877 if (unlikely(pdcs_osid != OS_ID_LINUX)) 877 if (unlikely(pdcs_osid != OS_ID_LINUX))
@@ -892,7 +892,7 @@ pdcs_osdep1_write(struct subsystem *entry, const char *buf, size_t count)
892 892
893/** 893/**
894 * pdcs_osdep2_write - Stable Storage OS-Dependent data area 2 input. 894 * pdcs_osdep2_write - Stable Storage OS-Dependent data area 2 input.
895 * @entry: An allocated and populated subsytem struct. We don't use it tho. 895 * @kset: An allocated and populated struct kset. We don't use it tho.
896 * @buf: The input buffer to read from. 896 * @buf: The input buffer to read from.
897 * @count: The number of bytes to be read. 897 * @count: The number of bytes to be read.
898 * 898 *
@@ -901,7 +901,7 @@ pdcs_osdep1_write(struct subsystem *entry, const char *buf, size_t count)
901 * constructing its input buffer. 901 * constructing its input buffer.
902 */ 902 */
903static ssize_t 903static ssize_t
904pdcs_osdep2_write(struct subsystem *entry, const char *buf, size_t count) 904pdcs_osdep2_write(struct kset *kset, const char *buf, size_t count)
905{ 905{
906 unsigned long size; 906 unsigned long size;
907 unsigned short i; 907 unsigned short i;
@@ -910,7 +910,7 @@ pdcs_osdep2_write(struct subsystem *entry, const char *buf, size_t count)
910 if (!capable(CAP_SYS_ADMIN)) 910 if (!capable(CAP_SYS_ADMIN))
911 return -EACCES; 911 return -EACCES;
912 912
913 if (!entry || !buf || !count) 913 if (!kset || !buf || !count)
914 return -EINVAL; 914 return -EINVAL;
915 915
916 if (unlikely(pdcs_size <= 224)) 916 if (unlikely(pdcs_size <= 224))
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 5ea5bc70cb82..7a1d6d512837 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -1,10 +1,14 @@
1# 1#
2# PCI configuration 2# PCI configuration
3# 3#
4config ARCH_SUPPORTS_MSI
5 bool
6 default n
7
4config PCI_MSI 8config PCI_MSI
5 bool "Message Signaled Interrupts (MSI and MSI-X)" 9 bool "Message Signaled Interrupts (MSI and MSI-X)"
6 depends on PCI 10 depends on PCI
7 depends on (X86_LOCAL_APIC && X86_IO_APIC) || IA64 || SPARC64 11 depends on ARCH_SUPPORTS_MSI
8 help 12 help
9 This allows device drivers to enable MSI (Message Signaled 13 This allows device drivers to enable MSI (Message Signaled
10 Interrupts). Message Signaled Interrupts enable a device to 14 Interrupts). Message Signaled Interrupts enable a device to
@@ -17,31 +21,6 @@ config PCI_MSI
17 21
18 If you don't know what to do here, say N. 22 If you don't know what to do here, say N.
19 23
20config PCI_MULTITHREAD_PROBE
21 bool "PCI Multi-threaded probe (EXPERIMENTAL)"
22 depends on PCI && EXPERIMENTAL && BROKEN
23 help
24 Say Y here if you want the PCI core to spawn a new thread for
25 every PCI device that is probed. This can cause a huge
26 speedup in boot times on multiprocessor machines, and even a
27 smaller speedup on single processor machines.
28
29 But it can also cause lots of bad things to happen. A number
30 of PCI drivers cannot properly handle running in this way,
31 some will just not work properly at all, while others might
32 decide to blow up power supplies with a huge load all at once,
33 so use this option at your own risk.
34
35 It is very unwise to use this option if you are not using a
36 boot process that can handle devices being created in any
37 order. A program that can create persistent block and network
38 device names (like udev) is a good idea if you wish to use
39 this option.
40
41 Again, use this option at your own risk, you have been warned!
42
43 When in doubt, say N.
44
45config PCI_DEBUG 24config PCI_DEBUG
46 bool "PCI Debugging" 25 bool "PCI Debugging"
47 depends on PCI && DEBUG_KERNEL 26 depends on PCI && DEBUG_KERNEL
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index aadaa3c8096b..9e5ea074ad20 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -77,7 +77,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
77 * This adds a single pci device to the global 77 * This adds a single pci device to the global
78 * device list and adds sysfs and procfs entries 78 * device list and adds sysfs and procfs entries
79 */ 79 */
80int __devinit pci_bus_add_device(struct pci_dev *dev) 80int pci_bus_add_device(struct pci_dev *dev)
81{ 81{
82 int retval; 82 int retval;
83 retval = device_add(&dev->dev); 83 retval = device_add(&dev->dev);
@@ -105,7 +105,7 @@ int __devinit pci_bus_add_device(struct pci_dev *dev)
105 * 105 *
106 * Call hotplug for each new devices. 106 * Call hotplug for each new devices.
107 */ 107 */
108void __devinit pci_bus_add_devices(struct pci_bus *bus) 108void pci_bus_add_devices(struct pci_bus *bus)
109{ 109{
110 struct pci_dev *dev; 110 struct pci_dev *dev;
111 int retval; 111 int retval;
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index be92695a7833..63d62752fb91 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -2,9 +2,7 @@
2# PCI Hotplug support 2# PCI Hotplug support
3# 3#
4 4
5menu "PCI Hotplug Support" 5menuconfig HOTPLUG_PCI
6
7config HOTPLUG_PCI
8 tristate "Support for PCI Hotplug (EXPERIMENTAL)" 6 tristate "Support for PCI Hotplug (EXPERIMENTAL)"
9 depends on PCI && EXPERIMENTAL && HOTPLUG 7 depends on PCI && EXPERIMENTAL && HOTPLUG
10 ---help--- 8 ---help---
@@ -17,9 +15,10 @@ config HOTPLUG_PCI
17 15
18 When in doubt, say N. 16 When in doubt, say N.
19 17
18if HOTPLUG_PCI
19
20config HOTPLUG_PCI_FAKE 20config HOTPLUG_PCI_FAKE
21 tristate "Fake PCI Hotplug driver" 21 tristate "Fake PCI Hotplug driver"
22 depends on HOTPLUG_PCI
23 help 22 help
24 Say Y here if you want to use the fake PCI hotplug driver. It can 23 Say Y here if you want to use the fake PCI hotplug driver. It can
25 be used to simulate PCI hotplug events if even if your system is 24 be used to simulate PCI hotplug events if even if your system is
@@ -42,7 +41,7 @@ config HOTPLUG_PCI_FAKE
42 41
43config HOTPLUG_PCI_COMPAQ 42config HOTPLUG_PCI_COMPAQ
44 tristate "Compaq PCI Hotplug driver" 43 tristate "Compaq PCI Hotplug driver"
45 depends on HOTPLUG_PCI && X86 && PCI_BIOS 44 depends on X86 && PCI_BIOS
46 help 45 help
47 Say Y here if you have a motherboard with a Compaq PCI Hotplug 46 Say Y here if you have a motherboard with a Compaq PCI Hotplug
48 controller. 47 controller.
@@ -64,7 +63,7 @@ config HOTPLUG_PCI_COMPAQ_NVRAM
64 63
65config HOTPLUG_PCI_IBM 64config HOTPLUG_PCI_IBM
66 tristate "IBM PCI Hotplug driver" 65 tristate "IBM PCI Hotplug driver"
67 depends on HOTPLUG_PCI && X86_IO_APIC && X86 && PCI_BIOS 66 depends on X86_IO_APIC && X86 && PCI_BIOS
68 help 67 help
69 Say Y here if you have a motherboard with a IBM PCI Hotplug 68 Say Y here if you have a motherboard with a IBM PCI Hotplug
70 controller. 69 controller.
@@ -76,7 +75,6 @@ config HOTPLUG_PCI_IBM
76 75
77config HOTPLUG_PCI_ACPI 76config HOTPLUG_PCI_ACPI
78 tristate "ACPI PCI Hotplug driver" 77 tristate "ACPI PCI Hotplug driver"
79 depends on HOTPLUG_PCI
80 depends on (!ACPI_DOCK && ACPI) || (ACPI_DOCK) 78 depends on (!ACPI_DOCK && ACPI) || (ACPI_DOCK)
81 help 79 help
82 Say Y here if you have a system that supports PCI Hotplug using 80 Say Y here if you have a system that supports PCI Hotplug using
@@ -101,7 +99,6 @@ config HOTPLUG_PCI_ACPI_IBM
101 99
102config HOTPLUG_PCI_CPCI 100config HOTPLUG_PCI_CPCI
103 bool "CompactPCI Hotplug driver" 101 bool "CompactPCI Hotplug driver"
104 depends on HOTPLUG_PCI
105 help 102 help
106 Say Y here if you have a CompactPCI system card with CompactPCI 103 Say Y here if you have a CompactPCI system card with CompactPCI
107 hotswap support per the PICMG 2.1 specification. 104 hotswap support per the PICMG 2.1 specification.
@@ -110,7 +107,7 @@ config HOTPLUG_PCI_CPCI
110 107
111config HOTPLUG_PCI_CPCI_ZT5550 108config HOTPLUG_PCI_CPCI_ZT5550
112 tristate "Ziatech ZT5550 CompactPCI Hotplug driver" 109 tristate "Ziatech ZT5550 CompactPCI Hotplug driver"
113 depends on HOTPLUG_PCI && HOTPLUG_PCI_CPCI && X86 110 depends on HOTPLUG_PCI_CPCI && X86
114 help 111 help
115 Say Y here if you have an Performance Technologies (formerly Intel, 112 Say Y here if you have an Performance Technologies (formerly Intel,
116 formerly just Ziatech) Ziatech ZT5550 CompactPCI system card. 113 formerly just Ziatech) Ziatech ZT5550 CompactPCI system card.
@@ -122,7 +119,7 @@ config HOTPLUG_PCI_CPCI_ZT5550
122 119
123config HOTPLUG_PCI_CPCI_GENERIC 120config HOTPLUG_PCI_CPCI_GENERIC
124 tristate "Generic port I/O CompactPCI Hotplug driver" 121 tristate "Generic port I/O CompactPCI Hotplug driver"
125 depends on HOTPLUG_PCI && HOTPLUG_PCI_CPCI && X86 122 depends on HOTPLUG_PCI_CPCI && X86
126 help 123 help
127 Say Y here if you have a CompactPCI system card that exposes the #ENUM 124 Say Y here if you have a CompactPCI system card that exposes the #ENUM
128 hotswap signal as a bit in a system register that can be read through 125 hotswap signal as a bit in a system register that can be read through
@@ -135,7 +132,6 @@ config HOTPLUG_PCI_CPCI_GENERIC
135 132
136config HOTPLUG_PCI_SHPC 133config HOTPLUG_PCI_SHPC
137 tristate "SHPC PCI Hotplug driver" 134 tristate "SHPC PCI Hotplug driver"
138 depends on HOTPLUG_PCI
139 help 135 help
140 Say Y here if you have a motherboard with a SHPC PCI Hotplug 136 Say Y here if you have a motherboard with a SHPC PCI Hotplug
141 controller. 137 controller.
@@ -147,7 +143,7 @@ config HOTPLUG_PCI_SHPC
147 143
148config HOTPLUG_PCI_RPA 144config HOTPLUG_PCI_RPA
149 tristate "RPA PCI Hotplug driver" 145 tristate "RPA PCI Hotplug driver"
150 depends on HOTPLUG_PCI && PPC_PSERIES && PPC64 && !HOTPLUG_PCI_FAKE 146 depends on PPC_PSERIES && PPC64 && !HOTPLUG_PCI_FAKE
151 help 147 help
152 Say Y here if you have a RPA system that supports PCI Hotplug. 148 Say Y here if you have a RPA system that supports PCI Hotplug.
153 149
@@ -170,12 +166,11 @@ config HOTPLUG_PCI_RPA_DLPAR
170 166
171config HOTPLUG_PCI_SGI 167config HOTPLUG_PCI_SGI
172 tristate "SGI PCI Hotplug Support" 168 tristate "SGI PCI Hotplug Support"
173 depends on HOTPLUG_PCI && (IA64_SGI_SN2 || IA64_GENERIC) 169 depends on IA64_SGI_SN2 || IA64_GENERIC
174 help 170 help
175 Say Y here if you want to use the SGI Altix Hotplug 171 Say Y here if you want to use the SGI Altix Hotplug
176 Driver for PCI devices. 172 Driver for PCI devices.
177 173
178 When in doubt, say N. 174 When in doubt, say N.
179 175
180endmenu 176endif # HOTPLUG_PCI
181
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 7f03881a8b68..e7322c25d377 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -424,7 +424,7 @@ static int __init ibm_acpiphp_init(void)
424 int retval = 0; 424 int retval = 0;
425 acpi_status status; 425 acpi_status status;
426 struct acpi_device *device; 426 struct acpi_device *device;
427 struct kobject *sysdir = &pci_hotplug_slots_subsys.kset.kobj; 427 struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
428 428
429 dbg("%s\n", __FUNCTION__); 429 dbg("%s\n", __FUNCTION__);
430 430
@@ -471,7 +471,7 @@ init_return:
471static void __exit ibm_acpiphp_exit(void) 471static void __exit ibm_acpiphp_exit(void)
472{ 472{
473 acpi_status status; 473 acpi_status status;
474 struct kobject *sysdir = &pci_hotplug_slots_subsys.kset.kobj; 474 struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
475 475
476 dbg("%s\n", __FUNCTION__); 476 dbg("%s\n", __FUNCTION__);
477 477
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
index 1c12e9171097..41f6a8d79c81 100644
--- a/drivers/pci/hotplug/cpcihp_zt5550.c
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
@@ -296,13 +296,17 @@ static struct pci_driver zt5550_hc_driver = {
296static int __init zt5550_init(void) 296static int __init zt5550_init(void)
297{ 297{
298 struct resource* r; 298 struct resource* r;
299 int rc;
299 300
300 info(DRIVER_DESC " version: " DRIVER_VERSION); 301 info(DRIVER_DESC " version: " DRIVER_VERSION);
301 r = request_region(ENUM_PORT, 1, "#ENUM hotswap signal register"); 302 r = request_region(ENUM_PORT, 1, "#ENUM hotswap signal register");
302 if(!r) 303 if(!r)
303 return -EBUSY; 304 return -EBUSY;
304 305
305 return pci_register_driver(&zt5550_hc_driver); 306 rc = pci_register_driver(&zt5550_hc_driver);
307 if(rc < 0)
308 release_region(ENUM_PORT, 1);
309 return rc;
306} 310}
307 311
308static void __exit 312static void __exit
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index e27907c91d92..027f6865d7e3 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -238,7 +238,7 @@ static void pci_rescan_bus(const struct pci_bus *bus)
238{ 238{
239 unsigned int devfn; 239 unsigned int devfn;
240 struct pci_dev *dev; 240 struct pci_dev *dev;
241 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 241 dev = alloc_pci_dev();
242 if (!dev) 242 if (!dev)
243 return; 243 return;
244 244
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index f5d632e72323..63f3bd1eecc4 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -62,7 +62,7 @@ static int debug;
62 62
63static LIST_HEAD(pci_hotplug_slot_list); 63static LIST_HEAD(pci_hotplug_slot_list);
64 64
65struct subsystem pci_hotplug_slots_subsys; 65struct kset pci_hotplug_slots_subsys;
66 66
67static ssize_t hotplug_slot_attr_show(struct kobject *kobj, 67static ssize_t hotplug_slot_attr_show(struct kobject *kobj,
68 struct attribute *attr, char *buf) 68 struct attribute *attr, char *buf)
@@ -764,7 +764,7 @@ static int __init pci_hotplug_init (void)
764{ 764{
765 int result; 765 int result;
766 766
767 kset_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys); 767 kobj_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys);
768 result = subsystem_register(&pci_hotplug_slots_subsys); 768 result = subsystem_register(&pci_hotplug_slots_subsys);
769 if (result) { 769 if (result) {
770 err("Register subsys with error %d\n", result); 770 err("Register subsys with error %d\n", result);
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index d19fcae8a7c0..ccc57627201e 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -43,6 +43,7 @@ extern int pciehp_poll_mode;
43extern int pciehp_poll_time; 43extern int pciehp_poll_time;
44extern int pciehp_debug; 44extern int pciehp_debug;
45extern int pciehp_force; 45extern int pciehp_force;
46extern struct workqueue_struct *pciehp_wq;
46 47
47#define dbg(format, arg...) \ 48#define dbg(format, arg...) \
48 do { \ 49 do { \
@@ -70,14 +71,16 @@ struct slot {
70 struct list_head slot_list; 71 struct list_head slot_list;
71 char name[SLOT_NAME_SIZE]; 72 char name[SLOT_NAME_SIZE];
72 unsigned long last_emi_toggle; 73 unsigned long last_emi_toggle;
74 struct delayed_work work; /* work for button event */
75 struct mutex lock;
73}; 76};
74 77
75struct event_info { 78struct event_info {
76 u32 event_type; 79 u32 event_type;
77 u8 hp_slot; 80 struct slot *p_slot;
81 struct work_struct work;
78}; 82};
79 83
80#define MAX_EVENTS 10
81struct controller { 84struct controller {
82 struct controller *next; 85 struct controller *next;
83 struct mutex crit_sect; /* critical section mutex */ 86 struct mutex crit_sect; /* critical section mutex */
@@ -86,11 +89,9 @@ struct controller {
86 int slot_num_inc; /* 1 or -1 */ 89 int slot_num_inc; /* 1 or -1 */
87 struct pci_dev *pci_dev; 90 struct pci_dev *pci_dev;
88 struct list_head slot_list; 91 struct list_head slot_list;
89 struct event_info event_queue[MAX_EVENTS];
90 struct slot *slot; 92 struct slot *slot;
91 struct hpc_ops *hpc_ops; 93 struct hpc_ops *hpc_ops;
92 wait_queue_head_t queue; /* sleep & wake process */ 94 wait_queue_head_t queue; /* sleep & wake process */
93 u8 next_event;
94 u8 bus; 95 u8 bus;
95 u8 device; 96 u8 device;
96 u8 function; 97 u8 function;
@@ -149,21 +150,17 @@ struct controller {
149#define HP_SUPR_RM(cap) (cap & HP_SUPR_RM_SUP) 150#define HP_SUPR_RM(cap) (cap & HP_SUPR_RM_SUP)
150#define EMI(cap) (cap & EMI_PRSN) 151#define EMI(cap) (cap & EMI_PRSN)
151 152
152extern int pciehp_event_start_thread(void); 153extern int pciehp_sysfs_enable_slot(struct slot *slot);
153extern void pciehp_event_stop_thread(void); 154extern int pciehp_sysfs_disable_slot(struct slot *slot);
154extern int pciehp_enable_slot(struct slot *slot);
155extern int pciehp_disable_slot(struct slot *slot);
156extern u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl); 155extern u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl);
157extern u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl); 156extern u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl);
158extern u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl); 157extern u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl);
159extern u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl); 158extern u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
160extern int pciehp_configure_device(struct slot *p_slot); 159extern int pciehp_configure_device(struct slot *p_slot);
161extern int pciehp_unconfigure_device(struct slot *p_slot); 160extern int pciehp_unconfigure_device(struct slot *p_slot);
161extern void pciehp_queue_pushbutton_work(struct work_struct *work);
162int pcie_init(struct controller *ctrl, struct pcie_device *dev); 162int pcie_init(struct controller *ctrl, struct pcie_device *dev);
163 163
164/* Global variables */
165extern struct controller *pciehp_ctrl_list;
166
167static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) 164static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
168{ 165{
169 struct slot *slot; 166 struct slot *slot;
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index a92eda6e02f6..e5d3f0b4f45a 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -41,7 +41,7 @@ int pciehp_debug;
41int pciehp_poll_mode; 41int pciehp_poll_mode;
42int pciehp_poll_time; 42int pciehp_poll_time;
43int pciehp_force; 43int pciehp_force;
44struct controller *pciehp_ctrl_list; 44struct workqueue_struct *pciehp_wq;
45 45
46#define DRIVER_VERSION "0.4" 46#define DRIVER_VERSION "0.4"
47#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" 47#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -62,7 +62,6 @@ MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing"
62 62
63#define PCIE_MODULE_NAME "pciehp" 63#define PCIE_MODULE_NAME "pciehp"
64 64
65static int pcie_start_thread (void);
66static int set_attention_status (struct hotplug_slot *slot, u8 value); 65static int set_attention_status (struct hotplug_slot *slot, u8 value);
67static int enable_slot (struct hotplug_slot *slot); 66static int enable_slot (struct hotplug_slot *slot);
68static int disable_slot (struct hotplug_slot *slot); 67static int disable_slot (struct hotplug_slot *slot);
@@ -229,6 +228,8 @@ static int init_slots(struct controller *ctrl)
229 slot->device = ctrl->slot_device_offset + i; 228 slot->device = ctrl->slot_device_offset + i;
230 slot->hpc_ops = ctrl->hpc_ops; 229 slot->hpc_ops = ctrl->hpc_ops;
231 slot->number = ctrl->first_slot; 230 slot->number = ctrl->first_slot;
231 mutex_init(&slot->lock);
232 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
232 233
233 /* register this slot with the hotplug pci core */ 234 /* register this slot with the hotplug pci core */
234 hotplug_slot->private = slot; 235 hotplug_slot->private = slot;
@@ -286,6 +287,9 @@ static void cleanup_slots(struct controller *ctrl)
286 if (EMI(ctrl->ctrlcap)) 287 if (EMI(ctrl->ctrlcap))
287 sysfs_remove_file(&slot->hotplug_slot->kobj, 288 sysfs_remove_file(&slot->hotplug_slot->kobj,
288 &hotplug_slot_attr_lock.attr); 289 &hotplug_slot_attr_lock.attr);
290 cancel_delayed_work(&slot->work);
291 flush_scheduled_work();
292 flush_workqueue(pciehp_wq);
289 pci_hp_deregister(slot->hotplug_slot); 293 pci_hp_deregister(slot->hotplug_slot);
290 } 294 }
291} 295}
@@ -314,7 +318,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
314 318
315 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 319 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
316 320
317 return pciehp_enable_slot(slot); 321 return pciehp_sysfs_enable_slot(slot);
318} 322}
319 323
320 324
@@ -324,7 +328,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
324 328
325 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 329 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
326 330
327 return pciehp_disable_slot(slot); 331 return pciehp_sysfs_disable_slot(slot);
328} 332}
329 333
330static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) 334static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
@@ -466,17 +470,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
466 470
467 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 471 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
468 472
469 /* Finish setting up the hot plug ctrl device */
470 ctrl->next_event = 0;
471
472 if (!pciehp_ctrl_list) {
473 pciehp_ctrl_list = ctrl;
474 ctrl->next = NULL;
475 } else {
476 ctrl->next = pciehp_ctrl_list;
477 pciehp_ctrl_list = ctrl;
478 }
479
480 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 473 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
481 if ((POWER_CTRL(ctrl->ctrlcap)) && !value) { 474 if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
482 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ 475 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
@@ -496,48 +489,14 @@ err_out_none:
496 return -ENODEV; 489 return -ENODEV;
497} 490}
498 491
499 492static void pciehp_remove (struct pcie_device *dev)
500static int pcie_start_thread(void)
501{ 493{
502 int retval = 0; 494 struct pci_dev *pdev = dev->port;
503 495 struct controller *ctrl = pci_get_drvdata(pdev);
504 dbg("Initialize + Start the notification/polling mechanism \n");
505
506 retval = pciehp_event_start_thread();
507 if (retval) {
508 dbg("pciehp_event_start_thread() failed\n");
509 return retval;
510 }
511
512 return retval;
513}
514
515static void __exit unload_pciehpd(void)
516{
517 struct controller *ctrl;
518 struct controller *tctrl;
519
520 ctrl = pciehp_ctrl_list;
521
522 while (ctrl) {
523 cleanup_slots(ctrl);
524 496
525 ctrl->hpc_ops->release_ctlr(ctrl); 497 cleanup_slots(ctrl);
526 498 ctrl->hpc_ops->release_ctlr(ctrl);
527 tctrl = ctrl; 499 kfree(ctrl);
528 ctrl = ctrl->next;
529
530 kfree(tctrl);
531 }
532
533 /* Stop the notification mechanism */
534 pciehp_event_stop_thread();
535
536}
537
538static void pciehp_remove (struct pcie_device *device)
539{
540 /* XXX - Needs to be adapted to device driver model */
541} 500}
542 501
543#ifdef CONFIG_PM 502#ifdef CONFIG_PM
@@ -585,31 +544,18 @@ static int __init pcied_init(void)
585 pciehp_poll_mode = 1; 544 pciehp_poll_mode = 1;
586#endif 545#endif
587 546
588 retval = pcie_start_thread();
589 if (retval)
590 goto error_hpc_init;
591
592 retval = pcie_port_service_register(&hpdriver_portdrv); 547 retval = pcie_port_service_register(&hpdriver_portdrv);
593 dbg("pcie_port_service_register = %d\n", retval); 548 dbg("pcie_port_service_register = %d\n", retval);
594 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 549 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
595 if (retval) 550 if (retval)
596 dbg("%s: Failure to register service\n", __FUNCTION__); 551 dbg("%s: Failure to register service\n", __FUNCTION__);
597
598error_hpc_init:
599 if (retval) {
600 pciehp_event_stop_thread();
601 };
602
603 return retval; 552 return retval;
604} 553}
605 554
606static void __exit pcied_cleanup(void) 555static void __exit pcied_cleanup(void)
607{ 556{
608 dbg("unload_pciehpd()\n"); 557 dbg("unload_pciehpd()\n");
609 unload_pciehpd();
610
611 pcie_port_service_unregister(&hpdriver_portdrv); 558 pcie_port_service_unregister(&hpdriver_portdrv);
612
613 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); 559 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
614} 560}
615 561
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 4283ef56dbd9..7f22caa70178 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -32,92 +32,61 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/workqueue.h>
35#include "../pci.h" 36#include "../pci.h"
36#include "pciehp.h" 37#include "pciehp.h"
37 38
38static void interrupt_event_handler(struct controller *ctrl); 39static void interrupt_event_handler(struct work_struct *work);
40static int pciehp_enable_slot(struct slot *p_slot);
41static int pciehp_disable_slot(struct slot *p_slot);
39 42
40static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ 43static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
41static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */
42static int event_finished;
43static unsigned long pushbutton_pending; /* = 0 */
44static unsigned long surprise_rm_pending; /* = 0 */
45
46static inline char *slot_name(struct slot *p_slot)
47{ 44{
48 return p_slot->hotplug_slot->name; 45 struct event_info *info;
46
47 info = kmalloc(sizeof(*info), GFP_ATOMIC);
48 if (!info)
49 return -ENOMEM;
50
51 info->event_type = event_type;
52 info->p_slot = p_slot;
53 INIT_WORK(&info->work, interrupt_event_handler);
54
55 schedule_work(&info->work);
56
57 return 0;
49} 58}
50 59
51u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl) 60u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl)
52{ 61{
53 struct slot *p_slot; 62 struct slot *p_slot;
54 u8 rc = 0; 63 u32 event_type;
55 u8 getstatus;
56 struct event_info *taskInfo;
57 64
58 /* Attention Button Change */ 65 /* Attention Button Change */
59 dbg("pciehp: Attention button interrupt received.\n"); 66 dbg("pciehp: Attention button interrupt received.\n");
60
61 /* This is the structure that tells the worker thread what to do */
62 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
63 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
64
65 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
66
67 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
68 taskInfo->hp_slot = hp_slot;
69 67
70 rc++; 68 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
71 69
72 /* 70 /*
73 * Button pressed - See if need to TAKE ACTION!!! 71 * Button pressed - See if need to TAKE ACTION!!!
74 */ 72 */
75 info("Button pressed on Slot(%s)\n", slot_name(p_slot)); 73 info("Button pressed on Slot(%s)\n", p_slot->name);
76 taskInfo->event_type = INT_BUTTON_PRESS; 74 event_type = INT_BUTTON_PRESS;
77
78 if ((p_slot->state == BLINKINGON_STATE)
79 || (p_slot->state == BLINKINGOFF_STATE)) {
80 /* Cancel if we are still blinking; this means that we press the
81 * attention again before the 5 sec. limit expires to cancel hot-add
82 * or hot-remove
83 */
84 taskInfo->event_type = INT_BUTTON_CANCEL;
85 info("Button cancel on Slot(%s)\n", slot_name(p_slot));
86 } else if ((p_slot->state == POWERON_STATE)
87 || (p_slot->state == POWEROFF_STATE)) {
88 /* Ignore if the slot is on power-on or power-off state; this
89 * means that the previous attention button action to hot-add or
90 * hot-remove is undergoing
91 */
92 taskInfo->event_type = INT_BUTTON_IGNORE;
93 info("Button ignore on Slot(%s)\n", slot_name(p_slot));
94 }
95 75
96 if (rc) 76 queue_interrupt_event(p_slot, event_type);
97 up(&event_semaphore); /* signal event thread that new event is posted */
98 77
99 return 0; 78 return 0;
100
101} 79}
102 80
103u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl) 81u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
104{ 82{
105 struct slot *p_slot; 83 struct slot *p_slot;
106 u8 rc = 0;
107 u8 getstatus; 84 u8 getstatus;
108 struct event_info *taskInfo; 85 u32 event_type;
109 86
110 /* Switch Change */ 87 /* Switch Change */
111 dbg("pciehp: Switch interrupt received.\n"); 88 dbg("pciehp: Switch interrupt received.\n");
112 89
113 /* This is the structure that tells the worker thread
114 * what to do
115 */
116 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
117 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
118 taskInfo->hp_slot = hp_slot;
119
120 rc++;
121 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 90 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
122 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 91 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
123 92
@@ -125,39 +94,30 @@ u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
125 /* 94 /*
126 * Switch opened 95 * Switch opened
127 */ 96 */
128 info("Latch open on Slot(%s)\n", slot_name(p_slot)); 97 info("Latch open on Slot(%s)\n", p_slot->name);
129 taskInfo->event_type = INT_SWITCH_OPEN; 98 event_type = INT_SWITCH_OPEN;
130 } else { 99 } else {
131 /* 100 /*
132 * Switch closed 101 * Switch closed
133 */ 102 */
134 info("Latch close on Slot(%s)\n", slot_name(p_slot)); 103 info("Latch close on Slot(%s)\n", p_slot->name);
135 taskInfo->event_type = INT_SWITCH_CLOSE; 104 event_type = INT_SWITCH_CLOSE;
136 } 105 }
137 106
138 if (rc) 107 queue_interrupt_event(p_slot, event_type);
139 up(&event_semaphore); /* signal event thread that new event is posted */
140 108
141 return rc; 109 return 1;
142} 110}
143 111
144u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl) 112u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
145{ 113{
146 struct slot *p_slot; 114 struct slot *p_slot;
147 u8 presence_save, rc = 0; 115 u32 event_type;
148 struct event_info *taskInfo; 116 u8 presence_save;
149 117
150 /* Presence Change */ 118 /* Presence Change */
151 dbg("pciehp: Presence/Notify input change.\n"); 119 dbg("pciehp: Presence/Notify input change.\n");
152 120
153 /* This is the structure that tells the worker thread
154 * what to do
155 */
156 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
157 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
158 taskInfo->hp_slot = hp_slot;
159
160 rc++;
161 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 121 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
162 122
163 /* Switch is open, assume a presence change 123 /* Switch is open, assume a presence change
@@ -168,59 +128,49 @@ u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
168 /* 128 /*
169 * Card Present 129 * Card Present
170 */ 130 */
171 info("Card present on Slot(%s)\n", slot_name(p_slot)); 131 info("Card present on Slot(%s)\n", p_slot->name);
172 taskInfo->event_type = INT_PRESENCE_ON; 132 event_type = INT_PRESENCE_ON;
173 } else { 133 } else {
174 /* 134 /*
175 * Not Present 135 * Not Present
176 */ 136 */
177 info("Card not present on Slot(%s)\n", slot_name(p_slot)); 137 info("Card not present on Slot(%s)\n", p_slot->name);
178 taskInfo->event_type = INT_PRESENCE_OFF; 138 event_type = INT_PRESENCE_OFF;
179 } 139 }
180 140
181 if (rc) 141 queue_interrupt_event(p_slot, event_type);
182 up(&event_semaphore); /* signal event thread that new event is posted */
183 142
184 return rc; 143 return 1;
185} 144}
186 145
187u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl) 146u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl)
188{ 147{
189 struct slot *p_slot; 148 struct slot *p_slot;
190 u8 rc = 0; 149 u32 event_type;
191 struct event_info *taskInfo;
192 150
193 /* power fault */ 151 /* power fault */
194 dbg("pciehp: Power fault interrupt received.\n"); 152 dbg("pciehp: Power fault interrupt received.\n");
195 153
196 /* this is the structure that tells the worker thread
197 * what to do
198 */
199 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
200 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
201 taskInfo->hp_slot = hp_slot;
202
203 rc++;
204 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 154 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
205 155
206 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { 156 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
207 /* 157 /*
208 * power fault Cleared 158 * power fault Cleared
209 */ 159 */
210 info("Power fault cleared on Slot(%s)\n", slot_name(p_slot)); 160 info("Power fault cleared on Slot(%s)\n", p_slot->name);
211 taskInfo->event_type = INT_POWER_FAULT_CLEAR; 161 event_type = INT_POWER_FAULT_CLEAR;
212 } else { 162 } else {
213 /* 163 /*
214 * power fault 164 * power fault
215 */ 165 */
216 info("Power fault on Slot(%s)\n", slot_name(p_slot)); 166 info("Power fault on Slot(%s)\n", p_slot->name);
217 taskInfo->event_type = INT_POWER_FAULT; 167 event_type = INT_POWER_FAULT;
218 info("power fault bit %x set\n", hp_slot); 168 info("power fault bit %x set\n", hp_slot);
219 } 169 }
220 if (rc)
221 up(&event_semaphore); /* signal event thread that new event is posted */
222 170
223 return rc; 171 queue_interrupt_event(p_slot, event_type);
172
173 return 1;
224} 174}
225 175
226/* The following routines constitute the bulk of the 176/* The following routines constitute the bulk of the
@@ -357,13 +307,10 @@ static int remove_board(struct slot *p_slot)
357 return 0; 307 return 0;
358} 308}
359 309
360 310struct power_work_info {
361static void pushbutton_helper_thread(unsigned long data) 311 struct slot *p_slot;
362{ 312 struct work_struct work;
363 pushbutton_pending = data; 313};
364
365 up(&event_semaphore);
366}
367 314
368/** 315/**
369 * pciehp_pushbutton_thread 316 * pciehp_pushbutton_thread
@@ -372,276 +319,214 @@ static void pushbutton_helper_thread(unsigned long data)
372 * Handles all pending events and exits. 319 * Handles all pending events and exits.
373 * 320 *
374 */ 321 */
375static void pciehp_pushbutton_thread(unsigned long slot) 322static void pciehp_power_thread(struct work_struct *work)
376{ 323{
377 struct slot *p_slot = (struct slot *) slot; 324 struct power_work_info *info =
378 u8 getstatus; 325 container_of(work, struct power_work_info, work);
379 326 struct slot *p_slot = info->p_slot;
380 pushbutton_pending = 0; 327
381 328 mutex_lock(&p_slot->lock);
382 if (!p_slot) { 329 switch (p_slot->state) {
383 dbg("%s: Error! slot NULL\n", __FUNCTION__); 330 case POWEROFF_STATE:
384 return; 331 mutex_unlock(&p_slot->lock);
385 } 332 dbg("%s: disabling bus:device(%x:%x)\n",
386 333 __FUNCTION__, p_slot->bus, p_slot->device);
387 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
388 if (getstatus) {
389 p_slot->state = POWEROFF_STATE;
390 dbg("%s: disabling bus:device(%x:%x)\n", __FUNCTION__,
391 p_slot->bus, p_slot->device);
392
393 pciehp_disable_slot(p_slot); 334 pciehp_disable_slot(p_slot);
335 mutex_lock(&p_slot->lock);
394 p_slot->state = STATIC_STATE; 336 p_slot->state = STATIC_STATE;
395 } else { 337 break;
396 p_slot->state = POWERON_STATE; 338 case POWERON_STATE:
397 dbg("%s: adding bus:device(%x:%x)\n", __FUNCTION__, 339 mutex_unlock(&p_slot->lock);
398 p_slot->bus, p_slot->device);
399
400 if (pciehp_enable_slot(p_slot) && 340 if (pciehp_enable_slot(p_slot) &&
401 PWR_LED(p_slot->ctrl->ctrlcap)) 341 PWR_LED(p_slot->ctrl->ctrlcap))
402 p_slot->hpc_ops->green_led_off(p_slot); 342 p_slot->hpc_ops->green_led_off(p_slot);
403 343 mutex_lock(&p_slot->lock);
404 p_slot->state = STATIC_STATE; 344 p_slot->state = STATIC_STATE;
345 break;
346 default:
347 break;
405 } 348 }
349 mutex_unlock(&p_slot->lock);
406 350
407 return; 351 kfree(info);
408} 352}
409 353
410/** 354void pciehp_queue_pushbutton_work(struct work_struct *work)
411 * pciehp_surprise_rm_thread
412 *
413 * Scheduled procedure to handle blocking stuff for the surprise removal
414 * Handles all pending events and exits.
415 *
416 */
417static void pciehp_surprise_rm_thread(unsigned long slot)
418{ 355{
419 struct slot *p_slot = (struct slot *) slot; 356 struct slot *p_slot = container_of(work, struct slot, work.work);
420 u8 getstatus; 357 struct power_work_info *info;
421
422 surprise_rm_pending = 0;
423 358
424 if (!p_slot) { 359 info = kmalloc(sizeof(*info), GFP_KERNEL);
425 dbg("%s: Error! slot NULL\n", __FUNCTION__); 360 if (!info) {
361 err("%s: Cannot allocate memory\n", __FUNCTION__);
426 return; 362 return;
427 } 363 }
364 info->p_slot = p_slot;
365 INIT_WORK(&info->work, pciehp_power_thread);
428 366
429 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 367 mutex_lock(&p_slot->lock);
430 if (!getstatus) { 368 switch (p_slot->state) {
369 case BLINKINGOFF_STATE:
431 p_slot->state = POWEROFF_STATE; 370 p_slot->state = POWEROFF_STATE;
432 dbg("%s: removing bus:device(%x:%x)\n", 371 break;
433 __FUNCTION__, p_slot->bus, p_slot->device); 372 case BLINKINGON_STATE:
434
435 pciehp_disable_slot(p_slot);
436 p_slot->state = STATIC_STATE;
437 } else {
438 p_slot->state = POWERON_STATE; 373 p_slot->state = POWERON_STATE;
439 dbg("%s: adding bus:device(%x:%x)\n", 374 break;
440 __FUNCTION__, p_slot->bus, p_slot->device); 375 default:
441 376 goto out;
442 if (pciehp_enable_slot(p_slot) &&
443 PWR_LED(p_slot->ctrl->ctrlcap))
444 p_slot->hpc_ops->green_led_off(p_slot);
445
446 p_slot->state = STATIC_STATE;
447 } 377 }
448 378 queue_work(pciehp_wq, &info->work);
449 return; 379 out:
380 mutex_unlock(&p_slot->lock);
450} 381}
451 382
452
453
454/* this is the main worker thread */
455static int event_thread(void* data)
456{
457 struct controller *ctrl;
458 lock_kernel();
459 daemonize("pciehpd_event");
460
461 unlock_kernel();
462
463 while (1) {
464 dbg("!!!!event_thread sleeping\n");
465 down_interruptible (&event_semaphore);
466 dbg("event_thread woken finished = %d\n", event_finished);
467 if (event_finished || signal_pending(current))
468 break;
469 /* Do stuff here */
470 if (pushbutton_pending)
471 pciehp_pushbutton_thread(pushbutton_pending);
472 else if (surprise_rm_pending)
473 pciehp_surprise_rm_thread(surprise_rm_pending);
474 else
475 for (ctrl = pciehp_ctrl_list; ctrl; ctrl=ctrl->next)
476 interrupt_event_handler(ctrl);
477 }
478 dbg("event_thread signals exit\n");
479 up(&event_exit);
480 return 0;
481}
482
483int pciehp_event_start_thread(void)
484{
485 int pid;
486
487 /* initialize our semaphores */
488 init_MUTEX_LOCKED(&event_exit);
489 event_finished=0;
490
491 init_MUTEX_LOCKED(&event_semaphore);
492 pid = kernel_thread(event_thread, NULL, 0);
493
494 if (pid < 0) {
495 err ("Can't start up our event thread\n");
496 return -1;
497 }
498 return 0;
499}
500
501
502void pciehp_event_stop_thread(void)
503{
504 event_finished = 1;
505 up(&event_semaphore);
506 down(&event_exit);
507}
508
509
510static int update_slot_info(struct slot *slot) 383static int update_slot_info(struct slot *slot)
511{ 384{
512 struct hotplug_slot_info *info; 385 struct hotplug_slot_info *info;
513 /* char buffer[SLOT_NAME_SIZE]; */
514 int result; 386 int result;
515 387
516 info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); 388 info = kmalloc(sizeof(*info), GFP_KERNEL);
517 if (!info) 389 if (!info)
518 return -ENOMEM; 390 return -ENOMEM;
519 391
520 /* make_slot_name (&buffer[0], SLOT_NAME_SIZE, slot); */
521
522 slot->hpc_ops->get_power_status(slot, &(info->power_status)); 392 slot->hpc_ops->get_power_status(slot, &(info->power_status));
523 slot->hpc_ops->get_attention_status(slot, &(info->attention_status)); 393 slot->hpc_ops->get_attention_status(slot, &(info->attention_status));
524 slot->hpc_ops->get_latch_status(slot, &(info->latch_status)); 394 slot->hpc_ops->get_latch_status(slot, &(info->latch_status));
525 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status)); 395 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status));
526 396
527 /* result = pci_hp_change_slot_info(buffer, info); */
528 result = pci_hp_change_slot_info(slot->hotplug_slot, info); 397 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
529 kfree (info); 398 kfree (info);
530 return result; 399 return result;
531} 400}
532 401
533static void interrupt_event_handler(struct controller *ctrl) 402/*
403 * Note: This function must be called with slot->lock held
404 */
405static void handle_button_press_event(struct slot *p_slot)
534{ 406{
535 int loop = 0; 407 struct controller *ctrl = p_slot->ctrl;
536 int change = 1;
537 u8 hp_slot;
538 u8 getstatus; 408 u8 getstatus;
539 struct slot *p_slot;
540 409
541 while (change) { 410 switch (p_slot->state) {
542 change = 0; 411 case STATIC_STATE:
543 412 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
544 for (loop = 0; loop < MAX_EVENTS; loop++) { 413 if (getstatus) {
545 if (ctrl->event_queue[loop].event_type != 0) { 414 p_slot->state = BLINKINGOFF_STATE;
546 hp_slot = ctrl->event_queue[loop].hp_slot; 415 info("PCI slot #%s - powering off due to button "
547 416 "press.\n", p_slot->name);
548 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 417 } else {
549 418 p_slot->state = BLINKINGON_STATE;
550 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) { 419 info("PCI slot #%s - powering on due to button "
551 dbg("button cancel\n"); 420 "press.\n", p_slot->name);
552 del_timer(&p_slot->task_event); 421 }
553 422 /* blink green LED and turn off amber */
554 switch (p_slot->state) { 423 if (PWR_LED(ctrl->ctrlcap))
555 case BLINKINGOFF_STATE: 424 p_slot->hpc_ops->green_led_blink(p_slot);
556 if (PWR_LED(ctrl->ctrlcap)) 425 if (ATTN_LED(ctrl->ctrlcap))
557 p_slot->hpc_ops->green_led_on(p_slot); 426 p_slot->hpc_ops->set_attention_status(p_slot, 0);
558 427
559 if (ATTN_LED(ctrl->ctrlcap)) 428 schedule_delayed_work(&p_slot->work, 5*HZ);
560 p_slot->hpc_ops->set_attention_status(p_slot, 0); 429 break;
561 break; 430 case BLINKINGOFF_STATE:
562 case BLINKINGON_STATE: 431 case BLINKINGON_STATE:
563 if (PWR_LED(ctrl->ctrlcap)) 432 /*
564 p_slot->hpc_ops->green_led_off(p_slot); 433 * Cancel if we are still blinking; this means that we
565 434 * press the attention again before the 5 sec. limit
566 if (ATTN_LED(ctrl->ctrlcap)) 435 * expires to cancel hot-add or hot-remove
567 p_slot->hpc_ops->set_attention_status(p_slot, 0); 436 */
568 break; 437 info("Button cancel on Slot(%s)\n", p_slot->name);
569 default: 438 dbg("%s: button cancel\n", __FUNCTION__);
570 warn("Not a valid state\n"); 439 cancel_delayed_work(&p_slot->work);
571 return; 440 if (p_slot->state == BLINKINGOFF_STATE) {
572 } 441 if (PWR_LED(ctrl->ctrlcap))
573 info("PCI slot #%s - action canceled due to button press.\n", slot_name(p_slot)); 442 p_slot->hpc_ops->green_led_on(p_slot);
574 p_slot->state = STATIC_STATE; 443 } else {
575 } 444 if (PWR_LED(ctrl->ctrlcap))
576 /* ***********Button Pressed (No action on 1st press...) */ 445 p_slot->hpc_ops->green_led_off(p_slot);
577 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) { 446 }
578 447 if (ATTN_LED(ctrl->ctrlcap))
579 if (ATTN_BUTTN(ctrl->ctrlcap)) { 448 p_slot->hpc_ops->set_attention_status(p_slot, 0);
580 dbg("Button pressed\n"); 449 info("PCI slot #%s - action canceled due to button press\n",
581 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 450 p_slot->name);
582 if (getstatus) { 451 p_slot->state = STATIC_STATE;
583 /* slot is on */ 452 break;
584 dbg("slot is on\n"); 453 case POWEROFF_STATE:
585 p_slot->state = BLINKINGOFF_STATE; 454 case POWERON_STATE:
586 info("PCI slot #%s - powering off due to button press.\n", slot_name(p_slot)); 455 /*
587 } else { 456 * Ignore if the slot is on power-on or power-off state;
588 /* slot is off */ 457 * this means that the previous attention button action
589 dbg("slot is off\n"); 458 * to hot-add or hot-remove is undergoing
590 p_slot->state = BLINKINGON_STATE; 459 */
591 info("PCI slot #%s - powering on due to button press.\n", slot_name(p_slot)); 460 info("Button ignore on Slot(%s)\n", p_slot->name);
592 } 461 update_slot_info(p_slot);
593 462 break;
594 /* blink green LED and turn off amber */ 463 default:
595 if (PWR_LED(ctrl->ctrlcap)) 464 warn("Not a valid state\n");
596 p_slot->hpc_ops->green_led_blink(p_slot); 465 break;
597
598 if (ATTN_LED(ctrl->ctrlcap))
599 p_slot->hpc_ops->set_attention_status(p_slot, 0);
600
601 init_timer(&p_slot->task_event);
602 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
603 p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
604 p_slot->task_event.data = (unsigned long) p_slot;
605
606 add_timer(&p_slot->task_event);
607 }
608 }
609 /***********POWER FAULT********************/
610 else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
611 if (POWER_CTRL(ctrl->ctrlcap)) {
612 dbg("power fault\n");
613 if (ATTN_LED(ctrl->ctrlcap))
614 p_slot->hpc_ops->set_attention_status(p_slot, 1);
615
616 if (PWR_LED(ctrl->ctrlcap))
617 p_slot->hpc_ops->green_led_off(p_slot);
618 }
619 }
620 /***********SURPRISE REMOVAL********************/
621 else if ((ctrl->event_queue[loop].event_type == INT_PRESENCE_ON) ||
622 (ctrl->event_queue[loop].event_type == INT_PRESENCE_OFF)) {
623 if (HP_SUPR_RM(ctrl->ctrlcap)) {
624 dbg("Surprise Removal\n");
625 if (p_slot) {
626 surprise_rm_pending = (unsigned long) p_slot;
627 up(&event_semaphore);
628 update_slot_info(p_slot);
629 }
630 }
631 } else {
632 /* refresh notification */
633 if (p_slot)
634 update_slot_info(p_slot);
635 }
636
637 ctrl->event_queue[loop].event_type = 0;
638
639 change = 1;
640 }
641 } /* End of FOR loop */
642 } 466 }
643} 467}
644 468
469/*
470 * Note: This function must be called with slot->lock held
471 */
472static void handle_surprise_event(struct slot *p_slot)
473{
474 u8 getstatus;
475 struct power_work_info *info;
476
477 info = kmalloc(sizeof(*info), GFP_KERNEL);
478 if (!info) {
479 err("%s: Cannot allocate memory\n", __FUNCTION__);
480 return;
481 }
482 info->p_slot = p_slot;
483 INIT_WORK(&info->work, pciehp_power_thread);
484
485 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
486 if (!getstatus)
487 p_slot->state = POWEROFF_STATE;
488 else
489 p_slot->state = POWERON_STATE;
490
491 queue_work(pciehp_wq, &info->work);
492}
493
494static void interrupt_event_handler(struct work_struct *work)
495{
496 struct event_info *info = container_of(work, struct event_info, work);
497 struct slot *p_slot = info->p_slot;
498 struct controller *ctrl = p_slot->ctrl;
499
500 mutex_lock(&p_slot->lock);
501 switch (info->event_type) {
502 case INT_BUTTON_PRESS:
503 handle_button_press_event(p_slot);
504 break;
505 case INT_POWER_FAULT:
506 if (!POWER_CTRL(ctrl->ctrlcap))
507 break;
508 if (ATTN_LED(ctrl->ctrlcap))
509 p_slot->hpc_ops->set_attention_status(p_slot, 1);
510 if (PWR_LED(ctrl->ctrlcap))
511 p_slot->hpc_ops->green_led_off(p_slot);
512 break;
513 case INT_PRESENCE_ON:
514 case INT_PRESENCE_OFF:
515 if (!HP_SUPR_RM(ctrl->ctrlcap))
516 break;
517 dbg("Surprise Removal\n");
518 update_slot_info(p_slot);
519 handle_surprise_event(p_slot);
520 break;
521 default:
522 update_slot_info(p_slot);
523 break;
524 }
525 mutex_unlock(&p_slot->lock);
526
527 kfree(info);
528}
529
645int pciehp_enable_slot(struct slot *p_slot) 530int pciehp_enable_slot(struct slot *p_slot)
646{ 531{
647 u8 getstatus = 0; 532 u8 getstatus = 0;
@@ -653,7 +538,7 @@ int pciehp_enable_slot(struct slot *p_slot)
653 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 538 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
654 if (rc || !getstatus) { 539 if (rc || !getstatus) {
655 info("%s: no adapter on slot(%s)\n", __FUNCTION__, 540 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
656 slot_name(p_slot)); 541 p_slot->name);
657 mutex_unlock(&p_slot->ctrl->crit_sect); 542 mutex_unlock(&p_slot->ctrl->crit_sect);
658 return -ENODEV; 543 return -ENODEV;
659 } 544 }
@@ -661,7 +546,7 @@ int pciehp_enable_slot(struct slot *p_slot)
661 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 546 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
662 if (rc || getstatus) { 547 if (rc || getstatus) {
663 info("%s: latch open on slot(%s)\n", __FUNCTION__, 548 info("%s: latch open on slot(%s)\n", __FUNCTION__,
664 slot_name(p_slot)); 549 p_slot->name);
665 mutex_unlock(&p_slot->ctrl->crit_sect); 550 mutex_unlock(&p_slot->ctrl->crit_sect);
666 return -ENODEV; 551 return -ENODEV;
667 } 552 }
@@ -671,7 +556,7 @@ int pciehp_enable_slot(struct slot *p_slot)
671 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 556 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
672 if (rc || getstatus) { 557 if (rc || getstatus) {
673 info("%s: already enabled on slot(%s)\n", __FUNCTION__, 558 info("%s: already enabled on slot(%s)\n", __FUNCTION__,
674 slot_name(p_slot)); 559 p_slot->name);
675 mutex_unlock(&p_slot->ctrl->crit_sect); 560 mutex_unlock(&p_slot->ctrl->crit_sect);
676 return -EINVAL; 561 return -EINVAL;
677 } 562 }
@@ -706,7 +591,7 @@ int pciehp_disable_slot(struct slot *p_slot)
706 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 591 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
707 if (ret || !getstatus) { 592 if (ret || !getstatus) {
708 info("%s: no adapter on slot(%s)\n", __FUNCTION__, 593 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
709 slot_name(p_slot)); 594 p_slot->name);
710 mutex_unlock(&p_slot->ctrl->crit_sect); 595 mutex_unlock(&p_slot->ctrl->crit_sect);
711 return -ENODEV; 596 return -ENODEV;
712 } 597 }
@@ -716,7 +601,7 @@ int pciehp_disable_slot(struct slot *p_slot)
716 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 601 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
717 if (ret || getstatus) { 602 if (ret || getstatus) {
718 info("%s: latch open on slot(%s)\n", __FUNCTION__, 603 info("%s: latch open on slot(%s)\n", __FUNCTION__,
719 slot_name(p_slot)); 604 p_slot->name);
720 mutex_unlock(&p_slot->ctrl->crit_sect); 605 mutex_unlock(&p_slot->ctrl->crit_sect);
721 return -ENODEV; 606 return -ENODEV;
722 } 607 }
@@ -726,7 +611,7 @@ int pciehp_disable_slot(struct slot *p_slot)
726 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 611 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
727 if (ret || !getstatus) { 612 if (ret || !getstatus) {
728 info("%s: already disabled slot(%s)\n", __FUNCTION__, 613 info("%s: already disabled slot(%s)\n", __FUNCTION__,
729 slot_name(p_slot)); 614 p_slot->name);
730 mutex_unlock(&p_slot->ctrl->crit_sect); 615 mutex_unlock(&p_slot->ctrl->crit_sect);
731 return -EINVAL; 616 return -EINVAL;
732 } 617 }
@@ -739,3 +624,66 @@ int pciehp_disable_slot(struct slot *p_slot)
739 return ret; 624 return ret;
740} 625}
741 626
627int pciehp_sysfs_enable_slot(struct slot *p_slot)
628{
629 int retval = -ENODEV;
630
631 mutex_lock(&p_slot->lock);
632 switch (p_slot->state) {
633 case BLINKINGON_STATE:
634 cancel_delayed_work(&p_slot->work);
635 case STATIC_STATE:
636 p_slot->state = POWERON_STATE;
637 mutex_unlock(&p_slot->lock);
638 retval = pciehp_enable_slot(p_slot);
639 mutex_lock(&p_slot->lock);
640 p_slot->state = STATIC_STATE;
641 break;
642 case POWERON_STATE:
643 info("Slot %s is already in powering on state\n",
644 p_slot->name);
645 break;
646 case BLINKINGOFF_STATE:
647 case POWEROFF_STATE:
648 info("Already enabled on slot %s\n", p_slot->name);
649 break;
650 default:
651 err("Not a valid state on slot %s\n", p_slot->name);
652 break;
653 }
654 mutex_unlock(&p_slot->lock);
655
656 return retval;
657}
658
659int pciehp_sysfs_disable_slot(struct slot *p_slot)
660{
661 int retval = -ENODEV;
662
663 mutex_lock(&p_slot->lock);
664 switch (p_slot->state) {
665 case BLINKINGOFF_STATE:
666 cancel_delayed_work(&p_slot->work);
667 case STATIC_STATE:
668 p_slot->state = POWEROFF_STATE;
669 mutex_unlock(&p_slot->lock);
670 retval = pciehp_disable_slot(p_slot);
671 mutex_lock(&p_slot->lock);
672 p_slot->state = STATIC_STATE;
673 break;
674 case POWEROFF_STATE:
675 info("Slot %s is already in powering off state\n",
676 p_slot->name);
677 break;
678 case BLINKINGON_STATE:
679 case POWERON_STATE:
680 info("Already disabled on slot %s\n", p_slot->name);
681 break;
682 default:
683 err("Not a valid state on slot %s\n", p_slot->name);
684 break;
685 }
686 mutex_unlock(&p_slot->lock);
687
688 return retval;
689}
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index fbc64aa2dd68..9aac6a87eb53 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -71,6 +71,8 @@
71#define DBG_LEAVE_ROUTINE 71#define DBG_LEAVE_ROUTINE
72#endif /* DEBUG */ 72#endif /* DEBUG */
73 73
74static atomic_t pciehp_num_controllers = ATOMIC_INIT(0);
75
74struct ctrl_reg { 76struct ctrl_reg {
75 u8 cap_id; 77 u8 cap_id;
76 u8 nxt_ptr; 78 u8 nxt_ptr;
@@ -219,10 +221,7 @@ static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
219#define EMI_STATE 0x0080 221#define EMI_STATE 0x0080
220#define EMI_STATUS_BIT 7 222#define EMI_STATUS_BIT 7
221 223
222static spinlock_t hpc_event_lock;
223
224DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */ 224DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */
225static int ctlr_seq_num = 0; /* Controller sequence # */
226 225
227static irqreturn_t pcie_isr(int irq, void *dev_id); 226static irqreturn_t pcie_isr(int irq, void *dev_id);
228static void start_int_poll_timer(struct controller *ctrl, int sec); 227static void start_int_poll_timer(struct controller *ctrl, int sec);
@@ -656,6 +655,13 @@ static void hpc_release_ctlr(struct controller *ctrl)
656 else 655 else
657 free_irq(ctrl->pci_dev->irq, ctrl); 656 free_irq(ctrl->pci_dev->irq, ctrl);
658 657
658 /*
659 * If this is the last controller to be released, destroy the
660 * pciehp work queue
661 */
662 if (atomic_dec_and_test(&pciehp_num_controllers))
663 destroy_workqueue(pciehp_wq);
664
659 DBG_LEAVE_ROUTINE 665 DBG_LEAVE_ROUTINE
660} 666}
661 667
@@ -1152,7 +1158,6 @@ int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev)
1152int pcie_init(struct controller * ctrl, struct pcie_device *dev) 1158int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1153{ 1159{
1154 int rc; 1160 int rc;
1155 static int first = 1;
1156 u16 temp_word; 1161 u16 temp_word;
1157 u16 cap_reg; 1162 u16 cap_reg;
1158 u16 intr_enable = 0; 1163 u16 intr_enable = 0;
@@ -1221,11 +1226,6 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1221 dbg("%s: SLOTCTRL offset %x slot_ctrl %x\n", 1226 dbg("%s: SLOTCTRL offset %x slot_ctrl %x\n",
1222 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_ctrl); 1227 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_ctrl);
1223 1228
1224 if (first) {
1225 spin_lock_init(&hpc_event_lock);
1226 first = 0;
1227 }
1228
1229 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++) 1229 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++)
1230 if (pci_resource_len(pdev, rc) > 0) 1230 if (pci_resource_len(pdev, rc) > 0)
1231 dbg("pci resource[%d] start=0x%llx(len=0x%llx)\n", rc, 1231 dbg("pci resource[%d] start=0x%llx(len=0x%llx)\n", rc,
@@ -1286,7 +1286,8 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1286 rc = request_irq(ctrl->pci_dev->irq, pcie_isr, IRQF_SHARED, 1286 rc = request_irq(ctrl->pci_dev->irq, pcie_isr, IRQF_SHARED,
1287 MY_NAME, (void *)ctrl); 1287 MY_NAME, (void *)ctrl);
1288 dbg("%s: request_irq %d for hpc%d (returns %d)\n", 1288 dbg("%s: request_irq %d for hpc%d (returns %d)\n",
1289 __FUNCTION__, ctrl->pci_dev->irq, ctlr_seq_num, rc); 1289 __FUNCTION__, ctrl->pci_dev->irq,
1290 atomic_read(&pciehp_num_controllers), rc);
1290 if (rc) { 1291 if (rc) {
1291 err("Can't get irq %d for the hotplug controller\n", 1292 err("Can't get irq %d for the hotplug controller\n",
1292 ctrl->pci_dev->irq); 1293 ctrl->pci_dev->irq);
@@ -1296,6 +1297,18 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1296 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number, 1297 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number,
1297 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq); 1298 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq);
1298 1299
1300 /*
1301 * If this is the first controller to be initialized,
1302 * initialize the pciehp work queue
1303 */
1304 if (atomic_add_return(1, &pciehp_num_controllers) == 1) {
1305 pciehp_wq = create_singlethread_workqueue("pciehpd");
1306 if (!pciehp_wq) {
1307 rc = -ENOMEM;
1308 goto abort_free_irq;
1309 }
1310 }
1311
1299 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word); 1312 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word);
1300 if (rc) { 1313 if (rc) {
1301 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__); 1314 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
@@ -1349,7 +1362,6 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1349 goto abort_disable_intr; 1362 goto abort_disable_intr;
1350 } 1363 }
1351 1364
1352 ctlr_seq_num++;
1353 ctrl->hpc_ops = &pciehp_hpc_ops; 1365 ctrl->hpc_ops = &pciehp_hpc_ops;
1354 1366
1355 DBG_LEAVE_ROUTINE 1367 DBG_LEAVE_ROUTINE
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 72383467a0d5..bb3c101c2c5a 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -98,7 +98,15 @@ static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
98 return NULL; 98 return NULL;
99} 99}
100 100
101static struct slot *find_slot(struct device_node *dn) 101/**
102 * find_php_slot - return hotplug slot structure for device node
103 *
104 * This routine will return the hotplug slot structure
105 * for a given device node. Note that built-in PCI slots
106 * may be dlpar-able, but not hot-pluggable, so this routine
107 * will return NULL for built-in PCI slots.
108 */
109static struct slot *find_php_slot(struct device_node *dn)
102{ 110{
103 struct list_head *tmp, *n; 111 struct list_head *tmp, *n;
104 struct slot *slot; 112 struct slot *slot;
@@ -224,9 +232,9 @@ static int dlpar_remove_phb(char *drc_name, struct device_node *dn)
224 if (!pcibios_find_pci_bus(dn)) 232 if (!pcibios_find_pci_bus(dn))
225 return -EINVAL; 233 return -EINVAL;
226 234
227 slot = find_slot(dn); 235 /* If pci slot is hotplugable, use hotplug to remove it */
236 slot = find_php_slot(dn);
228 if (slot) { 237 if (slot) {
229 /* Remove hotplug slot */
230 if (rpaphp_deregister_slot(slot)) { 238 if (rpaphp_deregister_slot(slot)) {
231 printk(KERN_ERR 239 printk(KERN_ERR
232 "%s: unable to remove hotplug slot %s\n", 240 "%s: unable to remove hotplug slot %s\n",
@@ -370,22 +378,17 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
370 if (!bus) 378 if (!bus)
371 return -EINVAL; 379 return -EINVAL;
372 380
373 slot = find_slot(dn); 381 /* If pci slot is hotplugable, use hotplug to remove it */
382 slot = find_php_slot(dn);
374 if (slot) { 383 if (slot) {
375 /* Remove hotplug slot */
376 if (rpaphp_deregister_slot(slot)) { 384 if (rpaphp_deregister_slot(slot)) {
377 printk(KERN_ERR 385 printk(KERN_ERR
378 "%s: unable to remove hotplug slot %s\n", 386 "%s: unable to remove hotplug slot %s\n",
379 __FUNCTION__, drc_name); 387 __FUNCTION__, drc_name);
380 return -EIO; 388 return -EIO;
381 } 389 }
382 } else { 390 } else
383 struct pci_dev *dev, *tmp; 391 pcibios_remove_pci_devices(bus);
384 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
385 eeh_remove_bus_device(dev);
386 pci_remove_bus_device(dev);
387 }
388 }
389 392
390 if (unmap_bus_range(bus)) { 393 if (unmap_bus_range(bus)) {
391 printk(KERN_ERR "%s: failed to unmap bus range\n", 394 printk(KERN_ERR "%s: failed to unmap bus range\n",
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 2e7accf0f734..c822a779653f 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -83,19 +83,15 @@ struct slot {
83 83
84extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops; 84extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
85extern struct list_head rpaphp_slot_head; 85extern struct list_head rpaphp_slot_head;
86extern int num_slots;
87 86
88/* function prototypes */ 87/* function prototypes */
89 88
90/* rpaphp_pci.c */ 89/* rpaphp_pci.c */
91extern int rpaphp_enable_pci_slot(struct slot *slot); 90extern int rpaphp_enable_slot(struct slot *slot);
92extern int rpaphp_register_pci_slot(struct slot *slot);
93extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
94extern int rpaphp_get_sensor_state(struct slot *slot, int *state); 91extern int rpaphp_get_sensor_state(struct slot *slot, int *state);
95 92
96/* rpaphp_core.c */ 93/* rpaphp_core.c */
97extern int rpaphp_add_slot(struct device_node *dn); 94extern int rpaphp_add_slot(struct device_node *dn);
98extern int rpaphp_remove_slot(struct slot *slot);
99extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, 95extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
100 char **drc_name, char **drc_type, int *drc_power_domain); 96 char **drc_name, char **drc_type, int *drc_power_domain);
101 97
@@ -104,7 +100,5 @@ extern void dealloc_slot_struct(struct slot *slot);
104extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain); 100extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
105extern int rpaphp_register_slot(struct slot *slot); 101extern int rpaphp_register_slot(struct slot *slot);
106extern int rpaphp_deregister_slot(struct slot *slot); 102extern int rpaphp_deregister_slot(struct slot *slot);
107extern int rpaphp_get_power_status(struct slot *slot, u8 * value);
108extern int rpaphp_set_attention_status(struct slot *slot, u8 status);
109 103
110#endif /* _PPC64PHP_H */ 104#endif /* _PPC64PHP_H */
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 71a2cb8baa4a..847936fe327e 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -39,9 +39,7 @@
39#include "rpaphp.h" 39#include "rpaphp.h"
40 40
41int debug; 41int debug;
42static struct semaphore rpaphp_sem;
43LIST_HEAD(rpaphp_slot_head); 42LIST_HEAD(rpaphp_slot_head);
44int num_slots;
45 43
46#define DRIVER_VERSION "0.1" 44#define DRIVER_VERSION "0.1"
47#define DRIVER_AUTHOR "Linda Xie <lxie@us.ibm.com>" 45#define DRIVER_AUTHOR "Linda Xie <lxie@us.ibm.com>"
@@ -55,11 +53,6 @@ MODULE_LICENSE("GPL");
55 53
56module_param(debug, bool, 0644); 54module_param(debug, bool, 0644);
57 55
58static int rpaphp_get_attention_status(struct slot *slot)
59{
60 return slot->hotplug_slot->info->attention_status;
61}
62
63/** 56/**
64 * set_attention_status - set attention LED 57 * set_attention_status - set attention LED
65 * echo 0 > attention -- set LED OFF 58 * echo 0 > attention -- set LED OFF
@@ -69,79 +62,75 @@ static int rpaphp_get_attention_status(struct slot *slot)
69 */ 62 */
70static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value) 63static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
71{ 64{
72 int retval = 0; 65 int rc;
73 struct slot *slot = (struct slot *)hotplug_slot->private; 66 struct slot *slot = (struct slot *)hotplug_slot->private;
74 67
75 down(&rpaphp_sem);
76 switch (value) { 68 switch (value) {
77 case 0: 69 case 0:
78 retval = rpaphp_set_attention_status(slot, LED_OFF);
79 hotplug_slot->info->attention_status = 0;
80 break;
81 case 1: 70 case 1:
82 default:
83 retval = rpaphp_set_attention_status(slot, LED_ON);
84 hotplug_slot->info->attention_status = 1;
85 break;
86 case 2: 71 case 2:
87 retval = rpaphp_set_attention_status(slot, LED_ID); 72 break;
88 hotplug_slot->info->attention_status = 2; 73 default:
74 value = 1;
89 break; 75 break;
90 } 76 }
91 up(&rpaphp_sem); 77
92 return retval; 78 rc = rtas_set_indicator(DR_INDICATOR, slot->index, value);
79 if (!rc)
80 hotplug_slot->info->attention_status = value;
81
82 return rc;
93} 83}
94 84
95/** 85/**
96 * get_power_status - get power status of a slot 86 * get_power_status - get power status of a slot
97 * @hotplug_slot: slot to get status 87 * @hotplug_slot: slot to get status
98 * @value: pointer to store status 88 * @value: pointer to store status
99 *
100 *
101 */ 89 */
102static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value) 90static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
103{ 91{
104 int retval; 92 int retval, level;
105 struct slot *slot = (struct slot *)hotplug_slot->private; 93 struct slot *slot = (struct slot *)hotplug_slot->private;
106 94
107 down(&rpaphp_sem); 95 retval = rtas_get_power_level (slot->power_domain, &level);
108 retval = rpaphp_get_power_status(slot, value); 96 if (!retval)
109 up(&rpaphp_sem); 97 *value = level;
110 return retval; 98 return retval;
111} 99}
112 100
113/** 101/**
114 * get_attention_status - get attention LED status 102 * get_attention_status - get attention LED status
115 *
116 *
117 */ 103 */
118static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value) 104static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
119{ 105{
120 int retval = 0;
121 struct slot *slot = (struct slot *)hotplug_slot->private; 106 struct slot *slot = (struct slot *)hotplug_slot->private;
122 107 *value = slot->hotplug_slot->info->attention_status;
123 down(&rpaphp_sem); 108 return 0;
124 *value = rpaphp_get_attention_status(slot);
125 up(&rpaphp_sem);
126 return retval;
127} 109}
128 110
129static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value) 111static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
130{ 112{
131 struct slot *slot = (struct slot *)hotplug_slot->private; 113 struct slot *slot = (struct slot *)hotplug_slot->private;
132 int retval = 0; 114 int rc, state;
133 115
134 down(&rpaphp_sem); 116 rc = rpaphp_get_sensor_state(slot, &state);
135 retval = rpaphp_get_pci_adapter_status(slot, 0, value); 117
136 up(&rpaphp_sem); 118 *value = NOT_VALID;
137 return retval; 119 if (rc)
120 return rc;
121
122 if (state == EMPTY)
123 *value = EMPTY;
124 else if (state == PRESENT)
125 *value = slot->state;
126
127 return 0;
138} 128}
139 129
140static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) 130static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
141{ 131{
142 struct slot *slot = (struct slot *)hotplug_slot->private; 132 struct slot *slot = (struct slot *)hotplug_slot->private;
143 133
144 down(&rpaphp_sem);
145 switch (slot->type) { 134 switch (slot->type) {
146 case 1: 135 case 1:
147 case 2: 136 case 2:
@@ -172,7 +161,6 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
172 break; 161 break;
173 162
174 } 163 }
175 up(&rpaphp_sem);
176 return 0; 164 return 0;
177} 165}
178 166
@@ -265,6 +253,14 @@ static int is_php_type(char *drc_type)
265 return 1; 253 return 1;
266} 254}
267 255
256/**
257 * is_php_dn() - return 1 if this is a hotpluggable pci slot, else 0
258 *
259 * This routine will return true only if the device node is
260 * a hotpluggable slot. This routine will return false
261 * for built-in pci slots (even when the built-in slots are
262 * dlparable.)
263 */
268static int is_php_dn(struct device_node *dn, const int **indexes, 264static int is_php_dn(struct device_node *dn, const int **indexes,
269 const int **names, const int **types, const int **power_domains) 265 const int **names, const int **types, const int **power_domains)
270{ 266{
@@ -272,24 +268,31 @@ static int is_php_dn(struct device_node *dn, const int **indexes,
272 int rc; 268 int rc;
273 269
274 rc = get_children_props(dn, indexes, names, &drc_types, power_domains); 270 rc = get_children_props(dn, indexes, names, &drc_types, power_domains);
275 if (rc >= 0) { 271 if (rc < 0)
276 if (is_php_type((char *) &drc_types[1])) { 272 return 0;
277 *types = drc_types;
278 return 1;
279 }
280 }
281 273
282 return 0; 274 if (!is_php_type((char *) &drc_types[1]))
275 return 0;
276
277 *types = drc_types;
278 return 1;
283} 279}
284 280
285/** 281/**
286 * rpaphp_add_slot -- add hotplug or dlpar slot 282 * rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem.
283 * @dn device node of slot
284 *
285 * This subroutine will register a hotplugable slot with the
286 * PCI hotplug infrastructure. This routine is typicaly called
287 * during boot time, if the hotplug slots are present at boot time,
288 * or is called later, by the dlpar add code, if the slot is
289 * being dynamically added during runtime.
290 *
291 * If the device node points at an embedded (built-in) slot, this
292 * routine will just return without doing anything, since embedded
293 * slots cannot be hotplugged.
287 * 294 *
288 * rpaphp not only registers PCI hotplug slots(HOTPLUG), 295 * To remove a slot, it suffices to call rpaphp_deregister_slot()
289 * but also logical DR slots(EMBEDDED).
290 * HOTPLUG slot: An adapter can be physically added/removed.
291 * EMBEDDED slot: An adapter can be logically removed/added
292 * from/to a partition with the slot.
293 */ 296 */
294int rpaphp_add_slot(struct device_node *dn) 297int rpaphp_add_slot(struct device_node *dn)
295{ 298{
@@ -299,34 +302,42 @@ int rpaphp_add_slot(struct device_node *dn)
299 const int *indexes, *names, *types, *power_domains; 302 const int *indexes, *names, *types, *power_domains;
300 char *name, *type; 303 char *name, *type;
301 304
305 if (!dn->name || strcmp(dn->name, "pci"))
306 return 0;
307
308 /* If this is not a hotplug slot, return without doing anything. */
309 if (!is_php_dn(dn, &indexes, &names, &types, &power_domains))
310 return 0;
311
302 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); 312 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name);
303 313
304 /* register PCI devices */ 314 /* register PCI devices */
305 if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { 315 name = (char *) &names[1];
306 if (!is_php_dn(dn, &indexes, &names, &types, &power_domains)) 316 type = (char *) &types[1];
307 goto exit; 317 for (i = 0; i < indexes[0]; i++) {
308 318
309 name = (char *) &names[1]; 319 slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
310 type = (char *) &types[1]; 320 if (!slot)
311 for (i = 0; i < indexes[0]; i++, 321 return -ENOMEM;
312 name += (strlen(name) + 1), type += (strlen(type) + 1)) { 322
313 323 slot->type = simple_strtoul(type, NULL, 10);
314 if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name,
315 power_domains[i + 1]))) {
316 retval = -ENOMEM;
317 goto exit;
318 }
319 slot->type = simple_strtoul(type, NULL, 10);
320 324
321 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n", 325 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n",
322 indexes[i + 1], name, type); 326 indexes[i + 1], name, type);
323 327
324 retval = rpaphp_register_pci_slot(slot); 328 retval = rpaphp_enable_slot(slot);
325 } 329 if (!retval)
330 retval = rpaphp_register_slot(slot);
331
332 if (retval)
333 dealloc_slot_struct(slot);
334
335 name += strlen(name) + 1;
336 type += strlen(type) + 1;
326 } 337 }
327exit: 338 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
328 dbg("%s - Exit: num_slots=%d rc[%d]\n", 339
329 __FUNCTION__, num_slots, retval); 340 /* XXX FIXME: reports a failure only if last entry in loop failed */
330 return retval; 341 return retval;
331} 342}
332 343
@@ -354,7 +365,6 @@ static int __init rpaphp_init(void)
354 struct device_node *dn = NULL; 365 struct device_node *dn = NULL;
355 366
356 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 367 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
357 init_MUTEX(&rpaphp_sem);
358 368
359 while ((dn = of_find_node_by_name(dn, "pci"))) 369 while ((dn = of_find_node_by_name(dn, "pci")))
360 rpaphp_add_slot(dn); 370 rpaphp_add_slot(dn);
@@ -367,8 +377,9 @@ static void __exit rpaphp_exit(void)
367 cleanup_slots(); 377 cleanup_slots();
368} 378}
369 379
370static int __enable_slot(struct slot *slot) 380static int enable_slot(struct hotplug_slot *hotplug_slot)
371{ 381{
382 struct slot *slot = (struct slot *)hotplug_slot->private;
372 int state; 383 int state;
373 int retval; 384 int retval;
374 385
@@ -392,46 +403,17 @@ static int __enable_slot(struct slot *slot)
392 return 0; 403 return 0;
393} 404}
394 405
395static int enable_slot(struct hotplug_slot *hotplug_slot) 406static int disable_slot(struct hotplug_slot *hotplug_slot)
396{ 407{
397 int retval;
398 struct slot *slot = (struct slot *)hotplug_slot->private; 408 struct slot *slot = (struct slot *)hotplug_slot->private;
399
400 down(&rpaphp_sem);
401 retval = __enable_slot(slot);
402 up(&rpaphp_sem);
403
404 return retval;
405}
406
407static int __disable_slot(struct slot *slot)
408{
409 struct pci_dev *dev, *tmp;
410
411 if (slot->state == NOT_CONFIGURED) 409 if (slot->state == NOT_CONFIGURED)
412 return -EINVAL; 410 return -EINVAL;
413 411
414 list_for_each_entry_safe(dev, tmp, &slot->bus->devices, bus_list) { 412 pcibios_remove_pci_devices(slot->bus);
415 eeh_remove_bus_device(dev);
416 pci_remove_bus_device(dev);
417 }
418
419 slot->state = NOT_CONFIGURED; 413 slot->state = NOT_CONFIGURED;
420 return 0; 414 return 0;
421} 415}
422 416
423static int disable_slot(struct hotplug_slot *hotplug_slot)
424{
425 struct slot *slot = (struct slot *)hotplug_slot->private;
426 int retval;
427
428 down(&rpaphp_sem);
429 retval = __disable_slot (slot);
430 up(&rpaphp_sem);
431
432 return retval;
433}
434
435struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { 417struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
436 .owner = THIS_MODULE, 418 .owner = THIS_MODULE,
437 .enable_slot = enable_slot, 419 .enable_slot = enable_slot,
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 6f6cbede5135..54ca8650d511 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -64,75 +64,6 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
64 return rc; 64 return rc;
65} 65}
66 66
67/**
68 * get_pci_adapter_status - get the status of a slot
69 *
70 * 0-- slot is empty
71 * 1-- adapter is configured
72 * 2-- adapter is not configured
73 * 3-- not valid
74 */
75int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value)
76{
77 struct pci_bus *bus;
78 int state, rc;
79
80 *value = NOT_VALID;
81 rc = rpaphp_get_sensor_state(slot, &state);
82 if (rc)
83 goto exit;
84
85 if (state == EMPTY)
86 *value = EMPTY;
87 else if (state == PRESENT) {
88 if (!is_init) {
89 /* at run-time slot->state can be changed by */
90 /* config/unconfig adapter */
91 *value = slot->state;
92 } else {
93 bus = pcibios_find_pci_bus(slot->dn);
94 if (bus && !list_empty(&bus->devices))
95 *value = CONFIGURED;
96 else
97 *value = NOT_CONFIGURED;
98 }
99 }
100exit:
101 return rc;
102}
103
104static void print_slot_pci_funcs(struct pci_bus *bus)
105{
106 struct device_node *dn;
107 struct pci_dev *dev;
108
109 dn = pci_bus_to_OF_node(bus);
110 if (!dn)
111 return;
112
113 dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, dn->full_name);
114 list_for_each_entry (dev, &bus->devices, bus_list)
115 dbg("\t%s\n", pci_name(dev));
116 return;
117}
118
119static int setup_pci_hotplug_slot_info(struct slot *slot)
120{
121 struct hotplug_slot_info *hotplug_slot_info = slot->hotplug_slot->info;
122
123 dbg("%s Initilize the PCI slot's hotplug->info structure ...\n",
124 __FUNCTION__);
125 rpaphp_get_power_status(slot, &hotplug_slot_info->power_status);
126 rpaphp_get_pci_adapter_status(slot, 1,
127 &hotplug_slot_info->adapter_status);
128 if (hotplug_slot_info->adapter_status == NOT_VALID) {
129 err("%s: NOT_VALID: skip dn->full_name=%s\n",
130 __FUNCTION__, slot->dn->full_name);
131 return -EINVAL;
132 }
133 return 0;
134}
135
136static void set_slot_name(struct slot *slot) 67static void set_slot_name(struct slot *slot)
137{ 68{
138 struct pci_bus *bus = slot->bus; 69 struct pci_bus *bus = slot->bus;
@@ -146,69 +77,73 @@ static void set_slot_name(struct slot *slot)
146 bus->number); 77 bus->number);
147} 78}
148 79
149static int setup_pci_slot(struct slot *slot) 80/**
81 * rpaphp_enable_slot - record slot state, config pci device
82 *
83 * Initialize values in the slot, and the hotplug_slot info
84 * structures to indicate if there is a pci card plugged into
85 * the slot. If the slot is not empty, run the pcibios routine
86 * to get pcibios stuff correctly set up.
87 */
88int rpaphp_enable_slot(struct slot *slot)
150{ 89{
151 struct device_node *dn = slot->dn; 90 int rc, level, state;
152 struct pci_bus *bus; 91 struct pci_bus *bus;
92 struct hotplug_slot_info *info = slot->hotplug_slot->info;
93
94 info->adapter_status = NOT_VALID;
95 slot->state = EMPTY;
96
97 /* Find out if the power is turned on for the slot */
98 rc = rtas_get_power_level(slot->power_domain, &level);
99 if (rc)
100 return rc;
101 info->power_status = level;
102
103 /* Figure out if there is an adapter in the slot */
104 rc = rpaphp_get_sensor_state(slot, &state);
105 if (rc)
106 return rc;
153 107
154 BUG_ON(!dn); 108 bus = pcibios_find_pci_bus(slot->dn);
155 bus = pcibios_find_pci_bus(dn);
156 if (!bus) { 109 if (!bus) {
157 err("%s: no pci_bus for dn %s\n", __FUNCTION__, dn->full_name); 110 err("%s: no pci_bus for dn %s\n", __FUNCTION__, slot->dn->full_name);
158 goto exit_rc; 111 return -EINVAL;
159 } 112 }
160 113
114 info->adapter_status = EMPTY;
161 slot->bus = bus; 115 slot->bus = bus;
162 slot->pci_devs = &bus->devices; 116 slot->pci_devs = &bus->devices;
163 set_slot_name(slot); 117 set_slot_name(slot);
164 118
165 /* find slot's pci_dev if it's not empty */ 119 /* if there's an adapter in the slot, go add the pci devices */
166 if (slot->hotplug_slot->info->adapter_status == EMPTY) { 120 if (state == PRESENT) {
167 slot->state = EMPTY; /* slot is empty */ 121 info->adapter_status = NOT_CONFIGURED;
168 } else { 122 slot->state = NOT_CONFIGURED;
169 /* slot is occupied */ 123
170 if (!dn->child) { 124 /* non-empty slot has to have child */
171 /* non-empty slot has to have child */ 125 if (!slot->dn->child) {
172 err("%s: slot[%s]'s device_node doesn't have child for adapter\n", 126 err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
173 __FUNCTION__, slot->name); 127 __FUNCTION__, slot->name);
174 goto exit_rc; 128 return -EINVAL;
175 } 129 }
176 130
177 if (slot->hotplug_slot->info->adapter_status == NOT_CONFIGURED) { 131 if (list_empty(&bus->devices))
178 dbg("%s CONFIGURING pci adapter in slot[%s]\n", 132 pcibios_add_pci_devices(bus);
179 __FUNCTION__, slot->name);
180 pcibios_add_pci_devices(slot->bus);
181 133
182 } else if (slot->hotplug_slot->info->adapter_status != CONFIGURED) { 134 if (!list_empty(&bus->devices)) {
183 err("%s: slot[%s]'s adapter_status is NOT_VALID.\n", 135 info->adapter_status = CONFIGURED;
184 __FUNCTION__, slot->name);
185 goto exit_rc;
186 }
187 print_slot_pci_funcs(slot->bus);
188 if (!list_empty(slot->pci_devs)) {
189 slot->state = CONFIGURED; 136 slot->state = CONFIGURED;
190 } else { 137 }
191 /* DLPAR add as opposed to 138
192 * boot time */ 139 if (debug) {
193 slot->state = NOT_CONFIGURED; 140 struct pci_dev *dev;
141 dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->dn->full_name);
142 list_for_each_entry (dev, &bus->devices, bus_list)
143 dbg("\t%s\n", pci_name(dev));
194 } 144 }
195 } 145 }
196 return 0;
197exit_rc:
198 dealloc_slot_struct(slot);
199 return -EINVAL;
200}
201 146
202int rpaphp_register_pci_slot(struct slot *slot) 147 return 0;
203{
204 int rc = -EINVAL;
205
206 if (setup_pci_hotplug_slot_info(slot))
207 goto exit_rc;
208 if (setup_pci_slot(slot))
209 goto exit_rc;
210 rc = rpaphp_register_slot(slot);
211exit_rc:
212 return rc;
213} 148}
214 149
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 3009193f0058..d4ee8723fcb3 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -56,7 +56,6 @@ static struct hotplug_slot_attribute php_attr_location = {
56static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot) 56static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
57{ 57{
58 struct slot *slot = (struct slot *) hotplug_slot->private; 58 struct slot *slot = (struct slot *) hotplug_slot->private;
59
60 dealloc_slot_struct(slot); 59 dealloc_slot_struct(slot);
61} 60}
62 61
@@ -65,12 +64,12 @@ void dealloc_slot_struct(struct slot *slot)
65 kfree(slot->hotplug_slot->info); 64 kfree(slot->hotplug_slot->info);
66 kfree(slot->hotplug_slot->name); 65 kfree(slot->hotplug_slot->name);
67 kfree(slot->hotplug_slot); 66 kfree(slot->hotplug_slot);
67 kfree(slot->location);
68 kfree(slot); 68 kfree(slot);
69 return;
70} 69}
71 70
72struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, 71struct slot *alloc_slot_struct(struct device_node *dn,
73 int power_domain) 72 int drc_index, char *drc_name, int power_domain)
74{ 73{
75 struct slot *slot; 74 struct slot *slot;
76 75
@@ -115,7 +114,7 @@ error_nomem:
115 114
116static int is_registered(struct slot *slot) 115static int is_registered(struct slot *slot)
117{ 116{
118 struct slot *tmp_slot; 117 struct slot *tmp_slot;
119 118
120 list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) { 119 list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) {
121 if (!strcmp(tmp_slot->name, slot->name)) 120 if (!strcmp(tmp_slot->name, slot->name))
@@ -140,8 +139,6 @@ int rpaphp_deregister_slot(struct slot *slot)
140 retval = pci_hp_deregister(php_slot); 139 retval = pci_hp_deregister(php_slot);
141 if (retval) 140 if (retval)
142 err("Problem unregistering a slot %s\n", slot->name); 141 err("Problem unregistering a slot %s\n", slot->name);
143 else
144 num_slots--;
145 142
146 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); 143 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
147 return retval; 144 return retval;
@@ -160,14 +157,13 @@ int rpaphp_register_slot(struct slot *slot)
160 /* should not try to register the same slot twice */ 157 /* should not try to register the same slot twice */
161 if (is_registered(slot)) { 158 if (is_registered(slot)) {
162 err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name); 159 err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name);
163 retval = -EAGAIN; 160 return -EAGAIN;
164 goto register_fail;
165 } 161 }
166 162
167 retval = pci_hp_register(php_slot); 163 retval = pci_hp_register(php_slot);
168 if (retval) { 164 if (retval) {
169 err("pci_hp_register failed with error %d\n", retval); 165 err("pci_hp_register failed with error %d\n", retval);
170 goto register_fail; 166 return retval;
171 } 167 }
172 168
173 /* create "phy_location" file */ 169 /* create "phy_location" file */
@@ -181,43 +177,10 @@ int rpaphp_register_slot(struct slot *slot)
181 list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); 177 list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head);
182 info("Slot [%s](PCI location=%s) registered\n", slot->name, 178 info("Slot [%s](PCI location=%s) registered\n", slot->name,
183 slot->location); 179 slot->location);
184 num_slots++;
185 return 0; 180 return 0;
186 181
187sysfs_fail: 182sysfs_fail:
188 pci_hp_deregister(php_slot); 183 pci_hp_deregister(php_slot);
189register_fail:
190 rpaphp_release_slot(php_slot);
191 return retval; 184 return retval;
192} 185}
193 186
194int rpaphp_get_power_status(struct slot *slot, u8 * value)
195{
196 int rc = 0, level;
197
198 rc = rtas_get_power_level(slot->power_domain, &level);
199 if (rc < 0) {
200 err("failed to get power-level for slot(%s), rc=0x%x\n",
201 slot->location, rc);
202 return rc;
203 }
204
205 dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n",
206 __FUNCTION__, slot->name, slot->power_domain, level);
207 *value = level;
208
209 return rc;
210}
211
212int rpaphp_set_attention_status(struct slot *slot, u8 status)
213{
214 int rc;
215
216 /* status: LED_OFF or LED_ON */
217 rc = rtas_set_indicator(DR_INDICATOR, slot->index, status);
218 if (rc < 0)
219 err("slot(name=%s location=%s index=0x%x) set attention-status(%d) failed! rc=0x%x\n",
220 slot->name, slot->location, slot->index, status, rc);
221
222 return rc;
223}
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 01d31a1f697c..37ed0884b972 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -166,7 +166,7 @@ extern u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
166extern int shpchp_configure_device(struct slot *p_slot); 166extern int shpchp_configure_device(struct slot *p_slot);
167extern int shpchp_unconfigure_device(struct slot *p_slot); 167extern int shpchp_unconfigure_device(struct slot *p_slot);
168extern void cleanup_slots(struct controller *ctrl); 168extern void cleanup_slots(struct controller *ctrl);
169extern void queue_pushbutton_work(struct work_struct *work); 169extern void shpchp_queue_pushbutton_work(struct work_struct *work);
170extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev); 170extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
171 171
172#ifdef CONFIG_ACPI 172#ifdef CONFIG_ACPI
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 5f4bc08a633a..80dec9796b31 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -136,7 +136,7 @@ static int init_slots(struct controller *ctrl)
136 slot->hpc_ops = ctrl->hpc_ops; 136 slot->hpc_ops = ctrl->hpc_ops;
137 slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i); 137 slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
138 mutex_init(&slot->lock); 138 mutex_init(&slot->lock);
139 INIT_DELAYED_WORK(&slot->work, queue_pushbutton_work); 139 INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work);
140 140
141 /* register this slot with the hotplug pci core */ 141 /* register this slot with the hotplug pci core */
142 hotplug_slot->private = slot; 142 hotplug_slot->private = slot;
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index b746bd265bc6..2c94d44279a3 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -433,7 +433,7 @@ static void shpchp_pushbutton_thread(struct work_struct *work)
433 kfree(info); 433 kfree(info);
434} 434}
435 435
436void queue_pushbutton_work(struct work_struct *work) 436void shpchp_queue_pushbutton_work(struct work_struct *work)
437{ 437{
438 struct slot *p_slot = container_of(work, struct slot, work.work); 438 struct slot *p_slot = container_of(work, struct slot, work.work);
439 struct pushbutton_work_info *info; 439 struct pushbutton_work_info *info;
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 435c1958a7b7..9e1321d0d5e6 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -24,20 +24,8 @@
24#include "pci.h" 24#include "pci.h"
25#include "msi.h" 25#include "msi.h"
26 26
27static struct kmem_cache* msi_cachep;
28
29static int pci_msi_enable = 1; 27static int pci_msi_enable = 1;
30 28
31static int msi_cache_init(void)
32{
33 msi_cachep = kmem_cache_create("msi_cache", sizeof(struct msi_desc),
34 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
35 if (!msi_cachep)
36 return -ENOMEM;
37
38 return 0;
39}
40
41static void msi_set_enable(struct pci_dev *dev, int enable) 29static void msi_set_enable(struct pci_dev *dev, int enable)
42{ 30{
43 int pos; 31 int pos;
@@ -68,6 +56,29 @@ static void msix_set_enable(struct pci_dev *dev, int enable)
68 } 56 }
69} 57}
70 58
59static void msix_flush_writes(unsigned int irq)
60{
61 struct msi_desc *entry;
62
63 entry = get_irq_msi(irq);
64 BUG_ON(!entry || !entry->dev);
65 switch (entry->msi_attrib.type) {
66 case PCI_CAP_ID_MSI:
67 /* nothing to do */
68 break;
69 case PCI_CAP_ID_MSIX:
70 {
71 int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
72 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET;
73 readl(entry->mask_base + offset);
74 break;
75 }
76 default:
77 BUG();
78 break;
79 }
80}
81
71static void msi_set_mask_bit(unsigned int irq, int flag) 82static void msi_set_mask_bit(unsigned int irq, int flag)
72{ 83{
73 struct msi_desc *entry; 84 struct msi_desc *entry;
@@ -187,41 +198,28 @@ void write_msi_msg(unsigned int irq, struct msi_msg *msg)
187void mask_msi_irq(unsigned int irq) 198void mask_msi_irq(unsigned int irq)
188{ 199{
189 msi_set_mask_bit(irq, 1); 200 msi_set_mask_bit(irq, 1);
201 msix_flush_writes(irq);
190} 202}
191 203
192void unmask_msi_irq(unsigned int irq) 204void unmask_msi_irq(unsigned int irq)
193{ 205{
194 msi_set_mask_bit(irq, 0); 206 msi_set_mask_bit(irq, 0);
207 msix_flush_writes(irq);
195} 208}
196 209
197static int msi_free_irq(struct pci_dev* dev, int irq); 210static int msi_free_irqs(struct pci_dev* dev);
198
199static int msi_init(void)
200{
201 static int status = -ENOMEM;
202
203 if (!status)
204 return status;
205 211
206 status = msi_cache_init();
207 if (status < 0) {
208 pci_msi_enable = 0;
209 printk(KERN_WARNING "PCI: MSI cache init failed\n");
210 return status;
211 }
212
213 return status;
214}
215 212
216static struct msi_desc* alloc_msi_entry(void) 213static struct msi_desc* alloc_msi_entry(void)
217{ 214{
218 struct msi_desc *entry; 215 struct msi_desc *entry;
219 216
220 entry = kmem_cache_zalloc(msi_cachep, GFP_KERNEL); 217 entry = kzalloc(sizeof(struct msi_desc), GFP_KERNEL);
221 if (!entry) 218 if (!entry)
222 return NULL; 219 return NULL;
223 220
224 entry->link.tail = entry->link.head = 0; /* single message */ 221 INIT_LIST_HEAD(&entry->list);
222 entry->irq = 0;
225 entry->dev = NULL; 223 entry->dev = NULL;
226 224
227 return entry; 225 return entry;
@@ -256,7 +254,6 @@ static void __pci_restore_msi_state(struct pci_dev *dev)
256static void __pci_restore_msix_state(struct pci_dev *dev) 254static void __pci_restore_msix_state(struct pci_dev *dev)
257{ 255{
258 int pos; 256 int pos;
259 int irq, head, tail = 0;
260 struct msi_desc *entry; 257 struct msi_desc *entry;
261 u16 control; 258 u16 control;
262 259
@@ -266,18 +263,15 @@ static void __pci_restore_msix_state(struct pci_dev *dev)
266 /* route the table */ 263 /* route the table */
267 pci_intx(dev, 0); /* disable intx */ 264 pci_intx(dev, 0); /* disable intx */
268 msix_set_enable(dev, 0); 265 msix_set_enable(dev, 0);
269 irq = head = dev->first_msi_irq;
270 entry = get_irq_msi(irq);
271 pos = entry->msi_attrib.pos;
272 while (head != tail) {
273 entry = get_irq_msi(irq);
274 write_msi_msg(irq, &entry->msg);
275 msi_set_mask_bit(irq, entry->msi_attrib.masked);
276 266
277 tail = entry->link.tail; 267 list_for_each_entry(entry, &dev->msi_list, list) {
278 irq = tail; 268 write_msi_msg(entry->irq, &entry->msg);
269 msi_set_mask_bit(entry->irq, entry->msi_attrib.masked);
279 } 270 }
280 271
272 BUG_ON(list_empty(&dev->msi_list));
273 entry = list_entry(dev->msi_list.next, struct msi_desc, list);
274 pos = entry->msi_attrib.pos;
281 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control); 275 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control);
282 control &= ~PCI_MSIX_FLAGS_MASKALL; 276 control &= ~PCI_MSIX_FLAGS_MASKALL;
283 control |= PCI_MSIX_FLAGS_ENABLE; 277 control |= PCI_MSIX_FLAGS_ENABLE;
@@ -303,7 +297,7 @@ void pci_restore_msi_state(struct pci_dev *dev)
303static int msi_capability_init(struct pci_dev *dev) 297static int msi_capability_init(struct pci_dev *dev)
304{ 298{
305 struct msi_desc *entry; 299 struct msi_desc *entry;
306 int pos, irq; 300 int pos, ret;
307 u16 control; 301 u16 control;
308 302
309 msi_set_enable(dev, 0); /* Ensure msi is disabled as I set it up */ 303 msi_set_enable(dev, 0); /* Ensure msi is disabled as I set it up */
@@ -340,23 +334,21 @@ static int msi_capability_init(struct pci_dev *dev)
340 msi_mask_bits_reg(pos, is_64bit_address(control)), 334 msi_mask_bits_reg(pos, is_64bit_address(control)),
341 maskbits); 335 maskbits);
342 } 336 }
337 list_add(&entry->list, &dev->msi_list);
338
343 /* Configure MSI capability structure */ 339 /* Configure MSI capability structure */
344 irq = arch_setup_msi_irq(dev, entry); 340 ret = arch_setup_msi_irqs(dev, 1, PCI_CAP_ID_MSI);
345 if (irq < 0) { 341 if (ret) {
346 kmem_cache_free(msi_cachep, entry); 342 msi_free_irqs(dev);
347 return irq; 343 return ret;
348 } 344 }
349 entry->link.head = irq;
350 entry->link.tail = irq;
351 dev->first_msi_irq = irq;
352 set_irq_msi(irq, entry);
353 345
354 /* Set MSI enabled bits */ 346 /* Set MSI enabled bits */
355 pci_intx(dev, 0); /* disable intx */ 347 pci_intx(dev, 0); /* disable intx */
356 msi_set_enable(dev, 1); 348 msi_set_enable(dev, 1);
357 dev->msi_enabled = 1; 349 dev->msi_enabled = 1;
358 350
359 dev->irq = irq; 351 dev->irq = entry->irq;
360 return 0; 352 return 0;
361} 353}
362 354
@@ -373,8 +365,8 @@ static int msi_capability_init(struct pci_dev *dev)
373static int msix_capability_init(struct pci_dev *dev, 365static int msix_capability_init(struct pci_dev *dev,
374 struct msix_entry *entries, int nvec) 366 struct msix_entry *entries, int nvec)
375{ 367{
376 struct msi_desc *head = NULL, *tail = NULL, *entry = NULL; 368 struct msi_desc *entry;
377 int irq, pos, i, j, nr_entries, temp = 0; 369 int pos, i, j, nr_entries, ret;
378 unsigned long phys_addr; 370 unsigned long phys_addr;
379 u32 table_offset; 371 u32 table_offset;
380 u16 control; 372 u16 control;
@@ -413,44 +405,34 @@ static int msix_capability_init(struct pci_dev *dev,
413 entry->dev = dev; 405 entry->dev = dev;
414 entry->mask_base = base; 406 entry->mask_base = base;
415 407
416 /* Configure MSI-X capability structure */ 408 list_add(&entry->list, &dev->msi_list);
417 irq = arch_setup_msi_irq(dev, entry);
418 if (irq < 0) {
419 kmem_cache_free(msi_cachep, entry);
420 break;
421 }
422 entries[i].vector = irq;
423 if (!head) {
424 entry->link.head = irq;
425 entry->link.tail = irq;
426 head = entry;
427 } else {
428 entry->link.head = temp;
429 entry->link.tail = tail->link.tail;
430 tail->link.tail = irq;
431 head->link.head = irq;
432 }
433 temp = irq;
434 tail = entry;
435
436 set_irq_msi(irq, entry);
437 } 409 }
438 if (i != nvec) { 410
439 int avail = i - 1; 411 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
440 i--; 412 if (ret) {
441 for (; i >= 0; i--) { 413 int avail = 0;
442 irq = (entries + i)->vector; 414 list_for_each_entry(entry, &dev->msi_list, list) {
443 msi_free_irq(dev, irq); 415 if (entry->irq != 0) {
444 (entries + i)->vector = 0; 416 avail++;
417 }
445 } 418 }
419
420 msi_free_irqs(dev);
421
446 /* If we had some success report the number of irqs 422 /* If we had some success report the number of irqs
447 * we succeeded in setting up. 423 * we succeeded in setting up.
448 */ 424 */
449 if (avail <= 0) 425 if (avail == 0)
450 avail = -EBUSY; 426 avail = ret;
451 return avail; 427 return avail;
452 } 428 }
453 dev->first_msi_irq = entries[0].vector; 429
430 i = 0;
431 list_for_each_entry(entry, &dev->msi_list, list) {
432 entries[i].vector = entry->irq;
433 set_irq_msi(entry->irq, entry);
434 i++;
435 }
454 /* Set MSI-X enabled bits */ 436 /* Set MSI-X enabled bits */
455 pci_intx(dev, 0); /* disable intx */ 437 pci_intx(dev, 0); /* disable intx */
456 msix_set_enable(dev, 1); 438 msix_set_enable(dev, 1);
@@ -460,21 +442,32 @@ static int msix_capability_init(struct pci_dev *dev,
460} 442}
461 443
462/** 444/**
463 * pci_msi_supported - check whether MSI may be enabled on device 445 * pci_msi_check_device - check whether MSI may be enabled on a device
464 * @dev: pointer to the pci_dev data structure of MSI device function 446 * @dev: pointer to the pci_dev data structure of MSI device function
447 * @nvec: how many MSIs have been requested ?
448 * @type: are we checking for MSI or MSI-X ?
465 * 449 *
466 * Look at global flags, the device itself, and its parent busses 450 * Look at global flags, the device itself, and its parent busses
467 * to return 0 if MSI are supported for the device. 451 * to determine if MSI/-X are supported for the device. If MSI/-X is
452 * supported return 0, else return an error code.
468 **/ 453 **/
469static 454static int pci_msi_check_device(struct pci_dev* dev, int nvec, int type)
470int pci_msi_supported(struct pci_dev * dev)
471{ 455{
472 struct pci_bus *bus; 456 struct pci_bus *bus;
457 int ret;
473 458
474 /* MSI must be globally enabled and supported by the device */ 459 /* MSI must be globally enabled and supported by the device */
475 if (!pci_msi_enable || !dev || dev->no_msi) 460 if (!pci_msi_enable || !dev || dev->no_msi)
476 return -EINVAL; 461 return -EINVAL;
477 462
463 /*
464 * You can't ask to have 0 or less MSIs configured.
465 * a) it's stupid ..
466 * b) the list manipulation code assumes nvec >= 1.
467 */
468 if (nvec < 1)
469 return -ERANGE;
470
478 /* Any bridge which does NOT route MSI transactions from it's 471 /* Any bridge which does NOT route MSI transactions from it's
479 * secondary bus to it's primary bus must set NO_MSI flag on 472 * secondary bus to it's primary bus must set NO_MSI flag on
480 * the secondary pci_bus. 473 * the secondary pci_bus.
@@ -485,6 +478,13 @@ int pci_msi_supported(struct pci_dev * dev)
485 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) 478 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
486 return -EINVAL; 479 return -EINVAL;
487 480
481 ret = arch_msi_check_device(dev, nvec, type);
482 if (ret)
483 return ret;
484
485 if (!pci_find_capability(dev, type))
486 return -EINVAL;
487
488 return 0; 488 return 0;
489} 489}
490 490
@@ -500,19 +500,12 @@ int pci_msi_supported(struct pci_dev * dev)
500 **/ 500 **/
501int pci_enable_msi(struct pci_dev* dev) 501int pci_enable_msi(struct pci_dev* dev)
502{ 502{
503 int pos, status; 503 int status;
504
505 if (pci_msi_supported(dev) < 0)
506 return -EINVAL;
507 504
508 status = msi_init(); 505 status = pci_msi_check_device(dev, 1, PCI_CAP_ID_MSI);
509 if (status < 0) 506 if (status)
510 return status; 507 return status;
511 508
512 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
513 if (!pos)
514 return -EINVAL;
515
516 WARN_ON(!!dev->msi_enabled); 509 WARN_ON(!!dev->msi_enabled);
517 510
518 /* Check whether driver already requested for MSI-X irqs */ 511 /* Check whether driver already requested for MSI-X irqs */
@@ -525,69 +518,54 @@ int pci_enable_msi(struct pci_dev* dev)
525 status = msi_capability_init(dev); 518 status = msi_capability_init(dev);
526 return status; 519 return status;
527} 520}
521EXPORT_SYMBOL(pci_enable_msi);
528 522
529void pci_disable_msi(struct pci_dev* dev) 523void pci_disable_msi(struct pci_dev* dev)
530{ 524{
531 struct msi_desc *entry; 525 struct msi_desc *entry;
532 int default_irq; 526 int default_irq;
533 527
534 if (!pci_msi_enable) 528 if (!pci_msi_enable || !dev || !dev->msi_enabled)
535 return;
536 if (!dev)
537 return;
538
539 if (!dev->msi_enabled)
540 return; 529 return;
541 530
542 msi_set_enable(dev, 0); 531 msi_set_enable(dev, 0);
543 pci_intx(dev, 1); /* enable intx */ 532 pci_intx(dev, 1); /* enable intx */
544 dev->msi_enabled = 0; 533 dev->msi_enabled = 0;
545 534
546 entry = get_irq_msi(dev->first_msi_irq); 535 BUG_ON(list_empty(&dev->msi_list));
547 if (!entry || !entry->dev || entry->msi_attrib.type != PCI_CAP_ID_MSI) { 536 entry = list_entry(dev->msi_list.next, struct msi_desc, list);
537 if (!entry->dev || entry->msi_attrib.type != PCI_CAP_ID_MSI) {
548 return; 538 return;
549 } 539 }
550 if (irq_has_action(dev->first_msi_irq)) { 540
551 printk(KERN_WARNING "PCI: %s: pci_disable_msi() called without " 541 default_irq = entry->msi_attrib.default_irq;
552 "free_irq() on MSI irq %d\n", 542 msi_free_irqs(dev);
553 pci_name(dev), dev->first_msi_irq); 543
554 BUG_ON(irq_has_action(dev->first_msi_irq)); 544 /* Restore dev->irq to its default pin-assertion irq */
555 } else { 545 dev->irq = default_irq;
556 default_irq = entry->msi_attrib.default_irq;
557 msi_free_irq(dev, dev->first_msi_irq);
558
559 /* Restore dev->irq to its default pin-assertion irq */
560 dev->irq = default_irq;
561 }
562 dev->first_msi_irq = 0;
563} 546}
547EXPORT_SYMBOL(pci_disable_msi);
564 548
565static int msi_free_irq(struct pci_dev* dev, int irq) 549static int msi_free_irqs(struct pci_dev* dev)
566{ 550{
567 struct msi_desc *entry; 551 struct msi_desc *entry, *tmp;
568 int head, entry_nr, type;
569 void __iomem *base;
570 552
571 entry = get_irq_msi(irq); 553 list_for_each_entry(entry, &dev->msi_list, list)
572 if (!entry || entry->dev != dev) { 554 BUG_ON(irq_has_action(entry->irq));
573 return -EINVAL; 555
574 } 556 arch_teardown_msi_irqs(dev);
575 type = entry->msi_attrib.type; 557
576 entry_nr = entry->msi_attrib.entry_nr; 558 list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
577 head = entry->link.head; 559 if (entry->msi_attrib.type == PCI_CAP_ID_MSIX) {
578 base = entry->mask_base; 560 if (list_is_last(&entry->list, &dev->msi_list))
579 get_irq_msi(entry->link.head)->link.tail = entry->link.tail; 561 iounmap(entry->mask_base);
580 get_irq_msi(entry->link.tail)->link.head = entry->link.head; 562
581 563 writel(1, entry->mask_base + entry->msi_attrib.entry_nr
582 arch_teardown_msi_irq(irq); 564 * PCI_MSIX_ENTRY_SIZE
583 kmem_cache_free(msi_cachep, entry); 565 + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
584 566 }
585 if (type == PCI_CAP_ID_MSIX) { 567 list_del(&entry->list);
586 writel(1, base + entry_nr * PCI_MSIX_ENTRY_SIZE + 568 kfree(entry);
587 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
588
589 if (head == irq)
590 iounmap(base);
591 } 569 }
592 570
593 return 0; 571 return 0;
@@ -614,17 +592,14 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
614 int i, j; 592 int i, j;
615 u16 control; 593 u16 control;
616 594
617 if (!entries || pci_msi_supported(dev) < 0) 595 if (!entries)
618 return -EINVAL; 596 return -EINVAL;
619 597
620 status = msi_init(); 598 status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX);
621 if (status < 0) 599 if (status)
622 return status; 600 return status;
623 601
624 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); 602 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
625 if (!pos)
626 return -EINVAL;
627
628 pci_read_config_word(dev, msi_control_reg(pos), &control); 603 pci_read_config_word(dev, msi_control_reg(pos), &control);
629 nr_entries = multi_msix_capable(control); 604 nr_entries = multi_msix_capable(control);
630 if (nvec > nr_entries) 605 if (nvec > nr_entries)
@@ -651,41 +626,25 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
651 status = msix_capability_init(dev, entries, nvec); 626 status = msix_capability_init(dev, entries, nvec);
652 return status; 627 return status;
653} 628}
629EXPORT_SYMBOL(pci_enable_msix);
654 630
655void pci_disable_msix(struct pci_dev* dev) 631static void msix_free_all_irqs(struct pci_dev *dev)
656{ 632{
657 int irq, head, tail = 0, warning = 0; 633 msi_free_irqs(dev);
658 634}
659 if (!pci_msi_enable)
660 return;
661 if (!dev)
662 return;
663 635
664 if (!dev->msix_enabled) 636void pci_disable_msix(struct pci_dev* dev)
637{
638 if (!pci_msi_enable || !dev || !dev->msix_enabled)
665 return; 639 return;
666 640
667 msix_set_enable(dev, 0); 641 msix_set_enable(dev, 0);
668 pci_intx(dev, 1); /* enable intx */ 642 pci_intx(dev, 1); /* enable intx */
669 dev->msix_enabled = 0; 643 dev->msix_enabled = 0;
670 644
671 irq = head = dev->first_msi_irq; 645 msix_free_all_irqs(dev);
672 while (head != tail) {
673 tail = get_irq_msi(irq)->link.tail;
674 if (irq_has_action(irq))
675 warning = 1;
676 else if (irq != head) /* Release MSI-X irq */
677 msi_free_irq(dev, irq);
678 irq = tail;
679 }
680 msi_free_irq(dev, irq);
681 if (warning) {
682 printk(KERN_WARNING "PCI: %s: pci_disable_msix() called without "
683 "free_irq() on all MSI-X irqs\n",
684 pci_name(dev));
685 BUG_ON(warning > 0);
686 }
687 dev->first_msi_irq = 0;
688} 646}
647EXPORT_SYMBOL(pci_disable_msix);
689 648
690/** 649/**
691 * msi_remove_pci_irq_vectors - reclaim MSI(X) irqs to unused state 650 * msi_remove_pci_irq_vectors - reclaim MSI(X) irqs to unused state
@@ -701,38 +660,11 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
701 if (!pci_msi_enable || !dev) 660 if (!pci_msi_enable || !dev)
702 return; 661 return;
703 662
704 if (dev->msi_enabled) { 663 if (dev->msi_enabled)
705 if (irq_has_action(dev->first_msi_irq)) { 664 msi_free_irqs(dev);
706 printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() " 665
707 "called without free_irq() on MSI irq %d\n", 666 if (dev->msix_enabled)
708 pci_name(dev), dev->first_msi_irq); 667 msix_free_all_irqs(dev);
709 BUG_ON(irq_has_action(dev->first_msi_irq));
710 } else /* Release MSI irq assigned to this device */
711 msi_free_irq(dev, dev->first_msi_irq);
712 }
713 if (dev->msix_enabled) {
714 int irq, head, tail = 0, warning = 0;
715 void __iomem *base = NULL;
716
717 irq = head = dev->first_msi_irq;
718 while (head != tail) {
719 tail = get_irq_msi(irq)->link.tail;
720 base = get_irq_msi(irq)->mask_base;
721 if (irq_has_action(irq))
722 warning = 1;
723 else if (irq != head) /* Release MSI-X irq */
724 msi_free_irq(dev, irq);
725 irq = tail;
726 }
727 msi_free_irq(dev, irq);
728 if (warning) {
729 iounmap(base);
730 printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() "
731 "called without free_irq() on all MSI-X irqs\n",
732 pci_name(dev));
733 BUG_ON(warning > 0);
734 }
735 }
736} 668}
737 669
738void pci_no_msi(void) 670void pci_no_msi(void)
@@ -740,7 +672,53 @@ void pci_no_msi(void)
740 pci_msi_enable = 0; 672 pci_msi_enable = 0;
741} 673}
742 674
743EXPORT_SYMBOL(pci_enable_msi); 675void pci_msi_init_pci_dev(struct pci_dev *dev)
744EXPORT_SYMBOL(pci_disable_msi); 676{
745EXPORT_SYMBOL(pci_enable_msix); 677 INIT_LIST_HEAD(&dev->msi_list);
746EXPORT_SYMBOL(pci_disable_msix); 678}
679
680
681/* Arch hooks */
682
683int __attribute__ ((weak))
684arch_msi_check_device(struct pci_dev* dev, int nvec, int type)
685{
686 return 0;
687}
688
689int __attribute__ ((weak))
690arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *entry)
691{
692 return 0;
693}
694
695int __attribute__ ((weak))
696arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
697{
698 struct msi_desc *entry;
699 int ret;
700
701 list_for_each_entry(entry, &dev->msi_list, list) {
702 ret = arch_setup_msi_irq(dev, entry);
703 if (ret)
704 return ret;
705 }
706
707 return 0;
708}
709
710void __attribute__ ((weak)) arch_teardown_msi_irq(unsigned int irq)
711{
712 return;
713}
714
715void __attribute__ ((weak))
716arch_teardown_msi_irqs(struct pci_dev *dev)
717{
718 struct msi_desc *entry;
719
720 list_for_each_entry(entry, &dev->msi_list, list) {
721 if (entry->irq != 0)
722 arch_teardown_msi_irq(entry->irq);
723 }
724}
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 39e80fcef4b3..3bb7739d26a5 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -14,20 +14,6 @@
14#include "pci.h" 14#include "pci.h"
15 15
16/* 16/*
17 * Registration of PCI drivers and handling of hot-pluggable devices.
18 */
19
20/* multithreaded probe logic */
21static int pci_multithread_probe =
22#ifdef CONFIG_PCI_MULTITHREAD_PROBE
23 1;
24#else
25 0;
26#endif
27__module_param_call("", pci_multithread_probe, param_set_bool, param_get_bool, &pci_multithread_probe, 0644);
28
29
30/*
31 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG 17 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
32 */ 18 */
33 19
@@ -52,7 +38,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
52{ 38{
53 struct pci_dynid *dynid; 39 struct pci_dynid *dynid;
54 struct pci_driver *pdrv = to_pci_driver(driver); 40 struct pci_driver *pdrv = to_pci_driver(driver);
55 __u32 vendor=PCI_ANY_ID, device=PCI_ANY_ID, subvendor=PCI_ANY_ID, 41 __u32 vendor, device, subvendor=PCI_ANY_ID,
56 subdevice=PCI_ANY_ID, class=0, class_mask=0; 42 subdevice=PCI_ANY_ID, class=0, class_mask=0;
57 unsigned long driver_data=0; 43 unsigned long driver_data=0;
58 int fields=0; 44 int fields=0;
@@ -61,7 +47,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
61 fields = sscanf(buf, "%x %x %x %x %x %x %lux", 47 fields = sscanf(buf, "%x %x %x %x %x %x %lux",
62 &vendor, &device, &subvendor, &subdevice, 48 &vendor, &device, &subvendor, &subdevice,
63 &class, &class_mask, &driver_data); 49 &class, &class_mask, &driver_data);
64 if (fields < 0) 50 if (fields < 2)
65 return -EINVAL; 51 return -EINVAL;
66 52
67 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 53 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
@@ -569,7 +555,6 @@ struct bus_type pci_bus_type = {
569 555
570static int __init pci_driver_init(void) 556static int __init pci_driver_init(void)
571{ 557{
572 pci_bus_type.multithread_probe = pci_multithread_probe;
573 return bus_register(&pci_bus_type); 558 return bus_register(&pci_bus_type);
574} 559}
575 560
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index cd913a2a416f..284e83a527f9 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -620,7 +620,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
620 goto err_bin_file; 620 goto err_bin_file;
621 621
622 /* If the device has a ROM, try to expose it in sysfs. */ 622 /* If the device has a ROM, try to expose it in sysfs. */
623 if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { 623 if (pci_resource_len(pdev, PCI_ROM_RESOURCE) ||
624 (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)) {
624 rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); 625 rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC);
625 if (rom_attr) { 626 if (rom_attr) {
626 pdev->rom_attr = rom_attr; 627 pdev->rom_attr = rom_attr;
@@ -635,7 +636,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
635 goto err_rom; 636 goto err_rom;
636 } else { 637 } else {
637 retval = -ENOMEM; 638 retval = -ENOMEM;
638 goto err_bin_file; 639 goto err_resource_files;
639 } 640 }
640 } 641 }
641 /* add platform-specific attributes */ 642 /* add platform-specific attributes */
@@ -645,6 +646,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
645 646
646err_rom: 647err_rom:
647 kfree(rom_attr); 648 kfree(rom_attr);
649err_resource_files:
650 pci_remove_resource_files(pdev);
648err_bin_file: 651err_bin_file:
649 if (pdev->cfg_size < 4096) 652 if (pdev->cfg_size < 4096)
650 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); 653 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
@@ -695,4 +698,4 @@ static int __init pci_sysfs_init(void)
695 return 0; 698 return 0;
696} 699}
697 700
698__initcall(pci_sysfs_init); 701late_initcall(pci_sysfs_init);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2a458279327a..fd47ac0c4730 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -35,8 +35,7 @@ unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
35 * Given a PCI bus, returns the highest PCI bus number present in the set 35 * Given a PCI bus, returns the highest PCI bus number present in the set
36 * including the given PCI bus and its list of child PCI buses. 36 * including the given PCI bus and its list of child PCI buses.
37 */ 37 */
38unsigned char __devinit 38unsigned char pci_bus_max_busnr(struct pci_bus* bus)
39pci_bus_max_busnr(struct pci_bus* bus)
40{ 39{
41 struct list_head *tmp; 40 struct list_head *tmp;
42 unsigned char max, n; 41 unsigned char max, n;
@@ -892,6 +891,34 @@ pci_disable_device(struct pci_dev *dev)
892} 891}
893 892
894/** 893/**
894 * pcibios_set_pcie_reset_state - set reset state for device dev
895 * @dev: the PCI-E device reset
896 * @state: Reset state to enter into
897 *
898 *
899 * Sets the PCI-E reset state for the device. This is the default
900 * implementation. Architecture implementations can override this.
901 */
902int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
903 enum pcie_reset_state state)
904{
905 return -EINVAL;
906}
907
908/**
909 * pci_set_pcie_reset_state - set reset state for device dev
910 * @dev: the PCI-E device reset
911 * @state: Reset state to enter into
912 *
913 *
914 * Sets the PCI reset state for the device.
915 */
916int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
917{
918 return pcibios_set_pcie_reset_state(dev, state);
919}
920
921/**
895 * pci_enable_wake - enable PCI device as wakeup event source 922 * pci_enable_wake - enable PCI device as wakeup event source
896 * @dev: PCI device affected 923 * @dev: PCI device affected
897 * @state: PCI state from which device will issue wakeup events 924 * @state: PCI state from which device will issue wakeup events
@@ -1295,7 +1322,7 @@ pci_intx(struct pci_dev *pdev, int enable)
1295 1322
1296/** 1323/**
1297 * pci_msi_off - disables any msi or msix capabilities 1324 * pci_msi_off - disables any msi or msix capabilities
1298 * @pdev: the PCI device to operate on 1325 * @dev: the PCI device to operate on
1299 * 1326 *
1300 * If you want to use msi see pci_enable_msi and friends. 1327 * If you want to use msi see pci_enable_msi and friends.
1301 * This is a lower level primitive that allows us to disable 1328 * This is a lower level primitive that allows us to disable
@@ -1427,4 +1454,5 @@ EXPORT_SYMBOL(pci_set_power_state);
1427EXPORT_SYMBOL(pci_save_state); 1454EXPORT_SYMBOL(pci_save_state);
1428EXPORT_SYMBOL(pci_restore_state); 1455EXPORT_SYMBOL(pci_restore_state);
1429EXPORT_SYMBOL(pci_enable_wake); 1456EXPORT_SYMBOL(pci_enable_wake);
1457EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
1430 1458
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 62ea04c8af64..3fec13d3add7 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -47,8 +47,10 @@ extern unsigned int pci_pm_d3_delay;
47 47
48#ifdef CONFIG_PCI_MSI 48#ifdef CONFIG_PCI_MSI
49void pci_no_msi(void); 49void pci_no_msi(void);
50extern void pci_msi_init_pci_dev(struct pci_dev *dev);
50#else 51#else
51static inline void pci_no_msi(void) { } 52static inline void pci_no_msi(void) { }
53static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { }
52#endif 54#endif
53 55
54#if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM) 56#if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 2fe1d690eb13..e48fcf089621 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -364,7 +364,7 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
364 } 364 }
365} 365}
366 366
367static struct pci_bus * __devinit pci_alloc_bus(void) 367static struct pci_bus * pci_alloc_bus(void)
368{ 368{
369 struct pci_bus *b; 369 struct pci_bus *b;
370 370
@@ -432,7 +432,7 @@ error_register:
432 return NULL; 432 return NULL;
433} 433}
434 434
435struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr) 435struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr)
436{ 436{
437 struct pci_bus *child; 437 struct pci_bus *child;
438 438
@@ -461,7 +461,7 @@ static void pci_enable_crs(struct pci_dev *dev)
461 pci_write_config_word(dev, rpcap + PCI_EXP_RTCTL, rpctl); 461 pci_write_config_word(dev, rpcap + PCI_EXP_RTCTL, rpctl);
462} 462}
463 463
464static void __devinit pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max) 464static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max)
465{ 465{
466 struct pci_bus *parent = child->parent; 466 struct pci_bus *parent = child->parent;
467 467
@@ -477,7 +477,7 @@ static void __devinit pci_fixup_parent_subordinate_busnr(struct pci_bus *child,
477 } 477 }
478} 478}
479 479
480unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus); 480unsigned int pci_scan_child_bus(struct pci_bus *bus);
481 481
482/* 482/*
483 * If it's a bridge, configure it and scan the bus behind it. 483 * If it's a bridge, configure it and scan the bus behind it.
@@ -489,7 +489,7 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus);
489 * them, we proceed to assigning numbers to the remaining buses in 489 * them, we proceed to assigning numbers to the remaining buses in
490 * order to avoid overlaps between old and new bus numbers. 490 * order to avoid overlaps between old and new bus numbers.
491 */ 491 */
492int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass) 492int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass)
493{ 493{
494 struct pci_bus *child; 494 struct pci_bus *child;
495 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); 495 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
@@ -846,6 +846,23 @@ static void pci_release_bus_bridge_dev(struct device *dev)
846 kfree(dev); 846 kfree(dev);
847} 847}
848 848
849struct pci_dev *alloc_pci_dev(void)
850{
851 struct pci_dev *dev;
852
853 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
854 if (!dev)
855 return NULL;
856
857 INIT_LIST_HEAD(&dev->global_list);
858 INIT_LIST_HEAD(&dev->bus_list);
859
860 pci_msi_init_pci_dev(dev);
861
862 return dev;
863}
864EXPORT_SYMBOL(alloc_pci_dev);
865
849/* 866/*
850 * Read the config data for a PCI device, sanity-check it 867 * Read the config data for a PCI device, sanity-check it
851 * and fill in the dev structure... 868 * and fill in the dev structure...
@@ -885,7 +902,7 @@ pci_scan_device(struct pci_bus *bus, int devfn)
885 if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) 902 if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type))
886 return NULL; 903 return NULL;
887 904
888 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 905 dev = alloc_pci_dev();
889 if (!dev) 906 if (!dev)
890 return NULL; 907 return NULL;
891 908
@@ -912,7 +929,7 @@ pci_scan_device(struct pci_bus *bus, int devfn)
912 return dev; 929 return dev;
913} 930}
914 931
915void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus) 932void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
916{ 933{
917 device_initialize(&dev->dev); 934 device_initialize(&dev->dev);
918 dev->dev.release = pci_release_dev; 935 dev->dev.release = pci_release_dev;
@@ -935,8 +952,7 @@ void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
935 up_write(&pci_bus_sem); 952 up_write(&pci_bus_sem);
936} 953}
937 954
938struct pci_dev * __devinit 955struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn)
939pci_scan_single_device(struct pci_bus *bus, int devfn)
940{ 956{
941 struct pci_dev *dev; 957 struct pci_dev *dev;
942 958
@@ -958,7 +974,7 @@ pci_scan_single_device(struct pci_bus *bus, int devfn)
958 * discovered devices to the @bus->devices list. New devices 974 * discovered devices to the @bus->devices list. New devices
959 * will have an empty dev->global_list head. 975 * will have an empty dev->global_list head.
960 */ 976 */
961int __devinit pci_scan_slot(struct pci_bus *bus, int devfn) 977int pci_scan_slot(struct pci_bus *bus, int devfn)
962{ 978{
963 int func, nr = 0; 979 int func, nr = 0;
964 int scan_all_fns; 980 int scan_all_fns;
@@ -991,7 +1007,7 @@ int __devinit pci_scan_slot(struct pci_bus *bus, int devfn)
991 return nr; 1007 return nr;
992} 1008}
993 1009
994unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) 1010unsigned int pci_scan_child_bus(struct pci_bus *bus)
995{ 1011{
996 unsigned int devfn, pass, max = bus->secondary; 1012 unsigned int devfn, pass, max = bus->secondary;
997 struct pci_dev *dev; 1013 struct pci_dev *dev;
@@ -1041,7 +1057,7 @@ unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus)
1041 return max; 1057 return max;
1042} 1058}
1043 1059
1044struct pci_bus * __devinit pci_create_bus(struct device *parent, 1060struct pci_bus * pci_create_bus(struct device *parent,
1045 int bus, struct pci_ops *ops, void *sysdata) 1061 int bus, struct pci_ops *ops, void *sysdata)
1046{ 1062{
1047 int error; 1063 int error;
@@ -1119,7 +1135,7 @@ err_out:
1119} 1135}
1120EXPORT_SYMBOL_GPL(pci_create_bus); 1136EXPORT_SYMBOL_GPL(pci_create_bus);
1121 1137
1122struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, 1138struct pci_bus *pci_scan_bus_parented(struct device *parent,
1123 int bus, struct pci_ops *ops, void *sysdata) 1139 int bus, struct pci_ops *ops, void *sysdata)
1124{ 1140{
1125 struct pci_bus *b; 1141 struct pci_bus *b;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 3411483240cd..147d86f8edbf 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1648,6 +1648,8 @@ static void __devinit quirk_disable_msi(struct pci_dev *dev)
1648 } 1648 }
1649} 1649}
1650DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi); 1650DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi);
1651DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_msi);
1652DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, quirk_disable_msi);
1651 1653
1652/* Go through the list of Hypertransport capabilities and 1654/* Go through the list of Hypertransport capabilities and
1653 * return 1 if a HT MSI capability is found and enabled */ 1655 * return 1 if a HT MSI capability is found and enabled */
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 2dd8681d6b31..b137a27472c7 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -15,8 +15,7 @@
15 15
16DECLARE_RWSEM(pci_bus_sem); 16DECLARE_RWSEM(pci_bus_sem);
17 17
18static struct pci_bus * 18static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
19pci_do_find_bus(struct pci_bus* bus, unsigned char busnr)
20{ 19{
21 struct pci_bus* child; 20 struct pci_bus* child;
22 struct list_head *tmp; 21 struct list_head *tmp;
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 3554f3948814..5ec297d7a5b4 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -36,8 +36,7 @@
36 36
37#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) 37#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
38 38
39static void __devinit 39static void pbus_assign_resources_sorted(struct pci_bus *bus)
40pbus_assign_resources_sorted(struct pci_bus *bus)
41{ 40{
42 struct pci_dev *dev; 41 struct pci_dev *dev;
43 struct resource *res; 42 struct resource *res;
@@ -220,8 +219,7 @@ pci_setup_bridge(struct pci_bus *bus)
220/* Check whether the bridge supports optional I/O and 219/* Check whether the bridge supports optional I/O and
221 prefetchable memory ranges. If not, the respective 220 prefetchable memory ranges. If not, the respective
222 base/limit registers must be read-only and read as 0. */ 221 base/limit registers must be read-only and read as 0. */
223static void __devinit 222static void pci_bridge_check_ranges(struct pci_bus *bus)
224pci_bridge_check_ranges(struct pci_bus *bus)
225{ 223{
226 u16 io; 224 u16 io;
227 u32 pmem; 225 u32 pmem;
@@ -259,8 +257,7 @@ pci_bridge_check_ranges(struct pci_bus *bus)
259 bus resource of a given type. Note: we intentionally skip 257 bus resource of a given type. Note: we intentionally skip
260 the bus resources which have already been assigned (that is, 258 the bus resources which have already been assigned (that is,
261 have non-NULL parent resource). */ 259 have non-NULL parent resource). */
262static struct resource * __devinit 260static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned long type)
263find_free_bus_resource(struct pci_bus *bus, unsigned long type)
264{ 261{
265 int i; 262 int i;
266 struct resource *r; 263 struct resource *r;
@@ -281,8 +278,7 @@ find_free_bus_resource(struct pci_bus *bus, unsigned long type)
281 since these windows have 4K granularity and the IO ranges 278 since these windows have 4K granularity and the IO ranges
282 of non-bridge PCI devices are limited to 256 bytes. 279 of non-bridge PCI devices are limited to 256 bytes.
283 We must be careful with the ISA aliasing though. */ 280 We must be careful with the ISA aliasing though. */
284static void __devinit 281static void pbus_size_io(struct pci_bus *bus)
285pbus_size_io(struct pci_bus *bus)
286{ 282{
287 struct pci_dev *dev; 283 struct pci_dev *dev;
288 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); 284 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
@@ -326,8 +322,7 @@ pbus_size_io(struct pci_bus *bus)
326 322
327/* Calculate the size of the bus and minimal alignment which 323/* Calculate the size of the bus and minimal alignment which
328 guarantees that all child resources fit in this size. */ 324 guarantees that all child resources fit in this size. */
329static int __devinit 325static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type)
330pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type)
331{ 326{
332 struct pci_dev *dev; 327 struct pci_dev *dev;
333 unsigned long min_align, align, size; 328 unsigned long min_align, align, size;
@@ -447,8 +442,7 @@ pci_bus_size_cardbus(struct pci_bus *bus)
447 } 442 }
448} 443}
449 444
450void __devinit 445void pci_bus_size_bridges(struct pci_bus *bus)
451pci_bus_size_bridges(struct pci_bus *bus)
452{ 446{
453 struct pci_dev *dev; 447 struct pci_dev *dev;
454 unsigned long mask, prefmask; 448 unsigned long mask, prefmask;
@@ -498,8 +492,7 @@ pci_bus_size_bridges(struct pci_bus *bus)
498} 492}
499EXPORT_SYMBOL(pci_bus_size_bridges); 493EXPORT_SYMBOL(pci_bus_size_bridges);
500 494
501void __devinit 495void pci_bus_assign_resources(struct pci_bus *bus)
502pci_bus_assign_resources(struct pci_bus *bus)
503{ 496{
504 struct pci_bus *b; 497 struct pci_bus *b;
505 struct pci_dev *dev; 498 struct pci_dev *dev;
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index cb4ced3560e9..6dfd86167e39 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -101,8 +101,7 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
101 new & ~PCI_REGION_FLAG_MASK); 101 new & ~PCI_REGION_FLAG_MASK);
102} 102}
103 103
104int __devinit 104int pci_claim_resource(struct pci_dev *dev, int resource)
105pci_claim_resource(struct pci_dev *dev, int resource)
106{ 105{
107 struct resource *res = &dev->resource[resource]; 106 struct resource *res = &dev->resource[resource];
108 struct resource *root = NULL; 107 struct resource *root = NULL;
@@ -212,8 +211,7 @@ EXPORT_SYMBOL_GPL(pci_assign_resource_fixed);
212#endif 211#endif
213 212
214/* Sort resources by alignment */ 213/* Sort resources by alignment */
215void __devinit 214void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
216pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
217{ 215{
218 int i; 216 int i;
219 217
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index ac004248324a..50cad3a59a6c 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -26,7 +26,6 @@
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/pci.h>
30#include <linux/device.h> 29#include <linux/device.h>
31#include <linux/kthread.h> 30#include <linux/kthread.h>
32#include <linux/freezer.h> 31#include <linux/freezer.h>
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index ea5765c3bdc0..a2bb46526b56 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -22,7 +22,6 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/pm.h> 24#include <linux/pm.h>
25#include <linux/pci.h>
26#include <linux/device.h> 25#include <linux/device.h>
27#include <linux/mutex.h> 26#include <linux/mutex.h>
28#include <asm/system.h> 27#include <asm/system.h>
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index d21e04ccb021..1393e64335f9 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -38,7 +38,24 @@
38static int timeout = 5000; /* in msec ( 5 sec ) */ 38static int timeout = 5000; /* in msec ( 5 sec ) */
39module_param(timeout, int, 0644); 39module_param(timeout, int, 0644);
40 40
41static struct ps3av ps3av; 41static struct ps3av {
42 int available;
43 struct mutex mutex;
44 struct work_struct work;
45 struct completion done;
46 struct workqueue_struct *wq;
47 int open_count;
48 struct ps3_vuart_port_device *dev;
49
50 int region;
51 struct ps3av_pkt_av_get_hw_conf av_hw_conf;
52 u32 av_port[PS3AV_AV_PORT_MAX + PS3AV_OPT_PORT_MAX];
53 u32 opt_port[PS3AV_OPT_PORT_MAX];
54 u32 head[PS3AV_HEAD_MAX];
55 u32 audio_port;
56 int ps3av_mode;
57 int ps3av_mode_old;
58} ps3av;
42 59
43static struct ps3_vuart_port_device ps3av_dev = { 60static struct ps3_vuart_port_device ps3av_dev = {
44 .match_id = PS3_MATCH_ID_AV_SETTINGS 61 .match_id = PS3_MATCH_ID_AV_SETTINGS
@@ -159,7 +176,7 @@ static int ps3av_parse_event_packet(const struct ps3av_reply_hdr *hdr)
159 else 176 else
160 printk(KERN_ERR 177 printk(KERN_ERR
161 "%s: failed event packet, cid:%08x size:%d\n", 178 "%s: failed event packet, cid:%08x size:%d\n",
162 __FUNCTION__, hdr->cid, hdr->size); 179 __func__, hdr->cid, hdr->size);
163 return 1; /* receive event packet */ 180 return 1; /* receive event packet */
164 } 181 }
165 return 0; 182 return 0;
@@ -181,7 +198,7 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
181 if (res < 0) { 198 if (res < 0) {
182 dev_dbg(&ps3av_dev.core, 199 dev_dbg(&ps3av_dev.core,
183 "%s: ps3av_vuart_write() failed (result=%d)\n", 200 "%s: ps3av_vuart_write() failed (result=%d)\n",
184 __FUNCTION__, res); 201 __func__, res);
185 return res; 202 return res;
186 } 203 }
187 204
@@ -194,7 +211,7 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
194 if (res != PS3AV_HDR_SIZE) { 211 if (res != PS3AV_HDR_SIZE) {
195 dev_dbg(&ps3av_dev.core, 212 dev_dbg(&ps3av_dev.core,
196 "%s: ps3av_vuart_read() failed (result=%d)\n", 213 "%s: ps3av_vuart_read() failed (result=%d)\n",
197 __FUNCTION__, res); 214 __func__, res);
198 return res; 215 return res;
199 } 216 }
200 217
@@ -204,7 +221,7 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
204 if (res < 0) { 221 if (res < 0) {
205 dev_dbg(&ps3av_dev.core, 222 dev_dbg(&ps3av_dev.core,
206 "%s: ps3av_vuart_read() failed (result=%d)\n", 223 "%s: ps3av_vuart_read() failed (result=%d)\n",
207 __FUNCTION__, res); 224 __func__, res);
208 return res; 225 return res;
209 } 226 }
210 res += PS3AV_HDR_SIZE; /* total len */ 227 res += PS3AV_HDR_SIZE; /* total len */
@@ -214,7 +231,7 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
214 231
215 if ((cmd | PS3AV_REPLY_BIT) != recv_buf->cid) { 232 if ((cmd | PS3AV_REPLY_BIT) != recv_buf->cid) {
216 dev_dbg(&ps3av_dev.core, "%s: reply err (result=%x)\n", 233 dev_dbg(&ps3av_dev.core, "%s: reply err (result=%x)\n",
217 __FUNCTION__, recv_buf->cid); 234 __func__, recv_buf->cid);
218 return -EINVAL; 235 return -EINVAL;
219 } 236 }
220 237
@@ -250,7 +267,7 @@ int ps3av_do_pkt(u32 cid, u16 send_len, size_t usr_buf_size,
250 struct ps3av_send_hdr *buf) 267 struct ps3av_send_hdr *buf)
251{ 268{
252 int res = 0; 269 int res = 0;
253 union { 270 static union {
254 struct ps3av_reply_hdr reply_hdr; 271 struct ps3av_reply_hdr reply_hdr;
255 u8 raw[PS3AV_BUF_SIZE]; 272 u8 raw[PS3AV_BUF_SIZE];
256 } recv_buf; 273 } recv_buf;
@@ -259,8 +276,7 @@ int ps3av_do_pkt(u32 cid, u16 send_len, size_t usr_buf_size,
259 276
260 BUG_ON(!ps3av.available); 277 BUG_ON(!ps3av.available);
261 278
262 if (down_interruptible(&ps3av.sem)) 279 mutex_lock(&ps3av.mutex);
263 return -ERESTARTSYS;
264 280
265 table = ps3av_search_cmd_table(cid, PS3AV_CID_MASK); 281 table = ps3av_search_cmd_table(cid, PS3AV_CID_MASK);
266 BUG_ON(!table); 282 BUG_ON(!table);
@@ -277,7 +293,7 @@ int ps3av_do_pkt(u32 cid, u16 send_len, size_t usr_buf_size,
277 if (res < 0) { 293 if (res < 0) {
278 printk(KERN_ERR 294 printk(KERN_ERR
279 "%s: ps3av_send_cmd_pkt() failed (result=%d)\n", 295 "%s: ps3av_send_cmd_pkt() failed (result=%d)\n",
280 __FUNCTION__, res); 296 __func__, res);
281 goto err; 297 goto err;
282 } 298 }
283 299
@@ -286,16 +302,16 @@ int ps3av_do_pkt(u32 cid, u16 send_len, size_t usr_buf_size,
286 usr_buf_size); 302 usr_buf_size);
287 if (res < 0) { 303 if (res < 0) {
288 printk(KERN_ERR "%s: put_return_status() failed (result=%d)\n", 304 printk(KERN_ERR "%s: put_return_status() failed (result=%d)\n",
289 __FUNCTION__, res); 305 __func__, res);
290 goto err; 306 goto err;
291 } 307 }
292 308
293 up(&ps3av.sem); 309 mutex_unlock(&ps3av.mutex);
294 return 0; 310 return 0;
295 311
296 err: 312 err:
297 up(&ps3av.sem); 313 mutex_unlock(&ps3av.mutex);
298 printk(KERN_ERR "%s: failed cid:%x res:%d\n", __FUNCTION__, cid, res); 314 printk(KERN_ERR "%s: failed cid:%x res:%d\n", __func__, cid, res);
299 return res; 315 return res;
300} 316}
301 317
@@ -440,7 +456,7 @@ static int ps3av_set_videomode(void)
440 ps3av_set_av_video_mute(PS3AV_CMD_MUTE_ON); 456 ps3av_set_av_video_mute(PS3AV_CMD_MUTE_ON);
441 457
442 /* wake up ps3avd to do the actual video mode setting */ 458 /* wake up ps3avd to do the actual video mode setting */
443 up(&ps3av.ping); 459 queue_work(ps3av.wq, &ps3av.work);
444 460
445 return 0; 461 return 0;
446} 462}
@@ -506,7 +522,7 @@ static void ps3av_set_videomode_cont(u32 id, u32 old_id)
506 if (res == PS3AV_STATUS_NO_SYNC_HEAD) 522 if (res == PS3AV_STATUS_NO_SYNC_HEAD)
507 printk(KERN_WARNING 523 printk(KERN_WARNING
508 "%s: Command failed. Please try your request again. \n", 524 "%s: Command failed. Please try your request again. \n",
509 __FUNCTION__); 525 __func__);
510 else if (res) 526 else if (res)
511 dev_dbg(&ps3av_dev.core, "ps3av_cmd_avb_param failed\n"); 527 dev_dbg(&ps3av_dev.core, "ps3av_cmd_avb_param failed\n");
512 528
@@ -515,18 +531,10 @@ static void ps3av_set_videomode_cont(u32 id, u32 old_id)
515 ps3av_set_av_video_mute(PS3AV_CMD_MUTE_OFF); 531 ps3av_set_av_video_mute(PS3AV_CMD_MUTE_OFF);
516} 532}
517 533
518static int ps3avd(void *p) 534static void ps3avd(struct work_struct *work)
519{ 535{
520 struct ps3av *info = p; 536 ps3av_set_videomode_cont(ps3av.ps3av_mode, ps3av.ps3av_mode_old);
521 537 complete(&ps3av.done);
522 daemonize("ps3avd");
523 while (1) {
524 down(&info->ping);
525 ps3av_set_videomode_cont(info->ps3av_mode,
526 info->ps3av_mode_old);
527 up(&info->pong);
528 }
529 return 0;
530} 538}
531 539
532static int ps3av_vid2table_id(int vid) 540static int ps3av_vid2table_id(int vid)
@@ -707,8 +715,7 @@ int ps3av_set_video_mode(u32 id, int boot)
707 715
708 size = ARRAY_SIZE(video_mode_table); 716 size = ARRAY_SIZE(video_mode_table);
709 if ((id & PS3AV_MODE_MASK) > size - 1 || id < 0) { 717 if ((id & PS3AV_MODE_MASK) > size - 1 || id < 0) {
710 dev_dbg(&ps3av_dev.core, "%s: error id :%d\n", __FUNCTION__, 718 dev_dbg(&ps3av_dev.core, "%s: error id :%d\n", __func__, id);
711 id);
712 return -EINVAL; 719 return -EINVAL;
713 } 720 }
714 721
@@ -717,15 +724,14 @@ int ps3av_set_video_mode(u32 id, int boot)
717 if ((id & PS3AV_MODE_MASK) == 0) { 724 if ((id & PS3AV_MODE_MASK) == 0) {
718 id = ps3av_auto_videomode(&ps3av.av_hw_conf, boot); 725 id = ps3av_auto_videomode(&ps3av.av_hw_conf, boot);
719 if (id < 1) { 726 if (id < 1) {
720 printk(KERN_ERR "%s: invalid id :%d\n", __FUNCTION__, 727 printk(KERN_ERR "%s: invalid id :%d\n", __func__, id);
721 id);
722 return -EINVAL; 728 return -EINVAL;
723 } 729 }
724 id |= option; 730 id |= option;
725 } 731 }
726 732
727 /* set videomode */ 733 /* set videomode */
728 down(&ps3av.pong); 734 wait_for_completion(&ps3av.done);
729 ps3av.ps3av_mode_old = ps3av.ps3av_mode; 735 ps3av.ps3av_mode_old = ps3av.ps3av_mode;
730 ps3av.ps3av_mode = id; 736 ps3av.ps3av_mode = id;
731 if (ps3av_set_videomode()) 737 if (ps3av_set_videomode())
@@ -736,6 +742,13 @@ int ps3av_set_video_mode(u32 id, int boot)
736 742
737EXPORT_SYMBOL_GPL(ps3av_set_video_mode); 743EXPORT_SYMBOL_GPL(ps3av_set_video_mode);
738 744
745int ps3av_get_auto_mode(int boot)
746{
747 return ps3av_auto_videomode(&ps3av.av_hw_conf, boot);
748}
749
750EXPORT_SYMBOL_GPL(ps3av_get_auto_mode);
751
739int ps3av_set_mode(u32 id, int boot) 752int ps3av_set_mode(u32 id, int boot)
740{ 753{
741 int res; 754 int res;
@@ -771,7 +784,7 @@ int ps3av_get_scanmode(int id)
771 id = id & PS3AV_MODE_MASK; 784 id = id & PS3AV_MODE_MASK;
772 size = ARRAY_SIZE(video_mode_table); 785 size = ARRAY_SIZE(video_mode_table);
773 if (id > size - 1 || id < 0) { 786 if (id > size - 1 || id < 0) {
774 printk(KERN_ERR "%s: invalid mode %d\n", __FUNCTION__, id); 787 printk(KERN_ERR "%s: invalid mode %d\n", __func__, id);
775 return -EINVAL; 788 return -EINVAL;
776 } 789 }
777 return video_mode_table[id].interlace; 790 return video_mode_table[id].interlace;
@@ -786,7 +799,7 @@ int ps3av_get_refresh_rate(int id)
786 id = id & PS3AV_MODE_MASK; 799 id = id & PS3AV_MODE_MASK;
787 size = ARRAY_SIZE(video_mode_table); 800 size = ARRAY_SIZE(video_mode_table);
788 if (id > size - 1 || id < 0) { 801 if (id > size - 1 || id < 0) {
789 printk(KERN_ERR "%s: invalid mode %d\n", __FUNCTION__, id); 802 printk(KERN_ERR "%s: invalid mode %d\n", __func__, id);
790 return -EINVAL; 803 return -EINVAL;
791 } 804 }
792 return video_mode_table[id].freq; 805 return video_mode_table[id].freq;
@@ -802,7 +815,7 @@ int ps3av_video_mode2res(u32 id, u32 *xres, u32 *yres)
802 id = id & PS3AV_MODE_MASK; 815 id = id & PS3AV_MODE_MASK;
803 size = ARRAY_SIZE(video_mode_table); 816 size = ARRAY_SIZE(video_mode_table);
804 if (id > size - 1 || id < 0) { 817 if (id > size - 1 || id < 0) {
805 printk(KERN_ERR "%s: invalid mode %d\n", __FUNCTION__, id); 818 printk(KERN_ERR "%s: invalid mode %d\n", __func__, id);
806 return -EINVAL; 819 return -EINVAL;
807 } 820 }
808 *xres = video_mode_table[id].x; 821 *xres = video_mode_table[id].x;
@@ -838,7 +851,7 @@ int ps3av_dev_open(void)
838 status = lv1_gpu_open(0); 851 status = lv1_gpu_open(0);
839 if (status) { 852 if (status) {
840 printk(KERN_ERR "%s: lv1_gpu_open failed %d\n", 853 printk(KERN_ERR "%s: lv1_gpu_open failed %d\n",
841 __FUNCTION__, status); 854 __func__, status);
842 ps3av.open_count--; 855 ps3av.open_count--;
843 } 856 }
844 } 857 }
@@ -855,13 +868,13 @@ int ps3av_dev_close(void)
855 868
856 mutex_lock(&ps3av.mutex); 869 mutex_lock(&ps3av.mutex);
857 if (ps3av.open_count <= 0) { 870 if (ps3av.open_count <= 0) {
858 printk(KERN_ERR "%s: GPU already closed\n", __FUNCTION__); 871 printk(KERN_ERR "%s: GPU already closed\n", __func__);
859 status = -1; 872 status = -1;
860 } else if (!--ps3av.open_count) { 873 } else if (!--ps3av.open_count) {
861 status = lv1_gpu_close(); 874 status = lv1_gpu_close();
862 if (status) 875 if (status)
863 printk(KERN_WARNING "%s: lv1_gpu_close failed %d\n", 876 printk(KERN_WARNING "%s: lv1_gpu_close failed %d\n",
864 __FUNCTION__, status); 877 __func__, status);
865 } 878 }
866 mutex_unlock(&ps3av.mutex); 879 mutex_unlock(&ps3av.mutex);
867 880
@@ -880,13 +893,16 @@ static int ps3av_probe(struct ps3_vuart_port_device *dev)
880 893
881 memset(&ps3av, 0, sizeof(ps3av)); 894 memset(&ps3av, 0, sizeof(ps3av));
882 895
883 init_MUTEX(&ps3av.sem);
884 init_MUTEX_LOCKED(&ps3av.ping);
885 init_MUTEX(&ps3av.pong);
886 mutex_init(&ps3av.mutex); 896 mutex_init(&ps3av.mutex);
887 ps3av.ps3av_mode = 0; 897 ps3av.ps3av_mode = 0;
888 ps3av.dev = dev; 898 ps3av.dev = dev;
889 kernel_thread(ps3avd, &ps3av, CLONE_KERNEL); 899
900 INIT_WORK(&ps3av.work, ps3avd);
901 init_completion(&ps3av.done);
902 complete(&ps3av.done);
903 ps3av.wq = create_singlethread_workqueue("ps3avd");
904 if (!ps3av.wq)
905 return -ENOMEM;
890 906
891 ps3av.available = 1; 907 ps3av.available = 1;
892 switch (ps3_os_area_get_av_multi_out()) { 908 switch (ps3_os_area_get_av_multi_out()) {
@@ -908,7 +924,7 @@ static int ps3av_probe(struct ps3_vuart_port_device *dev)
908 /* init avsetting modules */ 924 /* init avsetting modules */
909 res = ps3av_cmd_init(); 925 res = ps3av_cmd_init();
910 if (res < 0) 926 if (res < 0)
911 printk(KERN_ERR "%s: ps3av_cmd_init failed %d\n", __FUNCTION__, 927 printk(KERN_ERR "%s: ps3av_cmd_init failed %d\n", __func__,
912 res); 928 res);
913 929
914 ps3av_get_hw_conf(&ps3av); 930 ps3av_get_hw_conf(&ps3av);
@@ -926,6 +942,8 @@ static int ps3av_remove(struct ps3_vuart_port_device *dev)
926{ 942{
927 if (ps3av.available) { 943 if (ps3av.available) {
928 ps3av_cmd_fin(); 944 ps3av_cmd_fin();
945 if (ps3av.wq)
946 destroy_workqueue(ps3av.wq);
929 ps3av.available = 0; 947 ps3av.available = 0;
930 } 948 }
931 949
@@ -958,7 +976,7 @@ static int ps3av_module_init(void)
958 if (error) { 976 if (error) {
959 printk(KERN_ERR 977 printk(KERN_ERR
960 "%s: ps3_vuart_port_driver_register failed %d\n", 978 "%s: ps3_vuart_port_driver_register failed %d\n",
961 __FUNCTION__, error); 979 __func__, error);
962 return error; 980 return error;
963 } 981 }
964 982
@@ -966,7 +984,7 @@ static int ps3av_module_init(void)
966 if (error) 984 if (error)
967 printk(KERN_ERR 985 printk(KERN_ERR
968 "%s: ps3_vuart_port_device_register failed %d\n", 986 "%s: ps3_vuart_port_device_register failed %d\n",
969 __FUNCTION__, error); 987 __func__, error);
970 988
971 return error; 989 return error;
972} 990}
diff --git a/drivers/ps3/ps3av_cmd.c b/drivers/ps3/ps3av_cmd.c
index bc70e81f8cb0..0145ea173c42 100644
--- a/drivers/ps3/ps3av_cmd.c
+++ b/drivers/ps3/ps3av_cmd.c
@@ -395,7 +395,7 @@ u32 ps3av_cmd_set_video_mode(void *p, u32 head, int video_vid, int video_fmt,
395 video_mode->video_order = ps3av_video_fmt_table[video_fmt].order; 395 video_mode->video_order = ps3av_video_fmt_table[video_fmt].order;
396 396
397 pr_debug("%s: video_mode:vid:%x width:%d height:%d pitch:%d out_format:%d format:%x order:%x\n", 397 pr_debug("%s: video_mode:vid:%x width:%d height:%d pitch:%d out_format:%d format:%x order:%x\n",
398 __FUNCTION__, video_vid, video_mode->width, video_mode->height, 398 __func__, video_vid, video_mode->width, video_mode->height,
399 video_mode->pitch, video_mode->video_out_format, 399 video_mode->pitch, video_mode->video_out_format,
400 video_mode->video_format, video_mode->video_order); 400 video_mode->video_format, video_mode->video_order);
401 return sizeof(*video_mode); 401 return sizeof(*video_mode);
@@ -477,7 +477,7 @@ static u8 ps3av_cnv_mclk(u32 fs)
477 if (ps3av_cnv_mclk_table[i].fs == fs) 477 if (ps3av_cnv_mclk_table[i].fs == fs)
478 return ps3av_cnv_mclk_table[i].mclk; 478 return ps3av_cnv_mclk_table[i].mclk;
479 479
480 printk(KERN_ERR "%s failed, fs:%x\n", __FUNCTION__, fs); 480 printk(KERN_ERR "%s failed, fs:%x\n", __func__, fs);
481 return 0; 481 return 0;
482} 482}
483 483
@@ -526,13 +526,12 @@ static void ps3av_cnv_ns(u8 *ns, u32 fs, u32 video_vid)
526 d = 4; 526 d = 4;
527 break; 527 break;
528 default: 528 default:
529 printk(KERN_ERR "%s failed, vid:%x\n", __FUNCTION__, 529 printk(KERN_ERR "%s failed, vid:%x\n", __func__, video_vid);
530 video_vid);
531 break; 530 break;
532 } 531 }
533 532
534 if (fs < PS3AV_CMD_AUDIO_FS_44K || fs > PS3AV_CMD_AUDIO_FS_192K) 533 if (fs < PS3AV_CMD_AUDIO_FS_44K || fs > PS3AV_CMD_AUDIO_FS_192K)
535 printk(KERN_ERR "%s failed, fs:%x\n", __FUNCTION__, fs); 534 printk(KERN_ERR "%s failed, fs:%x\n", __func__, fs);
536 else 535 else
537 ns_val = ps3av_ns_table[PS3AV_CMD_AUDIO_FS_44K-BASE][d]; 536 ns_val = ps3av_ns_table[PS3AV_CMD_AUDIO_FS_44K-BASE][d];
538 537
@@ -555,8 +554,7 @@ static u8 ps3av_cnv_enable(u32 source, const u8 *enable)
555 ret = ((p[0] << 4) + (p[1] << 5) + (p[2] << 6) + (p[3] << 7)) | 554 ret = ((p[0] << 4) + (p[1] << 5) + (p[2] << 6) + (p[3] << 7)) |
556 0x01; 555 0x01;
557 } else 556 } else
558 printk(KERN_ERR "%s failed, source:%x\n", __FUNCTION__, 557 printk(KERN_ERR "%s failed, source:%x\n", __func__, source);
559 source);
560 return ret; 558 return ret;
561} 559}
562 560
@@ -585,7 +583,7 @@ static u8 ps3av_cnv_inputlen(u32 word_bits)
585 ret = PS3AV_CMD_AV_INPUTLEN_24; 583 ret = PS3AV_CMD_AV_INPUTLEN_24;
586 break; 584 break;
587 default: 585 default:
588 printk(KERN_ERR "%s failed, word_bits:%x\n", __FUNCTION__, 586 printk(KERN_ERR "%s failed, word_bits:%x\n", __func__,
589 word_bits); 587 word_bits);
590 break; 588 break;
591 } 589 }
@@ -595,7 +593,7 @@ static u8 ps3av_cnv_inputlen(u32 word_bits)
595static u8 ps3av_cnv_layout(u32 num_of_ch) 593static u8 ps3av_cnv_layout(u32 num_of_ch)
596{ 594{
597 if (num_of_ch > PS3AV_CMD_AUDIO_NUM_OF_CH_8) { 595 if (num_of_ch > PS3AV_CMD_AUDIO_NUM_OF_CH_8) {
598 printk(KERN_ERR "%s failed, num_of_ch:%x\n", __FUNCTION__, 596 printk(KERN_ERR "%s failed, num_of_ch:%x\n", __func__,
599 num_of_ch); 597 num_of_ch);
600 return 0; 598 return 0;
601 } 599 }
@@ -864,7 +862,7 @@ int ps3av_cmd_avb_param(struct ps3av_pkt_avb_param *avb, u32 send_len)
864 862
865 res = get_status(avb); 863 res = get_status(avb);
866 if (res) 864 if (res)
867 pr_debug("%s: PS3AV_CID_AVB_PARAM: failed %x\n", __FUNCTION__, 865 pr_debug("%s: PS3AV_CID_AVB_PARAM: failed %x\n", __func__,
868 res); 866 res);
869 867
870 out: 868 out:
@@ -1013,7 +1011,7 @@ int ps3av_vuart_read(struct ps3_vuart_port_device *dev, void *buf,
1013 return size; 1011 return size;
1014 if (error != -EAGAIN) { 1012 if (error != -EAGAIN) {
1015 printk(KERN_ERR "%s: ps3_vuart_read failed %d\n", 1013 printk(KERN_ERR "%s: ps3_vuart_read failed %d\n",
1016 __FUNCTION__, error); 1014 __func__, error);
1017 return error; 1015 return error;
1018 } 1016 }
1019 msleep(POLLING_INTERVAL); 1017 msleep(POLLING_INTERVAL);
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index e71929db8b06..977521013fe8 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2174,6 +2174,51 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
2174 return ret; 2174 return ret;
2175} 2175}
2176 2176
2177struct dasd_ccw_req * dasd_generic_build_rdc(struct dasd_device *device,
2178 void *rdc_buffer,
2179 int rdc_buffer_size, char *magic)
2180{
2181 struct dasd_ccw_req *cqr;
2182 struct ccw1 *ccw;
2183
2184 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device);
2185
2186 if (IS_ERR(cqr)) {
2187 DEV_MESSAGE(KERN_WARNING, device, "%s",
2188 "Could not allocate RDC request");
2189 return cqr;
2190 }
2191
2192 ccw = cqr->cpaddr;
2193 ccw->cmd_code = CCW_CMD_RDC;
2194 ccw->cda = (__u32)(addr_t)rdc_buffer;
2195 ccw->count = rdc_buffer_size;
2196
2197 cqr->device = device;
2198 cqr->expires = 10*HZ;
2199 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
2200 cqr->retries = 2;
2201 cqr->buildclk = get_clock();
2202 cqr->status = DASD_CQR_FILLED;
2203 return cqr;
2204}
2205
2206
2207int dasd_generic_read_dev_chars(struct dasd_device *device, char *magic,
2208 void **rdc_buffer, int rdc_buffer_size)
2209{
2210 int ret;
2211 struct dasd_ccw_req *cqr;
2212
2213 cqr = dasd_generic_build_rdc(device, *rdc_buffer, rdc_buffer_size,
2214 magic);
2215 if (IS_ERR(cqr))
2216 return PTR_ERR(cqr);
2217
2218 ret = dasd_sleep_on(cqr);
2219 dasd_sfree_request(cqr, cqr->device);
2220 return ret;
2221}
2177 2222
2178static int __init 2223static int __init
2179dasd_init(void) 2224dasd_init(void)
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index cecab2274a6e..c9583fbc2a7d 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -450,6 +450,81 @@ dasd_eckd_generate_uid(struct dasd_device *device, struct dasd_uid *uid)
450 return 0; 450 return 0;
451} 451}
452 452
453struct dasd_ccw_req * dasd_eckd_build_rcd_lpm(struct dasd_device *device,
454 void *rcd_buffer,
455 struct ciw *ciw, __u8 lpm)
456{
457 struct dasd_ccw_req *cqr;
458 struct ccw1 *ccw;
459
460 cqr = dasd_smalloc_request("ECKD", 1 /* RCD */, ciw->count, device);
461
462 if (IS_ERR(cqr)) {
463 DEV_MESSAGE(KERN_WARNING, device, "%s",
464 "Could not allocate RCD request");
465 return cqr;
466 }
467
468 ccw = cqr->cpaddr;
469 ccw->cmd_code = ciw->cmd;
470 ccw->cda = (__u32)(addr_t)rcd_buffer;
471 ccw->count = ciw->count;
472
473 cqr->device = device;
474 cqr->expires = 10*HZ;
475 cqr->lpm = lpm;
476 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
477 cqr->retries = 2;
478 cqr->buildclk = get_clock();
479 cqr->status = DASD_CQR_FILLED;
480 return cqr;
481}
482
483static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
484 void **rcd_buffer,
485 int *rcd_buffer_size, __u8 lpm)
486{
487 struct ciw *ciw;
488 char *rcd_buf = NULL;
489 int ret;
490 struct dasd_ccw_req *cqr;
491
492 /*
493 * scan for RCD command in extended SenseID data
494 */
495 ciw = ccw_device_get_ciw(device->cdev, CIW_TYPE_RCD);
496 if (!ciw || ciw->cmd == 0) {
497 ret = -EOPNOTSUPP;
498 goto out_error;
499 }
500 rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA);
501 if (!rcd_buf) {
502 ret = -ENOMEM;
503 goto out_error;
504 }
505 cqr = dasd_eckd_build_rcd_lpm(device, rcd_buf, ciw, lpm);
506 if (IS_ERR(cqr)) {
507 ret = PTR_ERR(cqr);
508 goto out_error;
509 }
510 ret = dasd_sleep_on(cqr);
511 /*
512 * on success we update the user input parms
513 */
514 dasd_sfree_request(cqr, cqr->device);
515 if (ret)
516 goto out_error;
517
518 *rcd_buffer_size = ciw->count;
519 *rcd_buffer = rcd_buf;
520 return 0;
521out_error:
522 kfree(rcd_buf);
523 *rcd_buffer = NULL;
524 *rcd_buffer_size = 0;
525 return ret;
526}
527
453static int 528static int
454dasd_eckd_read_conf(struct dasd_device *device) 529dasd_eckd_read_conf(struct dasd_device *device)
455{ 530{
@@ -469,8 +544,8 @@ dasd_eckd_read_conf(struct dasd_device *device)
469 /* get configuration data per operational path */ 544 /* get configuration data per operational path */
470 for (lpm = 0x80; lpm; lpm>>= 1) { 545 for (lpm = 0x80; lpm; lpm>>= 1) {
471 if (lpm & path_data->opm){ 546 if (lpm & path_data->opm){
472 rc = read_conf_data_lpm(device->cdev, &conf_data, 547 rc = dasd_eckd_read_conf_lpm(device, &conf_data,
473 &conf_len, lpm); 548 &conf_len, lpm);
474 if (rc && rc != -EOPNOTSUPP) { /* -EOPNOTSUPP is ok */ 549 if (rc && rc != -EOPNOTSUPP) { /* -EOPNOTSUPP is ok */
475 MESSAGE(KERN_WARNING, 550 MESSAGE(KERN_WARNING,
476 "Read configuration data returned " 551 "Read configuration data returned "
@@ -639,7 +714,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
639 /* Read Device Characteristics */ 714 /* Read Device Characteristics */
640 rdc_data = (void *) &(private->rdc_data); 715 rdc_data = (void *) &(private->rdc_data);
641 memset(rdc_data, 0, sizeof(rdc_data)); 716 memset(rdc_data, 0, sizeof(rdc_data));
642 rc = read_dev_chars(device->cdev, &rdc_data, 64); 717 rc = dasd_generic_read_dev_chars(device, "ECKD", &rdc_data, 64);
643 if (rc) 718 if (rc)
644 DEV_MESSAGE(KERN_WARNING, device, 719 DEV_MESSAGE(KERN_WARNING, device,
645 "Read device characteristics returned " 720 "Read device characteristics returned "
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index be0909e39226..da16ead8aff2 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -135,7 +135,7 @@ dasd_fba_check_characteristics(struct dasd_device *device)
135 } 135 }
136 /* Read Device Characteristics */ 136 /* Read Device Characteristics */
137 rdc_data = (void *) &(private->rdc_data); 137 rdc_data = (void *) &(private->rdc_data);
138 rc = read_dev_chars(device->cdev, &rdc_data, 32); 138 rc = dasd_generic_read_dev_chars(device, "FBA ", &rdc_data, 32);
139 if (rc) { 139 if (rc) {
140 DEV_MESSAGE(KERN_WARNING, device, 140 DEV_MESSAGE(KERN_WARNING, device,
141 "Read device characteristics returned error %d", 141 "Read device characteristics returned error %d",
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index a2cc69e11410..241294cba415 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -509,6 +509,8 @@ int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
509int dasd_generic_set_offline (struct ccw_device *cdev); 509int dasd_generic_set_offline (struct ccw_device *cdev);
510int dasd_generic_notify(struct ccw_device *, int); 510int dasd_generic_notify(struct ccw_device *, int);
511 511
512int dasd_generic_read_dev_chars(struct dasd_device *, char *, void **, int);
513
512/* externals in dasd_devmap.c */ 514/* externals in dasd_devmap.c */
513extern int dasd_max_devindex; 515extern int dasd_max_devindex;
514extern int dasd_probeonly; 516extern int dasd_probeonly;
diff --git a/drivers/s390/char/tape.h b/drivers/s390/char/tape.h
index bb4ff537729d..3b52f5c1dbef 100644
--- a/drivers/s390/char/tape.h
+++ b/drivers/s390/char/tape.h
@@ -103,6 +103,7 @@ enum tape_op {
103 TO_CRYPT_OFF, /* Disable encrpytion */ 103 TO_CRYPT_OFF, /* Disable encrpytion */
104 TO_KEKL_SET, /* Set KEK label */ 104 TO_KEKL_SET, /* Set KEK label */
105 TO_KEKL_QUERY, /* Query KEK label */ 105 TO_KEKL_QUERY, /* Query KEK label */
106 TO_RDC, /* Read device characteristics */
106 TO_SIZE, /* #entries in tape_op_t */ 107 TO_SIZE, /* #entries in tape_op_t */
107}; 108};
108 109
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
index 50f5edab83d7..7e2b2ab49264 100644
--- a/drivers/s390/char/tape_3590.c
+++ b/drivers/s390/char/tape_3590.c
@@ -788,6 +788,7 @@ tape_3590_done(struct tape_device *device, struct tape_request *request)
788 case TO_SIZE: 788 case TO_SIZE:
789 case TO_KEKL_SET: 789 case TO_KEKL_SET:
790 case TO_KEKL_QUERY: 790 case TO_KEKL_QUERY:
791 case TO_RDC:
791 break; 792 break;
792 } 793 }
793 return TAPE_IO_SUCCESS; 794 return TAPE_IO_SUCCESS;
@@ -1549,6 +1550,26 @@ tape_3590_irq(struct tape_device *device, struct tape_request *request,
1549 return TAPE_IO_STOP; 1550 return TAPE_IO_STOP;
1550} 1551}
1551 1552
1553
1554static int tape_3590_read_dev_chars(struct tape_device *device,
1555 struct tape_3590_rdc_data *rdc_data)
1556{
1557 int rc;
1558 struct tape_request *request;
1559
1560 request = tape_alloc_request(1, sizeof(*rdc_data));
1561 if (IS_ERR(request))
1562 return PTR_ERR(request);
1563 request->op = TO_RDC;
1564 tape_ccw_end(request->cpaddr, CCW_CMD_RDC, sizeof(*rdc_data),
1565 request->cpdata);
1566 rc = tape_do_io(device, request);
1567 if (rc == 0)
1568 memcpy(rdc_data, request->cpdata, sizeof(*rdc_data));
1569 tape_free_request(request);
1570 return rc;
1571}
1572
1552/* 1573/*
1553 * Setup device function 1574 * Setup device function
1554 */ 1575 */
@@ -1557,7 +1578,7 @@ tape_3590_setup_device(struct tape_device *device)
1557{ 1578{
1558 int rc; 1579 int rc;
1559 struct tape_3590_disc_data *data; 1580 struct tape_3590_disc_data *data;
1560 char *rdc_data; 1581 struct tape_3590_rdc_data *rdc_data;
1561 1582
1562 DBF_EVENT(6, "3590 device setup\n"); 1583 DBF_EVENT(6, "3590 device setup\n");
1563 data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA); 1584 data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA);
@@ -1566,12 +1587,12 @@ tape_3590_setup_device(struct tape_device *device)
1566 data->read_back_op = READ_PREVIOUS; 1587 data->read_back_op = READ_PREVIOUS;
1567 device->discdata = data; 1588 device->discdata = data;
1568 1589
1569 rdc_data = kmalloc(64, GFP_KERNEL | GFP_DMA); 1590 rdc_data = kmalloc(sizeof(*rdc_data), GFP_KERNEL | GFP_DMA);
1570 if (!rdc_data) { 1591 if (!rdc_data) {
1571 rc = -ENOMEM; 1592 rc = -ENOMEM;
1572 goto fail_kmalloc; 1593 goto fail_kmalloc;
1573 } 1594 }
1574 rc = read_dev_chars(device->cdev, (void**)&rdc_data, 64); 1595 rc = tape_3590_read_dev_chars(device, rdc_data);
1575 if (rc) { 1596 if (rc) {
1576 DBF_LH(3, "Read device characteristics failed!\n"); 1597 DBF_LH(3, "Read device characteristics failed!\n");
1577 goto fail_kmalloc; 1598 goto fail_kmalloc;
@@ -1579,7 +1600,7 @@ tape_3590_setup_device(struct tape_device *device)
1579 rc = tape_std_assign(device); 1600 rc = tape_std_assign(device);
1580 if (rc) 1601 if (rc)
1581 goto fail_rdc_data; 1602 goto fail_rdc_data;
1582 if (rdc_data[31] == 0x13) { 1603 if (rdc_data->data[31] == 0x13) {
1583 PRINT_INFO("Device has crypto support\n"); 1604 PRINT_INFO("Device has crypto support\n");
1584 data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK; 1605 data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK;
1585 tape_3592_disable_crypt(device); 1606 tape_3592_disable_crypt(device);
diff --git a/drivers/s390/char/tape_3590.h b/drivers/s390/char/tape_3590.h
index aa5138807af1..4534055f1376 100644
--- a/drivers/s390/char/tape_3590.h
+++ b/drivers/s390/char/tape_3590.h
@@ -129,6 +129,10 @@ struct tape_3590_med_sense {
129 char pad2[116]; 129 char pad2[116];
130} __attribute__ ((packed)); 130} __attribute__ ((packed));
131 131
132struct tape_3590_rdc_data {
133 char data[64];
134} __attribute__ ((packed));
135
132/* Datastructures for 3592 encryption support */ 136/* Datastructures for 3592 encryption support */
133 137
134struct tape3592_kekl { 138struct tape3592_kekl {
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index e2a8a1a04bab..2fae6338ee1c 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -73,7 +73,7 @@ const char *tape_op_verbose[TO_SIZE] =
73 [TO_DIS] = "DIS", [TO_ASSIGN] = "ASS", 73 [TO_DIS] = "DIS", [TO_ASSIGN] = "ASS",
74 [TO_UNASSIGN] = "UAS", [TO_CRYPT_ON] = "CON", 74 [TO_UNASSIGN] = "UAS", [TO_CRYPT_ON] = "CON",
75 [TO_CRYPT_OFF] = "COF", [TO_KEKL_SET] = "KLS", 75 [TO_CRYPT_OFF] = "COF", [TO_KEKL_SET] = "KLS",
76 [TO_KEKL_QUERY] = "KLQ", 76 [TO_KEKL_QUERY] = "KLQ",[TO_RDC] = "RDC",
77}; 77};
78 78
79static int 79static int
@@ -911,6 +911,7 @@ __tape_start_request(struct tape_device *device, struct tape_request *request)
911 case TO_ASSIGN: 911 case TO_ASSIGN:
912 case TO_UNASSIGN: 912 case TO_UNASSIGN:
913 case TO_READ_ATTMSG: 913 case TO_READ_ATTMSG:
914 case TO_RDC:
914 if (device->tape_state == TS_INIT) 915 if (device->tape_state == TS_INIT)
915 break; 916 break;
916 if (device->tape_state == TS_UNUSED) 917 if (device->tape_state == TS_UNUSED)
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 05fac0733f3d..cba64e4cfcd4 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -69,7 +69,6 @@ static const char version[] = "QDIO base support version 2";
69 69
70static int qdio_performance_stats = 0; 70static int qdio_performance_stats = 0;
71static int proc_perf_file_registration; 71static int proc_perf_file_registration;
72static unsigned long i_p_c, i_p_nc, o_p_c, o_p_nc, ii_p_c, ii_p_nc;
73static struct qdio_perf_stats perf_stats; 72static struct qdio_perf_stats perf_stats;
74 73
75static int hydra_thinints; 74static int hydra_thinints;
@@ -111,6 +110,31 @@ qdio_min(int a,int b)
111} 110}
112 111
113/***************** SCRUBBER HELPER ROUTINES **********************/ 112/***************** SCRUBBER HELPER ROUTINES **********************/
113#ifdef CONFIG_64BIT
114static inline void qdio_perf_stat_inc(atomic64_t *count)
115{
116 if (qdio_performance_stats)
117 atomic64_inc(count);
118}
119
120static inline void qdio_perf_stat_dec(atomic64_t *count)
121{
122 if (qdio_performance_stats)
123 atomic64_dec(count);
124}
125#else /* CONFIG_64BIT */
126static inline void qdio_perf_stat_inc(atomic_t *count)
127{
128 if (qdio_performance_stats)
129 atomic_inc(count);
130}
131
132static inline void qdio_perf_stat_dec(atomic_t *count)
133{
134 if (qdio_performance_stats)
135 atomic_dec(count);
136}
137#endif /* CONFIG_64BIT */
114 138
115static inline __u64 139static inline __u64
116qdio_get_micros(void) 140qdio_get_micros(void)
@@ -277,8 +301,7 @@ qdio_siga_sync(struct qdio_q *q, unsigned int gpr2,
277 QDIO_DBF_TEXT4(0,trace,"sigasync"); 301 QDIO_DBF_TEXT4(0,trace,"sigasync");
278 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); 302 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
279 303
280 if (qdio_performance_stats) 304 qdio_perf_stat_inc(&perf_stats.siga_syncs);
281 perf_stats.siga_syncs++;
282 305
283 cc = do_siga_sync(q->schid, gpr2, gpr3); 306 cc = do_siga_sync(q->schid, gpr2, gpr3);
284 if (cc) 307 if (cc)
@@ -323,8 +346,7 @@ qdio_siga_output(struct qdio_q *q)
323 __u32 busy_bit; 346 __u32 busy_bit;
324 __u64 start_time=0; 347 __u64 start_time=0;
325 348
326 if (qdio_performance_stats) 349 qdio_perf_stat_inc(&perf_stats.siga_outs);
327 perf_stats.siga_outs++;
328 350
329 QDIO_DBF_TEXT4(0,trace,"sigaout"); 351 QDIO_DBF_TEXT4(0,trace,"sigaout");
330 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); 352 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
@@ -358,8 +380,7 @@ qdio_siga_input(struct qdio_q *q)
358 QDIO_DBF_TEXT4(0,trace,"sigain"); 380 QDIO_DBF_TEXT4(0,trace,"sigain");
359 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); 381 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
360 382
361 if (qdio_performance_stats) 383 qdio_perf_stat_inc(&perf_stats.siga_ins);
362 perf_stats.siga_ins++;
363 384
364 cc = do_siga_input(q->schid, q->mask); 385 cc = do_siga_input(q->schid, q->mask);
365 386
@@ -953,8 +974,7 @@ __qdio_outbound_processing(struct qdio_q *q)
953 974
954 if (unlikely(qdio_reserve_q(q))) { 975 if (unlikely(qdio_reserve_q(q))) {
955 qdio_release_q(q); 976 qdio_release_q(q);
956 if (qdio_performance_stats) 977 qdio_perf_stat_inc(&perf_stats.outbound_tl_runs_resched);
957 o_p_c++;
958 /* as we're sissies, we'll check next time */ 978 /* as we're sissies, we'll check next time */
959 if (likely(!atomic_read(&q->is_in_shutdown))) { 979 if (likely(!atomic_read(&q->is_in_shutdown))) {
960 qdio_mark_q(q); 980 qdio_mark_q(q);
@@ -962,10 +982,8 @@ __qdio_outbound_processing(struct qdio_q *q)
962 } 982 }
963 return; 983 return;
964 } 984 }
965 if (qdio_performance_stats) { 985 qdio_perf_stat_inc(&perf_stats.outbound_tl_runs);
966 o_p_nc++; 986 qdio_perf_stat_inc(&perf_stats.tl_runs);
967 perf_stats.tl_runs++;
968 }
969 987
970 /* see comment in qdio_kick_outbound_q */ 988 /* see comment in qdio_kick_outbound_q */
971 siga_attempts=atomic_read(&q->busy_siga_counter); 989 siga_attempts=atomic_read(&q->busy_siga_counter);
@@ -1139,17 +1157,6 @@ qdio_has_inbound_q_moved(struct qdio_q *q)
1139{ 1157{
1140 int i; 1158 int i;
1141 1159
1142 static int old_pcis=0;
1143 static int old_thinints=0;
1144
1145 if (qdio_performance_stats) {
1146 if ((old_pcis==perf_stats.pcis)&&
1147 (old_thinints==perf_stats.thinints))
1148 perf_stats.start_time_inbound=NOW;
1149 else
1150 old_pcis=perf_stats.pcis;
1151 }
1152
1153 i=qdio_get_inbound_buffer_frontier(q); 1160 i=qdio_get_inbound_buffer_frontier(q);
1154 if ( (i!=GET_SAVED_FRONTIER(q)) || 1161 if ( (i!=GET_SAVED_FRONTIER(q)) ||
1155 (q->error_status_flags&QDIO_STATUS_LOOK_FOR_ERROR) ) { 1162 (q->error_status_flags&QDIO_STATUS_LOOK_FOR_ERROR) ) {
@@ -1337,10 +1344,7 @@ qdio_kick_inbound_handler(struct qdio_q *q)
1337 q->siga_error=0; 1344 q->siga_error=0;
1338 q->error_status_flags=0; 1345 q->error_status_flags=0;
1339 1346
1340 if (qdio_performance_stats) { 1347 qdio_perf_stat_inc(&perf_stats.inbound_cnt);
1341 perf_stats.inbound_time+=NOW-perf_stats.start_time_inbound;
1342 perf_stats.inbound_cnt++;
1343 }
1344} 1348}
1345 1349
1346static void 1350static void
@@ -1360,8 +1364,7 @@ __tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
1360 */ 1364 */
1361 if (unlikely(qdio_reserve_q(q))) { 1365 if (unlikely(qdio_reserve_q(q))) {
1362 qdio_release_q(q); 1366 qdio_release_q(q);
1363 if (qdio_performance_stats) 1367 qdio_perf_stat_inc(&perf_stats.inbound_thin_tl_runs_resched);
1364 ii_p_c++;
1365 /* 1368 /*
1366 * as we might just be about to stop polling, we make 1369 * as we might just be about to stop polling, we make
1367 * sure that we check again at least once more 1370 * sure that we check again at least once more
@@ -1369,8 +1372,7 @@ __tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
1369 tiqdio_sched_tl(); 1372 tiqdio_sched_tl();
1370 return; 1373 return;
1371 } 1374 }
1372 if (qdio_performance_stats) 1375 qdio_perf_stat_inc(&perf_stats.inbound_thin_tl_runs);
1373 ii_p_nc++;
1374 if (unlikely(atomic_read(&q->is_in_shutdown))) { 1376 if (unlikely(atomic_read(&q->is_in_shutdown))) {
1375 qdio_unmark_q(q); 1377 qdio_unmark_q(q);
1376 goto out; 1378 goto out;
@@ -1412,8 +1414,7 @@ __tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
1412 for (i=0;i<irq_ptr->no_output_qs;i++) { 1414 for (i=0;i<irq_ptr->no_output_qs;i++) {
1413 oq = irq_ptr->output_qs[i]; 1415 oq = irq_ptr->output_qs[i];
1414 if (!qdio_is_outbound_q_done(oq)) { 1416 if (!qdio_is_outbound_q_done(oq)) {
1415 if (qdio_performance_stats) 1417 qdio_perf_stat_dec(&perf_stats.tl_runs);
1416 perf_stats.tl_runs--;
1417 __qdio_outbound_processing(oq); 1418 __qdio_outbound_processing(oq);
1418 } 1419 }
1419 } 1420 }
@@ -1452,8 +1453,7 @@ __qdio_inbound_processing(struct qdio_q *q)
1452 1453
1453 if (unlikely(qdio_reserve_q(q))) { 1454 if (unlikely(qdio_reserve_q(q))) {
1454 qdio_release_q(q); 1455 qdio_release_q(q);
1455 if (qdio_performance_stats) 1456 qdio_perf_stat_inc(&perf_stats.inbound_tl_runs_resched);
1456 i_p_c++;
1457 /* as we're sissies, we'll check next time */ 1457 /* as we're sissies, we'll check next time */
1458 if (likely(!atomic_read(&q->is_in_shutdown))) { 1458 if (likely(!atomic_read(&q->is_in_shutdown))) {
1459 qdio_mark_q(q); 1459 qdio_mark_q(q);
@@ -1461,10 +1461,8 @@ __qdio_inbound_processing(struct qdio_q *q)
1461 } 1461 }
1462 return; 1462 return;
1463 } 1463 }
1464 if (qdio_performance_stats) { 1464 qdio_perf_stat_inc(&perf_stats.inbound_tl_runs);
1465 i_p_nc++; 1465 qdio_perf_stat_inc(&perf_stats.tl_runs);
1466 perf_stats.tl_runs++;
1467 }
1468 1466
1469again: 1467again:
1470 if (qdio_has_inbound_q_moved(q)) { 1468 if (qdio_has_inbound_q_moved(q)) {
@@ -1510,8 +1508,7 @@ tiqdio_reset_processing_state(struct qdio_q *q, int q_laps)
1510 1508
1511 if (unlikely(qdio_reserve_q(q))) { 1509 if (unlikely(qdio_reserve_q(q))) {
1512 qdio_release_q(q); 1510 qdio_release_q(q);
1513 if (qdio_performance_stats) 1511 qdio_perf_stat_inc(&perf_stats.inbound_thin_tl_runs_resched);
1514 ii_p_c++;
1515 /* 1512 /*
1516 * as we might just be about to stop polling, we make 1513 * as we might just be about to stop polling, we make
1517 * sure that we check again at least once more 1514 * sure that we check again at least once more
@@ -1602,8 +1599,7 @@ tiqdio_tl(unsigned long data)
1602{ 1599{
1603 QDIO_DBF_TEXT4(0,trace,"iqdio_tl"); 1600 QDIO_DBF_TEXT4(0,trace,"iqdio_tl");
1604 1601
1605 if (qdio_performance_stats) 1602 qdio_perf_stat_inc(&perf_stats.tl_runs);
1606 perf_stats.tl_runs++;
1607 1603
1608 tiqdio_inbound_checks(); 1604 tiqdio_inbound_checks();
1609} 1605}
@@ -1914,10 +1910,7 @@ tiqdio_thinint_handler(void)
1914{ 1910{
1915 QDIO_DBF_TEXT4(0,trace,"thin_int"); 1911 QDIO_DBF_TEXT4(0,trace,"thin_int");
1916 1912
1917 if (qdio_performance_stats) { 1913 qdio_perf_stat_inc(&perf_stats.thinints);
1918 perf_stats.thinints++;
1919 perf_stats.start_time_inbound=NOW;
1920 }
1921 1914
1922 /* SVS only when needed: 1915 /* SVS only when needed:
1923 * issue SVS to benefit from iqdio interrupt avoidance 1916 * issue SVS to benefit from iqdio interrupt avoidance
@@ -1972,17 +1965,12 @@ qdio_handle_pci(struct qdio_irq *irq_ptr)
1972 int i; 1965 int i;
1973 struct qdio_q *q; 1966 struct qdio_q *q;
1974 1967
1975 if (qdio_performance_stats) { 1968 qdio_perf_stat_inc(&perf_stats.pcis);
1976 perf_stats.pcis++;
1977 perf_stats.start_time_inbound=NOW;
1978 }
1979 for (i=0;i<irq_ptr->no_input_qs;i++) { 1969 for (i=0;i<irq_ptr->no_input_qs;i++) {
1980 q=irq_ptr->input_qs[i]; 1970 q=irq_ptr->input_qs[i];
1981 if (q->is_input_q&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT) 1971 if (q->is_input_q&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT)
1982 qdio_mark_q(q); 1972 qdio_mark_q(q);
1983 else { 1973 else {
1984 if (qdio_performance_stats)
1985 perf_stats.tl_runs--;
1986 __qdio_inbound_processing(q); 1974 __qdio_inbound_processing(q);
1987 } 1975 }
1988 } 1976 }
@@ -1992,8 +1980,7 @@ qdio_handle_pci(struct qdio_irq *irq_ptr)
1992 q=irq_ptr->output_qs[i]; 1980 q=irq_ptr->output_qs[i];
1993 if (qdio_is_outbound_q_done(q)) 1981 if (qdio_is_outbound_q_done(q))
1994 continue; 1982 continue;
1995 if (qdio_performance_stats) 1983 qdio_perf_stat_dec(&perf_stats.tl_runs);
1996 perf_stats.tl_runs--;
1997 if (!irq_ptr->sync_done_on_outb_pcis) 1984 if (!irq_ptr->sync_done_on_outb_pcis)
1998 SYNC_MEMORY; 1985 SYNC_MEMORY;
1999 __qdio_outbound_processing(q); 1986 __qdio_outbound_processing(q);
@@ -3463,18 +3450,12 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
3463 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; 3450 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
3464 3451
3465 /* This is the outbound handling of queues */ 3452 /* This is the outbound handling of queues */
3466 if (qdio_performance_stats)
3467 perf_stats.start_time_outbound=NOW;
3468
3469 qdio_do_qdio_fill_output(q,qidx,count,buffers); 3453 qdio_do_qdio_fill_output(q,qidx,count,buffers);
3470 3454
3471 used_elements=atomic_add_return(count, &q->number_of_buffers_used) - count; 3455 used_elements=atomic_add_return(count, &q->number_of_buffers_used) - count;
3472 3456
3473 if (callflags&QDIO_FLAG_DONT_SIGA) { 3457 if (callflags&QDIO_FLAG_DONT_SIGA) {
3474 if (qdio_performance_stats) { 3458 qdio_perf_stat_inc(&perf_stats.outbound_cnt);
3475 perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
3476 perf_stats.outbound_cnt++;
3477 }
3478 return; 3459 return;
3479 } 3460 }
3480 if (q->is_iqdio_q) { 3461 if (q->is_iqdio_q) {
@@ -3504,8 +3485,7 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
3504 qdio_kick_outbound_q(q); 3485 qdio_kick_outbound_q(q);
3505 } else { 3486 } else {
3506 QDIO_DBF_TEXT3(0,trace, "fast-req"); 3487 QDIO_DBF_TEXT3(0,trace, "fast-req");
3507 if (qdio_performance_stats) 3488 qdio_perf_stat_inc(&perf_stats.fast_reqs);
3508 perf_stats.fast_reqs++;
3509 } 3489 }
3510 } 3490 }
3511 /* 3491 /*
@@ -3516,10 +3496,7 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
3516 __qdio_outbound_processing(q); 3496 __qdio_outbound_processing(q);
3517 } 3497 }
3518 3498
3519 if (qdio_performance_stats) { 3499 qdio_perf_stat_inc(&perf_stats.outbound_cnt);
3520 perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
3521 perf_stats.outbound_cnt++;
3522 }
3523} 3500}
3524 3501
3525/* count must be 1 in iqdio */ 3502/* count must be 1 in iqdio */
@@ -3589,33 +3566,67 @@ qdio_perf_procfile_read(char *buffer, char **buffer_location, off_t offset,
3589 return 0; 3566 return 0;
3590 3567
3591#define _OUTP_IT(x...) c+=sprintf(buffer+c,x) 3568#define _OUTP_IT(x...) c+=sprintf(buffer+c,x)
3592 _OUTP_IT("i_p_nc/c=%lu/%lu\n",i_p_nc,i_p_c); 3569#ifdef CONFIG_64BIT
3593 _OUTP_IT("ii_p_nc/c=%lu/%lu\n",ii_p_nc,ii_p_c); 3570 _OUTP_IT("Number of tasklet runs (total) : %li\n",
3594 _OUTP_IT("o_p_nc/c=%lu/%lu\n",o_p_nc,o_p_c); 3571 (long)atomic64_read(&perf_stats.tl_runs));
3595 _OUTP_IT("Number of tasklet runs (total) : %lu\n", 3572 _OUTP_IT("Inbound tasklet runs tried/retried : %li/%li\n",
3596 perf_stats.tl_runs); 3573 (long)atomic64_read(&perf_stats.inbound_tl_runs),
3574 (long)atomic64_read(&perf_stats.inbound_tl_runs_resched));
3575 _OUTP_IT("Inbound-thin tasklet runs tried/retried : %li/%li\n",
3576 (long)atomic64_read(&perf_stats.inbound_thin_tl_runs),
3577 (long)atomic64_read(&perf_stats.inbound_thin_tl_runs_resched));
3578 _OUTP_IT("Outbound tasklet runs tried/retried : %li/%li\n",
3579 (long)atomic64_read(&perf_stats.outbound_tl_runs),
3580 (long)atomic64_read(&perf_stats.outbound_tl_runs_resched));
3597 _OUTP_IT("\n"); 3581 _OUTP_IT("\n");
3598 _OUTP_IT("Number of SIGA sync's issued : %lu\n", 3582 _OUTP_IT("Number of SIGA sync's issued : %li\n",
3599 perf_stats.siga_syncs); 3583 (long)atomic64_read(&perf_stats.siga_syncs));
3600 _OUTP_IT("Number of SIGA in's issued : %lu\n", 3584 _OUTP_IT("Number of SIGA in's issued : %li\n",
3601 perf_stats.siga_ins); 3585 (long)atomic64_read(&perf_stats.siga_ins));
3602 _OUTP_IT("Number of SIGA out's issued : %lu\n", 3586 _OUTP_IT("Number of SIGA out's issued : %li\n",
3603 perf_stats.siga_outs); 3587 (long)atomic64_read(&perf_stats.siga_outs));
3604 _OUTP_IT("Number of PCIs caught : %lu\n", 3588 _OUTP_IT("Number of PCIs caught : %li\n",
3605 perf_stats.pcis); 3589 (long)atomic64_read(&perf_stats.pcis));
3606 _OUTP_IT("Number of adapter interrupts caught : %lu\n", 3590 _OUTP_IT("Number of adapter interrupts caught : %li\n",
3607 perf_stats.thinints); 3591 (long)atomic64_read(&perf_stats.thinints));
3608 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %lu\n", 3592 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %li\n",
3609 perf_stats.fast_reqs); 3593 (long)atomic64_read(&perf_stats.fast_reqs));
3610 _OUTP_IT("\n"); 3594 _OUTP_IT("\n");
3611 _OUTP_IT("Total time of all inbound actions (us) incl. UL : %lu\n", 3595 _OUTP_IT("Number of inbound transfers : %li\n",
3612 perf_stats.inbound_time); 3596 (long)atomic64_read(&perf_stats.inbound_cnt));
3613 _OUTP_IT("Number of inbound transfers : %lu\n", 3597 _OUTP_IT("Number of do_QDIOs outbound : %li\n",
3614 perf_stats.inbound_cnt); 3598 (long)atomic64_read(&perf_stats.outbound_cnt));
3615 _OUTP_IT("Total time of all outbound do_QDIOs (us) : %lu\n", 3599#else /* CONFIG_64BIT */
3616 perf_stats.outbound_time); 3600 _OUTP_IT("Number of tasklet runs (total) : %i\n",
3617 _OUTP_IT("Number of do_QDIOs outbound : %lu\n", 3601 atomic_read(&perf_stats.tl_runs));
3618 perf_stats.outbound_cnt); 3602 _OUTP_IT("Inbound tasklet runs tried/retried : %i/%i\n",
3603 atomic_read(&perf_stats.inbound_tl_runs),
3604 atomic_read(&perf_stats.inbound_tl_runs_resched));
3605 _OUTP_IT("Inbound-thin tasklet runs tried/retried : %i/%i\n",
3606 atomic_read(&perf_stats.inbound_thin_tl_runs),
3607 atomic_read(&perf_stats.inbound_thin_tl_runs_resched));
3608 _OUTP_IT("Outbound tasklet runs tried/retried : %i/%i\n",
3609 atomic_read(&perf_stats.outbound_tl_runs),
3610 atomic_read(&perf_stats.outbound_tl_runs_resched));
3611 _OUTP_IT("\n");
3612 _OUTP_IT("Number of SIGA sync's issued : %i\n",
3613 atomic_read(&perf_stats.siga_syncs));
3614 _OUTP_IT("Number of SIGA in's issued : %i\n",
3615 atomic_read(&perf_stats.siga_ins));
3616 _OUTP_IT("Number of SIGA out's issued : %i\n",
3617 atomic_read(&perf_stats.siga_outs));
3618 _OUTP_IT("Number of PCIs caught : %i\n",
3619 atomic_read(&perf_stats.pcis));
3620 _OUTP_IT("Number of adapter interrupts caught : %i\n",
3621 atomic_read(&perf_stats.thinints));
3622 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %i\n",
3623 atomic_read(&perf_stats.fast_reqs));
3624 _OUTP_IT("\n");
3625 _OUTP_IT("Number of inbound transfers : %i\n",
3626 atomic_read(&perf_stats.inbound_cnt));
3627 _OUTP_IT("Number of do_QDIOs outbound : %i\n",
3628 atomic_read(&perf_stats.outbound_cnt));
3629#endif /* CONFIG_64BIT */
3619 _OUTP_IT("\n"); 3630 _OUTP_IT("\n");
3620 3631
3621 return c; 3632 return c;
@@ -3642,8 +3653,6 @@ qdio_add_procfs_entry(void)
3642static void 3653static void
3643qdio_remove_procfs_entry(void) 3654qdio_remove_procfs_entry(void)
3644{ 3655{
3645 perf_stats.tl_runs=0;
3646
3647 if (!proc_perf_file_registration) /* means if it went ok earlier */ 3656 if (!proc_perf_file_registration) /* means if it went ok earlier */
3648 remove_proc_entry(QDIO_PERF,&proc_root); 3657 remove_proc_entry(QDIO_PERF,&proc_root);
3649} 3658}
@@ -3671,13 +3680,38 @@ qdio_performance_stats_store(struct bus_type *bus, const char *buf, size_t count
3671 qdio_performance_stats = i; 3680 qdio_performance_stats = i;
3672 if (i==0) { 3681 if (i==0) {
3673 /* reset perf. stat. info */ 3682 /* reset perf. stat. info */
3674 i_p_nc = 0; 3683#ifdef CONFIG_64BIT
3675 i_p_c = 0; 3684 atomic64_set(&perf_stats.tl_runs, 0);
3676 ii_p_nc = 0; 3685 atomic64_set(&perf_stats.outbound_tl_runs, 0);
3677 ii_p_c = 0; 3686 atomic64_set(&perf_stats.inbound_tl_runs, 0);
3678 o_p_nc = 0; 3687 atomic64_set(&perf_stats.inbound_tl_runs_resched, 0);
3679 o_p_c = 0; 3688 atomic64_set(&perf_stats.inbound_thin_tl_runs, 0);
3680 memset(&perf_stats, 0, sizeof(struct qdio_perf_stats)); 3689 atomic64_set(&perf_stats.inbound_thin_tl_runs_resched,
3690 0);
3691 atomic64_set(&perf_stats.siga_outs, 0);
3692 atomic64_set(&perf_stats.siga_ins, 0);
3693 atomic64_set(&perf_stats.siga_syncs, 0);
3694 atomic64_set(&perf_stats.pcis, 0);
3695 atomic64_set(&perf_stats.thinints, 0);
3696 atomic64_set(&perf_stats.fast_reqs, 0);
3697 atomic64_set(&perf_stats.outbound_cnt, 0);
3698 atomic64_set(&perf_stats.inbound_cnt, 0);
3699#else /* CONFIG_64BIT */
3700 atomic_set(&perf_stats.tl_runs, 0);
3701 atomic_set(&perf_stats.outbound_tl_runs, 0);
3702 atomic_set(&perf_stats.inbound_tl_runs, 0);
3703 atomic_set(&perf_stats.inbound_tl_runs_resched, 0);
3704 atomic_set(&perf_stats.inbound_thin_tl_runs, 0);
3705 atomic_set(&perf_stats.inbound_thin_tl_runs_resched, 0);
3706 atomic_set(&perf_stats.siga_outs, 0);
3707 atomic_set(&perf_stats.siga_ins, 0);
3708 atomic_set(&perf_stats.siga_syncs, 0);
3709 atomic_set(&perf_stats.pcis, 0);
3710 atomic_set(&perf_stats.thinints, 0);
3711 atomic_set(&perf_stats.fast_reqs, 0);
3712 atomic_set(&perf_stats.outbound_cnt, 0);
3713 atomic_set(&perf_stats.inbound_cnt, 0);
3714#endif /* CONFIG_64BIT */
3681 } 3715 }
3682 } else { 3716 } else {
3683 QDIO_PRINT_WARN("QDIO performance_stats: write 0 or 1 to this file!\n"); 3717 QDIO_PRINT_WARN("QDIO performance_stats: write 0 or 1 to this file!\n");
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index ec9af72b2afc..2895392eaae4 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -406,21 +406,43 @@ do_clear_global_summary(void)
406#define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04 406#define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
407 407
408struct qdio_perf_stats { 408struct qdio_perf_stats {
409 unsigned long tl_runs; 409#ifdef CONFIG_64BIT
410 410 atomic64_t tl_runs;
411 unsigned long siga_outs; 411 atomic64_t outbound_tl_runs;
412 unsigned long siga_ins; 412 atomic64_t outbound_tl_runs_resched;
413 unsigned long siga_syncs; 413 atomic64_t inbound_tl_runs;
414 unsigned long pcis; 414 atomic64_t inbound_tl_runs_resched;
415 unsigned long thinints; 415 atomic64_t inbound_thin_tl_runs;
416 unsigned long fast_reqs; 416 atomic64_t inbound_thin_tl_runs_resched;
417 417
418 __u64 start_time_outbound; 418 atomic64_t siga_outs;
419 unsigned long outbound_cnt; 419 atomic64_t siga_ins;
420 unsigned long outbound_time; 420 atomic64_t siga_syncs;
421 __u64 start_time_inbound; 421 atomic64_t pcis;
422 unsigned long inbound_cnt; 422 atomic64_t thinints;
423 unsigned long inbound_time; 423 atomic64_t fast_reqs;
424
425 atomic64_t outbound_cnt;
426 atomic64_t inbound_cnt;
427#else /* CONFIG_64BIT */
428 atomic_t tl_runs;
429 atomic_t outbound_tl_runs;
430 atomic_t outbound_tl_runs_resched;
431 atomic_t inbound_tl_runs;
432 atomic_t inbound_tl_runs_resched;
433 atomic_t inbound_thin_tl_runs;
434 atomic_t inbound_thin_tl_runs_resched;
435
436 atomic_t siga_outs;
437 atomic_t siga_ins;
438 atomic_t siga_syncs;
439 atomic_t pcis;
440 atomic_t thinints;
441 atomic_t fast_reqs;
442
443 atomic_t outbound_cnt;
444 atomic_t inbound_cnt;
445#endif /* CONFIG_64BIT */
424}; 446};
425 447
426/* unlikely as the later the better */ 448/* unlikely as the later the better */
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index 84b108d7c7fd..b34eb82edd98 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -288,6 +288,7 @@ qeth_is_ipa_enabled(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
288 */ 288 */
289#define IF_NAME_LEN 16 289#define IF_NAME_LEN 16
290#define QETH_TX_TIMEOUT 100 * HZ 290#define QETH_TX_TIMEOUT 100 * HZ
291#define QETH_RCD_TIMEOUT 60 * HZ
291#define QETH_HEADER_SIZE 32 292#define QETH_HEADER_SIZE 32
292#define MAX_PORTNO 15 293#define MAX_PORTNO 15
293#define QETH_FAKE_LL_LEN_ETH ETH_HLEN 294#define QETH_FAKE_LL_LEN_ETH ETH_HLEN
@@ -582,6 +583,8 @@ enum qeth_channel_states {
582 CH_STATE_ACTIVATING, 583 CH_STATE_ACTIVATING,
583 CH_STATE_HALTED, 584 CH_STATE_HALTED,
584 CH_STATE_STOPPED, 585 CH_STATE_STOPPED,
586 CH_STATE_RCD,
587 CH_STATE_RCD_DONE,
585}; 588};
586/** 589/**
587 * card state machine 590 * card state machine
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index ad7792dc1a04..6fd8870551d3 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -315,7 +315,8 @@ qeth_alloc_card(void)
315} 315}
316 316
317static long 317static long
318__qeth_check_irb_error(struct ccw_device *cdev, struct irb *irb) 318__qeth_check_irb_error(struct ccw_device *cdev, unsigned long intparm,
319 struct irb *irb)
319{ 320{
320 if (!IS_ERR(irb)) 321 if (!IS_ERR(irb))
321 return 0; 322 return 0;
@@ -330,6 +331,14 @@ __qeth_check_irb_error(struct ccw_device *cdev, struct irb *irb)
330 PRINT_WARN("timeout on device %s\n", cdev->dev.bus_id); 331 PRINT_WARN("timeout on device %s\n", cdev->dev.bus_id);
331 QETH_DBF_TEXT(trace, 2, "ckirberr"); 332 QETH_DBF_TEXT(trace, 2, "ckirberr");
332 QETH_DBF_TEXT_(trace, 2, " rc%d", -ETIMEDOUT); 333 QETH_DBF_TEXT_(trace, 2, " rc%d", -ETIMEDOUT);
334 if (intparm == QETH_RCD_PARM) {
335 struct qeth_card *card = CARD_FROM_CDEV(cdev);
336
337 if (card && (card->data.ccwdev == cdev)) {
338 card->data.state = CH_STATE_DOWN;
339 wake_up(&card->wait_q);
340 }
341 }
333 break; 342 break;
334 default: 343 default:
335 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb), 344 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb),
@@ -401,7 +410,7 @@ qeth_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
401 410
402 QETH_DBF_TEXT(trace,5,"irq"); 411 QETH_DBF_TEXT(trace,5,"irq");
403 412
404 if (__qeth_check_irb_error(cdev, irb)) 413 if (__qeth_check_irb_error(cdev, intparm, irb))
405 return; 414 return;
406 cstat = irb->scsw.cstat; 415 cstat = irb->scsw.cstat;
407 dstat = irb->scsw.dstat; 416 dstat = irb->scsw.dstat;
@@ -429,7 +438,8 @@ qeth_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
429 channel->state = CH_STATE_HALTED; 438 channel->state = CH_STATE_HALTED;
430 439
431 /*let's wake up immediately on data channel*/ 440 /*let's wake up immediately on data channel*/
432 if ((channel == &card->data) && (intparm != 0)) 441 if ((channel == &card->data) && (intparm != 0) &&
442 (intparm != QETH_RCD_PARM))
433 goto out; 443 goto out;
434 444
435 if (intparm == QETH_CLEAR_CHANNEL_PARM) { 445 if (intparm == QETH_CLEAR_CHANNEL_PARM) {
@@ -453,6 +463,10 @@ qeth_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
453 HEXDUMP16(WARN,"irb: ",irb); 463 HEXDUMP16(WARN,"irb: ",irb);
454 HEXDUMP16(WARN,"sense data: ",irb->ecw); 464 HEXDUMP16(WARN,"sense data: ",irb->ecw);
455 } 465 }
466 if (intparm == QETH_RCD_PARM) {
467 channel->state = CH_STATE_DOWN;
468 goto out;
469 }
456 rc = qeth_get_problem(cdev,irb); 470 rc = qeth_get_problem(cdev,irb);
457 if (rc) { 471 if (rc) {
458 qeth_schedule_recovery(card); 472 qeth_schedule_recovery(card);
@@ -460,6 +474,10 @@ qeth_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
460 } 474 }
461 } 475 }
462 476
477 if (intparm == QETH_RCD_PARM) {
478 channel->state = CH_STATE_RCD_DONE;
479 goto out;
480 }
463 if (intparm) { 481 if (intparm) {
464 buffer = (struct qeth_cmd_buffer *) __va((addr_t)intparm); 482 buffer = (struct qeth_cmd_buffer *) __va((addr_t)intparm);
465 buffer->state = BUF_STATE_PROCESSED; 483 buffer->state = BUF_STATE_PROCESSED;
@@ -1204,6 +1222,54 @@ qeth_probe_device(struct ccwgroup_device *gdev)
1204} 1222}
1205 1223
1206 1224
1225static int qeth_read_conf_data(struct qeth_card *card, void **buffer,
1226 int *length)
1227{
1228 struct ciw *ciw;
1229 char *rcd_buf;
1230 int ret;
1231 struct qeth_channel *channel = &card->data;
1232 unsigned long flags;
1233
1234 /*
1235 * scan for RCD command in extended SenseID data
1236 */
1237 ciw = ccw_device_get_ciw(channel->ccwdev, CIW_TYPE_RCD);
1238 if (!ciw || ciw->cmd == 0)
1239 return -EOPNOTSUPP;
1240 rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA);
1241 if (!rcd_buf)
1242 return -ENOMEM;
1243
1244 channel->ccw.cmd_code = ciw->cmd;
1245 channel->ccw.cda = (__u32) __pa (rcd_buf);
1246 channel->ccw.count = ciw->count;
1247 channel->ccw.flags = CCW_FLAG_SLI;
1248 channel->state = CH_STATE_RCD;
1249 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1250 ret = ccw_device_start_timeout(channel->ccwdev, &channel->ccw,
1251 QETH_RCD_PARM, LPM_ANYPATH, 0,
1252 QETH_RCD_TIMEOUT);
1253 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
1254 if (!ret)
1255 wait_event(card->wait_q,
1256 (channel->state == CH_STATE_RCD_DONE ||
1257 channel->state == CH_STATE_DOWN));
1258 if (channel->state == CH_STATE_DOWN)
1259 ret = -EIO;
1260 else
1261 channel->state = CH_STATE_DOWN;
1262 if (ret) {
1263 kfree(rcd_buf);
1264 *buffer = NULL;
1265 *length = 0;
1266 } else {
1267 *length = ciw->count;
1268 *buffer = rcd_buf;
1269 }
1270 return ret;
1271}
1272
1207static int 1273static int
1208qeth_get_unitaddr(struct qeth_card *card) 1274qeth_get_unitaddr(struct qeth_card *card)
1209{ 1275{
@@ -1212,9 +1278,9 @@ qeth_get_unitaddr(struct qeth_card *card)
1212 int rc; 1278 int rc;
1213 1279
1214 QETH_DBF_TEXT(setup, 2, "getunit"); 1280 QETH_DBF_TEXT(setup, 2, "getunit");
1215 rc = read_conf_data(CARD_DDEV(card), (void **) &prcd, &length); 1281 rc = qeth_read_conf_data(card, (void **) &prcd, &length);
1216 if (rc) { 1282 if (rc) {
1217 PRINT_ERR("read_conf_data for device %s returned %i\n", 1283 PRINT_ERR("qeth_read_conf_data for device %s returned %i\n",
1218 CARD_DDEV_ID(card), rc); 1284 CARD_DDEV_ID(card), rc);
1219 return rc; 1285 return rc;
1220 } 1286 }
@@ -1223,6 +1289,7 @@ qeth_get_unitaddr(struct qeth_card *card)
1223 card->info.cula = prcd[63]; 1289 card->info.cula = prcd[63];
1224 card->info.guestlan = ((prcd[0x10] == _ascebc['V']) && 1290 card->info.guestlan = ((prcd[0x10] == _ascebc['V']) &&
1225 (prcd[0x11] == _ascebc['M'])); 1291 (prcd[0x11] == _ascebc['M']));
1292 kfree(prcd);
1226 return 0; 1293 return 0;
1227} 1294}
1228 1295
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h
index 0477c47471c5..d74bc43da72a 100644
--- a/drivers/s390/net/qeth_mpc.h
+++ b/drivers/s390/net/qeth_mpc.h
@@ -37,6 +37,7 @@ extern unsigned char IPA_PDU_HEADER[];
37 37
38#define QETH_CLEAR_CHANNEL_PARM -10 38#define QETH_CLEAR_CHANNEL_PARM -10
39#define QETH_HALT_CHANNEL_PARM -11 39#define QETH_HALT_CHANNEL_PARM -11
40#define QETH_RCD_PARM -12
40 41
41/*****************************************************************************/ 42/*****************************************************************************/
42/* IP Assist related definitions */ 43/* IP Assist related definitions */
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 421da1e7c0ea..c1f2d4b14c2b 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -186,7 +186,7 @@ void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req, unsigned long timeout)
186{ 186{
187 fsf_req->timer.function = zfcp_fsf_request_timeout_handler; 187 fsf_req->timer.function = zfcp_fsf_request_timeout_handler;
188 fsf_req->timer.data = (unsigned long) fsf_req->adapter; 188 fsf_req->timer.data = (unsigned long) fsf_req->adapter;
189 fsf_req->timer.expires = timeout; 189 fsf_req->timer.expires = jiffies + timeout;
190 add_timer(&fsf_req->timer); 190 add_timer(&fsf_req->timer);
191} 191}
192 192
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index ef16f7ca4bb1..4c0a59afd5c8 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -299,9 +299,10 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
299 } 299 }
300 300
301 /* log additional information provided by FSF (if any) */ 301 /* log additional information provided by FSF (if any) */
302 if (unlikely(qtcb->header.log_length)) { 302 if (likely(qtcb->header.log_length)) {
303 /* do not trust them ;-) */ 303 /* do not trust them ;-) */
304 if (qtcb->header.log_start > sizeof(struct fsf_qtcb)) { 304 if (unlikely(qtcb->header.log_start >
305 sizeof(struct fsf_qtcb))) {
305 ZFCP_LOG_NORMAL 306 ZFCP_LOG_NORMAL
306 ("bug: ULP (FSF logging) log data starts " 307 ("bug: ULP (FSF logging) log data starts "
307 "beyond end of packet header. Ignored. " 308 "beyond end of packet header. Ignored. "
@@ -310,8 +311,9 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
310 sizeof(struct fsf_qtcb)); 311 sizeof(struct fsf_qtcb));
311 goto forget_log; 312 goto forget_log;
312 } 313 }
313 if ((size_t) (qtcb->header.log_start + qtcb->header.log_length) 314 if (unlikely((size_t) (qtcb->header.log_start +
314 > sizeof(struct fsf_qtcb)) { 315 qtcb->header.log_length) >
316 sizeof(struct fsf_qtcb))) {
315 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends " 317 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
316 "beyond end of packet header. Ignored. " 318 "beyond end of packet header. Ignored. "
317 "(start=%i, length=%i, size=%li)\n", 319 "(start=%i, length=%i, size=%li)\n",
diff --git a/drivers/sbus/sbus.c b/drivers/sbus/sbus.c
index eee590a51d8a..002643392d42 100644
--- a/drivers/sbus/sbus.c
+++ b/drivers/sbus/sbus.c
@@ -6,7 +6,6 @@
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/slab.h> 7#include <linux/slab.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/pci.h>
10#include <linux/device.h> 9#include <linux/device.h>
11 10
12#include <asm/system.h> 11#include <asm/system.h>
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index e874b8944875..96f4cab07614 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -579,17 +579,17 @@ static void __init BusLogic_InitializeProbeInfoListISA(struct BusLogic_HostAdapt
579 /* 579 /*
580 Append the list of standard BusLogic MultiMaster ISA I/O Addresses. 580 Append the list of standard BusLogic MultiMaster ISA I/O Addresses.
581 */ 581 */
582 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0) 582 if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe330)
583 BusLogic_AppendProbeAddressISA(0x330); 583 BusLogic_AppendProbeAddressISA(0x330);
584 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0) 584 if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe334)
585 BusLogic_AppendProbeAddressISA(0x334); 585 BusLogic_AppendProbeAddressISA(0x334);
586 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0) 586 if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe230)
587 BusLogic_AppendProbeAddressISA(0x230); 587 BusLogic_AppendProbeAddressISA(0x230);
588 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0) 588 if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe234)
589 BusLogic_AppendProbeAddressISA(0x234); 589 BusLogic_AppendProbeAddressISA(0x234);
590 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0) 590 if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe130)
591 BusLogic_AppendProbeAddressISA(0x130); 591 BusLogic_AppendProbeAddressISA(0x130);
592 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0) 592 if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe134)
593 BusLogic_AppendProbeAddressISA(0x134); 593 BusLogic_AppendProbeAddressISA(0x134);
594} 594}
595 595
@@ -795,7 +795,9 @@ static int __init BusLogic_InitializeMultiMasterProbeInfo(struct BusLogic_HostAd
795 host adapters are probed. 795 host adapters are probed.
796 */ 796 */
797 if (!BusLogic_ProbeOptions.NoProbeISA) 797 if (!BusLogic_ProbeOptions.NoProbeISA)
798 if (PrimaryProbeInfo->IO_Address == 0 && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)) { 798 if (PrimaryProbeInfo->IO_Address == 0 &&
799 (!BusLogic_ProbeOptions.LimitedProbeISA ||
800 BusLogic_ProbeOptions.Probe330)) {
799 PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster; 801 PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster;
800 PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus; 802 PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus;
801 PrimaryProbeInfo->IO_Address = 0x330; 803 PrimaryProbeInfo->IO_Address = 0x330;
@@ -805,15 +807,25 @@ static int __init BusLogic_InitializeMultiMasterProbeInfo(struct BusLogic_HostAd
805 omitting the Primary I/O Address which has already been handled. 807 omitting the Primary I/O Address which has already been handled.
806 */ 808 */
807 if (!BusLogic_ProbeOptions.NoProbeISA) { 809 if (!BusLogic_ProbeOptions.NoProbeISA) {
808 if (!StandardAddressSeen[1] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0)) 810 if (!StandardAddressSeen[1] &&
811 (!BusLogic_ProbeOptions.LimitedProbeISA ||
812 BusLogic_ProbeOptions.Probe334))
809 BusLogic_AppendProbeAddressISA(0x334); 813 BusLogic_AppendProbeAddressISA(0x334);
810 if (!StandardAddressSeen[2] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0)) 814 if (!StandardAddressSeen[2] &&
815 (!BusLogic_ProbeOptions.LimitedProbeISA ||
816 BusLogic_ProbeOptions.Probe230))
811 BusLogic_AppendProbeAddressISA(0x230); 817 BusLogic_AppendProbeAddressISA(0x230);
812 if (!StandardAddressSeen[3] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0)) 818 if (!StandardAddressSeen[3] &&
819 (!BusLogic_ProbeOptions.LimitedProbeISA ||
820 BusLogic_ProbeOptions.Probe234))
813 BusLogic_AppendProbeAddressISA(0x234); 821 BusLogic_AppendProbeAddressISA(0x234);
814 if (!StandardAddressSeen[4] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0)) 822 if (!StandardAddressSeen[4] &&
823 (!BusLogic_ProbeOptions.LimitedProbeISA ||
824 BusLogic_ProbeOptions.Probe130))
815 BusLogic_AppendProbeAddressISA(0x130); 825 BusLogic_AppendProbeAddressISA(0x130);
816 if (!StandardAddressSeen[5] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0)) 826 if (!StandardAddressSeen[5] &&
827 (!BusLogic_ProbeOptions.LimitedProbeISA ||
828 BusLogic_ProbeOptions.Probe134))
817 BusLogic_AppendProbeAddressISA(0x134); 829 BusLogic_AppendProbeAddressISA(0x134);
818 } 830 }
819 /* 831 /*
@@ -2220,22 +2232,35 @@ static int __init BusLogic_init(void)
2220 HostAdapter->PCI_Device = ProbeInfo->PCI_Device; 2232 HostAdapter->PCI_Device = ProbeInfo->PCI_Device;
2221 HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel; 2233 HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel;
2222 HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType]; 2234 HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType];
2235
2236 /*
2237 Make sure region is free prior to probing.
2238 */
2239 if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount,
2240 "BusLogic"))
2241 continue;
2223 /* 2242 /*
2224 Probe the Host Adapter. If unsuccessful, abort further initialization. 2243 Probe the Host Adapter. If unsuccessful, abort further initialization.
2225 */ 2244 */
2226 if (!BusLogic_ProbeHostAdapter(HostAdapter)) 2245 if (!BusLogic_ProbeHostAdapter(HostAdapter)) {
2246 release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
2227 continue; 2247 continue;
2248 }
2228 /* 2249 /*
2229 Hard Reset the Host Adapter. If unsuccessful, abort further 2250 Hard Reset the Host Adapter. If unsuccessful, abort further
2230 initialization. 2251 initialization.
2231 */ 2252 */
2232 if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true)) 2253 if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true)) {
2254 release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
2233 continue; 2255 continue;
2256 }
2234 /* 2257 /*
2235 Check the Host Adapter. If unsuccessful, abort further initialization. 2258 Check the Host Adapter. If unsuccessful, abort further initialization.
2236 */ 2259 */
2237 if (!BusLogic_CheckHostAdapter(HostAdapter)) 2260 if (!BusLogic_CheckHostAdapter(HostAdapter)) {
2261 release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
2238 continue; 2262 continue;
2263 }
2239 /* 2264 /*
2240 Initialize the Driver Options field if provided. 2265 Initialize the Driver Options field if provided.
2241 */ 2266 */
@@ -2247,16 +2272,6 @@ static int __init BusLogic_init(void)
2247 */ 2272 */
2248 BusLogic_AnnounceDriver(HostAdapter); 2273 BusLogic_AnnounceDriver(HostAdapter);
2249 /* 2274 /*
2250 Register usage of the I/O Address range. From this point onward, any
2251 failure will be assumed to be due to a problem with the Host Adapter,
2252 rather than due to having mistakenly identified this port as belonging
2253 to a BusLogic Host Adapter. The I/O Address range will not be
2254 released, thereby preventing it from being incorrectly identified as
2255 any other type of Host Adapter.
2256 */
2257 if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, "BusLogic"))
2258 continue;
2259 /*
2260 Register the SCSI Host structure. 2275 Register the SCSI Host structure.
2261 */ 2276 */
2262 2277
@@ -2280,6 +2295,12 @@ static int __init BusLogic_init(void)
2280 Acquire the System Resources necessary to use the Host Adapter, then 2295 Acquire the System Resources necessary to use the Host Adapter, then
2281 Create the Initial CCBs, Initialize the Host Adapter, and finally 2296 Create the Initial CCBs, Initialize the Host Adapter, and finally
2282 perform Target Device Inquiry. 2297 perform Target Device Inquiry.
2298
2299 From this point onward, any failure will be assumed to be due to a
2300 problem with the Host Adapter, rather than due to having mistakenly
2301 identified this port as belonging to a BusLogic Host Adapter. The
2302 I/O Address range will not be released, thereby preventing it from
2303 being incorrectly identified as any other type of Host Adapter.
2283 */ 2304 */
2284 if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) && 2305 if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) &&
2285 BusLogic_ReportHostAdapterConfiguration(HostAdapter) && 2306 BusLogic_ReportHostAdapterConfiguration(HostAdapter) &&
@@ -3598,6 +3619,7 @@ static void __exit BusLogic_exit(void)
3598 3619
3599__setup("BusLogic=", BusLogic_Setup); 3620__setup("BusLogic=", BusLogic_Setup);
3600 3621
3622#ifdef MODULE
3601static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = { 3623static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = {
3602 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, 3624 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
3603 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 3625 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -3607,6 +3629,7 @@ static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = {
3607 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 3629 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3608 { } 3630 { }
3609}; 3631};
3632#endif
3610MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl); 3633MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl);
3611 3634
3612module_init(BusLogic_init); 3635module_init(BusLogic_init);
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index fcc4cb6c7f46..58c811d20eb2 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -241,6 +241,12 @@ config SCSI_SCAN_ASYNC
241 You can override this choice by specifying "scsi_mod.scan=sync" 241 You can override this choice by specifying "scsi_mod.scan=sync"
242 or async on the kernel's command line. 242 or async on the kernel's command line.
243 243
244config SCSI_WAIT_SCAN
245 tristate
246 default m
247 depends on SCSI
248 depends on MODULES
249
244menu "SCSI Transports" 250menu "SCSI Transports"
245 depends on SCSI 251 depends on SCSI
246 252
@@ -1194,17 +1200,6 @@ config SCSI_NCR53C8XX_SYNC
1194 There is no safe option other than using good cabling, right 1200 There is no safe option other than using good cabling, right
1195 terminations and SCSI conformant devices. 1201 terminations and SCSI conformant devices.
1196 1202
1197config SCSI_NCR53C8XX_PROFILE
1198 bool "enable profiling"
1199 depends on SCSI_ZALON || SCSI_NCR_Q720
1200 help
1201 This option allows you to enable profiling information gathering.
1202 These statistics are not very accurate due to the low frequency
1203 of the kernel clock (100 Hz on i386) and have performance impact
1204 on systems that use very fast devices.
1205
1206 The normal answer therefore is N.
1207
1208config SCSI_NCR53C8XX_NO_DISCONNECT 1203config SCSI_NCR53C8XX_NO_DISCONNECT
1209 bool "not allow targets to disconnect" 1204 bool "not allow targets to disconnect"
1210 depends on (SCSI_ZALON || SCSI_NCR_Q720) && SCSI_NCR53C8XX_DEFAULT_TAGS=0 1205 depends on (SCSI_ZALON || SCSI_NCR_Q720) && SCSI_NCR53C8XX_DEFAULT_TAGS=0
@@ -1334,11 +1329,6 @@ config SCSI_SIM710
1334 1329
1335 It currently supports Compaq EISA cards and NCR MCA cards 1330 It currently supports Compaq EISA cards and NCR MCA cards
1336 1331
1337config 53C700_IO_MAPPED
1338 bool
1339 depends on SCSI_SIM710
1340 default y
1341
1342config SCSI_SYM53C416 1332config SCSI_SYM53C416
1343 tristate "Symbios 53c416 SCSI support" 1333 tristate "Symbios 53c416 SCSI support"
1344 depends on ISA && SCSI 1334 depends on ISA && SCSI
@@ -1649,7 +1639,7 @@ config OKTAGON_SCSI
1649 1639
1650config ATARI_SCSI 1640config ATARI_SCSI
1651 tristate "Atari native SCSI support" 1641 tristate "Atari native SCSI support"
1652 depends on ATARI && SCSI && BROKEN 1642 depends on ATARI && SCSI
1653 select SCSI_SPI_ATTRS 1643 select SCSI_SPI_ATTRS
1654 ---help--- 1644 ---help---
1655 If you have an Atari with built-in NCR5380 SCSI controller (TT, 1645 If you have an Atari with built-in NCR5380 SCSI controller (TT,
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 70cff4c599d7..51e884fa10b0 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -146,7 +146,7 @@ obj-$(CONFIG_CHR_DEV_SCH) += ch.o
146# This goes last, so that "real" scsi devices probe earlier 146# This goes last, so that "real" scsi devices probe earlier
147obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o 147obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
148 148
149obj-$(CONFIG_SCSI) += scsi_wait_scan.o 149obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wait_scan.o
150 150
151scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 151scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
152 scsicam.o scsi_error.o scsi_lib.o \ 152 scsicam.o scsi_error.o scsi_lib.o \
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index d789e61bdc49..1e82c69b36b0 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -172,6 +172,30 @@ MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB) size.
172int expose_physicals = -1; 172int expose_physicals = -1;
173module_param(expose_physicals, int, S_IRUGO|S_IWUSR); 173module_param(expose_physicals, int, S_IRUGO|S_IWUSR);
174MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on"); 174MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on");
175
176
177static inline int aac_valid_context(struct scsi_cmnd *scsicmd,
178 struct fib *fibptr) {
179 struct scsi_device *device;
180
181 if (unlikely(!scsicmd || !scsicmd->scsi_done )) {
182 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"))
183;
184 aac_fib_complete(fibptr);
185 aac_fib_free(fibptr);
186 return 0;
187 }
188 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL;
189 device = scsicmd->device;
190 if (unlikely(!device || !scsi_device_online(device))) {
191 dprintk((KERN_WARNING "aac_valid_context: scsi device corrupt\n"));
192 aac_fib_complete(fibptr);
193 aac_fib_free(fibptr);
194 return 0;
195 }
196 return 1;
197}
198
175/** 199/**
176 * aac_get_config_status - check the adapter configuration 200 * aac_get_config_status - check the adapter configuration
177 * @common: adapter to query 201 * @common: adapter to query
@@ -258,13 +282,10 @@ int aac_get_containers(struct aac_dev *dev)
258 u32 index; 282 u32 index;
259 int status = 0; 283 int status = 0;
260 struct fib * fibptr; 284 struct fib * fibptr;
261 unsigned instance;
262 struct aac_get_container_count *dinfo; 285 struct aac_get_container_count *dinfo;
263 struct aac_get_container_count_resp *dresp; 286 struct aac_get_container_count_resp *dresp;
264 int maximum_num_containers = MAXIMUM_NUM_CONTAINERS; 287 int maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
265 288
266 instance = dev->scsi_host_ptr->unique_id;
267
268 if (!(fibptr = aac_fib_alloc(dev))) 289 if (!(fibptr = aac_fib_alloc(dev)))
269 return -ENOMEM; 290 return -ENOMEM;
270 291
@@ -284,88 +305,35 @@ int aac_get_containers(struct aac_dev *dev)
284 maximum_num_containers = le32_to_cpu(dresp->ContainerSwitchEntries); 305 maximum_num_containers = le32_to_cpu(dresp->ContainerSwitchEntries);
285 aac_fib_complete(fibptr); 306 aac_fib_complete(fibptr);
286 } 307 }
308 aac_fib_free(fibptr);
287 309
288 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) 310 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
289 maximum_num_containers = MAXIMUM_NUM_CONTAINERS; 311 maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
290 fsa_dev_ptr = kmalloc( 312 fsa_dev_ptr = kmalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers,
291 sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL); 313 GFP_KERNEL);
292 if (!fsa_dev_ptr) { 314 if (!fsa_dev_ptr)
293 aac_fib_free(fibptr);
294 return -ENOMEM; 315 return -ENOMEM;
295 }
296 memset(fsa_dev_ptr, 0, sizeof(*fsa_dev_ptr) * maximum_num_containers); 316 memset(fsa_dev_ptr, 0, sizeof(*fsa_dev_ptr) * maximum_num_containers);
297 317
298 dev->fsa_dev = fsa_dev_ptr; 318 dev->fsa_dev = fsa_dev_ptr;
299 dev->maximum_num_containers = maximum_num_containers; 319 dev->maximum_num_containers = maximum_num_containers;
300 320
301 for (index = 0; index < dev->maximum_num_containers; index++) { 321 for (index = 0; index < dev->maximum_num_containers; ) {
302 struct aac_query_mount *dinfo;
303 struct aac_mount *dresp;
304
305 fsa_dev_ptr[index].devname[0] = '\0'; 322 fsa_dev_ptr[index].devname[0] = '\0';
306 323
307 aac_fib_init(fibptr); 324 status = aac_probe_container(dev, index);
308 dinfo = (struct aac_query_mount *) fib_data(fibptr);
309
310 dinfo->command = cpu_to_le32(VM_NameServe);
311 dinfo->count = cpu_to_le32(index);
312 dinfo->type = cpu_to_le32(FT_FILESYS);
313 325
314 status = aac_fib_send(ContainerCommand, 326 if (status < 0) {
315 fibptr,
316 sizeof (struct aac_query_mount),
317 FsaNormal,
318 1, 1,
319 NULL, NULL);
320 if (status < 0 ) {
321 printk(KERN_WARNING "aac_get_containers: SendFIB failed.\n"); 327 printk(KERN_WARNING "aac_get_containers: SendFIB failed.\n");
322 break; 328 break;
323 } 329 }
324 dresp = (struct aac_mount *)fib_data(fibptr);
325 330
326 if ((le32_to_cpu(dresp->status) == ST_OK) &&
327 (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) {
328 dinfo->command = cpu_to_le32(VM_NameServe64);
329 dinfo->count = cpu_to_le32(index);
330 dinfo->type = cpu_to_le32(FT_FILESYS);
331
332 if (aac_fib_send(ContainerCommand,
333 fibptr,
334 sizeof(struct aac_query_mount),
335 FsaNormal,
336 1, 1,
337 NULL, NULL) < 0)
338 continue;
339 } else
340 dresp->mnt[0].capacityhigh = 0;
341
342 dprintk ((KERN_DEBUG
343 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n",
344 (int)index, (int)le32_to_cpu(dresp->status),
345 (int)le32_to_cpu(dresp->mnt[0].vol),
346 (int)le32_to_cpu(dresp->mnt[0].state),
347 ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
348 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32)));
349 if ((le32_to_cpu(dresp->status) == ST_OK) &&
350 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
351 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
352 fsa_dev_ptr[index].valid = 1;
353 fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol);
354 fsa_dev_ptr[index].size
355 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
356 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
357 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
358 fsa_dev_ptr[index].ro = 1;
359 }
360 aac_fib_complete(fibptr);
361 /* 331 /*
362 * If there are no more containers, then stop asking. 332 * If there are no more containers, then stop asking.
363 */ 333 */
364 if ((index + 1) >= le32_to_cpu(dresp->count)){ 334 if (++index >= status)
365 break; 335 break;
366 }
367 } 336 }
368 aac_fib_free(fibptr);
369 return status; 337 return status;
370} 338}
371 339
@@ -382,8 +350,9 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne
382 buf = scsicmd->request_buffer; 350 buf = scsicmd->request_buffer;
383 transfer_len = min(scsicmd->request_bufflen, len + offset); 351 transfer_len = min(scsicmd->request_bufflen, len + offset);
384 } 352 }
385 353 transfer_len -= offset;
386 memcpy(buf + offset, data, transfer_len - offset); 354 if (buf && transfer_len)
355 memcpy(buf + offset, data, transfer_len);
387 356
388 if (scsicmd->use_sg) 357 if (scsicmd->use_sg)
389 kunmap_atomic(buf - sg->offset, KM_IRQ0); 358 kunmap_atomic(buf - sg->offset, KM_IRQ0);
@@ -396,7 +365,9 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
396 struct scsi_cmnd * scsicmd; 365 struct scsi_cmnd * scsicmd;
397 366
398 scsicmd = (struct scsi_cmnd *) context; 367 scsicmd = (struct scsi_cmnd *) context;
399 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 368
369 if (!aac_valid_context(scsicmd, fibptr))
370 return;
400 371
401 dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies)); 372 dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies));
402 BUG_ON(fibptr == NULL); 373 BUG_ON(fibptr == NULL);
@@ -431,7 +402,7 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
431/** 402/**
432 * aac_get_container_name - get container name, none blocking. 403 * aac_get_container_name - get container name, none blocking.
433 */ 404 */
434static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid) 405static int aac_get_container_name(struct scsi_cmnd * scsicmd)
435{ 406{
436 int status; 407 int status;
437 struct aac_get_name *dinfo; 408 struct aac_get_name *dinfo;
@@ -448,7 +419,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid)
448 419
449 dinfo->command = cpu_to_le32(VM_ContainerConfig); 420 dinfo->command = cpu_to_le32(VM_ContainerConfig);
450 dinfo->type = cpu_to_le32(CT_READ_NAME); 421 dinfo->type = cpu_to_le32(CT_READ_NAME);
451 dinfo->cid = cpu_to_le32(cid); 422 dinfo->cid = cpu_to_le32(scmd_id(scsicmd));
452 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data)); 423 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
453 424
454 status = aac_fib_send(ContainerCommand, 425 status = aac_fib_send(ContainerCommand,
@@ -473,85 +444,192 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid)
473 return -1; 444 return -1;
474} 445}
475 446
476/** 447static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd)
477 * aac_probe_container - query a logical volume 448{
478 * @dev: device to query 449 struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev;
479 * @cid: container identifier 450
480 * 451 if (fsa_dev_ptr[scmd_id(scsicmd)].valid)
481 * Queries the controller about the given volume. The volume information 452 return aac_scsi_cmd(scsicmd);
482 * is updated in the struct fsa_dev_info structure rather than returned. 453
483 */ 454 scsicmd->result = DID_NO_CONNECT << 16;
484 455 scsicmd->scsi_done(scsicmd);
485int aac_probe_container(struct aac_dev *dev, int cid) 456 return 0;
457}
458
459static int _aac_probe_container2(void * context, struct fib * fibptr)
486{ 460{
487 struct fsa_dev_info *fsa_dev_ptr; 461 struct fsa_dev_info *fsa_dev_ptr;
488 int status; 462 int (*callback)(struct scsi_cmnd *);
463 struct scsi_cmnd * scsicmd = (struct scsi_cmnd *)context;
464
465 if (!aac_valid_context(scsicmd, fibptr))
466 return 0;
467
468 fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev;
469
470 scsicmd->SCp.Status = 0;
471 if (fsa_dev_ptr) {
472 struct aac_mount * dresp = (struct aac_mount *) fib_data(fibptr);
473 fsa_dev_ptr += scmd_id(scsicmd);
474
475 if ((le32_to_cpu(dresp->status) == ST_OK) &&
476 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
477 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
478 fsa_dev_ptr->valid = 1;
479 fsa_dev_ptr->type = le32_to_cpu(dresp->mnt[0].vol);
480 fsa_dev_ptr->size
481 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
482 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
483 fsa_dev_ptr->ro = ((le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) != 0);
484 }
485 if ((fsa_dev_ptr->valid & 1) == 0)
486 fsa_dev_ptr->valid = 0;
487 scsicmd->SCp.Status = le32_to_cpu(dresp->count);
488 }
489 aac_fib_complete(fibptr);
490 aac_fib_free(fibptr);
491 callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr);
492 scsicmd->SCp.ptr = NULL;
493 return (*callback)(scsicmd);
494}
495
496static int _aac_probe_container1(void * context, struct fib * fibptr)
497{
498 struct scsi_cmnd * scsicmd;
499 struct aac_mount * dresp;
489 struct aac_query_mount *dinfo; 500 struct aac_query_mount *dinfo;
490 struct aac_mount *dresp; 501 int status;
491 struct fib * fibptr;
492 unsigned instance;
493 502
494 fsa_dev_ptr = dev->fsa_dev; 503 dresp = (struct aac_mount *) fib_data(fibptr);
495 if (!fsa_dev_ptr) 504 dresp->mnt[0].capacityhigh = 0;
496 return -ENOMEM; 505 if ((le32_to_cpu(dresp->status) != ST_OK) ||
497 instance = dev->scsi_host_ptr->unique_id; 506 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE))
507 return _aac_probe_container2(context, fibptr);
508 scsicmd = (struct scsi_cmnd *) context;
509 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL;
498 510
499 if (!(fibptr = aac_fib_alloc(dev))) 511 if (!aac_valid_context(scsicmd, fibptr))
500 return -ENOMEM; 512 return 0;
501 513
502 aac_fib_init(fibptr); 514 aac_fib_init(fibptr);
503 515
504 dinfo = (struct aac_query_mount *)fib_data(fibptr); 516 dinfo = (struct aac_query_mount *)fib_data(fibptr);
505 517
506 dinfo->command = cpu_to_le32(VM_NameServe); 518 dinfo->command = cpu_to_le32(VM_NameServe64);
507 dinfo->count = cpu_to_le32(cid); 519 dinfo->count = cpu_to_le32(scmd_id(scsicmd));
508 dinfo->type = cpu_to_le32(FT_FILESYS); 520 dinfo->type = cpu_to_le32(FT_FILESYS);
509 521
510 status = aac_fib_send(ContainerCommand, 522 status = aac_fib_send(ContainerCommand,
511 fibptr, 523 fibptr,
512 sizeof(struct aac_query_mount), 524 sizeof(struct aac_query_mount),
513 FsaNormal, 525 FsaNormal,
514 1, 1, 526 0, 1,
515 NULL, NULL); 527 (fib_callback) _aac_probe_container2,
528 (void *) scsicmd);
529 /*
530 * Check that the command queued to the controller
531 */
532 if (status == -EINPROGRESS) {
533 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
534 return 0;
535 }
516 if (status < 0) { 536 if (status < 0) {
517 printk(KERN_WARNING "aacraid: aac_probe_container query failed.\n"); 537 /* Inherit results from VM_NameServe, if any */
518 goto error; 538 dresp->status = cpu_to_le32(ST_OK);
539 return _aac_probe_container2(context, fibptr);
519 } 540 }
541 return 0;
542}
520 543
521 dresp = (struct aac_mount *) fib_data(fibptr); 544static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(struct scsi_cmnd *))
545{
546 struct fib * fibptr;
547 int status = -ENOMEM;
522 548
523 if ((le32_to_cpu(dresp->status) == ST_OK) && 549 if ((fibptr = aac_fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata))) {
524 (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) { 550 struct aac_query_mount *dinfo;
525 dinfo->command = cpu_to_le32(VM_NameServe64);
526 dinfo->count = cpu_to_le32(cid);
527 dinfo->type = cpu_to_le32(FT_FILESYS);
528 551
529 if (aac_fib_send(ContainerCommand, 552 aac_fib_init(fibptr);
530 fibptr, 553
531 sizeof(struct aac_query_mount), 554 dinfo = (struct aac_query_mount *)fib_data(fibptr);
532 FsaNormal, 555
533 1, 1, 556 dinfo->command = cpu_to_le32(VM_NameServe);
534 NULL, NULL) < 0) 557 dinfo->count = cpu_to_le32(scmd_id(scsicmd));
535 goto error; 558 dinfo->type = cpu_to_le32(FT_FILESYS);
536 } else 559 scsicmd->SCp.ptr = (char *)callback;
537 dresp->mnt[0].capacityhigh = 0;
538 560
539 if ((le32_to_cpu(dresp->status) == ST_OK) && 561 status = aac_fib_send(ContainerCommand,
540 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && 562 fibptr,
541 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { 563 sizeof(struct aac_query_mount),
542 fsa_dev_ptr[cid].valid = 1; 564 FsaNormal,
543 fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol); 565 0, 1,
544 fsa_dev_ptr[cid].size 566 (fib_callback) _aac_probe_container1,
545 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + 567 (void *) scsicmd);
546 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32); 568 /*
547 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) 569 * Check that the command queued to the controller
548 fsa_dev_ptr[cid].ro = 1; 570 */
571 if (status == -EINPROGRESS) {
572 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
573 return 0;
574 }
575 if (status < 0) {
576 scsicmd->SCp.ptr = NULL;
577 aac_fib_complete(fibptr);
578 aac_fib_free(fibptr);
579 }
549 } 580 }
581 if (status < 0) {
582 struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev;
583 if (fsa_dev_ptr) {
584 fsa_dev_ptr += scmd_id(scsicmd);
585 if ((fsa_dev_ptr->valid & 1) == 0) {
586 fsa_dev_ptr->valid = 0;
587 return (*callback)(scsicmd);
588 }
589 }
590 }
591 return status;
592}
550 593
551error: 594/**
552 aac_fib_complete(fibptr); 595 * aac_probe_container - query a logical volume
553 aac_fib_free(fibptr); 596 * @dev: device to query
597 * @cid: container identifier
598 *
599 * Queries the controller about the given volume. The volume information
600 * is updated in the struct fsa_dev_info structure rather than returned.
601 */
602static int aac_probe_container_callback1(struct scsi_cmnd * scsicmd)
603{
604 scsicmd->device = NULL;
605 return 0;
606}
607
608int aac_probe_container(struct aac_dev *dev, int cid)
609{
610 struct scsi_cmnd *scsicmd = kmalloc(sizeof(*scsicmd), GFP_KERNEL);
611 struct scsi_device *scsidev = kmalloc(sizeof(*scsidev), GFP_KERNEL);
612 int status;
554 613
614 if (!scsicmd || !scsidev) {
615 kfree(scsicmd);
616 kfree(scsidev);
617 return -ENOMEM;
618 }
619 scsicmd->list.next = NULL;
620 scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))_aac_probe_container1;
621
622 scsicmd->device = scsidev;
623 scsidev->sdev_state = 0;
624 scsidev->id = cid;
625 scsidev->host = dev->scsi_host_ptr;
626
627 if (_aac_probe_container(scsicmd, aac_probe_container_callback1) == 0)
628 while (scsicmd->device == scsidev)
629 schedule();
630 kfree(scsidev);
631 status = scsicmd->SCp.Status;
632 kfree(scsicmd);
555 return status; 633 return status;
556} 634}
557 635
@@ -1115,6 +1193,12 @@ int aac_get_adapter_info(struct aac_dev* dev)
1115 printk(KERN_INFO "%s%d: serial %x\n", 1193 printk(KERN_INFO "%s%d: serial %x\n",
1116 dev->name, dev->id, 1194 dev->name, dev->id,
1117 le32_to_cpu(dev->adapter_info.serial[0])); 1195 le32_to_cpu(dev->adapter_info.serial[0]));
1196 if (dev->supplement_adapter_info.VpdInfo.Tsid[0]) {
1197 printk(KERN_INFO "%s%d: TSID %.*s\n",
1198 dev->name, dev->id,
1199 (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid),
1200 dev->supplement_adapter_info.VpdInfo.Tsid);
1201 }
1118 } 1202 }
1119 1203
1120 dev->nondasd_support = 0; 1204 dev->nondasd_support = 0;
@@ -1241,7 +1325,9 @@ static void io_callback(void *context, struct fib * fibptr)
1241 u32 cid; 1325 u32 cid;
1242 1326
1243 scsicmd = (struct scsi_cmnd *) context; 1327 scsicmd = (struct scsi_cmnd *) context;
1244 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 1328
1329 if (!aac_valid_context(scsicmd, fibptr))
1330 return;
1245 1331
1246 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 1332 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1247 cid = scmd_id(scsicmd); 1333 cid = scmd_id(scsicmd);
@@ -1317,7 +1403,7 @@ static void io_callback(void *context, struct fib * fibptr)
1317 scsicmd->scsi_done(scsicmd); 1403 scsicmd->scsi_done(scsicmd);
1318} 1404}
1319 1405
1320static int aac_read(struct scsi_cmnd * scsicmd, int cid) 1406static int aac_read(struct scsi_cmnd * scsicmd)
1321{ 1407{
1322 u64 lba; 1408 u64 lba;
1323 u32 count; 1409 u32 count;
@@ -1331,7 +1417,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
1331 */ 1417 */
1332 switch (scsicmd->cmnd[0]) { 1418 switch (scsicmd->cmnd[0]) {
1333 case READ_6: 1419 case READ_6:
1334 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid)); 1420 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd)));
1335 1421
1336 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | 1422 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
1337 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; 1423 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
@@ -1341,7 +1427,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
1341 count = 256; 1427 count = 256;
1342 break; 1428 break;
1343 case READ_16: 1429 case READ_16:
1344 dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", cid)); 1430 dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd)));
1345 1431
1346 lba = ((u64)scsicmd->cmnd[2] << 56) | 1432 lba = ((u64)scsicmd->cmnd[2] << 56) |
1347 ((u64)scsicmd->cmnd[3] << 48) | 1433 ((u64)scsicmd->cmnd[3] << 48) |
@@ -1355,7 +1441,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
1355 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; 1441 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
1356 break; 1442 break;
1357 case READ_12: 1443 case READ_12:
1358 dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", cid)); 1444 dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd)));
1359 1445
1360 lba = ((u64)scsicmd->cmnd[2] << 24) | 1446 lba = ((u64)scsicmd->cmnd[2] << 24) |
1361 (scsicmd->cmnd[3] << 16) | 1447 (scsicmd->cmnd[3] << 16) |
@@ -1365,7 +1451,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
1365 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; 1451 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1366 break; 1452 break;
1367 default: 1453 default:
1368 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid)); 1454 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd)));
1369 1455
1370 lba = ((u64)scsicmd->cmnd[2] << 24) | 1456 lba = ((u64)scsicmd->cmnd[2] << 24) |
1371 (scsicmd->cmnd[3] << 16) | 1457 (scsicmd->cmnd[3] << 16) |
@@ -1405,7 +1491,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
1405 return 0; 1491 return 0;
1406} 1492}
1407 1493
1408static int aac_write(struct scsi_cmnd * scsicmd, int cid) 1494static int aac_write(struct scsi_cmnd * scsicmd)
1409{ 1495{
1410 u64 lba; 1496 u64 lba;
1411 u32 count; 1497 u32 count;
@@ -1424,7 +1510,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1424 if (count == 0) 1510 if (count == 0)
1425 count = 256; 1511 count = 256;
1426 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */ 1512 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */
1427 dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", cid)); 1513 dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd)));
1428 1514
1429 lba = ((u64)scsicmd->cmnd[2] << 56) | 1515 lba = ((u64)scsicmd->cmnd[2] << 56) |
1430 ((u64)scsicmd->cmnd[3] << 48) | 1516 ((u64)scsicmd->cmnd[3] << 48) |
@@ -1436,14 +1522,14 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1436 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) | 1522 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) |
1437 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; 1523 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
1438 } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */ 1524 } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */
1439 dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", cid)); 1525 dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", scmd_id(scsicmd)));
1440 1526
1441 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) 1527 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16)
1442 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; 1528 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1443 count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16) 1529 count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16)
1444 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; 1530 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1445 } else { 1531 } else {
1446 dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid)); 1532 dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", scmd_id(scsicmd)));
1447 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; 1533 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1448 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; 1534 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1449 } 1535 }
@@ -1488,7 +1574,9 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1488 struct scsi_cmnd *cmd; 1574 struct scsi_cmnd *cmd;
1489 1575
1490 cmd = context; 1576 cmd = context;
1491 cmd->SCp.phase = AAC_OWNER_MIDLEVEL; 1577
1578 if (!aac_valid_context(cmd, fibptr))
1579 return;
1492 1580
1493 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n", 1581 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n",
1494 smp_processor_id(), jiffies)); 1582 smp_processor_id(), jiffies));
@@ -1523,7 +1611,7 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1523 cmd->scsi_done(cmd); 1611 cmd->scsi_done(cmd);
1524} 1612}
1525 1613
1526static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid) 1614static int aac_synchronize(struct scsi_cmnd *scsicmd)
1527{ 1615{
1528 int status; 1616 int status;
1529 struct fib *cmd_fibcontext; 1617 struct fib *cmd_fibcontext;
@@ -1568,7 +1656,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid)
1568 synchronizecmd = fib_data(cmd_fibcontext); 1656 synchronizecmd = fib_data(cmd_fibcontext);
1569 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig); 1657 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig);
1570 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE); 1658 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE);
1571 synchronizecmd->cid = cpu_to_le32(cid); 1659 synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd));
1572 synchronizecmd->count = 1660 synchronizecmd->count =
1573 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data)); 1661 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
1574 1662
@@ -1646,29 +1734,12 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1646 case TEST_UNIT_READY: 1734 case TEST_UNIT_READY:
1647 if (dev->in_reset) 1735 if (dev->in_reset)
1648 return -1; 1736 return -1;
1649 spin_unlock_irq(host->host_lock); 1737 return _aac_probe_container(scsicmd,
1650 aac_probe_container(dev, cid); 1738 aac_probe_container_callback2);
1651 if ((fsa_dev_ptr[cid].valid & 1) == 0)
1652 fsa_dev_ptr[cid].valid = 0;
1653 spin_lock_irq(host->host_lock);
1654 if (fsa_dev_ptr[cid].valid == 0) {
1655 scsicmd->result = DID_NO_CONNECT << 16;
1656 scsicmd->scsi_done(scsicmd);
1657 return 0;
1658 }
1659 default: 1739 default:
1660 break; 1740 break;
1661 } 1741 }
1662 } 1742 }
1663 /*
1664 * If the target container still doesn't exist,
1665 * return failure
1666 */
1667 if (fsa_dev_ptr[cid].valid == 0) {
1668 scsicmd->result = DID_BAD_TARGET << 16;
1669 scsicmd->scsi_done(scsicmd);
1670 return 0;
1671 }
1672 } else { /* check for physical non-dasd devices */ 1743 } else { /* check for physical non-dasd devices */
1673 if ((dev->nondasd_support == 1) || expose_physicals) { 1744 if ((dev->nondasd_support == 1) || expose_physicals) {
1674 if (dev->in_reset) 1745 if (dev->in_reset)
@@ -1733,7 +1804,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1733 setinqstr(dev, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type); 1804 setinqstr(dev, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type);
1734 inq_data.inqd_pdt = INQD_PDT_DA; /* Direct/random access device */ 1805 inq_data.inqd_pdt = INQD_PDT_DA; /* Direct/random access device */
1735 aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data)); 1806 aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
1736 return aac_get_container_name(scsicmd, cid); 1807 return aac_get_container_name(scsicmd);
1737 } 1808 }
1738 case SERVICE_ACTION_IN: 1809 case SERVICE_ACTION_IN:
1739 if (!(dev->raw_io_interface) || 1810 if (!(dev->raw_io_interface) ||
@@ -1899,7 +1970,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1899 min(sizeof(fsa_dev_ptr[cid].devname), 1970 min(sizeof(fsa_dev_ptr[cid].devname),
1900 sizeof(scsicmd->request->rq_disk->disk_name) + 1)); 1971 sizeof(scsicmd->request->rq_disk->disk_name) + 1));
1901 1972
1902 return aac_read(scsicmd, cid); 1973 return aac_read(scsicmd);
1903 1974
1904 case WRITE_6: 1975 case WRITE_6:
1905 case WRITE_10: 1976 case WRITE_10:
@@ -1907,11 +1978,11 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1907 case WRITE_16: 1978 case WRITE_16:
1908 if (dev->in_reset) 1979 if (dev->in_reset)
1909 return -1; 1980 return -1;
1910 return aac_write(scsicmd, cid); 1981 return aac_write(scsicmd);
1911 1982
1912 case SYNCHRONIZE_CACHE: 1983 case SYNCHRONIZE_CACHE:
1913 /* Issue FIB to tell Firmware to flush it's cache */ 1984 /* Issue FIB to tell Firmware to flush it's cache */
1914 return aac_synchronize(scsicmd, cid); 1985 return aac_synchronize(scsicmd);
1915 1986
1916 default: 1987 default:
1917 /* 1988 /*
@@ -2058,7 +2129,10 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
2058 struct scsi_cmnd *scsicmd; 2129 struct scsi_cmnd *scsicmd;
2059 2130
2060 scsicmd = (struct scsi_cmnd *) context; 2131 scsicmd = (struct scsi_cmnd *) context;
2061 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 2132
2133 if (!aac_valid_context(scsicmd, fibptr))
2134 return;
2135
2062 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 2136 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
2063 2137
2064 BUG_ON(fibptr == NULL); 2138 BUG_ON(fibptr == NULL);
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 39ecd0d22eb0..45ca3e801619 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -12,8 +12,8 @@
12 *----------------------------------------------------------------------------*/ 12 *----------------------------------------------------------------------------*/
13 13
14#ifndef AAC_DRIVER_BUILD 14#ifndef AAC_DRIVER_BUILD
15# define AAC_DRIVER_BUILD 2423 15# define AAC_DRIVER_BUILD 2437
16# define AAC_DRIVER_BRANCH "-mh3" 16# define AAC_DRIVER_BRANCH "-mh4"
17#endif 17#endif
18#define MAXIMUM_NUM_CONTAINERS 32 18#define MAXIMUM_NUM_CONTAINERS 32
19 19
@@ -48,49 +48,13 @@ struct diskparm
48 48
49 49
50/* 50/*
51 * DON'T CHANGE THE ORDER, this is set by the firmware 51 * Firmware constants
52 */ 52 */
53 53
54#define CT_NONE 0 54#define CT_NONE 0
55#define CT_VOLUME 1
56#define CT_MIRROR 2
57#define CT_STRIPE 3
58#define CT_RAID5 4
59#define CT_SSRW 5
60#define CT_SSRO 6
61#define CT_MORPH 7
62#define CT_PASSTHRU 8
63#define CT_RAID4 9
64#define CT_RAID10 10 /* stripe of mirror */
65#define CT_RAID00 11 /* stripe of stripe */
66#define CT_VOLUME_OF_MIRRORS 12 /* volume of mirror */
67#define CT_PSEUDO_RAID 13 /* really raid4 */
68#define CT_LAST_VOLUME_TYPE 14
69#define CT_OK 218 55#define CT_OK 218
70
71/*
72 * Types of objects addressable in some fashion by the client.
73 * This is a superset of those objects handled just by the filesystem
74 * and includes "raw" objects that an administrator would use to
75 * configure containers and filesystems.
76 */
77
78#define FT_REG 1 /* regular file */
79#define FT_DIR 2 /* directory */
80#define FT_BLK 3 /* "block" device - reserved */
81#define FT_CHR 4 /* "character special" device - reserved */
82#define FT_LNK 5 /* symbolic link */
83#define FT_SOCK 6 /* socket */
84#define FT_FIFO 7 /* fifo */
85#define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */ 56#define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */
86#define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */ 57#define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */
87#define FT_SLICE 10 /* virtual disk - raw volume - slice */
88#define FT_PARTITION 11 /* FSA partition - carved out of a slice - building block for containers */
89#define FT_VOLUME 12 /* Container - Volume Set */
90#define FT_STRIPE 13 /* Container - Stripe Set */
91#define FT_MIRROR 14 /* Container - Mirror Set */
92#define FT_RAID5 15 /* Container - Raid 5 Set */
93#define FT_DATABASE 16 /* Storage object with "foreign" content manager */
94 58
95/* 59/*
96 * Host side memory scatter gather list 60 * Host side memory scatter gather list
@@ -497,6 +461,7 @@ struct adapter_ops
497 void (*adapter_enable_int)(struct aac_dev *dev); 461 void (*adapter_enable_int)(struct aac_dev *dev);
498 int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4); 462 int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4);
499 int (*adapter_check_health)(struct aac_dev *dev); 463 int (*adapter_check_health)(struct aac_dev *dev);
464 int (*adapter_restart)(struct aac_dev *dev, int bled);
500 /* Transport operations */ 465 /* Transport operations */
501 int (*adapter_ioremap)(struct aac_dev * dev, u32 size); 466 int (*adapter_ioremap)(struct aac_dev * dev, u32 size);
502 irqreturn_t (*adapter_intr)(int irq, void *dev_id); 467 irqreturn_t (*adapter_intr)(int irq, void *dev_id);
@@ -833,7 +798,7 @@ struct fib {
833 */ 798 */
834 struct list_head fiblink; 799 struct list_head fiblink;
835 void *data; 800 void *data;
836 struct hw_fib *hw_fib; /* Actual shared object */ 801 struct hw_fib *hw_fib_va; /* Actual shared object */
837 dma_addr_t hw_fib_pa; /* physical address of hw_fib*/ 802 dma_addr_t hw_fib_pa; /* physical address of hw_fib*/
838}; 803};
839 804
@@ -878,10 +843,25 @@ struct aac_supplement_adapter_info
878 __le32 Version; 843 __le32 Version;
879 __le32 FeatureBits; 844 __le32 FeatureBits;
880 u8 SlotNumber; 845 u8 SlotNumber;
881 u8 ReservedPad0[0]; 846 u8 ReservedPad0[3];
882 u8 BuildDate[12]; 847 u8 BuildDate[12];
883 __le32 CurrentNumberPorts; 848 __le32 CurrentNumberPorts;
884 __le32 ReservedGrowth[24]; 849 struct {
850 u8 AssemblyPn[8];
851 u8 FruPn[8];
852 u8 BatteryFruPn[8];
853 u8 EcVersionString[8];
854 u8 Tsid[12];
855 } VpdInfo;
856 __le32 FlashFirmwareRevision;
857 __le32 FlashFirmwareBuild;
858 __le32 RaidTypeMorphOptions;
859 __le32 FlashFirmwareBootRevision;
860 __le32 FlashFirmwareBootBuild;
861 u8 MfgPcbaSerialNo[12];
862 u8 MfgWWNName[8];
863 __le32 MoreFeatureBits;
864 __le32 ReservedGrowth[1];
885}; 865};
886#define AAC_FEATURE_FALCON 0x00000010 866#define AAC_FEATURE_FALCON 0x00000010
887#define AAC_SIS_VERSION_V3 3 867#define AAC_SIS_VERSION_V3 3
@@ -970,7 +950,6 @@ struct aac_dev
970 struct fib *fibs; 950 struct fib *fibs;
971 951
972 struct fib *free_fib; 952 struct fib *free_fib;
973 struct fib *timeout_fib;
974 spinlock_t fib_lock; 953 spinlock_t fib_lock;
975 954
976 struct aac_queue_block *queues; 955 struct aac_queue_block *queues;
@@ -1060,6 +1039,9 @@ struct aac_dev
1060#define aac_adapter_check_health(dev) \ 1039#define aac_adapter_check_health(dev) \
1061 (dev)->a_ops.adapter_check_health(dev) 1040 (dev)->a_ops.adapter_check_health(dev)
1062 1041
1042#define aac_adapter_restart(dev,bled) \
1043 (dev)->a_ops.adapter_restart(dev,bled)
1044
1063#define aac_adapter_ioremap(dev, size) \ 1045#define aac_adapter_ioremap(dev, size) \
1064 (dev)->a_ops.adapter_ioremap(dev, size) 1046 (dev)->a_ops.adapter_ioremap(dev, size)
1065 1047
@@ -1516,8 +1498,7 @@ struct aac_mntent {
1516 struct creation_info create_info; /* if applicable */ 1498 struct creation_info create_info; /* if applicable */
1517 __le32 capacity; 1499 __le32 capacity;
1518 __le32 vol; /* substrate structure */ 1500 __le32 vol; /* substrate structure */
1519 __le32 obj; /* FT_FILESYS, 1501 __le32 obj; /* FT_FILESYS, etc. */
1520 FT_DATABASE, etc. */
1521 __le32 state; /* unready for mounting, 1502 __le32 state; /* unready for mounting,
1522 readonly, etc. */ 1503 readonly, etc. */
1523 union aac_contentinfo fileinfo; /* Info specific to content 1504 union aac_contentinfo fileinfo; /* Info specific to content
@@ -1817,7 +1798,7 @@ int aac_fib_send(u16 command, struct fib * context, unsigned long size, int prio
1817int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry); 1798int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry);
1818void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum); 1799void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum);
1819int aac_fib_complete(struct fib * context); 1800int aac_fib_complete(struct fib * context);
1820#define fib_data(fibctx) ((void *)(fibctx)->hw_fib->data) 1801#define fib_data(fibctx) ((void *)(fibctx)->hw_fib_va->data)
1821struct aac_dev *aac_init_adapter(struct aac_dev *dev); 1802struct aac_dev *aac_init_adapter(struct aac_dev *dev);
1822int aac_get_config_status(struct aac_dev *dev, int commit_flag); 1803int aac_get_config_status(struct aac_dev *dev, int commit_flag);
1823int aac_get_containers(struct aac_dev *dev); 1804int aac_get_containers(struct aac_dev *dev);
@@ -1840,8 +1821,11 @@ struct aac_driver_ident* aac_get_driver_ident(int devtype);
1840int aac_get_adapter_info(struct aac_dev* dev); 1821int aac_get_adapter_info(struct aac_dev* dev);
1841int aac_send_shutdown(struct aac_dev *dev); 1822int aac_send_shutdown(struct aac_dev *dev);
1842int aac_probe_container(struct aac_dev *dev, int cid); 1823int aac_probe_container(struct aac_dev *dev, int cid);
1824int _aac_rx_init(struct aac_dev *dev);
1825int aac_rx_select_comm(struct aac_dev *dev, int comm);
1843extern int numacb; 1826extern int numacb;
1844extern int acbsize; 1827extern int acbsize;
1845extern char aac_driver_version[]; 1828extern char aac_driver_version[];
1846extern int startup_timeout; 1829extern int startup_timeout;
1847extern int aif_timeout; 1830extern int aif_timeout;
1831extern int expose_physicals;
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index e21070f4eac1..72b0393b4596 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -64,12 +64,15 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
64 unsigned size; 64 unsigned size;
65 int retval; 65 int retval;
66 66
67 if (dev->in_reset) {
68 return -EBUSY;
69 }
67 fibptr = aac_fib_alloc(dev); 70 fibptr = aac_fib_alloc(dev);
68 if(fibptr == NULL) { 71 if(fibptr == NULL) {
69 return -ENOMEM; 72 return -ENOMEM;
70 } 73 }
71 74
72 kfib = fibptr->hw_fib; 75 kfib = fibptr->hw_fib_va;
73 /* 76 /*
74 * First copy in the header so that we can check the size field. 77 * First copy in the header so that we can check the size field.
75 */ 78 */
@@ -91,9 +94,9 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
91 goto cleanup; 94 goto cleanup;
92 } 95 }
93 /* Highjack the hw_fib */ 96 /* Highjack the hw_fib */
94 hw_fib = fibptr->hw_fib; 97 hw_fib = fibptr->hw_fib_va;
95 hw_fib_pa = fibptr->hw_fib_pa; 98 hw_fib_pa = fibptr->hw_fib_pa;
96 fibptr->hw_fib = kfib = pci_alloc_consistent(dev->pdev, size, &fibptr->hw_fib_pa); 99 fibptr->hw_fib_va = kfib = pci_alloc_consistent(dev->pdev, size, &fibptr->hw_fib_pa);
97 memset(((char *)kfib) + dev->max_fib_size, 0, size - dev->max_fib_size); 100 memset(((char *)kfib) + dev->max_fib_size, 0, size - dev->max_fib_size);
98 memcpy(kfib, hw_fib, dev->max_fib_size); 101 memcpy(kfib, hw_fib, dev->max_fib_size);
99 } 102 }
@@ -137,7 +140,7 @@ cleanup:
137 if (hw_fib) { 140 if (hw_fib) {
138 pci_free_consistent(dev->pdev, size, kfib, fibptr->hw_fib_pa); 141 pci_free_consistent(dev->pdev, size, kfib, fibptr->hw_fib_pa);
139 fibptr->hw_fib_pa = hw_fib_pa; 142 fibptr->hw_fib_pa = hw_fib_pa;
140 fibptr->hw_fib = hw_fib; 143 fibptr->hw_fib_va = hw_fib;
141 } 144 }
142 if (retval != -EINTR) 145 if (retval != -EINTR)
143 aac_fib_free(fibptr); 146 aac_fib_free(fibptr);
@@ -282,15 +285,15 @@ return_fib:
282 fib = list_entry(entry, struct fib, fiblink); 285 fib = list_entry(entry, struct fib, fiblink);
283 fibctx->count--; 286 fibctx->count--;
284 spin_unlock_irqrestore(&dev->fib_lock, flags); 287 spin_unlock_irqrestore(&dev->fib_lock, flags);
285 if (copy_to_user(f.fib, fib->hw_fib, sizeof(struct hw_fib))) { 288 if (copy_to_user(f.fib, fib->hw_fib_va, sizeof(struct hw_fib))) {
286 kfree(fib->hw_fib); 289 kfree(fib->hw_fib_va);
287 kfree(fib); 290 kfree(fib);
288 return -EFAULT; 291 return -EFAULT;
289 } 292 }
290 /* 293 /*
291 * Free the space occupied by this copy of the fib. 294 * Free the space occupied by this copy of the fib.
292 */ 295 */
293 kfree(fib->hw_fib); 296 kfree(fib->hw_fib_va);
294 kfree(fib); 297 kfree(fib);
295 status = 0; 298 status = 0;
296 } else { 299 } else {
@@ -340,7 +343,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx)
340 /* 343 /*
341 * Free the space occupied by this copy of the fib. 344 * Free the space occupied by this copy of the fib.
342 */ 345 */
343 kfree(fib->hw_fib); 346 kfree(fib->hw_fib_va);
344 kfree(fib); 347 kfree(fib);
345 } 348 }
346 /* 349 /*
@@ -388,10 +391,8 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)
388 /* 391 /*
389 * Extract the fibctx from the input parameters 392 * Extract the fibctx from the input parameters
390 */ 393 */
391 if (fibctx->unique == (u32)(unsigned long)arg) { 394 if (fibctx->unique == (u32)(ptrdiff_t)arg) /* We found a winner */
392 /* We found a winner */
393 break; 395 break;
394 }
395 entry = entry->next; 396 entry = entry->next;
396 fibctx = NULL; 397 fibctx = NULL;
397 } 398 }
@@ -465,16 +466,20 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
465 void *sg_list[32]; 466 void *sg_list[32];
466 u32 sg_indx = 0; 467 u32 sg_indx = 0;
467 u32 byte_count = 0; 468 u32 byte_count = 0;
468 u32 actual_fibsize = 0; 469 u32 actual_fibsize64, actual_fibsize = 0;
469 int i; 470 int i;
470 471
471 472
473 if (dev->in_reset) {
474 dprintk((KERN_DEBUG"aacraid: send raw srb -EBUSY\n"));
475 return -EBUSY;
476 }
472 if (!capable(CAP_SYS_ADMIN)){ 477 if (!capable(CAP_SYS_ADMIN)){
473 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n")); 478 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n"));
474 return -EPERM; 479 return -EPERM;
475 } 480 }
476 /* 481 /*
477 * Allocate and initialize a Fib then setup a BlockWrite command 482 * Allocate and initialize a Fib then setup a SRB command
478 */ 483 */
479 if (!(srbfib = aac_fib_alloc(dev))) { 484 if (!(srbfib = aac_fib_alloc(dev))) {
480 return -ENOMEM; 485 return -ENOMEM;
@@ -541,129 +546,183 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
541 rcode = -EINVAL; 546 rcode = -EINVAL;
542 goto cleanup; 547 goto cleanup;
543 } 548 }
544 if (dev->dac_support == 1) { 549 actual_fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) +
550 ((user_srbcmd->sg.count & 0xff) * sizeof(struct sgentry));
551 actual_fibsize64 = actual_fibsize + (user_srbcmd->sg.count & 0xff) *
552 (sizeof(struct sgentry64) - sizeof(struct sgentry));
553 /* User made a mistake - should not continue */
554 if ((actual_fibsize != fibsize) && (actual_fibsize64 != fibsize)) {
555 dprintk((KERN_DEBUG"aacraid: Bad Size specified in "
556 "Raw SRB command calculated fibsize=%lu;%lu "
557 "user_srbcmd->sg.count=%d aac_srb=%lu sgentry=%lu;%lu "
558 "issued fibsize=%d\n",
559 actual_fibsize, actual_fibsize64, user_srbcmd->sg.count,
560 sizeof(struct aac_srb), sizeof(struct sgentry),
561 sizeof(struct sgentry64), fibsize));
562 rcode = -EINVAL;
563 goto cleanup;
564 }
565 if ((data_dir == DMA_NONE) && user_srbcmd->sg.count) {
566 dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n"));
567 rcode = -EINVAL;
568 goto cleanup;
569 }
570 byte_count = 0;
571 if (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64) {
545 struct user_sgmap64* upsg = (struct user_sgmap64*)&user_srbcmd->sg; 572 struct user_sgmap64* upsg = (struct user_sgmap64*)&user_srbcmd->sg;
546 struct sgmap64* psg = (struct sgmap64*)&srbcmd->sg; 573 struct sgmap64* psg = (struct sgmap64*)&srbcmd->sg;
547 struct user_sgmap* usg;
548 byte_count = 0;
549 574
550 /* 575 /*
551 * This should also catch if user used the 32 bit sgmap 576 * This should also catch if user used the 32 bit sgmap
552 */ 577 */
553 actual_fibsize = sizeof(struct aac_srb) - 578 if (actual_fibsize64 == fibsize) {
554 sizeof(struct sgentry) + 579 actual_fibsize = actual_fibsize64;
555 ((upsg->count & 0xff) * 580 for (i = 0; i < upsg->count; i++) {
556 sizeof(struct sgentry)); 581 u64 addr;
557 if(actual_fibsize != fibsize){ // User made a mistake - should not continue 582 void* p;
558 dprintk((KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n")); 583 /* Does this really need to be GFP_DMA? */
559 rcode = -EINVAL; 584 p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA);
560 goto cleanup; 585 if(p == 0) {
561 } 586 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
562 usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) 587 upsg->sg[i].count,i,upsg->count));
563 + sizeof(struct sgmap), GFP_KERNEL); 588 rcode = -ENOMEM;
564 if (!usg) { 589 goto cleanup;
565 dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); 590 }
566 rcode = -ENOMEM; 591 addr = (u64)upsg->sg[i].addr[0];
567 goto cleanup; 592 addr += ((u64)upsg->sg[i].addr[1]) << 32;
568 } 593 sg_user[i] = (void __user *)(ptrdiff_t)addr;
569 memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) 594 sg_list[i] = p; // save so we can clean up later
570 + sizeof(struct sgmap)); 595 sg_indx = i;
571 actual_fibsize = sizeof(struct aac_srb) - 596
572 sizeof(struct sgentry) + ((usg->count & 0xff) * 597 if( flags & SRB_DataOut ){
573 sizeof(struct sgentry64)); 598 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
574 if ((data_dir == DMA_NONE) && upsg->count) { 599 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
575 kfree (usg); 600 rcode = -EFAULT;
576 dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n")); 601 goto cleanup;
577 rcode = -EINVAL; 602 }
578 goto cleanup; 603 }
579 } 604 addr = pci_map_single(dev->pdev, p, upsg->sg[i].count, data_dir);
580 605
581 for (i = 0; i < usg->count; i++) { 606 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
582 u64 addr; 607 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
583 void* p; 608 byte_count += upsg->sg[i].count;
584 /* Does this really need to be GFP_DMA? */ 609 psg->sg[i].count = cpu_to_le32(upsg->sg[i].count);
585 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); 610 }
586 if(p == 0) { 611 } else {
587 kfree (usg); 612 struct user_sgmap* usg;
588 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 613 usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
589 usg->sg[i].count,i,usg->count)); 614 + sizeof(struct sgmap), GFP_KERNEL);
615 if (!usg) {
616 dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
590 rcode = -ENOMEM; 617 rcode = -ENOMEM;
591 goto cleanup; 618 goto cleanup;
592 } 619 }
593 sg_user[i] = (void __user *)(long)usg->sg[i].addr; 620 memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb)
594 sg_list[i] = p; // save so we can clean up later 621 + sizeof(struct sgmap));
595 sg_indx = i; 622 actual_fibsize = actual_fibsize64;
596 623
597 if( flags & SRB_DataOut ){ 624 for (i = 0; i < usg->count; i++) {
598 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ 625 u64 addr;
626 void* p;
627 /* Does this really need to be GFP_DMA? */
628 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
629 if(p == 0) {
599 kfree (usg); 630 kfree (usg);
600 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 631 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
601 rcode = -EFAULT; 632 usg->sg[i].count,i,usg->count));
633 rcode = -ENOMEM;
602 goto cleanup; 634 goto cleanup;
603 } 635 }
604 } 636 sg_user[i] = (void __user *)(ptrdiff_t)usg->sg[i].addr;
605 addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir); 637 sg_list[i] = p; // save so we can clean up later
638 sg_indx = i;
639
640 if( flags & SRB_DataOut ){
641 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
642 kfree (usg);
643 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
644 rcode = -EFAULT;
645 goto cleanup;
646 }
647 }
648 addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir);
606 649
607 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); 650 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
608 psg->sg[i].addr[1] = cpu_to_le32(addr>>32); 651 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
609 psg->sg[i].count = cpu_to_le32(usg->sg[i].count); 652 byte_count += usg->sg[i].count;
610 byte_count += usg->sg[i].count; 653 psg->sg[i].count = cpu_to_le32(usg->sg[i].count);
654 }
655 kfree (usg);
611 } 656 }
612 kfree (usg);
613
614 srbcmd->count = cpu_to_le32(byte_count); 657 srbcmd->count = cpu_to_le32(byte_count);
615 psg->count = cpu_to_le32(sg_indx+1); 658 psg->count = cpu_to_le32(sg_indx+1);
616 status = aac_fib_send(ScsiPortCommand64, srbfib, actual_fibsize, FsaNormal, 1, 1,NULL,NULL); 659 status = aac_fib_send(ScsiPortCommand64, srbfib, actual_fibsize, FsaNormal, 1, 1,NULL,NULL);
617 } else { 660 } else {
618 struct user_sgmap* upsg = &user_srbcmd->sg; 661 struct user_sgmap* upsg = &user_srbcmd->sg;
619 struct sgmap* psg = &srbcmd->sg; 662 struct sgmap* psg = &srbcmd->sg;
620 byte_count = 0; 663
621 664 if (actual_fibsize64 == fibsize) {
622 actual_fibsize = sizeof (struct aac_srb) + (((user_srbcmd->sg.count & 0xff) - 1) * sizeof (struct sgentry)); 665 struct user_sgmap64* usg = (struct user_sgmap64 *)upsg;
623 if(actual_fibsize != fibsize){ // User made a mistake - should not continue 666 for (i = 0; i < upsg->count; i++) {
624 dprintk((KERN_DEBUG"aacraid: Bad Size specified in " 667 u64 addr;
625 "Raw SRB command calculated fibsize=%d " 668 void* p;
626 "user_srbcmd->sg.count=%d aac_srb=%d sgentry=%d " 669 /* Does this really need to be GFP_DMA? */
627 "issued fibsize=%d\n", 670 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
628 actual_fibsize, user_srbcmd->sg.count, 671 if(p == 0) {
629 sizeof(struct aac_srb), sizeof(struct sgentry), 672 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
630 fibsize)); 673 usg->sg[i].count,i,usg->count));
631 rcode = -EINVAL; 674 rcode = -ENOMEM;
632 goto cleanup;
633 }
634 if ((data_dir == DMA_NONE) && upsg->count) {
635 dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n"));
636 rcode = -EINVAL;
637 goto cleanup;
638 }
639 for (i = 0; i < upsg->count; i++) {
640 dma_addr_t addr;
641 void* p;
642 p = kmalloc(upsg->sg[i].count, GFP_KERNEL);
643 if(p == 0) {
644 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
645 upsg->sg[i].count, i, upsg->count));
646 rcode = -ENOMEM;
647 goto cleanup;
648 }
649 sg_user[i] = (void __user *)(long)upsg->sg[i].addr;
650 sg_list[i] = p; // save so we can clean up later
651 sg_indx = i;
652
653 if( flags & SRB_DataOut ){
654 if(copy_from_user(p, sg_user[i],
655 upsg->sg[i].count)) {
656 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
657 rcode = -EFAULT;
658 goto cleanup; 675 goto cleanup;
659 } 676 }
677 addr = (u64)usg->sg[i].addr[0];
678 addr += ((u64)usg->sg[i].addr[1]) << 32;
679 sg_user[i] = (void __user *)(ptrdiff_t)addr;
680 sg_list[i] = p; // save so we can clean up later
681 sg_indx = i;
682
683 if( flags & SRB_DataOut ){
684 if(copy_from_user(p,sg_user[i],usg->sg[i].count)){
685 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
686 rcode = -EFAULT;
687 goto cleanup;
688 }
689 }
690 addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir);
691
692 psg->sg[i].addr = cpu_to_le32(addr & 0xffffffff);
693 byte_count += usg->sg[i].count;
694 psg->sg[i].count = cpu_to_le32(usg->sg[i].count);
660 } 695 }
661 addr = pci_map_single(dev->pdev, p, 696 } else {
662 upsg->sg[i].count, data_dir); 697 for (i = 0; i < upsg->count; i++) {
698 dma_addr_t addr;
699 void* p;
700 p = kmalloc(upsg->sg[i].count, GFP_KERNEL);
701 if(p == 0) {
702 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
703 upsg->sg[i].count, i, upsg->count));
704 rcode = -ENOMEM;
705 goto cleanup;
706 }
707 sg_user[i] = (void __user *)(ptrdiff_t)upsg->sg[i].addr;
708 sg_list[i] = p; // save so we can clean up later
709 sg_indx = i;
710
711 if( flags & SRB_DataOut ){
712 if(copy_from_user(p, sg_user[i],
713 upsg->sg[i].count)) {
714 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
715 rcode = -EFAULT;
716 goto cleanup;
717 }
718 }
719 addr = pci_map_single(dev->pdev, p,
720 upsg->sg[i].count, data_dir);
663 721
664 psg->sg[i].addr = cpu_to_le32(addr); 722 psg->sg[i].addr = cpu_to_le32(addr);
665 psg->sg[i].count = cpu_to_le32(upsg->sg[i].count); 723 byte_count += upsg->sg[i].count;
666 byte_count += upsg->sg[i].count; 724 psg->sg[i].count = cpu_to_le32(upsg->sg[i].count);
725 }
667 } 726 }
668 srbcmd->count = cpu_to_le32(byte_count); 727 srbcmd->count = cpu_to_le32(byte_count);
669 psg->count = cpu_to_le32(sg_indx+1); 728 psg->count = cpu_to_le32(sg_indx+1);
@@ -682,7 +741,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
682 741
683 if( flags & SRB_DataIn ) { 742 if( flags & SRB_DataIn ) {
684 for(i = 0 ; i <= sg_indx; i++){ 743 for(i = 0 ; i <= sg_indx; i++){
685 byte_count = le32_to_cpu((dev->dac_support == 1) 744 byte_count = le32_to_cpu(
745 (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)
686 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count 746 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count
687 : srbcmd->sg.sg[i].count); 747 : srbcmd->sg.sg[i].count);
688 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){ 748 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index ae34768987a4..33682ce96a5d 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -110,7 +110,7 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co
110 /* 110 /*
111 * Align the beginning of Headers to commalign 111 * Align the beginning of Headers to commalign
112 */ 112 */
113 align = (commalign - ((unsigned long)(base) & (commalign - 1))); 113 align = (commalign - ((ptrdiff_t)(base) & (commalign - 1)));
114 base = base + align; 114 base = base + align;
115 phys = phys + align; 115 phys = phys + align;
116 /* 116 /*
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 1b97f60652ba..5824a757a753 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -94,7 +94,7 @@ void aac_fib_map_free(struct aac_dev *dev)
94int aac_fib_setup(struct aac_dev * dev) 94int aac_fib_setup(struct aac_dev * dev)
95{ 95{
96 struct fib *fibptr; 96 struct fib *fibptr;
97 struct hw_fib *hw_fib_va; 97 struct hw_fib *hw_fib;
98 dma_addr_t hw_fib_pa; 98 dma_addr_t hw_fib_pa;
99 int i; 99 int i;
100 100
@@ -106,24 +106,24 @@ int aac_fib_setup(struct aac_dev * dev)
106 if (i<0) 106 if (i<0)
107 return -ENOMEM; 107 return -ENOMEM;
108 108
109 hw_fib_va = dev->hw_fib_va; 109 hw_fib = dev->hw_fib_va;
110 hw_fib_pa = dev->hw_fib_pa; 110 hw_fib_pa = dev->hw_fib_pa;
111 memset(hw_fib_va, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB)); 111 memset(hw_fib, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB));
112 /* 112 /*
113 * Initialise the fibs 113 * Initialise the fibs
114 */ 114 */
115 for (i = 0, fibptr = &dev->fibs[i]; i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); i++, fibptr++) 115 for (i = 0, fibptr = &dev->fibs[i]; i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); i++, fibptr++)
116 { 116 {
117 fibptr->dev = dev; 117 fibptr->dev = dev;
118 fibptr->hw_fib = hw_fib_va; 118 fibptr->hw_fib_va = hw_fib;
119 fibptr->data = (void *) fibptr->hw_fib->data; 119 fibptr->data = (void *) fibptr->hw_fib_va->data;
120 fibptr->next = fibptr+1; /* Forward chain the fibs */ 120 fibptr->next = fibptr+1; /* Forward chain the fibs */
121 init_MUTEX_LOCKED(&fibptr->event_wait); 121 init_MUTEX_LOCKED(&fibptr->event_wait);
122 spin_lock_init(&fibptr->event_lock); 122 spin_lock_init(&fibptr->event_lock);
123 hw_fib_va->header.XferState = cpu_to_le32(0xffffffff); 123 hw_fib->header.XferState = cpu_to_le32(0xffffffff);
124 hw_fib_va->header.SenderSize = cpu_to_le16(dev->max_fib_size); 124 hw_fib->header.SenderSize = cpu_to_le16(dev->max_fib_size);
125 fibptr->hw_fib_pa = hw_fib_pa; 125 fibptr->hw_fib_pa = hw_fib_pa;
126 hw_fib_va = (struct hw_fib *)((unsigned char *)hw_fib_va + dev->max_fib_size); 126 hw_fib = (struct hw_fib *)((unsigned char *)hw_fib + dev->max_fib_size);
127 hw_fib_pa = hw_fib_pa + dev->max_fib_size; 127 hw_fib_pa = hw_fib_pa + dev->max_fib_size;
128 } 128 }
129 /* 129 /*
@@ -166,7 +166,7 @@ struct fib *aac_fib_alloc(struct aac_dev *dev)
166 * Null out fields that depend on being zero at the start of 166 * Null out fields that depend on being zero at the start of
167 * each I/O 167 * each I/O
168 */ 168 */
169 fibptr->hw_fib->header.XferState = 0; 169 fibptr->hw_fib_va->header.XferState = 0;
170 fibptr->callback = NULL; 170 fibptr->callback = NULL;
171 fibptr->callback_data = NULL; 171 fibptr->callback_data = NULL;
172 172
@@ -178,7 +178,6 @@ struct fib *aac_fib_alloc(struct aac_dev *dev)
178 * @fibptr: fib to free up 178 * @fibptr: fib to free up
179 * 179 *
180 * Frees up a fib and places it on the appropriate queue 180 * Frees up a fib and places it on the appropriate queue
181 * (either free or timed out)
182 */ 181 */
183 182
184void aac_fib_free(struct fib *fibptr) 183void aac_fib_free(struct fib *fibptr)
@@ -186,19 +185,15 @@ void aac_fib_free(struct fib *fibptr)
186 unsigned long flags; 185 unsigned long flags;
187 186
188 spin_lock_irqsave(&fibptr->dev->fib_lock, flags); 187 spin_lock_irqsave(&fibptr->dev->fib_lock, flags);
189 if (fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT) { 188 if (unlikely(fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT))
190 aac_config.fib_timeouts++; 189 aac_config.fib_timeouts++;
191 fibptr->next = fibptr->dev->timeout_fib; 190 if (fibptr->hw_fib_va->header.XferState != 0) {
192 fibptr->dev->timeout_fib = fibptr; 191 printk(KERN_WARNING "aac_fib_free, XferState != 0, fibptr = 0x%p, XferState = 0x%x\n",
193 } else { 192 (void*)fibptr,
194 if (fibptr->hw_fib->header.XferState != 0) { 193 le32_to_cpu(fibptr->hw_fib_va->header.XferState));
195 printk(KERN_WARNING "aac_fib_free, XferState != 0, fibptr = 0x%p, XferState = 0x%x\n", 194 }
196 (void*)fibptr, 195 fibptr->next = fibptr->dev->free_fib;
197 le32_to_cpu(fibptr->hw_fib->header.XferState)); 196 fibptr->dev->free_fib = fibptr;
198 }
199 fibptr->next = fibptr->dev->free_fib;
200 fibptr->dev->free_fib = fibptr;
201 }
202 spin_unlock_irqrestore(&fibptr->dev->fib_lock, flags); 197 spin_unlock_irqrestore(&fibptr->dev->fib_lock, flags);
203} 198}
204 199
@@ -211,7 +206,7 @@ void aac_fib_free(struct fib *fibptr)
211 206
212void aac_fib_init(struct fib *fibptr) 207void aac_fib_init(struct fib *fibptr)
213{ 208{
214 struct hw_fib *hw_fib = fibptr->hw_fib; 209 struct hw_fib *hw_fib = fibptr->hw_fib_va;
215 210
216 hw_fib->header.StructType = FIB_MAGIC; 211 hw_fib->header.StructType = FIB_MAGIC;
217 hw_fib->header.Size = cpu_to_le16(fibptr->dev->max_fib_size); 212 hw_fib->header.Size = cpu_to_le16(fibptr->dev->max_fib_size);
@@ -231,7 +226,7 @@ void aac_fib_init(struct fib *fibptr)
231 226
232static void fib_dealloc(struct fib * fibptr) 227static void fib_dealloc(struct fib * fibptr)
233{ 228{
234 struct hw_fib *hw_fib = fibptr->hw_fib; 229 struct hw_fib *hw_fib = fibptr->hw_fib_va;
235 BUG_ON(hw_fib->header.StructType != FIB_MAGIC); 230 BUG_ON(hw_fib->header.StructType != FIB_MAGIC);
236 hw_fib->header.XferState = 0; 231 hw_fib->header.XferState = 0;
237} 232}
@@ -386,7 +381,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
386 void *callback_data) 381 void *callback_data)
387{ 382{
388 struct aac_dev * dev = fibptr->dev; 383 struct aac_dev * dev = fibptr->dev;
389 struct hw_fib * hw_fib = fibptr->hw_fib; 384 struct hw_fib * hw_fib = fibptr->hw_fib_va;
390 unsigned long flags = 0; 385 unsigned long flags = 0;
391 unsigned long qflags; 386 unsigned long qflags;
392 387
@@ -430,7 +425,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
430 */ 425 */
431 hw_fib->header.Command = cpu_to_le16(command); 426 hw_fib->header.Command = cpu_to_le16(command);
432 hw_fib->header.XferState |= cpu_to_le32(SentFromHost); 427 hw_fib->header.XferState |= cpu_to_le32(SentFromHost);
433 fibptr->hw_fib->header.Flags = 0; /* 0 the flags field - internal only*/ 428 fibptr->hw_fib_va->header.Flags = 0; /* 0 the flags field - internal only*/
434 /* 429 /*
435 * Set the size of the Fib we want to send to the adapter 430 * Set the size of the Fib we want to send to the adapter
436 */ 431 */
@@ -462,7 +457,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
462 dprintk((KERN_DEBUG " Command = %d.\n", le32_to_cpu(hw_fib->header.Command))); 457 dprintk((KERN_DEBUG " Command = %d.\n", le32_to_cpu(hw_fib->header.Command)));
463 dprintk((KERN_DEBUG " SubCommand = %d.\n", le32_to_cpu(((struct aac_query_mount *)fib_data(fibptr))->command))); 458 dprintk((KERN_DEBUG " SubCommand = %d.\n", le32_to_cpu(((struct aac_query_mount *)fib_data(fibptr))->command)));
464 dprintk((KERN_DEBUG " XferState = %x.\n", le32_to_cpu(hw_fib->header.XferState))); 459 dprintk((KERN_DEBUG " XferState = %x.\n", le32_to_cpu(hw_fib->header.XferState)));
465 dprintk((KERN_DEBUG " hw_fib va being sent=%p\n",fibptr->hw_fib)); 460 dprintk((KERN_DEBUG " hw_fib va being sent=%p\n",fibptr->hw_fib_va));
466 dprintk((KERN_DEBUG " hw_fib pa being sent=%lx\n",(ulong)fibptr->hw_fib_pa)); 461 dprintk((KERN_DEBUG " hw_fib pa being sent=%lx\n",(ulong)fibptr->hw_fib_pa));
467 dprintk((KERN_DEBUG " fib being sent=%p\n",fibptr)); 462 dprintk((KERN_DEBUG " fib being sent=%p\n",fibptr));
468 463
@@ -513,22 +508,20 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
513 } 508 }
514 udelay(5); 509 udelay(5);
515 } 510 }
516 } else if (down_interruptible(&fibptr->event_wait)) { 511 } else
517 spin_lock_irqsave(&fibptr->event_lock, flags); 512 (void)down_interruptible(&fibptr->event_wait);
518 if (fibptr->done == 0) { 513 spin_lock_irqsave(&fibptr->event_lock, flags);
519 fibptr->done = 2; /* Tell interrupt we aborted */ 514 if (fibptr->done == 0) {
520 spin_unlock_irqrestore(&fibptr->event_lock, flags); 515 fibptr->done = 2; /* Tell interrupt we aborted */
521 return -EINTR;
522 }
523 spin_unlock_irqrestore(&fibptr->event_lock, flags); 516 spin_unlock_irqrestore(&fibptr->event_lock, flags);
517 return -EINTR;
524 } 518 }
519 spin_unlock_irqrestore(&fibptr->event_lock, flags);
525 BUG_ON(fibptr->done == 0); 520 BUG_ON(fibptr->done == 0);
526 521
527 if((fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT)){ 522 if(unlikely(fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT))
528 return -ETIMEDOUT; 523 return -ETIMEDOUT;
529 } else { 524 return 0;
530 return 0;
531 }
532 } 525 }
533 /* 526 /*
534 * If the user does not want a response than return success otherwise 527 * If the user does not want a response than return success otherwise
@@ -624,7 +617,7 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid)
624 617
625int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) 618int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size)
626{ 619{
627 struct hw_fib * hw_fib = fibptr->hw_fib; 620 struct hw_fib * hw_fib = fibptr->hw_fib_va;
628 struct aac_dev * dev = fibptr->dev; 621 struct aac_dev * dev = fibptr->dev;
629 struct aac_queue * q; 622 struct aac_queue * q;
630 unsigned long nointr = 0; 623 unsigned long nointr = 0;
@@ -688,7 +681,7 @@ int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size)
688 681
689int aac_fib_complete(struct fib *fibptr) 682int aac_fib_complete(struct fib *fibptr)
690{ 683{
691 struct hw_fib * hw_fib = fibptr->hw_fib; 684 struct hw_fib * hw_fib = fibptr->hw_fib_va;
692 685
693 /* 686 /*
694 * Check for a fib which has already been completed 687 * Check for a fib which has already been completed
@@ -774,9 +767,8 @@ void aac_printf(struct aac_dev *dev, u32 val)
774#define AIF_SNIFF_TIMEOUT (30*HZ) 767#define AIF_SNIFF_TIMEOUT (30*HZ)
775static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) 768static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
776{ 769{
777 struct hw_fib * hw_fib = fibptr->hw_fib; 770 struct hw_fib * hw_fib = fibptr->hw_fib_va;
778 struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data; 771 struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data;
779 int busy;
780 u32 container; 772 u32 container;
781 struct scsi_device *device; 773 struct scsi_device *device;
782 enum { 774 enum {
@@ -988,9 +980,6 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
988 * behind you. 980 * behind you.
989 */ 981 */
990 982
991 busy = 0;
992
993
994 /* 983 /*
995 * Find the scsi_device associated with the SCSI address, 984 * Find the scsi_device associated with the SCSI address,
996 * and mark it as changed, invalidating the cache. This deals 985 * and mark it as changed, invalidating the cache. This deals
@@ -1035,7 +1024,6 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
1035static int _aac_reset_adapter(struct aac_dev *aac) 1024static int _aac_reset_adapter(struct aac_dev *aac)
1036{ 1025{
1037 int index, quirks; 1026 int index, quirks;
1038 u32 ret;
1039 int retval; 1027 int retval;
1040 struct Scsi_Host *host; 1028 struct Scsi_Host *host;
1041 struct scsi_device *dev; 1029 struct scsi_device *dev;
@@ -1059,35 +1047,29 @@ static int _aac_reset_adapter(struct aac_dev *aac)
1059 * If a positive health, means in a known DEAD PANIC 1047 * If a positive health, means in a known DEAD PANIC
1060 * state and the adapter could be reset to `try again'. 1048 * state and the adapter could be reset to `try again'.
1061 */ 1049 */
1062 retval = aac_adapter_check_health(aac); 1050 retval = aac_adapter_restart(aac, aac_adapter_check_health(aac));
1063 if (retval == 0)
1064 retval = aac_adapter_sync_cmd(aac, IOP_RESET_ALWAYS,
1065 0, 0, 0, 0, 0, 0, &ret, NULL, NULL, NULL, NULL);
1066 if (retval)
1067 retval = aac_adapter_sync_cmd(aac, IOP_RESET,
1068 0, 0, 0, 0, 0, 0, &ret, NULL, NULL, NULL, NULL);
1069 1051
1070 if (retval) 1052 if (retval)
1071 goto out; 1053 goto out;
1072 if (ret != 0x00000001) {
1073 retval = -ENODEV;
1074 goto out;
1075 }
1076 1054
1077 /* 1055 /*
1078 * Loop through the fibs, close the synchronous FIBS 1056 * Loop through the fibs, close the synchronous FIBS
1079 */ 1057 */
1080 for (index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) { 1058 for (retval = 1, index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) {
1081 struct fib *fib = &aac->fibs[index]; 1059 struct fib *fib = &aac->fibs[index];
1082 if (!(fib->hw_fib->header.XferState & cpu_to_le32(NoResponseExpected | Async)) && 1060 if (!(fib->hw_fib_va->header.XferState & cpu_to_le32(NoResponseExpected | Async)) &&
1083 (fib->hw_fib->header.XferState & cpu_to_le32(ResponseExpected))) { 1061 (fib->hw_fib_va->header.XferState & cpu_to_le32(ResponseExpected))) {
1084 unsigned long flagv; 1062 unsigned long flagv;
1085 spin_lock_irqsave(&fib->event_lock, flagv); 1063 spin_lock_irqsave(&fib->event_lock, flagv);
1086 up(&fib->event_wait); 1064 up(&fib->event_wait);
1087 spin_unlock_irqrestore(&fib->event_lock, flagv); 1065 spin_unlock_irqrestore(&fib->event_lock, flagv);
1088 schedule(); 1066 schedule();
1067 retval = 0;
1089 } 1068 }
1090 } 1069 }
1070 /* Give some extra time for ioctls to complete. */
1071 if (retval == 0)
1072 ssleep(2);
1091 index = aac->cardtype; 1073 index = aac->cardtype;
1092 1074
1093 /* 1075 /*
@@ -1248,7 +1230,7 @@ int aac_check_health(struct aac_dev * aac)
1248 1230
1249 memset(hw_fib, 0, sizeof(struct hw_fib)); 1231 memset(hw_fib, 0, sizeof(struct hw_fib));
1250 memset(fib, 0, sizeof(struct fib)); 1232 memset(fib, 0, sizeof(struct fib));
1251 fib->hw_fib = hw_fib; 1233 fib->hw_fib_va = hw_fib;
1252 fib->dev = aac; 1234 fib->dev = aac;
1253 aac_fib_init(fib); 1235 aac_fib_init(fib);
1254 fib->type = FSAFS_NTC_FIB_CONTEXT; 1236 fib->type = FSAFS_NTC_FIB_CONTEXT;
@@ -1354,11 +1336,11 @@ int aac_command_thread(void *data)
1354 * do anything at this point since we don't have 1336 * do anything at this point since we don't have
1355 * anything defined for this thread to do. 1337 * anything defined for this thread to do.
1356 */ 1338 */
1357 hw_fib = fib->hw_fib; 1339 hw_fib = fib->hw_fib_va;
1358 memset(fib, 0, sizeof(struct fib)); 1340 memset(fib, 0, sizeof(struct fib));
1359 fib->type = FSAFS_NTC_FIB_CONTEXT; 1341 fib->type = FSAFS_NTC_FIB_CONTEXT;
1360 fib->size = sizeof( struct fib ); 1342 fib->size = sizeof( struct fib );
1361 fib->hw_fib = hw_fib; 1343 fib->hw_fib_va = hw_fib;
1362 fib->data = hw_fib->data; 1344 fib->data = hw_fib->data;
1363 fib->dev = dev; 1345 fib->dev = dev;
1364 /* 1346 /*
@@ -1485,7 +1467,7 @@ int aac_command_thread(void *data)
1485 */ 1467 */
1486 memcpy(hw_newfib, hw_fib, sizeof(struct hw_fib)); 1468 memcpy(hw_newfib, hw_fib, sizeof(struct hw_fib));
1487 memcpy(newfib, fib, sizeof(struct fib)); 1469 memcpy(newfib, fib, sizeof(struct fib));
1488 newfib->hw_fib = hw_newfib; 1470 newfib->hw_fib_va = hw_newfib;
1489 /* 1471 /*
1490 * Put the FIB onto the 1472 * Put the FIB onto the
1491 * fibctx's fibs 1473 * fibctx's fibs
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c
index d38b628be1ad..42c7dcda6d9b 100644
--- a/drivers/scsi/aacraid/dpcsup.c
+++ b/drivers/scsi/aacraid/dpcsup.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -32,7 +32,6 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/pci.h>
36#include <linux/spinlock.h> 35#include <linux/spinlock.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include <linux/completion.h> 37#include <linux/completion.h>
@@ -73,7 +72,7 @@ unsigned int aac_response_normal(struct aac_queue * q)
73 u32 index = le32_to_cpu(entry->addr); 72 u32 index = le32_to_cpu(entry->addr);
74 fast = index & 0x01; 73 fast = index & 0x01;
75 fib = &dev->fibs[index >> 2]; 74 fib = &dev->fibs[index >> 2];
76 hwfib = fib->hw_fib; 75 hwfib = fib->hw_fib_va;
77 76
78 aac_consumer_free(dev, q, HostNormRespQueue); 77 aac_consumer_free(dev, q, HostNormRespQueue);
79 /* 78 /*
@@ -84,11 +83,13 @@ unsigned int aac_response_normal(struct aac_queue * q)
84 * continue. The caller has already been notified that 83 * continue. The caller has already been notified that
85 * the fib timed out. 84 * the fib timed out.
86 */ 85 */
87 if (!(fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) 86 dev->queues->queue[AdapNormCmdQueue].numpending--;
88 dev->queues->queue[AdapNormCmdQueue].numpending--; 87
89 else { 88 if (unlikely(fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) {
90 printk(KERN_WARNING "aacraid: FIB timeout (%x).\n", fib->flags); 89 spin_unlock_irqrestore(q->lock, flags);
91 printk(KERN_DEBUG"aacraid: hwfib=%p fib index=%i fib=%p\n",hwfib, hwfib->header.SenderData,fib); 90 aac_fib_complete(fib);
91 aac_fib_free(fib);
92 spin_lock_irqsave(q->lock, flags);
92 continue; 93 continue;
93 } 94 }
94 spin_unlock_irqrestore(q->lock, flags); 95 spin_unlock_irqrestore(q->lock, flags);
@@ -193,7 +194,7 @@ unsigned int aac_command_normal(struct aac_queue *q)
193 INIT_LIST_HEAD(&fib->fiblink); 194 INIT_LIST_HEAD(&fib->fiblink);
194 fib->type = FSAFS_NTC_FIB_CONTEXT; 195 fib->type = FSAFS_NTC_FIB_CONTEXT;
195 fib->size = sizeof(struct fib); 196 fib->size = sizeof(struct fib);
196 fib->hw_fib = hw_fib; 197 fib->hw_fib_va = hw_fib;
197 fib->data = hw_fib->data; 198 fib->data = hw_fib->data;
198 fib->dev = dev; 199 fib->dev = dev;
199 200
@@ -254,12 +255,13 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index)
254 return 1; 255 return 1;
255 } 256 }
256 memset(hw_fib, 0, sizeof(struct hw_fib)); 257 memset(hw_fib, 0, sizeof(struct hw_fib));
257 memcpy(hw_fib, (struct hw_fib *)(((unsigned long)(dev->regs.sa)) + (index & ~0x00000002L)), sizeof(struct hw_fib)); 258 memcpy(hw_fib, (struct hw_fib *)(((ptrdiff_t)(dev->regs.sa)) +
259 (index & ~0x00000002L)), sizeof(struct hw_fib));
258 memset(fib, 0, sizeof(struct fib)); 260 memset(fib, 0, sizeof(struct fib));
259 INIT_LIST_HEAD(&fib->fiblink); 261 INIT_LIST_HEAD(&fib->fiblink);
260 fib->type = FSAFS_NTC_FIB_CONTEXT; 262 fib->type = FSAFS_NTC_FIB_CONTEXT;
261 fib->size = sizeof(struct fib); 263 fib->size = sizeof(struct fib);
262 fib->hw_fib = hw_fib; 264 fib->hw_fib_va = hw_fib;
263 fib->data = hw_fib->data; 265 fib->data = hw_fib->data;
264 fib->dev = dev; 266 fib->dev = dev;
265 267
@@ -271,7 +273,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index)
271 } else { 273 } else {
272 int fast = index & 0x01; 274 int fast = index & 0x01;
273 struct fib * fib = &dev->fibs[index >> 2]; 275 struct fib * fib = &dev->fibs[index >> 2];
274 struct hw_fib * hwfib = fib->hw_fib; 276 struct hw_fib * hwfib = fib->hw_fib_va;
275 277
276 /* 278 /*
277 * Remove this fib from the Outstanding I/O queue. 279 * Remove this fib from the Outstanding I/O queue.
@@ -281,14 +283,14 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index)
281 * continue. The caller has already been notified that 283 * continue. The caller has already been notified that
282 * the fib timed out. 284 * the fib timed out.
283 */ 285 */
284 if ((fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) { 286 dev->queues->queue[AdapNormCmdQueue].numpending--;
285 printk(KERN_WARNING "aacraid: FIB timeout (%x).\n", fib->flags); 287
286 printk(KERN_DEBUG"aacraid: hwfib=%p index=%i fib=%p\n",hwfib, hwfib->header.SenderData,fib); 288 if (unlikely(fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) {
289 aac_fib_complete(fib);
290 aac_fib_free(fib);
287 return 0; 291 return 0;
288 } 292 }
289 293
290 dev->queues->queue[AdapNormCmdQueue].numpending--;
291
292 if (fast) { 294 if (fast) {
293 /* 295 /*
294 * Doctor the fib 296 * Doctor the fib
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 0f948c2fb609..350ea7feb61d 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -82,8 +82,6 @@ static LIST_HEAD(aac_devices);
82static int aac_cfg_major = -1; 82static int aac_cfg_major = -1;
83char aac_driver_version[] = AAC_DRIVER_FULL_VERSION; 83char aac_driver_version[] = AAC_DRIVER_FULL_VERSION;
84 84
85extern int expose_physicals;
86
87/* 85/*
88 * Because of the way Linux names scsi devices, the order in this table has 86 * Because of the way Linux names scsi devices, the order in this table has
89 * become important. Check for on-board Raid first, add-in cards second. 87 * become important. Check for on-board Raid first, add-in cards second.
@@ -247,7 +245,19 @@ static struct aac_driver_ident aac_drivers[] = {
247 245
248static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 246static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
249{ 247{
248 struct Scsi_Host *host = cmd->device->host;
249 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
250 u32 count = 0;
250 cmd->scsi_done = done; 251 cmd->scsi_done = done;
252 for (; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
253 struct fib * fib = &dev->fibs[count];
254 struct scsi_cmnd * command;
255 if (fib->hw_fib_va->header.XferState &&
256 ((command = fib->callback_data)) &&
257 (command == cmd) &&
258 (cmd->SCp.phase == AAC_OWNER_FIRMWARE))
259 return 0; /* Already owned by Adapter */
260 }
251 cmd->SCp.phase = AAC_OWNER_LOWLEVEL; 261 cmd->SCp.phase = AAC_OWNER_LOWLEVEL;
252 return (aac_scsi_cmd(cmd) ? FAILED : 0); 262 return (aac_scsi_cmd(cmd) ? FAILED : 0);
253} 263}
@@ -446,6 +456,40 @@ static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg)
446 return aac_do_ioctl(dev, cmd, arg); 456 return aac_do_ioctl(dev, cmd, arg);
447} 457}
448 458
459static int aac_eh_abort(struct scsi_cmnd* cmd)
460{
461 struct scsi_device * dev = cmd->device;
462 struct Scsi_Host * host = dev->host;
463 struct aac_dev * aac = (struct aac_dev *)host->hostdata;
464 int count;
465 int ret = FAILED;
466
467 printk(KERN_ERR "%s: Host adapter abort request (%d,%d,%d,%d)\n",
468 AAC_DRIVERNAME,
469 host->host_no, sdev_channel(dev), sdev_id(dev), dev->lun);
470 switch (cmd->cmnd[0]) {
471 case SERVICE_ACTION_IN:
472 if (!(aac->raw_io_interface) ||
473 !(aac->raw_io_64) ||
474 ((cmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
475 break;
476 case INQUIRY:
477 case READ_CAPACITY:
478 case TEST_UNIT_READY:
479 /* Mark associated FIB to not complete, eh handler does this */
480 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
481 struct fib * fib = &aac->fibs[count];
482 if (fib->hw_fib_va->header.XferState &&
483 (fib->callback_data == cmd)) {
484 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
485 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;
486 ret = SUCCESS;
487 }
488 }
489 }
490 return ret;
491}
492
449/* 493/*
450 * aac_eh_reset - Reset command handling 494 * aac_eh_reset - Reset command handling
451 * @scsi_cmd: SCSI command block causing the reset 495 * @scsi_cmd: SCSI command block causing the reset
@@ -457,12 +501,20 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
457 struct Scsi_Host * host = dev->host; 501 struct Scsi_Host * host = dev->host;
458 struct scsi_cmnd * command; 502 struct scsi_cmnd * command;
459 int count; 503 int count;
460 struct aac_dev * aac; 504 struct aac_dev * aac = (struct aac_dev *)host->hostdata;
461 unsigned long flags; 505 unsigned long flags;
462 506
507 /* Mark the associated FIB to not complete, eh handler does this */
508 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
509 struct fib * fib = &aac->fibs[count];
510 if (fib->hw_fib_va->header.XferState &&
511 (fib->callback_data == cmd)) {
512 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
513 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;
514 }
515 }
463 printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n", 516 printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n",
464 AAC_DRIVERNAME); 517 AAC_DRIVERNAME);
465 aac = (struct aac_dev *)host->hostdata;
466 518
467 if ((count = aac_check_health(aac))) 519 if ((count = aac_check_health(aac)))
468 return count; 520 return count;
@@ -496,7 +548,7 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
496 ssleep(1); 548 ssleep(1);
497 } 549 }
498 printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME); 550 printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME);
499 return -ETIMEDOUT; 551 return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */
500} 552}
501 553
502/** 554/**
@@ -796,6 +848,7 @@ static struct scsi_host_template aac_driver_template = {
796 .bios_param = aac_biosparm, 848 .bios_param = aac_biosparm,
797 .shost_attrs = aac_attrs, 849 .shost_attrs = aac_attrs,
798 .slave_configure = aac_slave_configure, 850 .slave_configure = aac_slave_configure,
851 .eh_abort_handler = aac_eh_abort,
799 .eh_host_reset_handler = aac_eh_reset, 852 .eh_host_reset_handler = aac_eh_reset,
800 .can_queue = AAC_NUM_IO_FIB, 853 .can_queue = AAC_NUM_IO_FIB,
801 .this_id = MAXIMUM_NUM_CONTAINERS, 854 .this_id = MAXIMUM_NUM_CONTAINERS,
diff --git a/drivers/scsi/aacraid/nark.c b/drivers/scsi/aacraid/nark.c
index c76b611b6afb..a8ace5677813 100644
--- a/drivers/scsi/aacraid/nark.c
+++ b/drivers/scsi/aacraid/nark.c
@@ -74,9 +74,6 @@ static int aac_nark_ioremap(struct aac_dev * dev, u32 size)
74 74
75int aac_nark_init(struct aac_dev * dev) 75int aac_nark_init(struct aac_dev * dev)
76{ 76{
77 extern int _aac_rx_init(struct aac_dev *dev);
78 extern int aac_rx_select_comm(struct aac_dev *dev, int comm);
79
80 /* 77 /*
81 * Fill in the function dispatch table. 78 * Fill in the function dispatch table.
82 */ 79 */
diff --git a/drivers/scsi/aacraid/rkt.c b/drivers/scsi/aacraid/rkt.c
index d953c3fe998a..9c5fcfb398c2 100644
--- a/drivers/scsi/aacraid/rkt.c
+++ b/drivers/scsi/aacraid/rkt.c
@@ -45,7 +45,6 @@
45static int aac_rkt_select_comm(struct aac_dev *dev, int comm) 45static int aac_rkt_select_comm(struct aac_dev *dev, int comm)
46{ 46{
47 int retval; 47 int retval;
48 extern int aac_rx_select_comm(struct aac_dev *dev, int comm);
49 retval = aac_rx_select_comm(dev, comm); 48 retval = aac_rx_select_comm(dev, comm);
50 if (comm == AAC_COMM_MESSAGE) { 49 if (comm == AAC_COMM_MESSAGE) {
51 /* 50 /*
@@ -97,8 +96,6 @@ static int aac_rkt_ioremap(struct aac_dev * dev, u32 size)
97 96
98int aac_rkt_init(struct aac_dev *dev) 97int aac_rkt_init(struct aac_dev *dev)
99{ 98{
100 extern int _aac_rx_init(struct aac_dev *dev);
101
102 /* 99 /*
103 * Fill in the function dispatch table. 100 * Fill in the function dispatch table.
104 */ 101 */
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index d242e2611d67..0c71315cbf1a 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -57,25 +57,25 @@ static irqreturn_t aac_rx_intr_producer(int irq, void *dev_id)
57 * been enabled. 57 * been enabled.
58 * Check to see if this is our interrupt. If it isn't just return 58 * Check to see if this is our interrupt. If it isn't just return
59 */ 59 */
60 if (intstat & ~(dev->OIMR)) { 60 if (likely(intstat & ~(dev->OIMR))) {
61 bellbits = rx_readl(dev, OutboundDoorbellReg); 61 bellbits = rx_readl(dev, OutboundDoorbellReg);
62 if (bellbits & DoorBellPrintfReady) { 62 if (unlikely(bellbits & DoorBellPrintfReady)) {
63 aac_printf(dev, readl (&dev->IndexRegs->Mailbox[5])); 63 aac_printf(dev, readl (&dev->IndexRegs->Mailbox[5]));
64 rx_writel(dev, MUnit.ODR,DoorBellPrintfReady); 64 rx_writel(dev, MUnit.ODR,DoorBellPrintfReady);
65 rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone); 65 rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone);
66 } 66 }
67 else if (bellbits & DoorBellAdapterNormCmdReady) { 67 else if (unlikely(bellbits & DoorBellAdapterNormCmdReady)) {
68 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdReady); 68 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdReady);
69 aac_command_normal(&dev->queues->queue[HostNormCmdQueue]); 69 aac_command_normal(&dev->queues->queue[HostNormCmdQueue]);
70 } 70 }
71 else if (bellbits & DoorBellAdapterNormRespReady) { 71 else if (likely(bellbits & DoorBellAdapterNormRespReady)) {
72 rx_writel(dev, MUnit.ODR,DoorBellAdapterNormRespReady); 72 rx_writel(dev, MUnit.ODR,DoorBellAdapterNormRespReady);
73 aac_response_normal(&dev->queues->queue[HostNormRespQueue]); 73 aac_response_normal(&dev->queues->queue[HostNormRespQueue]);
74 } 74 }
75 else if (bellbits & DoorBellAdapterNormCmdNotFull) { 75 else if (unlikely(bellbits & DoorBellAdapterNormCmdNotFull)) {
76 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull); 76 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull);
77 } 77 }
78 else if (bellbits & DoorBellAdapterNormRespNotFull) { 78 else if (unlikely(bellbits & DoorBellAdapterNormRespNotFull)) {
79 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull); 79 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull);
80 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespNotFull); 80 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespNotFull);
81 } 81 }
@@ -88,11 +88,11 @@ static irqreturn_t aac_rx_intr_message(int irq, void *dev_id)
88{ 88{
89 struct aac_dev *dev = dev_id; 89 struct aac_dev *dev = dev_id;
90 u32 Index = rx_readl(dev, MUnit.OutboundQueue); 90 u32 Index = rx_readl(dev, MUnit.OutboundQueue);
91 if (Index == 0xFFFFFFFFL) 91 if (unlikely(Index == 0xFFFFFFFFL))
92 Index = rx_readl(dev, MUnit.OutboundQueue); 92 Index = rx_readl(dev, MUnit.OutboundQueue);
93 if (Index != 0xFFFFFFFFL) { 93 if (likely(Index != 0xFFFFFFFFL)) {
94 do { 94 do {
95 if (aac_intr_normal(dev, Index)) { 95 if (unlikely(aac_intr_normal(dev, Index))) {
96 rx_writel(dev, MUnit.OutboundQueue, Index); 96 rx_writel(dev, MUnit.OutboundQueue, Index);
97 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespReady); 97 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespReady);
98 } 98 }
@@ -204,7 +204,7 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command,
204 */ 204 */
205 msleep(1); 205 msleep(1);
206 } 206 }
207 if (ok != 1) { 207 if (unlikely(ok != 1)) {
208 /* 208 /*
209 * Restore interrupt mask even though we timed out 209 * Restore interrupt mask even though we timed out
210 */ 210 */
@@ -294,7 +294,7 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event)
294 * Start up processing on an i960 based AAC adapter 294 * Start up processing on an i960 based AAC adapter
295 */ 295 */
296 296
297void aac_rx_start_adapter(struct aac_dev *dev) 297static void aac_rx_start_adapter(struct aac_dev *dev)
298{ 298{
299 struct aac_init *init; 299 struct aac_init *init;
300 300
@@ -319,12 +319,12 @@ static int aac_rx_check_health(struct aac_dev *dev)
319 /* 319 /*
320 * Check to see if the board failed any self tests. 320 * Check to see if the board failed any self tests.
321 */ 321 */
322 if (status & SELF_TEST_FAILED) 322 if (unlikely(status & SELF_TEST_FAILED))
323 return -1; 323 return -1;
324 /* 324 /*
325 * Check to see if the board panic'd. 325 * Check to see if the board panic'd.
326 */ 326 */
327 if (status & KERNEL_PANIC) { 327 if (unlikely(status & KERNEL_PANIC)) {
328 char * buffer; 328 char * buffer;
329 struct POSTSTATUS { 329 struct POSTSTATUS {
330 __le32 Post_Command; 330 __le32 Post_Command;
@@ -333,15 +333,15 @@ static int aac_rx_check_health(struct aac_dev *dev)
333 dma_addr_t paddr, baddr; 333 dma_addr_t paddr, baddr;
334 int ret; 334 int ret;
335 335
336 if ((status & 0xFF000000L) == 0xBC000000L) 336 if (likely((status & 0xFF000000L) == 0xBC000000L))
337 return (status >> 16) & 0xFF; 337 return (status >> 16) & 0xFF;
338 buffer = pci_alloc_consistent(dev->pdev, 512, &baddr); 338 buffer = pci_alloc_consistent(dev->pdev, 512, &baddr);
339 ret = -2; 339 ret = -2;
340 if (buffer == NULL) 340 if (unlikely(buffer == NULL))
341 return ret; 341 return ret;
342 post = pci_alloc_consistent(dev->pdev, 342 post = pci_alloc_consistent(dev->pdev,
343 sizeof(struct POSTSTATUS), &paddr); 343 sizeof(struct POSTSTATUS), &paddr);
344 if (post == NULL) { 344 if (unlikely(post == NULL)) {
345 pci_free_consistent(dev->pdev, 512, buffer, baddr); 345 pci_free_consistent(dev->pdev, 512, buffer, baddr);
346 return ret; 346 return ret;
347 } 347 }
@@ -353,7 +353,7 @@ static int aac_rx_check_health(struct aac_dev *dev)
353 NULL, NULL, NULL, NULL, NULL); 353 NULL, NULL, NULL, NULL, NULL);
354 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), 354 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
355 post, paddr); 355 post, paddr);
356 if ((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X'))) { 356 if (likely((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X')))) {
357 ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10); 357 ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10);
358 ret <<= 4; 358 ret <<= 4;
359 ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10); 359 ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
@@ -364,7 +364,7 @@ static int aac_rx_check_health(struct aac_dev *dev)
364 /* 364 /*
365 * Wait for the adapter to be up and running. 365 * Wait for the adapter to be up and running.
366 */ 366 */
367 if (!(status & KERNEL_UP_AND_RUNNING)) 367 if (unlikely(!(status & KERNEL_UP_AND_RUNNING)))
368 return -3; 368 return -3;
369 /* 369 /*
370 * Everything is OK 370 * Everything is OK
@@ -387,7 +387,7 @@ static int aac_rx_deliver_producer(struct fib * fib)
387 unsigned long nointr = 0; 387 unsigned long nointr = 0;
388 388
389 spin_lock_irqsave(q->lock, qflags); 389 spin_lock_irqsave(q->lock, qflags);
390 aac_queue_get( dev, &Index, AdapNormCmdQueue, fib->hw_fib, 1, fib, &nointr); 390 aac_queue_get( dev, &Index, AdapNormCmdQueue, fib->hw_fib_va, 1, fib, &nointr);
391 391
392 q->numpending++; 392 q->numpending++;
393 *(q->headers.producer) = cpu_to_le32(Index + 1); 393 *(q->headers.producer) = cpu_to_le32(Index + 1);
@@ -419,9 +419,9 @@ static int aac_rx_deliver_message(struct fib * fib)
419 spin_unlock_irqrestore(q->lock, qflags); 419 spin_unlock_irqrestore(q->lock, qflags);
420 for(;;) { 420 for(;;) {
421 Index = rx_readl(dev, MUnit.InboundQueue); 421 Index = rx_readl(dev, MUnit.InboundQueue);
422 if (Index == 0xFFFFFFFFL) 422 if (unlikely(Index == 0xFFFFFFFFL))
423 Index = rx_readl(dev, MUnit.InboundQueue); 423 Index = rx_readl(dev, MUnit.InboundQueue);
424 if (Index != 0xFFFFFFFFL) 424 if (likely(Index != 0xFFFFFFFFL))
425 break; 425 break;
426 if (--count == 0) { 426 if (--count == 0) {
427 spin_lock_irqsave(q->lock, qflags); 427 spin_lock_irqsave(q->lock, qflags);
@@ -437,7 +437,7 @@ static int aac_rx_deliver_message(struct fib * fib)
437 device += sizeof(u32); 437 device += sizeof(u32);
438 writel((u32)(addr >> 32), device); 438 writel((u32)(addr >> 32), device);
439 device += sizeof(u32); 439 device += sizeof(u32);
440 writel(le16_to_cpu(fib->hw_fib->header.Size), device); 440 writel(le16_to_cpu(fib->hw_fib_va->header.Size), device);
441 rx_writel(dev, MUnit.InboundQueue, Index); 441 rx_writel(dev, MUnit.InboundQueue, Index);
442 return 0; 442 return 0;
443} 443}
@@ -460,22 +460,34 @@ static int aac_rx_ioremap(struct aac_dev * dev, u32 size)
460 return 0; 460 return 0;
461} 461}
462 462
463static int aac_rx_restart_adapter(struct aac_dev *dev) 463static int aac_rx_restart_adapter(struct aac_dev *dev, int bled)
464{ 464{
465 u32 var; 465 u32 var;
466 466
467 printk(KERN_ERR "%s%d: adapter kernel panic'd.\n", 467 if (bled)
468 dev->name, dev->id); 468 printk(KERN_ERR "%s%d: adapter kernel panic'd %x.\n",
469 469 dev->name, dev->id, bled);
470 if (aac_rx_check_health(dev) <= 0) 470 else {
471 return 1; 471 bled = aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS,
472 if (rx_sync_cmd(dev, IOP_RESET, 0, 0, 0, 0, 0, 0, 472 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL);
473 &var, NULL, NULL, NULL, NULL)) 473 if (!bled && (var != 0x00000001))
474 return 1; 474 bled = -EINVAL;
475 }
476 if (bled && (bled != -ETIMEDOUT))
477 bled = aac_adapter_sync_cmd(dev, IOP_RESET,
478 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL);
479
480 if (bled && (bled != -ETIMEDOUT))
481 return -EINVAL;
482 if (bled || (var == 0x3803000F)) { /* USE_OTHER_METHOD */
483 rx_writel(dev, MUnit.reserved2, 3);
484 msleep(5000); /* Delay 5 seconds */
485 var = 0x00000001;
486 }
475 if (var != 0x00000001) 487 if (var != 0x00000001)
476 return 1; 488 return -EINVAL;
477 if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC) 489 if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC)
478 return 1; 490 return -ENODEV;
479 return 0; 491 return 0;
480} 492}
481 493
@@ -517,24 +529,29 @@ int _aac_rx_init(struct aac_dev *dev)
517{ 529{
518 unsigned long start; 530 unsigned long start;
519 unsigned long status; 531 unsigned long status;
520 int instance; 532 int restart = 0;
521 const char * name; 533 int instance = dev->id;
522 534 const char * name = dev->name;
523 instance = dev->id;
524 name = dev->name;
525 535
526 if (aac_adapter_ioremap(dev, dev->base_size)) { 536 if (aac_adapter_ioremap(dev, dev->base_size)) {
527 printk(KERN_WARNING "%s: unable to map adapter.\n", name); 537 printk(KERN_WARNING "%s: unable to map adapter.\n", name);
528 goto error_iounmap; 538 goto error_iounmap;
529 } 539 }
530 540
541 /* Failure to reset here is an option ... */
542 dev->OIMR = status = rx_readb (dev, MUnit.OIMR);
543 if ((((status & 0xff) != 0xff) || reset_devices) &&
544 !aac_rx_restart_adapter(dev, 0))
545 ++restart;
531 /* 546 /*
532 * Check to see if the board panic'd while booting. 547 * Check to see if the board panic'd while booting.
533 */ 548 */
534 status = rx_readl(dev, MUnit.OMRx[0]); 549 status = rx_readl(dev, MUnit.OMRx[0]);
535 if (status & KERNEL_PANIC) 550 if (status & KERNEL_PANIC) {
536 if (aac_rx_restart_adapter(dev)) 551 if (aac_rx_restart_adapter(dev, aac_rx_check_health(dev)))
537 goto error_iounmap; 552 goto error_iounmap;
553 ++restart;
554 }
538 /* 555 /*
539 * Check to see if the board failed any self tests. 556 * Check to see if the board failed any self tests.
540 */ 557 */
@@ -556,12 +573,23 @@ int _aac_rx_init(struct aac_dev *dev)
556 */ 573 */
557 while (!((status = rx_readl(dev, MUnit.OMRx[0])) & KERNEL_UP_AND_RUNNING)) 574 while (!((status = rx_readl(dev, MUnit.OMRx[0])) & KERNEL_UP_AND_RUNNING))
558 { 575 {
559 if(time_after(jiffies, start+startup_timeout*HZ)) 576 if ((restart &&
560 { 577 (status & (KERNEL_PANIC|SELF_TEST_FAILED|MONITOR_PANIC))) ||
578 time_after(jiffies, start+HZ*startup_timeout)) {
561 printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n", 579 printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n",
562 dev->name, instance, status); 580 dev->name, instance, status);
563 goto error_iounmap; 581 goto error_iounmap;
564 } 582 }
583 if (!restart &&
584 ((status & (KERNEL_PANIC|SELF_TEST_FAILED|MONITOR_PANIC)) ||
585 time_after(jiffies, start + HZ *
586 ((startup_timeout > 60)
587 ? (startup_timeout - 60)
588 : (startup_timeout / 2))))) {
589 if (likely(!aac_rx_restart_adapter(dev, aac_rx_check_health(dev))))
590 start = jiffies;
591 ++restart;
592 }
565 msleep(1); 593 msleep(1);
566 } 594 }
567 /* 595 /*
@@ -572,6 +600,7 @@ int _aac_rx_init(struct aac_dev *dev)
572 dev->a_ops.adapter_notify = aac_rx_notify_adapter; 600 dev->a_ops.adapter_notify = aac_rx_notify_adapter;
573 dev->a_ops.adapter_sync_cmd = rx_sync_cmd; 601 dev->a_ops.adapter_sync_cmd = rx_sync_cmd;
574 dev->a_ops.adapter_check_health = aac_rx_check_health; 602 dev->a_ops.adapter_check_health = aac_rx_check_health;
603 dev->a_ops.adapter_restart = aac_rx_restart_adapter;
575 604
576 /* 605 /*
577 * First clear out all interrupts. Then enable the one's that we 606 * First clear out all interrupts. Then enable the one's that we
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index 6f1a1780efce..f4b5e9742ab0 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -31,7 +31,6 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/pci.h>
35#include <linux/spinlock.h> 34#include <linux/spinlock.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/blkdev.h> 36#include <linux/blkdev.h>
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 1d239f6c0103..cbbfbc9f3e0f 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -35,7 +35,6 @@
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/pci.h>
39#include <linux/isapnp.h> 38#include <linux/isapnp.h>
40#include <linux/blkdev.h> 39#include <linux/blkdev.h>
41#include <linux/mca.h> 40#include <linux/mca.h>
diff --git a/drivers/scsi/aic7xxx/Kconfig.aic79xx b/drivers/scsi/aic7xxx/Kconfig.aic79xx
index 911ea1756e55..5e6620f8dabc 100644
--- a/drivers/scsi/aic7xxx/Kconfig.aic79xx
+++ b/drivers/scsi/aic7xxx/Kconfig.aic79xx
@@ -57,18 +57,6 @@ config AIC79XX_BUILD_FIRMWARE
57 or modify the assembler Makefile or the files it includes if your 57 or modify the assembler Makefile or the files it includes if your
58 build environment is different than that of the author. 58 build environment is different than that of the author.
59 59
60config AIC79XX_ENABLE_RD_STRM
61 bool "Enable Read Streaming for All Targets"
62 depends on SCSI_AIC79XX
63 default n
64 help
65 Read Streaming is a U320 protocol option that should enhance
66 performance. Early U320 drive firmware actually performs slower
67 with read streaming enabled so it is disabled by default. Read
68 Streaming can be configured in much the same way as tagged queueing
69 using the "rd_strm" command line option. See
70 drivers/scsi/aic7xxx/README.aic79xx for details.
71
72config AIC79XX_DEBUG_ENABLE 60config AIC79XX_DEBUG_ENABLE
73 bool "Compile in Debugging Code" 61 bool "Compile in Debugging Code"
74 depends on SCSI_AIC79XX 62 depends on SCSI_AIC79XX
diff --git a/drivers/scsi/aic7xxx/Kconfig.aic7xxx b/drivers/scsi/aic7xxx/Kconfig.aic7xxx
index cd93f9a8611f..88da670a7915 100644
--- a/drivers/scsi/aic7xxx/Kconfig.aic7xxx
+++ b/drivers/scsi/aic7xxx/Kconfig.aic7xxx
@@ -50,16 +50,6 @@ config AIC7XXX_RESET_DELAY_MS
50 50
51 Default: 5000 (5 seconds) 51 Default: 5000 (5 seconds)
52 52
53config AIC7XXX_PROBE_EISA_VL
54 bool "Probe for EISA and VL AIC7XXX Adapters"
55 depends on SCSI_AIC7XXX && EISA
56 help
57 Probe for EISA and VLB Aic7xxx controllers. In many newer systems,
58 the invasive probes necessary to detect these controllers can cause
59 other devices to fail. For this reason, the non-PCI probe code is
60 disabled by default. The current value of this option can be "toggled"
61 via the no_probe kernel command line option.
62
63config AIC7XXX_BUILD_FIRMWARE 53config AIC7XXX_BUILD_FIRMWARE
64 bool "Build Adapter Firmware with Kernel Build" 54 bool "Build Adapter Firmware with Kernel Build"
65 depends on SCSI_AIC7XXX && !PREVENT_FIRMWARE_BUILD 55 depends on SCSI_AIC7XXX && !PREVENT_FIRMWARE_BUILD
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 2be03e975d97..6054881f21f1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -363,6 +363,8 @@ static int ahd_linux_run_command(struct ahd_softc*,
363 struct scsi_cmnd *); 363 struct scsi_cmnd *);
364static void ahd_linux_setup_tag_info_global(char *p); 364static void ahd_linux_setup_tag_info_global(char *p);
365static int aic79xx_setup(char *c); 365static int aic79xx_setup(char *c);
366static void ahd_freeze_simq(struct ahd_softc *ahd);
367static void ahd_release_simq(struct ahd_softc *ahd);
366 368
367static int ahd_linux_unit; 369static int ahd_linux_unit;
368 370
@@ -2016,13 +2018,13 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd)
2016 cmd->scsi_done(cmd); 2018 cmd->scsi_done(cmd);
2017} 2019}
2018 2020
2019void 2021static void
2020ahd_freeze_simq(struct ahd_softc *ahd) 2022ahd_freeze_simq(struct ahd_softc *ahd)
2021{ 2023{
2022 scsi_block_requests(ahd->platform_data->host); 2024 scsi_block_requests(ahd->platform_data->host);
2023} 2025}
2024 2026
2025void 2027static void
2026ahd_release_simq(struct ahd_softc *ahd) 2028ahd_release_simq(struct ahd_softc *ahd)
2027{ 2029{
2028 scsi_unblock_requests(ahd->platform_data->host); 2030 scsi_unblock_requests(ahd->platform_data->host);
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index 147c83c456a5..9218f29314fa 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -837,8 +837,6 @@ int ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg);
837void ahd_platform_free(struct ahd_softc *ahd); 837void ahd_platform_free(struct ahd_softc *ahd);
838void ahd_platform_init(struct ahd_softc *ahd); 838void ahd_platform_init(struct ahd_softc *ahd);
839void ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb); 839void ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
840void ahd_freeze_simq(struct ahd_softc *ahd);
841void ahd_release_simq(struct ahd_softc *ahd);
842 840
843static __inline void 841static __inline void
844ahd_freeze_scb(struct scb *scb) 842ahd_freeze_scb(struct scb *scb)
diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h
index 954c7c24501d..e1bd57b9f23d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx.h
+++ b/drivers/scsi/aic7xxx/aic7xxx.h
@@ -1278,11 +1278,6 @@ typedef enum {
1278 AHC_QUEUE_TAGGED 1278 AHC_QUEUE_TAGGED
1279} ahc_queue_alg; 1279} ahc_queue_alg;
1280 1280
1281void ahc_set_tags(struct ahc_softc *ahc,
1282 struct scsi_cmnd *cmd,
1283 struct ahc_devinfo *devinfo,
1284 ahc_queue_alg alg);
1285
1286/**************************** Target Mode *************************************/ 1281/**************************** Target Mode *************************************/
1287#ifdef AHC_TARGET_MODE 1282#ifdef AHC_TARGET_MODE
1288void ahc_send_lstate_events(struct ahc_softc *, 1283void ahc_send_lstate_events(struct ahc_softc *,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 50ef785224de..75733b09f27a 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -2073,7 +2073,7 @@ ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2073/* 2073/*
2074 * Update the current state of tagged queuing for a given target. 2074 * Update the current state of tagged queuing for a given target.
2075 */ 2075 */
2076void 2076static void
2077ahc_set_tags(struct ahc_softc *ahc, struct scsi_cmnd *cmd, 2077ahc_set_tags(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
2078 struct ahc_devinfo *devinfo, ahc_queue_alg alg) 2078 struct ahc_devinfo *devinfo, ahc_queue_alg alg)
2079{ 2079{
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 8f43ff772f23..db6ab1a3b81e 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -24,7 +24,6 @@
24 * 24 *
25 */ 25 */
26 26
27#include <linux/pci.h>
28#include <scsi/scsi_host.h> 27#include <scsi/scsi_host.h>
29 28
30#include "aic94xx.h" 29#include "aic94xx.h"
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index 12497da5529d..03bfed61bffc 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -49,7 +49,6 @@
49#include <linux/init.h> 49#include <linux/init.h>
50#include <linux/errno.h> 50#include <linux/errno.h>
51#include <linux/delay.h> 51#include <linux/delay.h>
52#include <linux/pci.h>
53 52
54#include <scsi/scsi_cmnd.h> 53#include <scsi/scsi_cmnd.h>
55#include <scsi/scsi_device.h> 54#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 0f920c84ac0f..eff846ae0aff 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -1,19 +1,19 @@
1/* 1/*
2 * NCR 5380 generic driver routines. These should make it *trivial* 2 * NCR 5380 generic driver routines. These should make it *trivial*
3 * to implement 5380 SCSI drivers under Linux with a non-trantor 3 * to implement 5380 SCSI drivers under Linux with a non-trantor
4 * architecture. 4 * architecture.
5 * 5 *
6 * Note that these routines also work with NR53c400 family chips. 6 * Note that these routines also work with NR53c400 family chips.
7 * 7 *
8 * Copyright 1993, Drew Eckhardt 8 * Copyright 1993, Drew Eckhardt
9 * Visionary Computing 9 * Visionary Computing
10 * (Unix and Linux consulting and custom programming) 10 * (Unix and Linux consulting and custom programming)
11 * drew@colorado.edu 11 * drew@colorado.edu
12 * +1 (303) 666-5836 12 * +1 (303) 666-5836
13 * 13 *
14 * DISTRIBUTION RELEASE 6. 14 * DISTRIBUTION RELEASE 6.
15 * 15 *
16 * For more information, please consult 16 * For more information, please consult
17 * 17 *
18 * NCR 5380 Family 18 * NCR 5380 Family
19 * SCSI Protocol Controller 19 * SCSI Protocol Controller
@@ -57,7 +57,7 @@
57 * - I've deleted all the stuff for AUTOPROBE_IRQ, REAL_DMA_POLL, PSEUDO_DMA 57 * - I've deleted all the stuff for AUTOPROBE_IRQ, REAL_DMA_POLL, PSEUDO_DMA
58 * and USLEEP, because these were messing up readability and will never be 58 * and USLEEP, because these were messing up readability and will never be
59 * needed for Atari SCSI. 59 * needed for Atari SCSI.
60 * 60 *
61 * - I've revised the NCR5380_main() calling scheme (relax the 'main_running' 61 * - I've revised the NCR5380_main() calling scheme (relax the 'main_running'
62 * stuff), and 'main' is executed in a bottom half if awoken by an 62 * stuff), and 'main' is executed in a bottom half if awoken by an
63 * interrupt. 63 * interrupt.
@@ -69,21 +69,29 @@
69 */ 69 */
70 70
71/* 71/*
72 * Further development / testing that should be done : 72 * Further development / testing that should be done :
73 * 1. Test linked command handling code after Eric is ready with 73 * 1. Test linked command handling code after Eric is ready with
74 * the high level code. 74 * the high level code.
75 */ 75 */
76#include <scsi/scsi_dbg.h> 76#include <scsi/scsi_dbg.h>
77#include <scsi/scsi_transport_spi.h> 77#include <scsi/scsi_transport_spi.h>
78 78
79#if (NDEBUG & NDEBUG_LISTS) 79#if (NDEBUG & NDEBUG_LISTS)
80#define LIST(x,y) \ 80#define LIST(x, y) \
81 { printk("LINE:%d Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); \ 81 do { \
82 if ((x)==(y)) udelay(5); } 82 printk("LINE:%d Adding %p to %p\n", \
83#define REMOVE(w,x,y,z) \ 83 __LINE__, (void*)(x), (void*)(y)); \
84 { printk("LINE:%d Removing: %p->%p %p->%p \n", __LINE__, \ 84 if ((x) == (y)) \
85 (void*)(w), (void*)(x), (void*)(y), (void*)(z)); \ 85 udelay(5); \
86 if ((x)==(y)) udelay(5); } 86 } while (0)
87#define REMOVE(w, x, y, z) \
88 do { \
89 printk("LINE:%d Removing: %p->%p %p->%p \n", \
90 __LINE__, (void*)(w), (void*)(x), \
91 (void*)(y), (void*)(z)); \
92 if ((x) == (y)) \
93 udelay(5); \
94 } while (0)
87#else 95#else
88#define LIST(x,y) 96#define LIST(x,y)
89#define REMOVE(w,x,y,z) 97#define REMOVE(w,x,y,z)
@@ -103,62 +111,62 @@
103 * more difficult than it has to be. 111 * more difficult than it has to be.
104 * 112 *
105 * Also, many of the SCSI drivers were written before the command queuing 113 * Also, many of the SCSI drivers were written before the command queuing
106 * routines were implemented, meaning their implementations of queued 114 * routines were implemented, meaning their implementations of queued
107 * commands were hacked on rather than designed in from the start. 115 * commands were hacked on rather than designed in from the start.
108 * 116 *
109 * When I designed the Linux SCSI drivers I figured that 117 * When I designed the Linux SCSI drivers I figured that
110 * while having two different SCSI boards in a system might be useful 118 * while having two different SCSI boards in a system might be useful
111 * for debugging things, two of the same type wouldn't be used. 119 * for debugging things, two of the same type wouldn't be used.
112 * Well, I was wrong and a number of users have mailed me about running 120 * Well, I was wrong and a number of users have mailed me about running
113 * multiple high-performance SCSI boards in a server. 121 * multiple high-performance SCSI boards in a server.
114 * 122 *
115 * Finally, when I get questions from users, I have no idea what 123 * Finally, when I get questions from users, I have no idea what
116 * revision of my driver they are running. 124 * revision of my driver they are running.
117 * 125 *
118 * This driver attempts to address these problems : 126 * This driver attempts to address these problems :
119 * This is a generic 5380 driver. To use it on a different platform, 127 * This is a generic 5380 driver. To use it on a different platform,
120 * one simply writes appropriate system specific macros (ie, data 128 * one simply writes appropriate system specific macros (ie, data
121 * transfer - some PC's will use the I/O bus, 68K's must use 129 * transfer - some PC's will use the I/O bus, 68K's must use
122 * memory mapped) and drops this file in their 'C' wrapper. 130 * memory mapped) and drops this file in their 'C' wrapper.
123 * 131 *
124 * As far as command queueing, two queues are maintained for 132 * As far as command queueing, two queues are maintained for
125 * each 5380 in the system - commands that haven't been issued yet, 133 * each 5380 in the system - commands that haven't been issued yet,
126 * and commands that are currently executing. This means that an 134 * and commands that are currently executing. This means that an
127 * unlimited number of commands may be queued, letting 135 * unlimited number of commands may be queued, letting
128 * more commands propagate from the higher driver levels giving higher 136 * more commands propagate from the higher driver levels giving higher
129 * throughput. Note that both I_T_L and I_T_L_Q nexuses are supported, 137 * throughput. Note that both I_T_L and I_T_L_Q nexuses are supported,
130 * allowing multiple commands to propagate all the way to a SCSI-II device 138 * allowing multiple commands to propagate all the way to a SCSI-II device
131 * while a command is already executing. 139 * while a command is already executing.
132 * 140 *
133 * To solve the multiple-boards-in-the-same-system problem, 141 * To solve the multiple-boards-in-the-same-system problem,
134 * there is a separate instance structure for each instance 142 * there is a separate instance structure for each instance
135 * of a 5380 in the system. So, multiple NCR5380 drivers will 143 * of a 5380 in the system. So, multiple NCR5380 drivers will
136 * be able to coexist with appropriate changes to the high level 144 * be able to coexist with appropriate changes to the high level
137 * SCSI code. 145 * SCSI code.
138 * 146 *
139 * A NCR5380_PUBLIC_REVISION macro is provided, with the release 147 * A NCR5380_PUBLIC_REVISION macro is provided, with the release
140 * number (updated for each public release) printed by the 148 * number (updated for each public release) printed by the
141 * NCR5380_print_options command, which should be called from the 149 * NCR5380_print_options command, which should be called from the
142 * wrapper detect function, so that I know what release of the driver 150 * wrapper detect function, so that I know what release of the driver
143 * users are using. 151 * users are using.
144 * 152 *
145 * Issues specific to the NCR5380 : 153 * Issues specific to the NCR5380 :
146 * 154 *
147 * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead 155 * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead
148 * piece of hardware that requires you to sit in a loop polling for 156 * piece of hardware that requires you to sit in a loop polling for
149 * the REQ signal as long as you are connected. Some devices are 157 * the REQ signal as long as you are connected. Some devices are
150 * brain dead (ie, many TEXEL CD ROM drives) and won't disconnect 158 * brain dead (ie, many TEXEL CD ROM drives) and won't disconnect
151 * while doing long seek operations. 159 * while doing long seek operations.
152 * 160 *
153 * The workaround for this is to keep track of devices that have 161 * The workaround for this is to keep track of devices that have
154 * disconnected. If the device hasn't disconnected, for commands that 162 * disconnected. If the device hasn't disconnected, for commands that
155 * should disconnect, we do something like 163 * should disconnect, we do something like
156 * 164 *
157 * while (!REQ is asserted) { sleep for N usecs; poll for M usecs } 165 * while (!REQ is asserted) { sleep for N usecs; poll for M usecs }
158 * 166 *
159 * Some tweaking of N and M needs to be done. An algorithm based 167 * Some tweaking of N and M needs to be done. An algorithm based
160 * on "time to data" would give the best results as long as short time 168 * on "time to data" would give the best results as long as short time
161 * to datas (ie, on the same track) were considered, however these 169 * to datas (ie, on the same track) were considered, however these
162 * broken devices are the exception rather than the rule and I'd rather 170 * broken devices are the exception rather than the rule and I'd rather
163 * spend my time optimizing for the normal case. 171 * spend my time optimizing for the normal case.
164 * 172 *
@@ -167,9 +175,9 @@
167 * At the heart of the design is a coroutine, NCR5380_main, 175 * At the heart of the design is a coroutine, NCR5380_main,
168 * which is started when not running by the interrupt handler, 176 * which is started when not running by the interrupt handler,
169 * timer, and queue command function. It attempts to establish 177 * timer, and queue command function. It attempts to establish
170 * I_T_L or I_T_L_Q nexuses by removing the commands from the 178 * I_T_L or I_T_L_Q nexuses by removing the commands from the
171 * issue queue and calling NCR5380_select() if a nexus 179 * issue queue and calling NCR5380_select() if a nexus
172 * is not established. 180 * is not established.
173 * 181 *
174 * Once a nexus is established, the NCR5380_information_transfer() 182 * Once a nexus is established, the NCR5380_information_transfer()
175 * phase goes through the various phases as instructed by the target. 183 * phase goes through the various phases as instructed by the target.
@@ -183,10 +191,10 @@
183 * calling NCR5380_intr() which will in turn call NCR5380_reselect 191 * calling NCR5380_intr() which will in turn call NCR5380_reselect
184 * to reestablish a nexus. This will run main if necessary. 192 * to reestablish a nexus. This will run main if necessary.
185 * 193 *
186 * On command termination, the done function will be called as 194 * On command termination, the done function will be called as
187 * appropriate. 195 * appropriate.
188 * 196 *
189 * SCSI pointers are maintained in the SCp field of SCSI command 197 * SCSI pointers are maintained in the SCp field of SCSI command
190 * structures, being initialized after the command is connected 198 * structures, being initialized after the command is connected
191 * in NCR5380_select, and set as appropriate in NCR5380_information_transfer. 199 * in NCR5380_select, and set as appropriate in NCR5380_information_transfer.
192 * Note that in violation of the standard, an implicit SAVE POINTERS operation 200 * Note that in violation of the standard, an implicit SAVE POINTERS operation
@@ -196,12 +204,12 @@
196/* 204/*
197 * Using this file : 205 * Using this file :
198 * This file a skeleton Linux SCSI driver for the NCR 5380 series 206 * This file a skeleton Linux SCSI driver for the NCR 5380 series
199 * of chips. To use it, you write an architecture specific functions 207 * of chips. To use it, you write an architecture specific functions
200 * and macros and include this file in your driver. 208 * and macros and include this file in your driver.
201 * 209 *
202 * These macros control options : 210 * These macros control options :
203 * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically 211 * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
204 * for commands that return with a CHECK CONDITION status. 212 * for commands that return with a CHECK CONDITION status.
205 * 213 *
206 * LINKED - if defined, linked commands are supported. 214 * LINKED - if defined, linked commands are supported.
207 * 215 *
@@ -210,18 +218,18 @@
210 * SUPPORT_TAGS - if defined, SCSI-2 tagged queuing is used where possible 218 * SUPPORT_TAGS - if defined, SCSI-2 tagged queuing is used where possible
211 * 219 *
212 * These macros MUST be defined : 220 * These macros MUST be defined :
213 * 221 *
214 * NCR5380_read(register) - read from the specified register 222 * NCR5380_read(register) - read from the specified register
215 * 223 *
216 * NCR5380_write(register, value) - write to the specific register 224 * NCR5380_write(register, value) - write to the specific register
217 * 225 *
218 * Either real DMA *or* pseudo DMA may be implemented 226 * Either real DMA *or* pseudo DMA may be implemented
219 * REAL functions : 227 * REAL functions :
220 * NCR5380_REAL_DMA should be defined if real DMA is to be used. 228 * NCR5380_REAL_DMA should be defined if real DMA is to be used.
221 * Note that the DMA setup functions should return the number of bytes 229 * Note that the DMA setup functions should return the number of bytes
222 * that they were able to program the controller for. 230 * that they were able to program the controller for.
223 * 231 *
224 * Also note that generic i386/PC versions of these macros are 232 * Also note that generic i386/PC versions of these macros are
225 * available as NCR5380_i386_dma_write_setup, 233 * available as NCR5380_i386_dma_write_setup,
226 * NCR5380_i386_dma_read_setup, and NCR5380_i386_dma_residual. 234 * NCR5380_i386_dma_read_setup, and NCR5380_i386_dma_residual.
227 * 235 *
@@ -234,14 +242,14 @@
234 * NCR5380_pread(instance, dst, count); 242 * NCR5380_pread(instance, dst, count);
235 * 243 *
236 * If nothing specific to this implementation needs doing (ie, with external 244 * If nothing specific to this implementation needs doing (ie, with external
237 * hardware), you must also define 245 * hardware), you must also define
238 * 246 *
239 * NCR5380_queue_command 247 * NCR5380_queue_command
240 * NCR5380_reset 248 * NCR5380_reset
241 * NCR5380_abort 249 * NCR5380_abort
242 * NCR5380_proc_info 250 * NCR5380_proc_info
243 * 251 *
244 * to be the global entry points into the specific driver, ie 252 * to be the global entry points into the specific driver, ie
245 * #define NCR5380_queue_command t128_queue_command. 253 * #define NCR5380_queue_command t128_queue_command.
246 * 254 *
247 * If this is not done, the routines will be defined as static functions 255 * If this is not done, the routines will be defined as static functions
@@ -249,7 +257,7 @@
249 * accessible wrapper function. 257 * accessible wrapper function.
250 * 258 *
251 * The generic driver is initialized by calling NCR5380_init(instance), 259 * The generic driver is initialized by calling NCR5380_init(instance),
252 * after setting the appropriate host specific fields and ID. If the 260 * after setting the appropriate host specific fields and ID. If the
253 * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance, 261 * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
254 * possible) function may be used. Before the specific driver initialization 262 * possible) function may be used. Before the specific driver initialization
255 * code finishes, NCR5380_print_options should be called. 263 * code finishes, NCR5380_print_options should be called.
@@ -264,8 +272,9 @@ static struct scsi_host_template *the_template = NULL;
264 (struct NCR5380_hostdata *)(in)->hostdata 272 (struct NCR5380_hostdata *)(in)->hostdata
265#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) 273#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata)
266 274
267#define NEXT(cmd) ((Scsi_Cmnd *)((cmd)->host_scribble)) 275#define NEXT(cmd) ((Scsi_Cmnd *)(cmd)->host_scribble)
268#define NEXTADDR(cmd) ((Scsi_Cmnd **)&((cmd)->host_scribble)) 276#define SET_NEXT(cmd,next) ((cmd)->host_scribble = (void *)(next))
277#define NEXTADDR(cmd) ((Scsi_Cmnd **)&(cmd)->host_scribble)
269 278
270#define HOSTNO instance->host_no 279#define HOSTNO instance->host_no
271#define H_NO(cmd) (cmd)->device->host->host_no 280#define H_NO(cmd) (cmd)->device->host->host_no
@@ -312,34 +321,34 @@ static struct scsi_host_template *the_template = NULL;
312#define TAG_NONE 0xff 321#define TAG_NONE 0xff
313 322
314typedef struct { 323typedef struct {
315 DECLARE_BITMAP(allocated, MAX_TAGS); 324 DECLARE_BITMAP(allocated, MAX_TAGS);
316 int nr_allocated; 325 int nr_allocated;
317 int queue_size; 326 int queue_size;
318} TAG_ALLOC; 327} TAG_ALLOC;
319 328
320static TAG_ALLOC TagAlloc[8][8]; /* 8 targets and 8 LUNs */ 329static TAG_ALLOC TagAlloc[8][8]; /* 8 targets and 8 LUNs */
321 330
322 331
323static void __init init_tags( void ) 332static void __init init_tags(void)
324{ 333{
325 int target, lun; 334 int target, lun;
326 TAG_ALLOC *ta; 335 TAG_ALLOC *ta;
327 336
328 if (!setup_use_tagged_queuing) 337 if (!setup_use_tagged_queuing)
329 return; 338 return;
330 339
331 for( target = 0; target < 8; ++target ) { 340 for (target = 0; target < 8; ++target) {
332 for( lun = 0; lun < 8; ++lun ) { 341 for (lun = 0; lun < 8; ++lun) {
333 ta = &TagAlloc[target][lun]; 342 ta = &TagAlloc[target][lun];
334 bitmap_zero(ta->allocated, MAX_TAGS); 343 bitmap_zero(ta->allocated, MAX_TAGS);
335 ta->nr_allocated = 0; 344 ta->nr_allocated = 0;
336 /* At the beginning, assume the maximum queue size we could 345 /* At the beginning, assume the maximum queue size we could
337 * support (MAX_TAGS). This value will be decreased if the target 346 * support (MAX_TAGS). This value will be decreased if the target
338 * returns QUEUE_FULL status. 347 * returns QUEUE_FULL status.
339 */ 348 */
340 ta->queue_size = MAX_TAGS; 349 ta->queue_size = MAX_TAGS;
350 }
341 } 351 }
342 }
343} 352}
344 353
345 354
@@ -348,24 +357,24 @@ static void __init init_tags( void )
348 * check that there is a free tag and the target's queue won't overflow. This 357 * check that there is a free tag and the target's queue won't overflow. This
349 * function should be called with interrupts disabled to avoid race 358 * function should be called with interrupts disabled to avoid race
350 * conditions. 359 * conditions.
351 */ 360 */
352 361
353static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged ) 362static int is_lun_busy(Scsi_Cmnd *cmd, int should_be_tagged)
354{ 363{
355 SETUP_HOSTDATA(cmd->device->host); 364 SETUP_HOSTDATA(cmd->device->host);
356 365
357 if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)) 366 if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun))
358 return( 1 ); 367 return 1;
359 if (!should_be_tagged || 368 if (!should_be_tagged ||
360 !setup_use_tagged_queuing || !cmd->device->tagged_supported) 369 !setup_use_tagged_queuing || !cmd->device->tagged_supported)
361 return( 0 ); 370 return 0;
362 if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >= 371 if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >=
363 TagAlloc[cmd->device->id][cmd->device->lun].queue_size ) { 372 TagAlloc[cmd->device->id][cmd->device->lun].queue_size) {
364 TAG_PRINTK( "scsi%d: target %d lun %d: no free tags\n", 373 TAG_PRINTK("scsi%d: target %d lun %d: no free tags\n",
365 H_NO(cmd), cmd->device->id, cmd->device->lun ); 374 H_NO(cmd), cmd->device->id, cmd->device->lun);
366 return( 1 ); 375 return 1;
367 } 376 }
368 return( 0 ); 377 return 0;
369} 378}
370 379
371 380
@@ -374,31 +383,30 @@ static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged )
374 * untagged. 383 * untagged.
375 */ 384 */
376 385
377static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged ) 386static void cmd_get_tag(Scsi_Cmnd *cmd, int should_be_tagged)
378{ 387{
379 SETUP_HOSTDATA(cmd->device->host); 388 SETUP_HOSTDATA(cmd->device->host);
380 389
381 /* If we or the target don't support tagged queuing, allocate the LUN for 390 /* If we or the target don't support tagged queuing, allocate the LUN for
382 * an untagged command. 391 * an untagged command.
383 */ 392 */
384 if (!should_be_tagged || 393 if (!should_be_tagged ||
385 !setup_use_tagged_queuing || !cmd->device->tagged_supported) { 394 !setup_use_tagged_queuing || !cmd->device->tagged_supported) {
386 cmd->tag = TAG_NONE; 395 cmd->tag = TAG_NONE;
387 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); 396 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
388 TAG_PRINTK( "scsi%d: target %d lun %d now allocated by untagged " 397 TAG_PRINTK("scsi%d: target %d lun %d now allocated by untagged "
389 "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun ); 398 "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun);
390 } 399 } else {
391 else { 400 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
392 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; 401
393 402 cmd->tag = find_first_zero_bit(ta->allocated, MAX_TAGS);
394 cmd->tag = find_first_zero_bit( ta->allocated, MAX_TAGS ); 403 set_bit(cmd->tag, ta->allocated);
395 set_bit( cmd->tag, ta->allocated ); 404 ta->nr_allocated++;
396 ta->nr_allocated++; 405 TAG_PRINTK("scsi%d: using tag %d for target %d lun %d "
397 TAG_PRINTK( "scsi%d: using tag %d for target %d lun %d " 406 "(now %d tags in use)\n",
398 "(now %d tags in use)\n", 407 H_NO(cmd), cmd->tag, cmd->device->id,
399 H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun, 408 cmd->device->lun, ta->nr_allocated);
400 ta->nr_allocated ); 409 }
401 }
402} 410}
403 411
404 412
@@ -406,44 +414,42 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged )
406 * unlock the LUN. 414 * unlock the LUN.
407 */ 415 */
408 416
409static void cmd_free_tag( Scsi_Cmnd *cmd ) 417static void cmd_free_tag(Scsi_Cmnd *cmd)
410{ 418{
411 SETUP_HOSTDATA(cmd->device->host); 419 SETUP_HOSTDATA(cmd->device->host);
412 420
413 if (cmd->tag == TAG_NONE) { 421 if (cmd->tag == TAG_NONE) {
414 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); 422 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
415 TAG_PRINTK( "scsi%d: target %d lun %d untagged cmd finished\n", 423 TAG_PRINTK("scsi%d: target %d lun %d untagged cmd finished\n",
416 H_NO(cmd), cmd->device->id, cmd->device->lun ); 424 H_NO(cmd), cmd->device->id, cmd->device->lun);
417 } 425 } else if (cmd->tag >= MAX_TAGS) {
418 else if (cmd->tag >= MAX_TAGS) { 426 printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n",
419 printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n", 427 H_NO(cmd), cmd->tag);
420 H_NO(cmd), cmd->tag ); 428 } else {
421 } 429 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
422 else { 430 clear_bit(cmd->tag, ta->allocated);
423 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; 431 ta->nr_allocated--;
424 clear_bit( cmd->tag, ta->allocated ); 432 TAG_PRINTK("scsi%d: freed tag %d for target %d lun %d\n",
425 ta->nr_allocated--; 433 H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun);
426 TAG_PRINTK( "scsi%d: freed tag %d for target %d lun %d\n", 434 }
427 H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun );
428 }
429} 435}
430 436
431 437
432static void free_all_tags( void ) 438static void free_all_tags(void)
433{ 439{
434 int target, lun; 440 int target, lun;
435 TAG_ALLOC *ta; 441 TAG_ALLOC *ta;
436 442
437 if (!setup_use_tagged_queuing) 443 if (!setup_use_tagged_queuing)
438 return; 444 return;
439 445
440 for( target = 0; target < 8; ++target ) { 446 for (target = 0; target < 8; ++target) {
441 for( lun = 0; lun < 8; ++lun ) { 447 for (lun = 0; lun < 8; ++lun) {
442 ta = &TagAlloc[target][lun]; 448 ta = &TagAlloc[target][lun];
443 bitmap_zero(ta->allocated, MAX_TAGS); 449 bitmap_zero(ta->allocated, MAX_TAGS);
444 ta->nr_allocated = 0; 450 ta->nr_allocated = 0;
451 }
445 } 452 }
446 }
447} 453}
448 454
449#endif /* SUPPORT_TAGS */ 455#endif /* SUPPORT_TAGS */
@@ -461,89 +467,94 @@ static void free_all_tags( void )
461 * assumed to be already transfered into ptr/this_residual. 467 * assumed to be already transfered into ptr/this_residual.
462 */ 468 */
463 469
464static void merge_contiguous_buffers( Scsi_Cmnd *cmd ) 470static void merge_contiguous_buffers(Scsi_Cmnd *cmd)
465{ 471{
466 unsigned long endaddr; 472 unsigned long endaddr;
467#if (NDEBUG & NDEBUG_MERGING) 473#if (NDEBUG & NDEBUG_MERGING)
468 unsigned long oldlen = cmd->SCp.this_residual; 474 unsigned long oldlen = cmd->SCp.this_residual;
469 int cnt = 1; 475 int cnt = 1;
470#endif 476#endif
471 477
472 for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; 478 for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1;
473 cmd->SCp.buffers_residual && 479 cmd->SCp.buffers_residual &&
474 virt_to_phys(page_address(cmd->SCp.buffer[1].page)+ 480 virt_to_phys(page_address(cmd->SCp.buffer[1].page) +
475 cmd->SCp.buffer[1].offset) == endaddr; ) { 481 cmd->SCp.buffer[1].offset) == endaddr;) {
476 MER_PRINTK("VTOP(%p) == %08lx -> merging\n", 482 MER_PRINTK("VTOP(%p) == %08lx -> merging\n",
477 cmd->SCp.buffer[1].address, endaddr); 483 page_address(cmd->SCp.buffer[1].page), endaddr);
478#if (NDEBUG & NDEBUG_MERGING) 484#if (NDEBUG & NDEBUG_MERGING)
479 ++cnt; 485 ++cnt;
480#endif 486#endif
481 ++cmd->SCp.buffer; 487 ++cmd->SCp.buffer;
482 --cmd->SCp.buffers_residual; 488 --cmd->SCp.buffers_residual;
483 cmd->SCp.this_residual += cmd->SCp.buffer->length; 489 cmd->SCp.this_residual += cmd->SCp.buffer->length;
484 endaddr += cmd->SCp.buffer->length; 490 endaddr += cmd->SCp.buffer->length;
485 } 491 }
486#if (NDEBUG & NDEBUG_MERGING) 492#if (NDEBUG & NDEBUG_MERGING)
487 if (oldlen != cmd->SCp.this_residual) 493 if (oldlen != cmd->SCp.this_residual)
488 MER_PRINTK("merged %d buffers from %p, new length %08x\n", 494 MER_PRINTK("merged %d buffers from %p, new length %08x\n",
489 cnt, cmd->SCp.ptr, cmd->SCp.this_residual); 495 cnt, cmd->SCp.ptr, cmd->SCp.this_residual);
490#endif 496#endif
491} 497}
492 498
493/* 499/*
494 * Function : void initialize_SCp(Scsi_Cmnd *cmd) 500 * Function : void initialize_SCp(Scsi_Cmnd *cmd)
495 * 501 *
496 * Purpose : initialize the saved data pointers for cmd to point to the 502 * Purpose : initialize the saved data pointers for cmd to point to the
497 * start of the buffer. 503 * start of the buffer.
498 * 504 *
499 * Inputs : cmd - Scsi_Cmnd structure to have pointers reset. 505 * Inputs : cmd - Scsi_Cmnd structure to have pointers reset.
500 */ 506 */
501 507
502static __inline__ void initialize_SCp(Scsi_Cmnd *cmd) 508static inline void initialize_SCp(Scsi_Cmnd *cmd)
503{ 509{
504 /* 510 /*
505 * Initialize the Scsi Pointer field so that all of the commands in the 511 * Initialize the Scsi Pointer field so that all of the commands in the
506 * various queues are valid. 512 * various queues are valid.
507 */
508
509 if (cmd->use_sg) {
510 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
511 cmd->SCp.buffers_residual = cmd->use_sg - 1;
512 cmd->SCp.ptr = (char *)page_address(cmd->SCp.buffer->page)+
513 cmd->SCp.buffer->offset;
514 cmd->SCp.this_residual = cmd->SCp.buffer->length;
515 /* ++roman: Try to merge some scatter-buffers if they are at
516 * contiguous physical addresses.
517 */ 513 */
518 merge_contiguous_buffers( cmd ); 514
519 } else { 515 if (cmd->use_sg) {
520 cmd->SCp.buffer = NULL; 516 cmd->SCp.buffer = (struct scatterlist *)cmd->request_buffer;
521 cmd->SCp.buffers_residual = 0; 517 cmd->SCp.buffers_residual = cmd->use_sg - 1;
522 cmd->SCp.ptr = (char *) cmd->request_buffer; 518 cmd->SCp.ptr = (char *)page_address(cmd->SCp.buffer->page) +
523 cmd->SCp.this_residual = cmd->request_bufflen; 519 cmd->SCp.buffer->offset;
524 } 520 cmd->SCp.this_residual = cmd->SCp.buffer->length;
521 /* ++roman: Try to merge some scatter-buffers if they are at
522 * contiguous physical addresses.
523 */
524 merge_contiguous_buffers(cmd);
525 } else {
526 cmd->SCp.buffer = NULL;
527 cmd->SCp.buffers_residual = 0;
528 cmd->SCp.ptr = (char *)cmd->request_buffer;
529 cmd->SCp.this_residual = cmd->request_bufflen;
530 }
525} 531}
526 532
527#include <linux/delay.h> 533#include <linux/delay.h>
528 534
529#if NDEBUG 535#if NDEBUG
530static struct { 536static struct {
531 unsigned char mask; 537 unsigned char mask;
532 const char * name;} 538 const char *name;
533signals[] = {{ SR_DBP, "PARITY"}, { SR_RST, "RST" }, { SR_BSY, "BSY" }, 539} signals[] = {
534 { SR_REQ, "REQ" }, { SR_MSG, "MSG" }, { SR_CD, "CD" }, { SR_IO, "IO" }, 540 { SR_DBP, "PARITY"}, { SR_RST, "RST" }, { SR_BSY, "BSY" },
535 { SR_SEL, "SEL" }, {0, NULL}}, 541 { SR_REQ, "REQ" }, { SR_MSG, "MSG" }, { SR_CD, "CD" }, { SR_IO, "IO" },
536basrs[] = {{BASR_ATN, "ATN"}, {BASR_ACK, "ACK"}, {0, NULL}}, 542 { SR_SEL, "SEL" }, {0, NULL}
537icrs[] = {{ICR_ASSERT_RST, "ASSERT RST"},{ICR_ASSERT_ACK, "ASSERT ACK"}, 543}, basrs[] = {
538 {ICR_ASSERT_BSY, "ASSERT BSY"}, {ICR_ASSERT_SEL, "ASSERT SEL"}, 544 {BASR_ATN, "ATN"}, {BASR_ACK, "ACK"}, {0, NULL}
539 {ICR_ASSERT_ATN, "ASSERT ATN"}, {ICR_ASSERT_DATA, "ASSERT DATA"}, 545}, icrs[] = {
540 {0, NULL}}, 546 {ICR_ASSERT_RST, "ASSERT RST"},{ICR_ASSERT_ACK, "ASSERT ACK"},
541mrs[] = {{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"}, 547 {ICR_ASSERT_BSY, "ASSERT BSY"}, {ICR_ASSERT_SEL, "ASSERT SEL"},
542 {MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"}, {MR_ENABLE_PAR_INTR, 548 {ICR_ASSERT_ATN, "ASSERT ATN"}, {ICR_ASSERT_DATA, "ASSERT DATA"},
543 "MODE PARITY INTR"}, {MR_ENABLE_EOP_INTR,"MODE EOP INTR"}, 549 {0, NULL}
544 {MR_MONITOR_BSY, "MODE MONITOR BSY"}, 550}, mrs[] = {
545 {MR_DMA_MODE, "MODE DMA"}, {MR_ARBITRATE, "MODE ARBITRATION"}, 551 {MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"},
546 {0, NULL}}; 552 {MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"}, {MR_ENABLE_PAR_INTR,
553 "MODE PARITY INTR"}, {MR_ENABLE_EOP_INTR,"MODE EOP INTR"},
554 {MR_MONITOR_BSY, "MODE MONITOR BSY"},
555 {MR_DMA_MODE, "MODE DMA"}, {MR_ARBITRATE, "MODE ARBITRATION"},
556 {0, NULL}
557};
547 558
548/* 559/*
549 * Function : void NCR5380_print(struct Scsi_Host *instance) 560 * Function : void NCR5380_print(struct Scsi_Host *instance)
@@ -553,45 +564,47 @@ mrs[] = {{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"},
553 * Input : instance - which NCR5380 564 * Input : instance - which NCR5380
554 */ 565 */
555 566
556static void NCR5380_print(struct Scsi_Host *instance) { 567static void NCR5380_print(struct Scsi_Host *instance)
557 unsigned char status, data, basr, mr, icr, i; 568{
558 unsigned long flags; 569 unsigned char status, data, basr, mr, icr, i;
559 570 unsigned long flags;
560 local_irq_save(flags); 571
561 data = NCR5380_read(CURRENT_SCSI_DATA_REG); 572 local_irq_save(flags);
562 status = NCR5380_read(STATUS_REG); 573 data = NCR5380_read(CURRENT_SCSI_DATA_REG);
563 mr = NCR5380_read(MODE_REG); 574 status = NCR5380_read(STATUS_REG);
564 icr = NCR5380_read(INITIATOR_COMMAND_REG); 575 mr = NCR5380_read(MODE_REG);
565 basr = NCR5380_read(BUS_AND_STATUS_REG); 576 icr = NCR5380_read(INITIATOR_COMMAND_REG);
566 local_irq_restore(flags); 577 basr = NCR5380_read(BUS_AND_STATUS_REG);
567 printk("STATUS_REG: %02x ", status); 578 local_irq_restore(flags);
568 for (i = 0; signals[i].mask ; ++i) 579 printk("STATUS_REG: %02x ", status);
569 if (status & signals[i].mask) 580 for (i = 0; signals[i].mask; ++i)
570 printk(",%s", signals[i].name); 581 if (status & signals[i].mask)
571 printk("\nBASR: %02x ", basr); 582 printk(",%s", signals[i].name);
572 for (i = 0; basrs[i].mask ; ++i) 583 printk("\nBASR: %02x ", basr);
573 if (basr & basrs[i].mask) 584 for (i = 0; basrs[i].mask; ++i)
574 printk(",%s", basrs[i].name); 585 if (basr & basrs[i].mask)
575 printk("\nICR: %02x ", icr); 586 printk(",%s", basrs[i].name);
576 for (i = 0; icrs[i].mask; ++i) 587 printk("\nICR: %02x ", icr);
577 if (icr & icrs[i].mask) 588 for (i = 0; icrs[i].mask; ++i)
578 printk(",%s", icrs[i].name); 589 if (icr & icrs[i].mask)
579 printk("\nMODE: %02x ", mr); 590 printk(",%s", icrs[i].name);
580 for (i = 0; mrs[i].mask; ++i) 591 printk("\nMODE: %02x ", mr);
581 if (mr & mrs[i].mask) 592 for (i = 0; mrs[i].mask; ++i)
582 printk(",%s", mrs[i].name); 593 if (mr & mrs[i].mask)
583 printk("\n"); 594 printk(",%s", mrs[i].name);
595 printk("\n");
584} 596}
585 597
586static struct { 598static struct {
587 unsigned char value; 599 unsigned char value;
588 const char *name; 600 const char *name;
589} phases[] = { 601} phases[] = {
590 {PHASE_DATAOUT, "DATAOUT"}, {PHASE_DATAIN, "DATAIN"}, {PHASE_CMDOUT, "CMDOUT"}, 602 {PHASE_DATAOUT, "DATAOUT"}, {PHASE_DATAIN, "DATAIN"}, {PHASE_CMDOUT, "CMDOUT"},
591 {PHASE_STATIN, "STATIN"}, {PHASE_MSGOUT, "MSGOUT"}, {PHASE_MSGIN, "MSGIN"}, 603 {PHASE_STATIN, "STATIN"}, {PHASE_MSGOUT, "MSGOUT"}, {PHASE_MSGIN, "MSGIN"},
592 {PHASE_UNKNOWN, "UNKNOWN"}}; 604 {PHASE_UNKNOWN, "UNKNOWN"}
605};
593 606
594/* 607/*
595 * Function : void NCR5380_print_phase(struct Scsi_Host *instance) 608 * Function : void NCR5380_print_phase(struct Scsi_Host *instance)
596 * 609 *
597 * Purpose : print the current SCSI phase for debugging purposes 610 * Purpose : print the current SCSI phase for debugging purposes
@@ -601,30 +614,35 @@ static struct {
601 614
602static void NCR5380_print_phase(struct Scsi_Host *instance) 615static void NCR5380_print_phase(struct Scsi_Host *instance)
603{ 616{
604 unsigned char status; 617 unsigned char status;
605 int i; 618 int i;
606 619
607 status = NCR5380_read(STATUS_REG); 620 status = NCR5380_read(STATUS_REG);
608 if (!(status & SR_REQ)) 621 if (!(status & SR_REQ))
609 printk(KERN_DEBUG "scsi%d: REQ not asserted, phase unknown.\n", HOSTNO); 622 printk(KERN_DEBUG "scsi%d: REQ not asserted, phase unknown.\n", HOSTNO);
610 else { 623 else {
611 for (i = 0; (phases[i].value != PHASE_UNKNOWN) && 624 for (i = 0; (phases[i].value != PHASE_UNKNOWN) &&
612 (phases[i].value != (status & PHASE_MASK)); ++i); 625 (phases[i].value != (status & PHASE_MASK)); ++i)
613 printk(KERN_DEBUG "scsi%d: phase %s\n", HOSTNO, phases[i].name); 626 ;
614 } 627 printk(KERN_DEBUG "scsi%d: phase %s\n", HOSTNO, phases[i].name);
628 }
615} 629}
616 630
617#else /* !NDEBUG */ 631#else /* !NDEBUG */
618 632
619/* dummies... */ 633/* dummies... */
620__inline__ void NCR5380_print(struct Scsi_Host *instance) { }; 634static inline void NCR5380_print(struct Scsi_Host *instance)
621__inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { }; 635{
636};
637static inline void NCR5380_print_phase(struct Scsi_Host *instance)
638{
639};
622 640
623#endif 641#endif
624 642
625/* 643/*
626 * ++roman: New scheme of calling NCR5380_main() 644 * ++roman: New scheme of calling NCR5380_main()
627 * 645 *
628 * If we're not in an interrupt, we can call our main directly, it cannot be 646 * If we're not in an interrupt, we can call our main directly, it cannot be
629 * already running. Else, we queue it on a task queue, if not 'main_running' 647 * already running. Else, we queue it on a task queue, if not 'main_running'
630 * tells us that a lower level is already executing it. This way, 648 * tells us that a lower level is already executing it. This way,
@@ -638,33 +656,33 @@ __inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { };
638#include <linux/workqueue.h> 656#include <linux/workqueue.h>
639#include <linux/interrupt.h> 657#include <linux/interrupt.h>
640 658
641static volatile int main_running = 0; 659static volatile int main_running;
642static DECLARE_WORK(NCR5380_tqueue, (void (*)(void*))NCR5380_main, NULL); 660static DECLARE_WORK(NCR5380_tqueue, NCR5380_main);
643 661
644static __inline__ void queue_main(void) 662static inline void queue_main(void)
645{ 663{
646 if (!main_running) { 664 if (!main_running) {
647 /* If in interrupt and NCR5380_main() not already running, 665 /* If in interrupt and NCR5380_main() not already running,
648 queue it on the 'immediate' task queue, to be processed 666 queue it on the 'immediate' task queue, to be processed
649 immediately after the current interrupt processing has 667 immediately after the current interrupt processing has
650 finished. */ 668 finished. */
651 schedule_work(&NCR5380_tqueue); 669 schedule_work(&NCR5380_tqueue);
652 } 670 }
653 /* else: nothing to do: the running NCR5380_main() will pick up 671 /* else: nothing to do: the running NCR5380_main() will pick up
654 any newly queued command. */ 672 any newly queued command. */
655} 673}
656 674
657 675
658static inline void NCR5380_all_init (void) 676static inline void NCR5380_all_init(void)
659{ 677{
660 static int done = 0; 678 static int done = 0;
661 if (!done) { 679 if (!done) {
662 INI_PRINTK("scsi : NCR5380_all_init()\n"); 680 INI_PRINTK("scsi : NCR5380_all_init()\n");
663 done = 1; 681 done = 1;
664 } 682 }
665} 683}
666 684
667 685
668/* 686/*
669 * Function : void NCR58380_print_options (struct Scsi_Host *instance) 687 * Function : void NCR58380_print_options (struct Scsi_Host *instance)
670 * 688 *
@@ -674,23 +692,23 @@ static inline void NCR5380_all_init (void)
674 * Inputs : instance, pointer to this instance. Unused. 692 * Inputs : instance, pointer to this instance. Unused.
675 */ 693 */
676 694
677static void __init NCR5380_print_options (struct Scsi_Host *instance) 695static void __init NCR5380_print_options(struct Scsi_Host *instance)
678{ 696{
679 printk(" generic options" 697 printk(" generic options"
680#ifdef AUTOSENSE 698#ifdef AUTOSENSE
681 " AUTOSENSE" 699 " AUTOSENSE"
682#endif 700#endif
683#ifdef REAL_DMA 701#ifdef REAL_DMA
684 " REAL DMA" 702 " REAL DMA"
685#endif 703#endif
686#ifdef PARITY 704#ifdef PARITY
687 " PARITY" 705 " PARITY"
688#endif 706#endif
689#ifdef SUPPORT_TAGS 707#ifdef SUPPORT_TAGS
690 " SCSI-2 TAGGED QUEUING" 708 " SCSI-2 TAGGED QUEUING"
691#endif 709#endif
692 ); 710 );
693 printk(" generic release=%d", NCR5380_PUBLIC_RELEASE); 711 printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
694} 712}
695 713
696/* 714/*
@@ -699,27 +717,27 @@ static void __init NCR5380_print_options (struct Scsi_Host *instance)
699 * Purpose : print commands in the various queues, called from 717 * Purpose : print commands in the various queues, called from
700 * NCR5380_abort and NCR5380_debug to aid debugging. 718 * NCR5380_abort and NCR5380_debug to aid debugging.
701 * 719 *
702 * Inputs : instance, pointer to this instance. 720 * Inputs : instance, pointer to this instance.
703 */ 721 */
704 722
705static void NCR5380_print_status (struct Scsi_Host *instance) 723static void NCR5380_print_status(struct Scsi_Host *instance)
706{ 724{
707 char *pr_bfr; 725 char *pr_bfr;
708 char *start; 726 char *start;
709 int len; 727 int len;
710 728
711 NCR_PRINT(NDEBUG_ANY); 729 NCR_PRINT(NDEBUG_ANY);
712 NCR_PRINT_PHASE(NDEBUG_ANY); 730 NCR_PRINT_PHASE(NDEBUG_ANY);
713 731
714 pr_bfr = (char *) __get_free_page(GFP_ATOMIC); 732 pr_bfr = (char *)__get_free_page(GFP_ATOMIC);
715 if (!pr_bfr) { 733 if (!pr_bfr) {
716 printk("NCR5380_print_status: no memory for print buffer\n"); 734 printk("NCR5380_print_status: no memory for print buffer\n");
717 return; 735 return;
718 } 736 }
719 len = NCR5380_proc_info(pr_bfr, &start, 0, PAGE_SIZE, HOSTNO, 0); 737 len = NCR5380_proc_info(instance, pr_bfr, &start, 0, PAGE_SIZE, 0);
720 pr_bfr[len] = 0; 738 pr_bfr[len] = 0;
721 printk("\n%s\n", pr_bfr); 739 printk("\n%s\n", pr_bfr);
722 free_page((unsigned long) pr_bfr); 740 free_page((unsigned long)pr_bfr);
723} 741}
724 742
725 743
@@ -738,443 +756,478 @@ static void NCR5380_print_status (struct Scsi_Host *instance)
738*/ 756*/
739 757
740#undef SPRINTF 758#undef SPRINTF
741#define SPRINTF(fmt,args...) \ 759#define SPRINTF(fmt,args...) \
742 do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ 760 do { \
743 pos += sprintf(pos, fmt , ## args); } while(0) 761 if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \
744static 762 pos += sprintf(pos, fmt , ## args); \
745char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length); 763 } while(0)
746 764static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length);
747static 765
748int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **start, off_t offset, 766static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer,
749 int length, int inout) 767 char **start, off_t offset, int length, int inout)
750{ 768{
751 char *pos = buffer; 769 char *pos = buffer;
752 struct NCR5380_hostdata *hostdata; 770 struct NCR5380_hostdata *hostdata;
753 Scsi_Cmnd *ptr; 771 Scsi_Cmnd *ptr;
754 unsigned long flags; 772 unsigned long flags;
755 off_t begin = 0; 773 off_t begin = 0;
756#define check_offset() \ 774#define check_offset() \
757 do { \ 775 do { \
758 if (pos - buffer < offset - begin) { \ 776 if (pos - buffer < offset - begin) { \
759 begin += pos - buffer; \ 777 begin += pos - buffer; \
760 pos = buffer; \ 778 pos = buffer; \
761 } \ 779 } \
762 } while (0) 780 } while (0)
763 781
764 hostdata = (struct NCR5380_hostdata *)instance->hostdata; 782 hostdata = (struct NCR5380_hostdata *)instance->hostdata;
765 783
766 if (inout) { /* Has data been written to the file ? */ 784 if (inout) /* Has data been written to the file ? */
767 return(-ENOSYS); /* Currently this is a no-op */ 785 return -ENOSYS; /* Currently this is a no-op */
768 } 786 SPRINTF("NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
769 SPRINTF("NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
770 check_offset();
771 local_irq_save(flags);
772 SPRINTF("NCR5380: coroutine is%s running.\n", main_running ? "" : "n't");
773 check_offset();
774 if (!hostdata->connected)
775 SPRINTF("scsi%d: no currently connected command\n", HOSTNO);
776 else
777 pos = lprint_Scsi_Cmnd ((Scsi_Cmnd *) hostdata->connected,
778 pos, buffer, length);
779 SPRINTF("scsi%d: issue_queue\n", HOSTNO);
780 check_offset();
781 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr)) {
782 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
783 check_offset(); 787 check_offset();
784 } 788 local_irq_save(flags);
789 SPRINTF("NCR5380: coroutine is%s running.\n",
790 main_running ? "" : "n't");
791 check_offset();
792 if (!hostdata->connected)
793 SPRINTF("scsi%d: no currently connected command\n", HOSTNO);
794 else
795 pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected,
796 pos, buffer, length);
797 SPRINTF("scsi%d: issue_queue\n", HOSTNO);
798 check_offset();
799 for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) {
800 pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length);
801 check_offset();
802 }
785 803
786 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); 804 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO);
787 check_offset();
788 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
789 ptr = NEXT(ptr)) {
790 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
791 check_offset(); 805 check_offset();
792 } 806 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
807 ptr = NEXT(ptr)) {
808 pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length);
809 check_offset();
810 }
793 811
794 local_irq_restore(flags); 812 local_irq_restore(flags);
795 *start = buffer + (offset - begin); 813 *start = buffer + (offset - begin);
796 if (pos - buffer < offset - begin) 814 if (pos - buffer < offset - begin)
797 return 0; 815 return 0;
798 else if (pos - buffer - (offset - begin) < length) 816 else if (pos - buffer - (offset - begin) < length)
799 return pos - buffer - (offset - begin); 817 return pos - buffer - (offset - begin);
800 return length; 818 return length;
801} 819}
802 820
803static char * 821static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length)
804lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length)
805{ 822{
806 int i, s; 823 int i, s;
807 unsigned char *command; 824 unsigned char *command;
808 SPRINTF("scsi%d: destination target %d, lun %d\n", 825 SPRINTF("scsi%d: destination target %d, lun %d\n",
809 H_NO(cmd), cmd->device->id, cmd->device->lun); 826 H_NO(cmd), cmd->device->id, cmd->device->lun);
810 SPRINTF(" command = "); 827 SPRINTF(" command = ");
811 command = cmd->cmnd; 828 command = cmd->cmnd;
812 SPRINTF("%2d (0x%02x)", command[0], command[0]); 829 SPRINTF("%2d (0x%02x)", command[0], command[0]);
813 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) 830 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
814 SPRINTF(" %02x", command[i]); 831 SPRINTF(" %02x", command[i]);
815 SPRINTF("\n"); 832 SPRINTF("\n");
816 return pos; 833 return pos;
817} 834}
818 835
819 836
820/* 837/*
821 * Function : void NCR5380_init (struct Scsi_Host *instance) 838 * Function : void NCR5380_init (struct Scsi_Host *instance)
822 * 839 *
823 * Purpose : initializes *instance and corresponding 5380 chip. 840 * Purpose : initializes *instance and corresponding 5380 chip.
824 * 841 *
825 * Inputs : instance - instantiation of the 5380 driver. 842 * Inputs : instance - instantiation of the 5380 driver.
826 * 843 *
827 * Notes : I assume that the host, hostno, and id bits have been 844 * Notes : I assume that the host, hostno, and id bits have been
828 * set correctly. I don't care about the irq and other fields. 845 * set correctly. I don't care about the irq and other fields.
829 * 846 *
830 */ 847 */
831 848
832static int NCR5380_init (struct Scsi_Host *instance, int flags) 849static int NCR5380_init(struct Scsi_Host *instance, int flags)
833{ 850{
834 int i; 851 int i;
835 SETUP_HOSTDATA(instance); 852 SETUP_HOSTDATA(instance);
836 853
837 NCR5380_all_init(); 854 NCR5380_all_init();
838 855
839 hostdata->aborted = 0; 856 hostdata->aborted = 0;
840 hostdata->id_mask = 1 << instance->this_id; 857 hostdata->id_mask = 1 << instance->this_id;
841 hostdata->id_higher_mask = 0; 858 hostdata->id_higher_mask = 0;
842 for (i = hostdata->id_mask; i <= 0x80; i <<= 1) 859 for (i = hostdata->id_mask; i <= 0x80; i <<= 1)
843 if (i > hostdata->id_mask) 860 if (i > hostdata->id_mask)
844 hostdata->id_higher_mask |= i; 861 hostdata->id_higher_mask |= i;
845 for (i = 0; i < 8; ++i) 862 for (i = 0; i < 8; ++i)
846 hostdata->busy[i] = 0; 863 hostdata->busy[i] = 0;
847#ifdef SUPPORT_TAGS 864#ifdef SUPPORT_TAGS
848 init_tags(); 865 init_tags();
849#endif 866#endif
850#if defined (REAL_DMA) 867#if defined (REAL_DMA)
851 hostdata->dma_len = 0; 868 hostdata->dma_len = 0;
852#endif 869#endif
853 hostdata->targets_present = 0; 870 hostdata->targets_present = 0;
854 hostdata->connected = NULL; 871 hostdata->connected = NULL;
855 hostdata->issue_queue = NULL; 872 hostdata->issue_queue = NULL;
856 hostdata->disconnected_queue = NULL; 873 hostdata->disconnected_queue = NULL;
857 hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT; 874 hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT;
858 875
859 if (!the_template) { 876 if (!the_template) {
860 the_template = instance->hostt; 877 the_template = instance->hostt;
861 first_instance = instance; 878 first_instance = instance;
862 } 879 }
863
864 880
865#ifndef AUTOSENSE 881#ifndef AUTOSENSE
866 if ((instance->cmd_per_lun > 1) || (instance->can_queue > 1)) 882 if ((instance->cmd_per_lun > 1) || (instance->can_queue > 1))
867 printk("scsi%d: WARNING : support for multiple outstanding commands enabled\n" 883 printk("scsi%d: WARNING : support for multiple outstanding commands enabled\n"
868 " without AUTOSENSE option, contingent allegiance conditions may\n" 884 " without AUTOSENSE option, contingent allegiance conditions may\n"
869 " be incorrectly cleared.\n", HOSTNO); 885 " be incorrectly cleared.\n", HOSTNO);
870#endif /* def AUTOSENSE */ 886#endif /* def AUTOSENSE */
871 887
872 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 888 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
873 NCR5380_write(MODE_REG, MR_BASE); 889 NCR5380_write(MODE_REG, MR_BASE);
874 NCR5380_write(TARGET_COMMAND_REG, 0); 890 NCR5380_write(TARGET_COMMAND_REG, 0);
875 NCR5380_write(SELECT_ENABLE_REG, 0); 891 NCR5380_write(SELECT_ENABLE_REG, 0);
876 892
877 return 0; 893 return 0;
878} 894}
879 895
880/* 896/*
881 * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd, 897 * our own old-style timeout update
882 * void (*done)(Scsi_Cmnd *)) 898 */
899/*
900 * The strategy is to cause the timer code to call scsi_times_out()
901 * when the soonest timeout is pending.
902 * The arguments are used when we are queueing a new command, because
903 * we do not want to subtract the time used from this time, but when we
904 * set the timer, we want to take this value into account.
905 */
906
907int atari_scsi_update_timeout(Scsi_Cmnd * SCset, int timeout)
908{
909 int rtn;
910
911 /*
912 * We are using the new error handling code to actually register/deregister
913 * timers for timeout.
914 */
915
916 if (!timer_pending(&SCset->eh_timeout))
917 rtn = 0;
918 else
919 rtn = SCset->eh_timeout.expires - jiffies;
920
921 if (timeout == 0) {
922 del_timer(&SCset->eh_timeout);
923 SCset->eh_timeout.data = (unsigned long)NULL;
924 SCset->eh_timeout.expires = 0;
925 } else {
926 if (SCset->eh_timeout.data != (unsigned long)NULL)
927 del_timer(&SCset->eh_timeout);
928 SCset->eh_timeout.data = (unsigned long)SCset;
929 SCset->eh_timeout.expires = jiffies + timeout;
930 add_timer(&SCset->eh_timeout);
931 }
932 return rtn;
933}
934
935/*
936 * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd,
937 * void (*done)(Scsi_Cmnd *))
883 * 938 *
884 * Purpose : enqueues a SCSI command 939 * Purpose : enqueues a SCSI command
885 * 940 *
886 * Inputs : cmd - SCSI command, done - function called on completion, with 941 * Inputs : cmd - SCSI command, done - function called on completion, with
887 * a pointer to the command descriptor. 942 * a pointer to the command descriptor.
888 * 943 *
889 * Returns : 0 944 * Returns : 0
890 * 945 *
891 * Side effects : 946 * Side effects :
892 * cmd is added to the per instance issue_queue, with minor 947 * cmd is added to the per instance issue_queue, with minor
893 * twiddling done to the host specific fields of cmd. If the 948 * twiddling done to the host specific fields of cmd. If the
894 * main coroutine is not running, it is restarted. 949 * main coroutine is not running, it is restarted.
895 * 950 *
896 */ 951 */
897 952
898static 953static int NCR5380_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
899int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
900{ 954{
901 SETUP_HOSTDATA(cmd->device->host); 955 SETUP_HOSTDATA(cmd->device->host);
902 Scsi_Cmnd *tmp; 956 Scsi_Cmnd *tmp;
903 int oldto; 957 int oldto;
904 unsigned long flags; 958 unsigned long flags;
905 extern int update_timeout(Scsi_Cmnd * SCset, int timeout); 959 // extern int update_timeout(Scsi_Cmnd * SCset, int timeout);
906 960
907#if (NDEBUG & NDEBUG_NO_WRITE) 961#if (NDEBUG & NDEBUG_NO_WRITE)
908 switch (cmd->cmnd[0]) { 962 switch (cmd->cmnd[0]) {
909 case WRITE_6: 963 case WRITE_6:
910 case WRITE_10: 964 case WRITE_10:
911 printk(KERN_NOTICE "scsi%d: WRITE attempted with NO_WRITE debugging flag set\n", 965 printk(KERN_NOTICE "scsi%d: WRITE attempted with NO_WRITE debugging flag set\n",
912 H_NO(cmd)); 966 H_NO(cmd));
913 cmd->result = (DID_ERROR << 16); 967 cmd->result = (DID_ERROR << 16);
914 done(cmd); 968 done(cmd);
915 return 0; 969 return 0;
916 } 970 }
917#endif /* (NDEBUG & NDEBUG_NO_WRITE) */ 971#endif /* (NDEBUG & NDEBUG_NO_WRITE) */
918 972
919
920#ifdef NCR5380_STATS 973#ifdef NCR5380_STATS
921# if 0 974# if 0
922 if (!hostdata->connected && !hostdata->issue_queue && 975 if (!hostdata->connected && !hostdata->issue_queue &&
923 !hostdata->disconnected_queue) { 976 !hostdata->disconnected_queue) {
924 hostdata->timebase = jiffies; 977 hostdata->timebase = jiffies;
925 } 978 }
926# endif 979# endif
927# ifdef NCR5380_STAT_LIMIT 980# ifdef NCR5380_STAT_LIMIT
928 if (cmd->request_bufflen > NCR5380_STAT_LIMIT) 981 if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
929# endif 982# endif
930 switch (cmd->cmnd[0]) 983 switch (cmd->cmnd[0]) {
931 { 984 case WRITE:
932 case WRITE: 985 case WRITE_6:
933 case WRITE_6: 986 case WRITE_10:
934 case WRITE_10: 987 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
935 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase); 988 hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;
936 hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen; 989 hostdata->pendingw++;
937 hostdata->pendingw++; 990 break;
938 break; 991 case READ:
939 case READ: 992 case READ_6:
940 case READ_6: 993 case READ_10:
941 case READ_10: 994 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
942 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase); 995 hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;
943 hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen; 996 hostdata->pendingr++;
944 hostdata->pendingr++; 997 break;
945 break; 998 }
946 }
947#endif 999#endif
948 1000
949 /* 1001 /*
950 * We use the host_scribble field as a pointer to the next command 1002 * We use the host_scribble field as a pointer to the next command
951 * in a queue 1003 * in a queue
952 */ 1004 */
953 1005
954 NEXT(cmd) = NULL; 1006 SET_NEXT(cmd, NULL);
955 cmd->scsi_done = done; 1007 cmd->scsi_done = done;
956 1008
957 cmd->result = 0; 1009 cmd->result = 0;
958 1010
959 1011 /*
960 /* 1012 * Insert the cmd into the issue queue. Note that REQUEST SENSE
961 * Insert the cmd into the issue queue. Note that REQUEST SENSE 1013 * commands are added to the head of the queue since any command will
962 * commands are added to the head of the queue since any command will 1014 * clear the contingent allegiance condition that exists and the
963 * clear the contingent allegiance condition that exists and the 1015 * sense data is only guaranteed to be valid while the condition exists.
964 * sense data is only guaranteed to be valid while the condition exists. 1016 */
965 */ 1017
966 1018 local_irq_save(flags);
967 local_irq_save(flags); 1019 /* ++guenther: now that the issue queue is being set up, we can lock ST-DMA.
968 /* ++guenther: now that the issue queue is being set up, we can lock ST-DMA. 1020 * Otherwise a running NCR5380_main may steal the lock.
969 * Otherwise a running NCR5380_main may steal the lock. 1021 * Lock before actually inserting due to fairness reasons explained in
970 * Lock before actually inserting due to fairness reasons explained in 1022 * atari_scsi.c. If we insert first, then it's impossible for this driver
971 * atari_scsi.c. If we insert first, then it's impossible for this driver 1023 * to release the lock.
972 * to release the lock. 1024 * Stop timer for this command while waiting for the lock, or timeouts
973 * Stop timer for this command while waiting for the lock, or timeouts 1025 * may happen (and they really do), and it's no good if the command doesn't
974 * may happen (and they really do), and it's no good if the command doesn't 1026 * appear in any of the queues.
975 * appear in any of the queues. 1027 * ++roman: Just disabling the NCR interrupt isn't sufficient here,
976 * ++roman: Just disabling the NCR interrupt isn't sufficient here, 1028 * because also a timer int can trigger an abort or reset, which would
977 * because also a timer int can trigger an abort or reset, which would 1029 * alter queues and touch the lock.
978 * alter queues and touch the lock. 1030 */
979 */ 1031 if (!IS_A_TT()) {
980 if (!IS_A_TT()) { 1032 oldto = atari_scsi_update_timeout(cmd, 0);
981 oldto = update_timeout(cmd, 0); 1033 falcon_get_lock();
982 falcon_get_lock(); 1034 atari_scsi_update_timeout(cmd, oldto);
983 update_timeout(cmd, oldto); 1035 }
984 } 1036 if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
985 if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) { 1037 LIST(cmd, hostdata->issue_queue);
986 LIST(cmd, hostdata->issue_queue); 1038 SET_NEXT(cmd, hostdata->issue_queue);
987 NEXT(cmd) = hostdata->issue_queue; 1039 hostdata->issue_queue = cmd;
988 hostdata->issue_queue = cmd; 1040 } else {
989 } else { 1041 for (tmp = (Scsi_Cmnd *)hostdata->issue_queue;
990 for (tmp = (Scsi_Cmnd *)hostdata->issue_queue; 1042 NEXT(tmp); tmp = NEXT(tmp))
991 NEXT(tmp); tmp = NEXT(tmp)) 1043 ;
992 ; 1044 LIST(cmd, tmp);
993 LIST(cmd, tmp); 1045 SET_NEXT(tmp, cmd);
994 NEXT(tmp) = cmd; 1046 }
995 } 1047 local_irq_restore(flags);
996 local_irq_restore(flags); 1048
997 1049 QU_PRINTK("scsi%d: command added to %s of queue\n", H_NO(cmd),
998 QU_PRINTK("scsi%d: command added to %s of queue\n", H_NO(cmd), 1050 (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail");
999 (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"); 1051
1000 1052 /* If queue_command() is called from an interrupt (real one or bottom
1001 /* If queue_command() is called from an interrupt (real one or bottom 1053 * half), we let queue_main() do the job of taking care about main. If it
1002 * half), we let queue_main() do the job of taking care about main. If it 1054 * is already running, this is a no-op, else main will be queued.
1003 * is already running, this is a no-op, else main will be queued. 1055 *
1004 * 1056 * If we're not in an interrupt, we can call NCR5380_main()
1005 * If we're not in an interrupt, we can call NCR5380_main() 1057 * unconditionally, because it cannot be already running.
1006 * unconditionally, because it cannot be already running. 1058 */
1007 */ 1059 if (in_interrupt() || ((flags >> 8) & 7) >= 6)
1008 if (in_interrupt() || ((flags >> 8) & 7) >= 6) 1060 queue_main();
1009 queue_main(); 1061 else
1010 else 1062 NCR5380_main(NULL);
1011 NCR5380_main(NULL); 1063 return 0;
1012 return 0;
1013} 1064}
1014 1065
1015/* 1066/*
1016 * Function : NCR5380_main (void) 1067 * Function : NCR5380_main (void)
1017 * 1068 *
1018 * Purpose : NCR5380_main is a coroutine that runs as long as more work can 1069 * Purpose : NCR5380_main is a coroutine that runs as long as more work can
1019 * be done on the NCR5380 host adapters in a system. Both 1070 * be done on the NCR5380 host adapters in a system. Both
1020 * NCR5380_queue_command() and NCR5380_intr() will try to start it 1071 * NCR5380_queue_command() and NCR5380_intr() will try to start it
1021 * in case it is not running. 1072 * in case it is not running.
1022 * 1073 *
1023 * NOTE : NCR5380_main exits with interrupts *disabled*, the caller should 1074 * NOTE : NCR5380_main exits with interrupts *disabled*, the caller should
1024 * reenable them. This prevents reentrancy and kernel stack overflow. 1075 * reenable them. This prevents reentrancy and kernel stack overflow.
1025 */ 1076 */
1026 1077
1027static void NCR5380_main (void *bl) 1078static void NCR5380_main(struct work_struct *work)
1028{ 1079{
1029 Scsi_Cmnd *tmp, *prev; 1080 Scsi_Cmnd *tmp, *prev;
1030 struct Scsi_Host *instance = first_instance; 1081 struct Scsi_Host *instance = first_instance;
1031 struct NCR5380_hostdata *hostdata = HOSTDATA(instance); 1082 struct NCR5380_hostdata *hostdata = HOSTDATA(instance);
1032 int done; 1083 int done;
1033 unsigned long flags; 1084 unsigned long flags;
1034 1085
1035 /* 1086 /*
1036 * We run (with interrupts disabled) until we're sure that none of 1087 * We run (with interrupts disabled) until we're sure that none of
1037 * the host adapters have anything that can be done, at which point 1088 * the host adapters have anything that can be done, at which point
1038 * we set main_running to 0 and exit. 1089 * we set main_running to 0 and exit.
1039 * 1090 *
1040 * Interrupts are enabled before doing various other internal 1091 * Interrupts are enabled before doing various other internal
1041 * instructions, after we've decided that we need to run through 1092 * instructions, after we've decided that we need to run through
1042 * the loop again. 1093 * the loop again.
1043 * 1094 *
1044 * this should prevent any race conditions. 1095 * this should prevent any race conditions.
1045 * 1096 *
1046 * ++roman: Just disabling the NCR interrupt isn't sufficient here, 1097 * ++roman: Just disabling the NCR interrupt isn't sufficient here,
1047 * because also a timer int can trigger an abort or reset, which can 1098 * because also a timer int can trigger an abort or reset, which can
1048 * alter queues and touch the Falcon lock. 1099 * alter queues and touch the Falcon lock.
1049 */ 1100 */
1050 1101
1051 /* Tell int handlers main() is now already executing. Note that 1102 /* Tell int handlers main() is now already executing. Note that
1052 no races are possible here. If an int comes in before 1103 no races are possible here. If an int comes in before
1053 'main_running' is set here, and queues/executes main via the 1104 'main_running' is set here, and queues/executes main via the
1054 task queue, it doesn't do any harm, just this instance of main 1105 task queue, it doesn't do any harm, just this instance of main
1055 won't find any work left to do. */ 1106 won't find any work left to do. */
1056 if (main_running) 1107 if (main_running)
1057 return; 1108 return;
1058 main_running = 1; 1109 main_running = 1;
1059 1110
1060 local_save_flags(flags); 1111 local_save_flags(flags);
1061 do { 1112 do {
1062 local_irq_disable(); /* Freeze request queues */ 1113 local_irq_disable(); /* Freeze request queues */
1063 done = 1; 1114 done = 1;
1064 1115
1065 if (!hostdata->connected) { 1116 if (!hostdata->connected) {
1066 MAIN_PRINTK( "scsi%d: not connected\n", HOSTNO ); 1117 MAIN_PRINTK("scsi%d: not connected\n", HOSTNO);
1067 /* 1118 /*
1068 * Search through the issue_queue for a command destined 1119 * Search through the issue_queue for a command destined
1069 * for a target that's not busy. 1120 * for a target that's not busy.
1070 */ 1121 */
1071#if (NDEBUG & NDEBUG_LISTS) 1122#if (NDEBUG & NDEBUG_LISTS)
1072 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; 1123 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL;
1073 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp)) 1124 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp))
1074 ; 1125 ;
1075 /*printk("%p ", tmp);*/ 1126 /*printk("%p ", tmp);*/
1076 if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/ 1127 if ((tmp == prev) && tmp)
1128 printk(" LOOP\n");
1129 /* else printk("\n"); */
1077#endif 1130#endif
1078 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, 1131 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue,
1079 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) { 1132 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) {
1080 1133
1081#if (NDEBUG & NDEBUG_LISTS) 1134#if (NDEBUG & NDEBUG_LISTS)
1082 if (prev != tmp) 1135 if (prev != tmp)
1083 printk("MAIN tmp=%p target=%d busy=%d lun=%d\n", 1136 printk("MAIN tmp=%p target=%d busy=%d lun=%d\n",
1084 tmp, tmp->device->id, hostdata->busy[tmp->device->id], 1137 tmp, tmp->device->id, hostdata->busy[tmp->device->id],
1085 tmp->device->lun); 1138 tmp->device->lun);
1086#endif 1139#endif
1087 /* When we find one, remove it from the issue queue. */ 1140 /* When we find one, remove it from the issue queue. */
1088 /* ++guenther: possible race with Falcon locking */ 1141 /* ++guenther: possible race with Falcon locking */
1089 if ( 1142 if (
1090#ifdef SUPPORT_TAGS 1143#ifdef SUPPORT_TAGS
1091 !is_lun_busy( tmp, tmp->cmnd[0] != REQUEST_SENSE) 1144 !is_lun_busy( tmp, tmp->cmnd[0] != REQUEST_SENSE)
1092#else 1145#else
1093 !(hostdata->busy[tmp->device->id] & (1 << tmp->device->lun)) 1146 !(hostdata->busy[tmp->device->id] & (1 << tmp->device->lun))
1094#endif 1147#endif
1095 ) { 1148 ) {
1096 /* ++guenther: just to be sure, this must be atomic */ 1149 /* ++guenther: just to be sure, this must be atomic */
1097 local_irq_disable(); 1150 local_irq_disable();
1098 if (prev) { 1151 if (prev) {
1099 REMOVE(prev, NEXT(prev), tmp, NEXT(tmp)); 1152 REMOVE(prev, NEXT(prev), tmp, NEXT(tmp));
1100 NEXT(prev) = NEXT(tmp); 1153 SET_NEXT(prev, NEXT(tmp));
1101 } else { 1154 } else {
1102 REMOVE(-1, hostdata->issue_queue, tmp, NEXT(tmp)); 1155 REMOVE(-1, hostdata->issue_queue, tmp, NEXT(tmp));
1103 hostdata->issue_queue = NEXT(tmp); 1156 hostdata->issue_queue = NEXT(tmp);
1104 } 1157 }
1105 NEXT(tmp) = NULL; 1158 SET_NEXT(tmp, NULL);
1106 falcon_dont_release++; 1159 falcon_dont_release++;
1107 1160
1108 /* reenable interrupts after finding one */ 1161 /* reenable interrupts after finding one */
1109 local_irq_restore(flags); 1162 local_irq_restore(flags);
1110 1163
1111 /* 1164 /*
1112 * Attempt to establish an I_T_L nexus here. 1165 * Attempt to establish an I_T_L nexus here.
1113 * On success, instance->hostdata->connected is set. 1166 * On success, instance->hostdata->connected is set.
1114 * On failure, we must add the command back to the 1167 * On failure, we must add the command back to the
1115 * issue queue so we can keep trying. 1168 * issue queue so we can keep trying.
1116 */ 1169 */
1117 MAIN_PRINTK("scsi%d: main(): command for target %d " 1170 MAIN_PRINTK("scsi%d: main(): command for target %d "
1118 "lun %d removed from issue_queue\n", 1171 "lun %d removed from issue_queue\n",
1119 HOSTNO, tmp->device->id, tmp->device->lun); 1172 HOSTNO, tmp->device->id, tmp->device->lun);
1120 /* 1173 /*
1121 * REQUEST SENSE commands are issued without tagged 1174 * REQUEST SENSE commands are issued without tagged
1122 * queueing, even on SCSI-II devices because the 1175 * queueing, even on SCSI-II devices because the
1123 * contingent allegiance condition exists for the 1176 * contingent allegiance condition exists for the
1124 * entire unit. 1177 * entire unit.
1125 */ 1178 */
1126 /* ++roman: ...and the standard also requires that 1179 /* ++roman: ...and the standard also requires that
1127 * REQUEST SENSE command are untagged. 1180 * REQUEST SENSE command are untagged.
1128 */ 1181 */
1129 1182
1130#ifdef SUPPORT_TAGS 1183#ifdef SUPPORT_TAGS
1131 cmd_get_tag( tmp, tmp->cmnd[0] != REQUEST_SENSE ); 1184 cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE);
1132#endif 1185#endif
1133 if (!NCR5380_select(instance, tmp, 1186 if (!NCR5380_select(instance, tmp,
1134 (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : 1187 (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE :
1135 TAG_NEXT)) { 1188 TAG_NEXT)) {
1136 falcon_dont_release--; 1189 falcon_dont_release--;
1137 /* release if target did not response! */ 1190 /* release if target did not response! */
1138 falcon_release_lock_if_possible( hostdata ); 1191 falcon_release_lock_if_possible(hostdata);
1139 break; 1192 break;
1140 } else { 1193 } else {
1141 local_irq_disable(); 1194 local_irq_disable();
1142 LIST(tmp, hostdata->issue_queue); 1195 LIST(tmp, hostdata->issue_queue);
1143 NEXT(tmp) = hostdata->issue_queue; 1196 SET_NEXT(tmp, hostdata->issue_queue);
1144 hostdata->issue_queue = tmp; 1197 hostdata->issue_queue = tmp;
1145#ifdef SUPPORT_TAGS 1198#ifdef SUPPORT_TAGS
1146 cmd_free_tag( tmp ); 1199 cmd_free_tag(tmp);
1147#endif 1200#endif
1148 falcon_dont_release--; 1201 falcon_dont_release--;
1149 local_irq_restore(flags); 1202 local_irq_restore(flags);
1150 MAIN_PRINTK("scsi%d: main(): select() failed, " 1203 MAIN_PRINTK("scsi%d: main(): select() failed, "
1151 "returned to issue_queue\n", HOSTNO); 1204 "returned to issue_queue\n", HOSTNO);
1152 if (hostdata->connected) 1205 if (hostdata->connected)
1153 break; 1206 break;
1154 } 1207 }
1155 } /* if target/lun/target queue is not busy */ 1208 } /* if target/lun/target queue is not busy */
1156 } /* for issue_queue */ 1209 } /* for issue_queue */
1157 } /* if (!hostdata->connected) */ 1210 } /* if (!hostdata->connected) */
1158 1211
1159 if (hostdata->connected 1212 if (hostdata->connected
1160#ifdef REAL_DMA 1213#ifdef REAL_DMA
1161 && !hostdata->dma_len 1214 && !hostdata->dma_len
1162#endif 1215#endif
1163 ) { 1216 ) {
1164 local_irq_restore(flags); 1217 local_irq_restore(flags);
1165 MAIN_PRINTK("scsi%d: main: performing information transfer\n", 1218 MAIN_PRINTK("scsi%d: main: performing information transfer\n",
1166 HOSTNO); 1219 HOSTNO);
1167 NCR5380_information_transfer(instance); 1220 NCR5380_information_transfer(instance);
1168 MAIN_PRINTK("scsi%d: main: done set false\n", HOSTNO); 1221 MAIN_PRINTK("scsi%d: main: done set false\n", HOSTNO);
1169 done = 0; 1222 done = 0;
1170 } 1223 }
1171 } while (!done); 1224 } while (!done);
1172 1225
1173 /* Better allow ints _after_ 'main_running' has been cleared, else 1226 /* Better allow ints _after_ 'main_running' has been cleared, else
1174 an interrupt could believe we'll pick up the work it left for 1227 an interrupt could believe we'll pick up the work it left for
1175 us, but we won't see it anymore here... */ 1228 us, but we won't see it anymore here... */
1176 main_running = 0; 1229 main_running = 0;
1177 local_irq_restore(flags); 1230 local_irq_restore(flags);
1178} 1231}
1179 1232
1180 1233
@@ -1183,1441 +1236,1439 @@ static void NCR5380_main (void *bl)
1183 * Function : void NCR5380_dma_complete (struct Scsi_Host *instance) 1236 * Function : void NCR5380_dma_complete (struct Scsi_Host *instance)
1184 * 1237 *
1185 * Purpose : Called by interrupt handler when DMA finishes or a phase 1238 * Purpose : Called by interrupt handler when DMA finishes or a phase
1186 * mismatch occurs (which would finish the DMA transfer). 1239 * mismatch occurs (which would finish the DMA transfer).
1187 * 1240 *
1188 * Inputs : instance - this instance of the NCR5380. 1241 * Inputs : instance - this instance of the NCR5380.
1189 * 1242 *
1190 */ 1243 */
1191 1244
1192static void NCR5380_dma_complete( struct Scsi_Host *instance ) 1245static void NCR5380_dma_complete(struct Scsi_Host *instance)
1193{ 1246{
1194 SETUP_HOSTDATA(instance); 1247 SETUP_HOSTDATA(instance);
1195 int transfered, saved_data = 0, overrun = 0, cnt, toPIO; 1248 int transfered, saved_data = 0, overrun = 0, cnt, toPIO;
1196 unsigned char **data, p; 1249 unsigned char **data, p;
1197 volatile int *count; 1250 volatile int *count;
1198 1251
1199 if (!hostdata->connected) { 1252 if (!hostdata->connected) {
1200 printk(KERN_WARNING "scsi%d: received end of DMA interrupt with " 1253 printk(KERN_WARNING "scsi%d: received end of DMA interrupt with "
1201 "no connected cmd\n", HOSTNO); 1254 "no connected cmd\n", HOSTNO);
1202 return; 1255 return;
1203 }
1204
1205 if (atari_read_overruns) {
1206 p = hostdata->connected->SCp.phase;
1207 if (p & SR_IO) {
1208 udelay(10);
1209 if ((((NCR5380_read(BUS_AND_STATUS_REG)) &
1210 (BASR_PHASE_MATCH|BASR_ACK)) ==
1211 (BASR_PHASE_MATCH|BASR_ACK))) {
1212 saved_data = NCR5380_read(INPUT_DATA_REG);
1213 overrun = 1;
1214 DMA_PRINTK("scsi%d: read overrun handled\n", HOSTNO);
1215 }
1216 } 1256 }
1217 } 1257
1218 1258 if (atari_read_overruns) {
1219 DMA_PRINTK("scsi%d: real DMA transfer complete, basr 0x%X, sr 0x%X\n", 1259 p = hostdata->connected->SCp.phase;
1220 HOSTNO, NCR5380_read(BUS_AND_STATUS_REG), 1260 if (p & SR_IO) {
1221 NCR5380_read(STATUS_REG)); 1261 udelay(10);
1222 1262 if ((NCR5380_read(BUS_AND_STATUS_REG) &
1223 (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); 1263 (BASR_PHASE_MATCH|BASR_ACK)) ==
1224 NCR5380_write(MODE_REG, MR_BASE); 1264 (BASR_PHASE_MATCH|BASR_ACK)) {
1225 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 1265 saved_data = NCR5380_read(INPUT_DATA_REG);
1226 1266 overrun = 1;
1227 transfered = hostdata->dma_len - NCR5380_dma_residual(instance); 1267 DMA_PRINTK("scsi%d: read overrun handled\n", HOSTNO);
1228 hostdata->dma_len = 0; 1268 }
1229 1269 }
1230 data = (unsigned char **) &(hostdata->connected->SCp.ptr); 1270 }
1231 count = &(hostdata->connected->SCp.this_residual); 1271
1232 *data += transfered; 1272 DMA_PRINTK("scsi%d: real DMA transfer complete, basr 0x%X, sr 0x%X\n",
1233 *count -= transfered; 1273 HOSTNO, NCR5380_read(BUS_AND_STATUS_REG),
1234 1274 NCR5380_read(STATUS_REG));
1235 if (atari_read_overruns) { 1275
1236 if ((NCR5380_read(STATUS_REG) & PHASE_MASK) == p && (p & SR_IO)) { 1276 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
1237 cnt = toPIO = atari_read_overruns; 1277 NCR5380_write(MODE_REG, MR_BASE);
1238 if (overrun) { 1278 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1239 DMA_PRINTK("Got an input overrun, using saved byte\n"); 1279
1240 *(*data)++ = saved_data; 1280 transfered = hostdata->dma_len - NCR5380_dma_residual(instance);
1241 (*count)--; 1281 hostdata->dma_len = 0;
1242 cnt--; 1282
1243 toPIO--; 1283 data = (unsigned char **)&hostdata->connected->SCp.ptr;
1244 } 1284 count = &hostdata->connected->SCp.this_residual;
1245 DMA_PRINTK("Doing %d-byte PIO to 0x%08lx\n", cnt, (long)*data); 1285 *data += transfered;
1246 NCR5380_transfer_pio(instance, &p, &cnt, data); 1286 *count -= transfered;
1247 *count -= toPIO - cnt; 1287
1288 if (atari_read_overruns) {
1289 if ((NCR5380_read(STATUS_REG) & PHASE_MASK) == p && (p & SR_IO)) {
1290 cnt = toPIO = atari_read_overruns;
1291 if (overrun) {
1292 DMA_PRINTK("Got an input overrun, using saved byte\n");
1293 *(*data)++ = saved_data;
1294 (*count)--;
1295 cnt--;
1296 toPIO--;
1297 }
1298 DMA_PRINTK("Doing %d-byte PIO to 0x%08lx\n", cnt, (long)*data);
1299 NCR5380_transfer_pio(instance, &p, &cnt, data);
1300 *count -= toPIO - cnt;
1301 }
1248 } 1302 }
1249 }
1250} 1303}
1251#endif /* REAL_DMA */ 1304#endif /* REAL_DMA */
1252 1305
1253 1306
1254/* 1307/*
1255 * Function : void NCR5380_intr (int irq) 1308 * Function : void NCR5380_intr (int irq)
1256 * 1309 *
1257 * Purpose : handle interrupts, reestablishing I_T_L or I_T_L_Q nexuses 1310 * Purpose : handle interrupts, reestablishing I_T_L or I_T_L_Q nexuses
1258 * from the disconnected queue, and restarting NCR5380_main() 1311 * from the disconnected queue, and restarting NCR5380_main()
1259 * as required. 1312 * as required.
1260 * 1313 *
1261 * Inputs : int irq, irq that caused this interrupt. 1314 * Inputs : int irq, irq that caused this interrupt.
1262 * 1315 *
1263 */ 1316 */
1264 1317
1265static irqreturn_t NCR5380_intr (int irq, void *dev_id) 1318static irqreturn_t NCR5380_intr(int irq, void *dev_id)
1266{ 1319{
1267 struct Scsi_Host *instance = first_instance; 1320 struct Scsi_Host *instance = first_instance;
1268 int done = 1, handled = 0; 1321 int done = 1, handled = 0;
1269 unsigned char basr; 1322 unsigned char basr;
1270 1323
1271 INT_PRINTK("scsi%d: NCR5380 irq triggered\n", HOSTNO); 1324 INT_PRINTK("scsi%d: NCR5380 irq triggered\n", HOSTNO);
1272 1325
1273 /* Look for pending interrupts */ 1326 /* Look for pending interrupts */
1274 basr = NCR5380_read(BUS_AND_STATUS_REG); 1327 basr = NCR5380_read(BUS_AND_STATUS_REG);
1275 INT_PRINTK("scsi%d: BASR=%02x\n", HOSTNO, basr); 1328 INT_PRINTK("scsi%d: BASR=%02x\n", HOSTNO, basr);
1276 /* dispatch to appropriate routine if found and done=0 */ 1329 /* dispatch to appropriate routine if found and done=0 */
1277 if (basr & BASR_IRQ) { 1330 if (basr & BASR_IRQ) {
1278 NCR_PRINT(NDEBUG_INTR); 1331 NCR_PRINT(NDEBUG_INTR);
1279 if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) { 1332 if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) {
1280 done = 0; 1333 done = 0;
1281 ENABLE_IRQ(); 1334 ENABLE_IRQ();
1282 INT_PRINTK("scsi%d: SEL interrupt\n", HOSTNO); 1335 INT_PRINTK("scsi%d: SEL interrupt\n", HOSTNO);
1283 NCR5380_reselect(instance); 1336 NCR5380_reselect(instance);
1284 (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); 1337 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
1285 } 1338 } else if (basr & BASR_PARITY_ERROR) {
1286 else if (basr & BASR_PARITY_ERROR) { 1339 INT_PRINTK("scsi%d: PARITY interrupt\n", HOSTNO);
1287 INT_PRINTK("scsi%d: PARITY interrupt\n", HOSTNO); 1340 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
1288 (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); 1341 } else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) {
1289 } 1342 INT_PRINTK("scsi%d: RESET interrupt\n", HOSTNO);
1290 else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) { 1343 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
1291 INT_PRINTK("scsi%d: RESET interrupt\n", HOSTNO); 1344 } else {
1292 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG); 1345 /*
1293 } 1346 * The rest of the interrupt conditions can occur only during a
1294 else { 1347 * DMA transfer
1295 /* 1348 */
1296 * The rest of the interrupt conditions can occur only during a
1297 * DMA transfer
1298 */
1299 1349
1300#if defined(REAL_DMA) 1350#if defined(REAL_DMA)
1301 /* 1351 /*
1302 * We should only get PHASE MISMATCH and EOP interrupts if we have 1352 * We should only get PHASE MISMATCH and EOP interrupts if we have
1303 * DMA enabled, so do a sanity check based on the current setting 1353 * DMA enabled, so do a sanity check based on the current setting
1304 * of the MODE register. 1354 * of the MODE register.
1305 */ 1355 */
1306 1356
1307 if ((NCR5380_read(MODE_REG) & MR_DMA_MODE) && 1357 if ((NCR5380_read(MODE_REG) & MR_DMA_MODE) &&
1308 ((basr & BASR_END_DMA_TRANSFER) || 1358 ((basr & BASR_END_DMA_TRANSFER) ||
1309 !(basr & BASR_PHASE_MATCH))) { 1359 !(basr & BASR_PHASE_MATCH))) {
1310 1360
1311 INT_PRINTK("scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO); 1361 INT_PRINTK("scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO);
1312 NCR5380_dma_complete( instance ); 1362 NCR5380_dma_complete( instance );
1313 done = 0; 1363 done = 0;
1314 ENABLE_IRQ(); 1364 ENABLE_IRQ();
1315 } else 1365 } else
1316#endif /* REAL_DMA */ 1366#endif /* REAL_DMA */
1317 { 1367 {
1318/* MS: Ignore unknown phase mismatch interrupts (caused by EOP interrupt) */ 1368/* MS: Ignore unknown phase mismatch interrupts (caused by EOP interrupt) */
1319 if (basr & BASR_PHASE_MATCH) 1369 if (basr & BASR_PHASE_MATCH)
1320 printk(KERN_NOTICE "scsi%d: unknown interrupt, " 1370 printk(KERN_NOTICE "scsi%d: unknown interrupt, "
1321 "BASR 0x%x, MR 0x%x, SR 0x%x\n", 1371 "BASR 0x%x, MR 0x%x, SR 0x%x\n",
1322 HOSTNO, basr, NCR5380_read(MODE_REG), 1372 HOSTNO, basr, NCR5380_read(MODE_REG),
1323 NCR5380_read(STATUS_REG)); 1373 NCR5380_read(STATUS_REG));
1324 (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); 1374 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
1325 } 1375 }
1326 } /* if !(SELECTION || PARITY) */ 1376 } /* if !(SELECTION || PARITY) */
1327 handled = 1; 1377 handled = 1;
1328 } /* BASR & IRQ */ 1378 } /* BASR & IRQ */ else {
1329 else { 1379 printk(KERN_NOTICE "scsi%d: interrupt without IRQ bit set in BASR, "
1330 printk(KERN_NOTICE "scsi%d: interrupt without IRQ bit set in BASR, " 1380 "BASR 0x%X, MR 0x%X, SR 0x%x\n", HOSTNO, basr,
1331 "BASR 0x%X, MR 0x%X, SR 0x%x\n", HOSTNO, basr, 1381 NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG));
1332 NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG)); 1382 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
1333 (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); 1383 }
1334 } 1384
1335 1385 if (!done) {
1336 if (!done) { 1386 INT_PRINTK("scsi%d: in int routine, calling main\n", HOSTNO);
1337 INT_PRINTK("scsi%d: in int routine, calling main\n", HOSTNO); 1387 /* Put a call to NCR5380_main() on the queue... */
1338 /* Put a call to NCR5380_main() on the queue... */ 1388 queue_main();
1339 queue_main(); 1389 }
1340 } 1390 return IRQ_RETVAL(handled);
1341 return IRQ_RETVAL(handled);
1342} 1391}
1343 1392
1344#ifdef NCR5380_STATS 1393#ifdef NCR5380_STATS
1345static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd) 1394static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd *cmd)
1346{ 1395{
1347# ifdef NCR5380_STAT_LIMIT 1396# ifdef NCR5380_STAT_LIMIT
1348 if (cmd->request_bufflen > NCR5380_STAT_LIMIT) 1397 if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
1349# endif 1398# endif
1350 switch (cmd->cmnd[0]) 1399 switch (cmd->cmnd[0]) {
1351 { 1400 case WRITE:
1352 case WRITE: 1401 case WRITE_6:
1353 case WRITE_6: 1402 case WRITE_10:
1354 case WRITE_10: 1403 hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);
1355 hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase); 1404 /*hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;*/
1356 /*hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;*/ 1405 hostdata->pendingw--;
1357 hostdata->pendingw--; 1406 break;
1358 break; 1407 case READ:
1359 case READ: 1408 case READ_6:
1360 case READ_6: 1409 case READ_10:
1361 case READ_10: 1410 hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);
1362 hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase); 1411 /*hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;*/
1363 /*hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;*/ 1412 hostdata->pendingr--;
1364 hostdata->pendingr--; 1413 break;
1365 break; 1414 }
1366 }
1367} 1415}
1368#endif 1416#endif
1369 1417
1370/* 1418/*
1371 * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, 1419 * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd,
1372 * int tag); 1420 * int tag);
1373 * 1421 *
1374 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, 1422 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
1375 * including ARBITRATION, SELECTION, and initial message out for 1423 * including ARBITRATION, SELECTION, and initial message out for
1376 * IDENTIFY and queue messages. 1424 * IDENTIFY and queue messages.
1377 * 1425 *
1378 * Inputs : instance - instantiation of the 5380 driver on which this 1426 * Inputs : instance - instantiation of the 5380 driver on which this
1379 * target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for 1427 * target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for
1380 * new tag, TAG_NONE for untagged queueing, otherwise set to the tag for 1428 * new tag, TAG_NONE for untagged queueing, otherwise set to the tag for
1381 * the command that is presently connected. 1429 * the command that is presently connected.
1382 * 1430 *
1383 * Returns : -1 if selection could not execute for some reason, 1431 * Returns : -1 if selection could not execute for some reason,
1384 * 0 if selection succeeded or failed because the target 1432 * 0 if selection succeeded or failed because the target
1385 * did not respond. 1433 * did not respond.
1386 * 1434 *
1387 * Side effects : 1435 * Side effects :
1388 * If bus busy, arbitration failed, etc, NCR5380_select() will exit 1436 * If bus busy, arbitration failed, etc, NCR5380_select() will exit
1389 * with registers as they should have been on entry - ie 1437 * with registers as they should have been on entry - ie
1390 * SELECT_ENABLE will be set appropriately, the NCR5380 1438 * SELECT_ENABLE will be set appropriately, the NCR5380
1391 * will cease to drive any SCSI bus signals. 1439 * will cease to drive any SCSI bus signals.
1392 * 1440 *
1393 * If successful : I_T_L or I_T_L_Q nexus will be established, 1441 * If successful : I_T_L or I_T_L_Q nexus will be established,
1394 * instance->connected will be set to cmd. 1442 * instance->connected will be set to cmd.
1395 * SELECT interrupt will be disabled. 1443 * SELECT interrupt will be disabled.
1396 * 1444 *
1397 * If failed (no target) : cmd->scsi_done() will be called, and the 1445 * If failed (no target) : cmd->scsi_done() will be called, and the
1398 * cmd->result host byte set to DID_BAD_TARGET. 1446 * cmd->result host byte set to DID_BAD_TARGET.
1399 */ 1447 */
1400 1448
1401static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag) 1449static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
1402{ 1450{
1403 SETUP_HOSTDATA(instance); 1451 SETUP_HOSTDATA(instance);
1404 unsigned char tmp[3], phase; 1452 unsigned char tmp[3], phase;
1405 unsigned char *data; 1453 unsigned char *data;
1406 int len; 1454 int len;
1407 unsigned long timeout; 1455 unsigned long timeout;
1408 unsigned long flags; 1456 unsigned long flags;
1409 1457
1410 hostdata->restart_select = 0; 1458 hostdata->restart_select = 0;
1411 NCR_PRINT(NDEBUG_ARBITRATION); 1459 NCR_PRINT(NDEBUG_ARBITRATION);
1412 ARB_PRINTK("scsi%d: starting arbitration, id = %d\n", HOSTNO, 1460 ARB_PRINTK("scsi%d: starting arbitration, id = %d\n", HOSTNO,
1413 instance->this_id); 1461 instance->this_id);
1414 1462
1415 /* 1463 /*
1416 * Set the phase bits to 0, otherwise the NCR5380 won't drive the 1464 * Set the phase bits to 0, otherwise the NCR5380 won't drive the
1417 * data bus during SELECTION. 1465 * data bus during SELECTION.
1418 */ 1466 */
1419 1467
1420 local_irq_save(flags); 1468 local_irq_save(flags);
1421 if (hostdata->connected) { 1469 if (hostdata->connected) {
1470 local_irq_restore(flags);
1471 return -1;
1472 }
1473 NCR5380_write(TARGET_COMMAND_REG, 0);
1474
1475 /*
1476 * Start arbitration.
1477 */
1478
1479 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
1480 NCR5380_write(MODE_REG, MR_ARBITRATE);
1481
1422 local_irq_restore(flags); 1482 local_irq_restore(flags);
1423 return -1; 1483
1424 } 1484 /* Wait for arbitration logic to complete */
1425 NCR5380_write(TARGET_COMMAND_REG, 0); 1485#if defined(NCR_TIMEOUT)
1426 1486 {
1427 1487 unsigned long timeout = jiffies + 2*NCR_TIMEOUT;
1428 /* 1488
1429 * Start arbitration. 1489 while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) &&
1430 */ 1490 time_before(jiffies, timeout) && !hostdata->connected)
1431 1491 ;
1432 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); 1492 if (time_after_eq(jiffies, timeout)) {
1433 NCR5380_write(MODE_REG, MR_ARBITRATE); 1493 printk("scsi : arbitration timeout at %d\n", __LINE__);
1434 1494 NCR5380_write(MODE_REG, MR_BASE);
1435 local_irq_restore(flags); 1495 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
1436 1496 return -1;
1437 /* Wait for arbitration logic to complete */ 1497 }
1438#if NCR_TIMEOUT 1498 }
1439 {
1440 unsigned long timeout = jiffies + 2*NCR_TIMEOUT;
1441
1442 while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
1443 && time_before(jiffies, timeout) && !hostdata->connected)
1444 ;
1445 if (time_after_eq(jiffies, timeout))
1446 {
1447 printk("scsi : arbitration timeout at %d\n", __LINE__);
1448 NCR5380_write(MODE_REG, MR_BASE);
1449 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
1450 return -1;
1451 }
1452 }
1453#else /* NCR_TIMEOUT */ 1499#else /* NCR_TIMEOUT */
1454 while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) 1500 while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) &&
1455 && !hostdata->connected); 1501 !hostdata->connected)
1502 ;
1456#endif 1503#endif
1457 1504
1458 ARB_PRINTK("scsi%d: arbitration complete\n", HOSTNO); 1505 ARB_PRINTK("scsi%d: arbitration complete\n", HOSTNO);
1459
1460 if (hostdata->connected) {
1461 NCR5380_write(MODE_REG, MR_BASE);
1462 return -1;
1463 }
1464 /*
1465 * The arbitration delay is 2.2us, but this is a minimum and there is
1466 * no maximum so we can safely sleep for ceil(2.2) usecs to accommodate
1467 * the integral nature of udelay().
1468 *
1469 */
1470
1471 udelay(3);
1472
1473 /* Check for lost arbitration */
1474 if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
1475 (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) ||
1476 (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
1477 hostdata->connected) {
1478 NCR5380_write(MODE_REG, MR_BASE);
1479 ARB_PRINTK("scsi%d: lost arbitration, deasserting MR_ARBITRATE\n",
1480 HOSTNO);
1481 return -1;
1482 }
1483
1484 /* after/during arbitration, BSY should be asserted.
1485 IBM DPES-31080 Version S31Q works now */
1486 /* Tnx to Thomas_Roesch@m2.maus.de for finding this! (Roman) */
1487 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_SEL |
1488 ICR_ASSERT_BSY ) ;
1489
1490 if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
1491 hostdata->connected) {
1492 NCR5380_write(MODE_REG, MR_BASE);
1493 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1494 ARB_PRINTK("scsi%d: lost arbitration, deasserting ICR_ASSERT_SEL\n",
1495 HOSTNO);
1496 return -1;
1497 }
1498 1506
1499 /* 1507 if (hostdata->connected) {
1500 * Again, bus clear + bus settle time is 1.2us, however, this is 1508 NCR5380_write(MODE_REG, MR_BASE);
1501 * a minimum so we'll udelay ceil(1.2) 1509 return -1;
1502 */ 1510 }
1511 /*
1512 * The arbitration delay is 2.2us, but this is a minimum and there is
1513 * no maximum so we can safely sleep for ceil(2.2) usecs to accommodate
1514 * the integral nature of udelay().
1515 *
1516 */
1517
1518 udelay(3);
1519
1520 /* Check for lost arbitration */
1521 if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
1522 (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) ||
1523 (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
1524 hostdata->connected) {
1525 NCR5380_write(MODE_REG, MR_BASE);
1526 ARB_PRINTK("scsi%d: lost arbitration, deasserting MR_ARBITRATE\n",
1527 HOSTNO);
1528 return -1;
1529 }
1530
1531 /* after/during arbitration, BSY should be asserted.
1532 IBM DPES-31080 Version S31Q works now */
1533 /* Tnx to Thomas_Roesch@m2.maus.de for finding this! (Roman) */
1534 NCR5380_write(INITIATOR_COMMAND_REG,
1535 ICR_BASE | ICR_ASSERT_SEL | ICR_ASSERT_BSY);
1536
1537 if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
1538 hostdata->connected) {
1539 NCR5380_write(MODE_REG, MR_BASE);
1540 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1541 ARB_PRINTK("scsi%d: lost arbitration, deasserting ICR_ASSERT_SEL\n",
1542 HOSTNO);
1543 return -1;
1544 }
1545
1546 /*
1547 * Again, bus clear + bus settle time is 1.2us, however, this is
1548 * a minimum so we'll udelay ceil(1.2)
1549 */
1503 1550
1504#ifdef CONFIG_ATARI_SCSI_TOSHIBA_DELAY 1551#ifdef CONFIG_ATARI_SCSI_TOSHIBA_DELAY
1505 /* ++roman: But some targets (see above :-) seem to need a bit more... */ 1552 /* ++roman: But some targets (see above :-) seem to need a bit more... */
1506 udelay(15); 1553 udelay(15);
1507#else 1554#else
1508 udelay(2); 1555 udelay(2);
1509#endif 1556#endif
1510 1557
1511 if (hostdata->connected) { 1558 if (hostdata->connected) {
1559 NCR5380_write(MODE_REG, MR_BASE);
1560 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1561 return -1;
1562 }
1563
1564 ARB_PRINTK("scsi%d: won arbitration\n", HOSTNO);
1565
1566 /*
1567 * Now that we have won arbitration, start Selection process, asserting
1568 * the host and target ID's on the SCSI bus.
1569 */
1570
1571 NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id)));
1572
1573 /*
1574 * Raise ATN while SEL is true before BSY goes false from arbitration,
1575 * since this is the only way to guarantee that we'll get a MESSAGE OUT
1576 * phase immediately after selection.
1577 */
1578
1579 NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_BSY |
1580 ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL ));
1512 NCR5380_write(MODE_REG, MR_BASE); 1581 NCR5380_write(MODE_REG, MR_BASE);
1513 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1514 return -1;
1515 }
1516 1582
1517 ARB_PRINTK("scsi%d: won arbitration\n", HOSTNO); 1583 /*
1584 * Reselect interrupts must be turned off prior to the dropping of BSY,
1585 * otherwise we will trigger an interrupt.
1586 */
1587
1588 if (hostdata->connected) {
1589 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1590 return -1;
1591 }
1518 1592
1519 /* 1593 NCR5380_write(SELECT_ENABLE_REG, 0);
1520 * Now that we have won arbitration, start Selection process, asserting 1594
1521 * the host and target ID's on the SCSI bus. 1595 /*
1522 */ 1596 * The initiator shall then wait at least two deskew delays and release
1597 * the BSY signal.
1598 */
1599 udelay(1); /* wingel -- wait two bus deskew delay >2*45ns */
1600
1601 /* Reset BSY */
1602 NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_DATA |
1603 ICR_ASSERT_ATN | ICR_ASSERT_SEL));
1604
1605 /*
1606 * Something weird happens when we cease to drive BSY - looks
1607 * like the board/chip is letting us do another read before the
1608 * appropriate propagation delay has expired, and we're confusing
1609 * a BSY signal from ourselves as the target's response to SELECTION.
1610 *
1611 * A small delay (the 'C++' frontend breaks the pipeline with an
1612 * unnecessary jump, making it work on my 386-33/Trantor T128, the
1613 * tighter 'C' code breaks and requires this) solves the problem -
1614 * the 1 us delay is arbitrary, and only used because this delay will
1615 * be the same on other platforms and since it works here, it should
1616 * work there.
1617 *
1618 * wingel suggests that this could be due to failing to wait
1619 * one deskew delay.
1620 */
1523 1621
1524 NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id))); 1622 udelay(1);
1525 1623
1526 /* 1624 SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->device->id);
1527 * Raise ATN while SEL is true before BSY goes false from arbitration,
1528 * since this is the only way to guarantee that we'll get a MESSAGE OUT
1529 * phase immediately after selection.
1530 */
1531 1625
1532 NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_BSY | 1626 /*
1533 ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL )); 1627 * The SCSI specification calls for a 250 ms timeout for the actual
1534 NCR5380_write(MODE_REG, MR_BASE); 1628 * selection.
1629 */
1535 1630
1536 /* 1631 timeout = jiffies + 25;
1537 * Reselect interrupts must be turned off prior to the dropping of BSY,
1538 * otherwise we will trigger an interrupt.
1539 */
1540 1632
1541 if (hostdata->connected) { 1633 /*
1542 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 1634 * XXX very interesting - we're seeing a bounce where the BSY we
1543 return -1; 1635 * asserted is being reflected / still asserted (propagation delay?)
1544 } 1636 * and it's detecting as true. Sigh.
1545 1637 */
1546 NCR5380_write(SELECT_ENABLE_REG, 0);
1547
1548 /*
1549 * The initiator shall then wait at least two deskew delays and release
1550 * the BSY signal.
1551 */
1552 udelay(1); /* wingel -- wait two bus deskew delay >2*45ns */
1553
1554 /* Reset BSY */
1555 NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_DATA |
1556 ICR_ASSERT_ATN | ICR_ASSERT_SEL));
1557
1558 /*
1559 * Something weird happens when we cease to drive BSY - looks
1560 * like the board/chip is letting us do another read before the
1561 * appropriate propagation delay has expired, and we're confusing
1562 * a BSY signal from ourselves as the target's response to SELECTION.
1563 *
1564 * A small delay (the 'C++' frontend breaks the pipeline with an
1565 * unnecessary jump, making it work on my 386-33/Trantor T128, the
1566 * tighter 'C' code breaks and requires this) solves the problem -
1567 * the 1 us delay is arbitrary, and only used because this delay will
1568 * be the same on other platforms and since it works here, it should
1569 * work there.
1570 *
1571 * wingel suggests that this could be due to failing to wait
1572 * one deskew delay.
1573 */
1574
1575 udelay(1);
1576
1577 SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->device->id);
1578
1579 /*
1580 * The SCSI specification calls for a 250 ms timeout for the actual
1581 * selection.
1582 */
1583
1584 timeout = jiffies + 25;
1585
1586 /*
1587 * XXX very interesting - we're seeing a bounce where the BSY we
1588 * asserted is being reflected / still asserted (propagation delay?)
1589 * and it's detecting as true. Sigh.
1590 */
1591 1638
1592#if 0 1639#if 0
1593 /* ++roman: If a target conformed to the SCSI standard, it wouldn't assert 1640 /* ++roman: If a target conformed to the SCSI standard, it wouldn't assert
1594 * IO while SEL is true. But again, there are some disks out the in the 1641 * IO while SEL is true. But again, there are some disks out the in the
1595 * world that do that nevertheless. (Somebody claimed that this announces 1642 * world that do that nevertheless. (Somebody claimed that this announces
1596 * reselection capability of the target.) So we better skip that test and 1643 * reselection capability of the target.) So we better skip that test and
1597 * only wait for BSY... (Famous german words: Der Klügere gibt nach :-) 1644 * only wait for BSY... (Famous german words: Der Klügere gibt nach :-)
1598 */ 1645 */
1599 1646
1600 while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & 1647 while (time_before(jiffies, timeout) &&
1601 (SR_BSY | SR_IO))); 1648 !(NCR5380_read(STATUS_REG) & (SR_BSY | SR_IO)))
1602 1649 ;
1603 if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == 1650
1604 (SR_SEL | SR_IO)) { 1651 if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) {
1605 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 1652 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1606 NCR5380_reselect(instance); 1653 NCR5380_reselect(instance);
1607 printk (KERN_ERR "scsi%d: reselection after won arbitration?\n", 1654 printk(KERN_ERR "scsi%d: reselection after won arbitration?\n",
1608 HOSTNO); 1655 HOSTNO);
1609 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 1656 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
1610 return -1; 1657 return -1;
1611 } 1658 }
1612#else 1659#else
1613 while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY)); 1660 while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY))
1661 ;
1614#endif 1662#endif
1615 1663
1616 /* 1664 /*
1617 * No less than two deskew delays after the initiator detects the 1665 * No less than two deskew delays after the initiator detects the
1618 * BSY signal is true, it shall release the SEL signal and may 1666 * BSY signal is true, it shall release the SEL signal and may
1619 * change the DATA BUS. -wingel 1667 * change the DATA BUS. -wingel
1620 */ 1668 */
1621 1669
1622 udelay(1); 1670 udelay(1);
1623 1671
1624 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); 1672 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1625 1673
1626 if (!(NCR5380_read(STATUS_REG) & SR_BSY)) { 1674 if (!(NCR5380_read(STATUS_REG) & SR_BSY)) {
1627 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 1675 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1628 if (hostdata->targets_present & (1 << cmd->device->id)) { 1676 if (hostdata->targets_present & (1 << cmd->device->id)) {
1629 printk(KERN_ERR "scsi%d: weirdness\n", HOSTNO); 1677 printk(KERN_ERR "scsi%d: weirdness\n", HOSTNO);
1630 if (hostdata->restart_select) 1678 if (hostdata->restart_select)
1631 printk(KERN_NOTICE "\trestart select\n"); 1679 printk(KERN_NOTICE "\trestart select\n");
1632 NCR_PRINT(NDEBUG_ANY); 1680 NCR_PRINT(NDEBUG_ANY);
1633 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 1681 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
1634 return -1; 1682 return -1;
1635 } 1683 }
1636 cmd->result = DID_BAD_TARGET << 16; 1684 cmd->result = DID_BAD_TARGET << 16;
1637#ifdef NCR5380_STATS 1685#ifdef NCR5380_STATS
1638 collect_stats(hostdata, cmd); 1686 collect_stats(hostdata, cmd);
1639#endif 1687#endif
1640#ifdef SUPPORT_TAGS 1688#ifdef SUPPORT_TAGS
1641 cmd_free_tag( cmd ); 1689 cmd_free_tag(cmd);
1642#endif 1690#endif
1643 cmd->scsi_done(cmd); 1691 cmd->scsi_done(cmd);
1644 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 1692 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
1645 SEL_PRINTK("scsi%d: target did not respond within 250ms\n", HOSTNO); 1693 SEL_PRINTK("scsi%d: target did not respond within 250ms\n", HOSTNO);
1646 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 1694 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
1647 return 0; 1695 return 0;
1648 } 1696 }
1649 1697
1650 hostdata->targets_present |= (1 << cmd->device->id); 1698 hostdata->targets_present |= (1 << cmd->device->id);
1651 1699
1652 /* 1700 /*
1653 * Since we followed the SCSI spec, and raised ATN while SEL 1701 * Since we followed the SCSI spec, and raised ATN while SEL
1654 * was true but before BSY was false during selection, the information 1702 * was true but before BSY was false during selection, the information
1655 * transfer phase should be a MESSAGE OUT phase so that we can send the 1703 * transfer phase should be a MESSAGE OUT phase so that we can send the
1656 * IDENTIFY message. 1704 * IDENTIFY message.
1657 * 1705 *
1658 * If SCSI-II tagged queuing is enabled, we also send a SIMPLE_QUEUE_TAG 1706 * If SCSI-II tagged queuing is enabled, we also send a SIMPLE_QUEUE_TAG
1659 * message (2 bytes) with a tag ID that we increment with every command 1707 * message (2 bytes) with a tag ID that we increment with every command
1660 * until it wraps back to 0. 1708 * until it wraps back to 0.
1661 * 1709 *
1662 * XXX - it turns out that there are some broken SCSI-II devices, 1710 * XXX - it turns out that there are some broken SCSI-II devices,
1663 * which claim to support tagged queuing but fail when more than 1711 * which claim to support tagged queuing but fail when more than
1664 * some number of commands are issued at once. 1712 * some number of commands are issued at once.
1665 */ 1713 */
1666 1714
1667 /* Wait for start of REQ/ACK handshake */ 1715 /* Wait for start of REQ/ACK handshake */
1668 while (!(NCR5380_read(STATUS_REG) & SR_REQ)); 1716 while (!(NCR5380_read(STATUS_REG) & SR_REQ))
1669 1717 ;
1670 SEL_PRINTK("scsi%d: target %d selected, going into MESSAGE OUT phase.\n", 1718
1671 HOSTNO, cmd->device->id); 1719 SEL_PRINTK("scsi%d: target %d selected, going into MESSAGE OUT phase.\n",
1672 tmp[0] = IDENTIFY(1, cmd->device->lun); 1720 HOSTNO, cmd->device->id);
1721 tmp[0] = IDENTIFY(1, cmd->device->lun);
1673 1722
1674#ifdef SUPPORT_TAGS 1723#ifdef SUPPORT_TAGS
1675 if (cmd->tag != TAG_NONE) { 1724 if (cmd->tag != TAG_NONE) {
1676 tmp[1] = hostdata->last_message = SIMPLE_QUEUE_TAG; 1725 tmp[1] = hostdata->last_message = SIMPLE_QUEUE_TAG;
1677 tmp[2] = cmd->tag; 1726 tmp[2] = cmd->tag;
1678 len = 3; 1727 len = 3;
1679 } else 1728 } else
1680 len = 1; 1729 len = 1;
1681#else 1730#else
1682 len = 1; 1731 len = 1;
1683 cmd->tag=0; 1732 cmd->tag = 0;
1684#endif /* SUPPORT_TAGS */ 1733#endif /* SUPPORT_TAGS */
1685 1734
1686 /* Send message(s) */ 1735 /* Send message(s) */
1687 data = tmp; 1736 data = tmp;
1688 phase = PHASE_MSGOUT; 1737 phase = PHASE_MSGOUT;
1689 NCR5380_transfer_pio(instance, &phase, &len, &data); 1738 NCR5380_transfer_pio(instance, &phase, &len, &data);
1690 SEL_PRINTK("scsi%d: nexus established.\n", HOSTNO); 1739 SEL_PRINTK("scsi%d: nexus established.\n", HOSTNO);
1691 /* XXX need to handle errors here */ 1740 /* XXX need to handle errors here */
1692 hostdata->connected = cmd; 1741 hostdata->connected = cmd;
1693#ifndef SUPPORT_TAGS 1742#ifndef SUPPORT_TAGS
1694 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); 1743 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
1695#endif 1744#endif
1696
1697 initialize_SCp(cmd);
1698 1745
1746 initialize_SCp(cmd);
1699 1747
1700 return 0; 1748 return 0;
1701} 1749}
1702 1750
1703/* 1751/*
1704 * Function : int NCR5380_transfer_pio (struct Scsi_Host *instance, 1752 * Function : int NCR5380_transfer_pio (struct Scsi_Host *instance,
1705 * unsigned char *phase, int *count, unsigned char **data) 1753 * unsigned char *phase, int *count, unsigned char **data)
1706 * 1754 *
1707 * Purpose : transfers data in given phase using polled I/O 1755 * Purpose : transfers data in given phase using polled I/O
1708 * 1756 *
1709 * Inputs : instance - instance of driver, *phase - pointer to 1757 * Inputs : instance - instance of driver, *phase - pointer to
1710 * what phase is expected, *count - pointer to number of 1758 * what phase is expected, *count - pointer to number of
1711 * bytes to transfer, **data - pointer to data pointer. 1759 * bytes to transfer, **data - pointer to data pointer.
1712 * 1760 *
1713 * Returns : -1 when different phase is entered without transferring 1761 * Returns : -1 when different phase is entered without transferring
1714 * maximum number of bytes, 0 if all bytes are transfered or exit 1762 * maximum number of bytes, 0 if all bytes are transfered or exit
1715 * is in same phase. 1763 * is in same phase.
1716 * 1764 *
1717 * Also, *phase, *count, *data are modified in place. 1765 * Also, *phase, *count, *data are modified in place.
1718 * 1766 *
1719 * XXX Note : handling for bus free may be useful. 1767 * XXX Note : handling for bus free may be useful.
1720 */ 1768 */
1721 1769
1722/* 1770/*
1723 * Note : this code is not as quick as it could be, however it 1771 * Note : this code is not as quick as it could be, however it
1724 * IS 100% reliable, and for the actual data transfer where speed 1772 * IS 100% reliable, and for the actual data transfer where speed
1725 * counts, we will always do a pseudo DMA or DMA transfer. 1773 * counts, we will always do a pseudo DMA or DMA transfer.
1726 */ 1774 */
1727 1775
1728static int NCR5380_transfer_pio( struct Scsi_Host *instance, 1776static int NCR5380_transfer_pio(struct Scsi_Host *instance,
1729 unsigned char *phase, int *count, 1777 unsigned char *phase, int *count,
1730 unsigned char **data) 1778 unsigned char **data)
1731{ 1779{
1732 register unsigned char p = *phase, tmp; 1780 register unsigned char p = *phase, tmp;
1733 register int c = *count; 1781 register int c = *count;
1734 register unsigned char *d = *data; 1782 register unsigned char *d = *data;
1735 1783
1736 /* 1784 /*
1737 * The NCR5380 chip will only drive the SCSI bus when the 1785 * The NCR5380 chip will only drive the SCSI bus when the
1738 * phase specified in the appropriate bits of the TARGET COMMAND 1786 * phase specified in the appropriate bits of the TARGET COMMAND
1739 * REGISTER match the STATUS REGISTER 1787 * REGISTER match the STATUS REGISTER
1740 */
1741
1742 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
1743
1744 do {
1745 /*
1746 * Wait for assertion of REQ, after which the phase bits will be
1747 * valid
1748 */ 1788 */
1749 while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ));
1750 1789
1751 HSH_PRINTK("scsi%d: REQ detected\n", HOSTNO); 1790 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
1752 1791
1753 /* Check for phase mismatch */ 1792 do {
1754 if ((tmp & PHASE_MASK) != p) { 1793 /*
1755 PIO_PRINTK("scsi%d: phase mismatch\n", HOSTNO); 1794 * Wait for assertion of REQ, after which the phase bits will be
1756 NCR_PRINT_PHASE(NDEBUG_PIO); 1795 * valid
1757 break; 1796 */
1758 } 1797 while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ))
1798 ;
1759 1799
1760 /* Do actual transfer from SCSI bus to / from memory */ 1800 HSH_PRINTK("scsi%d: REQ detected\n", HOSTNO);
1761 if (!(p & SR_IO))
1762 NCR5380_write(OUTPUT_DATA_REG, *d);
1763 else
1764 *d = NCR5380_read(CURRENT_SCSI_DATA_REG);
1765 1801
1766 ++d; 1802 /* Check for phase mismatch */
1803 if ((tmp & PHASE_MASK) != p) {
1804 PIO_PRINTK("scsi%d: phase mismatch\n", HOSTNO);
1805 NCR_PRINT_PHASE(NDEBUG_PIO);
1806 break;
1807 }
1767 1808
1768 /* 1809 /* Do actual transfer from SCSI bus to / from memory */
1769 * The SCSI standard suggests that in MSGOUT phase, the initiator 1810 if (!(p & SR_IO))
1770 * should drop ATN on the last byte of the message phase 1811 NCR5380_write(OUTPUT_DATA_REG, *d);
1771 * after REQ has been asserted for the handshake but before 1812 else
1772 * the initiator raises ACK. 1813 *d = NCR5380_read(CURRENT_SCSI_DATA_REG);
1773 */
1774 1814
1775 if (!(p & SR_IO)) { 1815 ++d;
1776 if (!((p & SR_MSG) && c > 1)) {
1777 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
1778 ICR_ASSERT_DATA);
1779 NCR_PRINT(NDEBUG_PIO);
1780 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
1781 ICR_ASSERT_DATA | ICR_ASSERT_ACK);
1782 } else {
1783 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
1784 ICR_ASSERT_DATA | ICR_ASSERT_ATN);
1785 NCR_PRINT(NDEBUG_PIO);
1786 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
1787 ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
1788 }
1789 } else {
1790 NCR_PRINT(NDEBUG_PIO);
1791 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK);
1792 }
1793 1816
1794 while (NCR5380_read(STATUS_REG) & SR_REQ); 1817 /*
1818 * The SCSI standard suggests that in MSGOUT phase, the initiator
1819 * should drop ATN on the last byte of the message phase
1820 * after REQ has been asserted for the handshake but before
1821 * the initiator raises ACK.
1822 */
1795 1823
1796 HSH_PRINTK("scsi%d: req false, handshake complete\n", HOSTNO); 1824 if (!(p & SR_IO)) {
1825 if (!((p & SR_MSG) && c > 1)) {
1826 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA);
1827 NCR_PRINT(NDEBUG_PIO);
1828 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
1829 ICR_ASSERT_DATA | ICR_ASSERT_ACK);
1830 } else {
1831 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
1832 ICR_ASSERT_DATA | ICR_ASSERT_ATN);
1833 NCR_PRINT(NDEBUG_PIO);
1834 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
1835 ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
1836 }
1837 } else {
1838 NCR_PRINT(NDEBUG_PIO);
1839 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK);
1840 }
1797 1841
1798/* 1842 while (NCR5380_read(STATUS_REG) & SR_REQ)
1799 * We have several special cases to consider during REQ/ACK handshaking : 1843 ;
1800 * 1. We were in MSGOUT phase, and we are on the last byte of the 1844
1801 * message. ATN must be dropped as ACK is dropped. 1845 HSH_PRINTK("scsi%d: req false, handshake complete\n", HOSTNO);
1802 * 1846
1803 * 2. We are in a MSGIN phase, and we are on the last byte of the 1847 /*
1804 * message. We must exit with ACK asserted, so that the calling 1848 * We have several special cases to consider during REQ/ACK handshaking :
1805 * code may raise ATN before dropping ACK to reject the message. 1849 * 1. We were in MSGOUT phase, and we are on the last byte of the
1806 * 1850 * message. ATN must be dropped as ACK is dropped.
1807 * 3. ACK and ATN are clear and the target may proceed as normal. 1851 *
1808 */ 1852 * 2. We are in a MSGIN phase, and we are on the last byte of the
1809 if (!(p == PHASE_MSGIN && c == 1)) { 1853 * message. We must exit with ACK asserted, so that the calling
1810 if (p == PHASE_MSGOUT && c > 1) 1854 * code may raise ATN before dropping ACK to reject the message.
1811 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); 1855 *
1812 else 1856 * 3. ACK and ATN are clear and the target may proceed as normal.
1813 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 1857 */
1814 } 1858 if (!(p == PHASE_MSGIN && c == 1)) {
1815 } while (--c); 1859 if (p == PHASE_MSGOUT && c > 1)
1816 1860 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1817 PIO_PRINTK("scsi%d: residual %d\n", HOSTNO, c); 1861 else
1818 1862 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1819 *count = c; 1863 }
1820 *data = d; 1864 } while (--c);
1821 tmp = NCR5380_read(STATUS_REG); 1865
1822 /* The phase read from the bus is valid if either REQ is (already) 1866 PIO_PRINTK("scsi%d: residual %d\n", HOSTNO, c);
1823 * asserted or if ACK hasn't been released yet. The latter is the case if 1867
1824 * we're in MSGIN and all wanted bytes have been received. */ 1868 *count = c;
1825 if ((tmp & SR_REQ) || (p == PHASE_MSGIN && c == 0)) 1869 *data = d;
1826 *phase = tmp & PHASE_MASK; 1870 tmp = NCR5380_read(STATUS_REG);
1827 else 1871 /* The phase read from the bus is valid if either REQ is (already)
1828 *phase = PHASE_UNKNOWN; 1872 * asserted or if ACK hasn't been released yet. The latter is the case if
1829 1873 * we're in MSGIN and all wanted bytes have been received.
1830 if (!c || (*phase == p)) 1874 */
1831 return 0; 1875 if ((tmp & SR_REQ) || (p == PHASE_MSGIN && c == 0))
1832 else 1876 *phase = tmp & PHASE_MASK;
1833 return -1; 1877 else
1878 *phase = PHASE_UNKNOWN;
1879
1880 if (!c || (*phase == p))
1881 return 0;
1882 else
1883 return -1;
1834} 1884}
1835 1885
1836/* 1886/*
1837 * Function : do_abort (Scsi_Host *host) 1887 * Function : do_abort (Scsi_Host *host)
1838 * 1888 *
1839 * Purpose : abort the currently established nexus. Should only be 1889 * Purpose : abort the currently established nexus. Should only be
1840 * called from a routine which can drop into a 1890 * called from a routine which can drop into a
1841 * 1891 *
1842 * Returns : 0 on success, -1 on failure. 1892 * Returns : 0 on success, -1 on failure.
1843 */ 1893 */
1844 1894
1845static int do_abort (struct Scsi_Host *host) 1895static int do_abort(struct Scsi_Host *host)
1846{ 1896{
1847 unsigned char tmp, *msgptr, phase; 1897 unsigned char tmp, *msgptr, phase;
1848 int len; 1898 int len;
1849 1899
1850 /* Request message out phase */ 1900 /* Request message out phase */
1851 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1852
1853 /*
1854 * Wait for the target to indicate a valid phase by asserting
1855 * REQ. Once this happens, we'll have either a MSGOUT phase
1856 * and can immediately send the ABORT message, or we'll have some
1857 * other phase and will have to source/sink data.
1858 *
1859 * We really don't care what value was on the bus or what value
1860 * the target sees, so we just handshake.
1861 */
1862
1863 while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ);
1864
1865 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
1866
1867 if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
1868 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN |
1869 ICR_ASSERT_ACK);
1870 while (NCR5380_read(STATUS_REG) & SR_REQ);
1871 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); 1901 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1872 } 1902
1873 1903 /*
1874 tmp = ABORT; 1904 * Wait for the target to indicate a valid phase by asserting
1875 msgptr = &tmp; 1905 * REQ. Once this happens, we'll have either a MSGOUT phase
1876 len = 1; 1906 * and can immediately send the ABORT message, or we'll have some
1877 phase = PHASE_MSGOUT; 1907 * other phase and will have to source/sink data.
1878 NCR5380_transfer_pio (host, &phase, &len, &msgptr); 1908 *
1879 1909 * We really don't care what value was on the bus or what value
1880 /* 1910 * the target sees, so we just handshake.
1881 * If we got here, and the command completed successfully, 1911 */
1882 * we're about to go into bus free state. 1912
1883 */ 1913 while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ)
1884 1914 ;
1885 return len ? -1 : 0; 1915
1916 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
1917
1918 if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
1919 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN |
1920 ICR_ASSERT_ACK);
1921 while (NCR5380_read(STATUS_REG) & SR_REQ)
1922 ;
1923 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1924 }
1925
1926 tmp = ABORT;
1927 msgptr = &tmp;
1928 len = 1;
1929 phase = PHASE_MSGOUT;
1930 NCR5380_transfer_pio(host, &phase, &len, &msgptr);
1931
1932 /*
1933 * If we got here, and the command completed successfully,
1934 * we're about to go into bus free state.
1935 */
1936
1937 return len ? -1 : 0;
1886} 1938}
1887 1939
1888#if defined(REAL_DMA) 1940#if defined(REAL_DMA)
1889/* 1941/*
1890 * Function : int NCR5380_transfer_dma (struct Scsi_Host *instance, 1942 * Function : int NCR5380_transfer_dma (struct Scsi_Host *instance,
1891 * unsigned char *phase, int *count, unsigned char **data) 1943 * unsigned char *phase, int *count, unsigned char **data)
1892 * 1944 *
1893 * Purpose : transfers data in given phase using either real 1945 * Purpose : transfers data in given phase using either real
1894 * or pseudo DMA. 1946 * or pseudo DMA.
1895 * 1947 *
1896 * Inputs : instance - instance of driver, *phase - pointer to 1948 * Inputs : instance - instance of driver, *phase - pointer to
1897 * what phase is expected, *count - pointer to number of 1949 * what phase is expected, *count - pointer to number of
1898 * bytes to transfer, **data - pointer to data pointer. 1950 * bytes to transfer, **data - pointer to data pointer.
1899 * 1951 *
1900 * Returns : -1 when different phase is entered without transferring 1952 * Returns : -1 when different phase is entered without transferring
1901 * maximum number of bytes, 0 if all bytes or transfered or exit 1953 * maximum number of bytes, 0 if all bytes or transfered or exit
1902 * is in same phase. 1954 * is in same phase.
1903 * 1955 *
1904 * Also, *phase, *count, *data are modified in place. 1956 * Also, *phase, *count, *data are modified in place.
1905 * 1957 *
1906 */ 1958 */
1907 1959
1908 1960
1909static int NCR5380_transfer_dma( struct Scsi_Host *instance, 1961static int NCR5380_transfer_dma(struct Scsi_Host *instance,
1910 unsigned char *phase, int *count, 1962 unsigned char *phase, int *count,
1911 unsigned char **data) 1963 unsigned char **data)
1912{ 1964{
1913 SETUP_HOSTDATA(instance); 1965 SETUP_HOSTDATA(instance);
1914 register int c = *count; 1966 register int c = *count;
1915 register unsigned char p = *phase; 1967 register unsigned char p = *phase;
1916 register unsigned char *d = *data; 1968 register unsigned char *d = *data;
1917 unsigned char tmp; 1969 unsigned char tmp;
1918 unsigned long flags; 1970 unsigned long flags;
1919 1971
1920 if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) { 1972 if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
1921 *phase = tmp; 1973 *phase = tmp;
1922 return -1; 1974 return -1;
1923 } 1975 }
1924 1976
1925 if (atari_read_overruns && (p & SR_IO)) { 1977 if (atari_read_overruns && (p & SR_IO))
1926 c -= atari_read_overruns; 1978 c -= atari_read_overruns;
1927 }
1928 1979
1929 DMA_PRINTK("scsi%d: initializing DMA for %s, %d bytes %s %p\n", 1980 DMA_PRINTK("scsi%d: initializing DMA for %s, %d bytes %s %p\n",
1930 HOSTNO, (p & SR_IO) ? "reading" : "writing", 1981 HOSTNO, (p & SR_IO) ? "reading" : "writing",
1931 c, (p & SR_IO) ? "to" : "from", d); 1982 c, (p & SR_IO) ? "to" : "from", d);
1932 1983
1933 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p)); 1984 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
1934 1985
1935#ifdef REAL_DMA 1986#ifdef REAL_DMA
1936 NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY); 1987 NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY);
1937#endif /* def REAL_DMA */ 1988#endif /* def REAL_DMA */
1938 1989
1939 if (IS_A_TT()) { 1990 if (IS_A_TT()) {
1940 /* On the Medusa, it is a must to initialize the DMA before 1991 /* On the Medusa, it is a must to initialize the DMA before
1941 * starting the NCR. This is also the cleaner way for the TT. 1992 * starting the NCR. This is also the cleaner way for the TT.
1942 */ 1993 */
1943 local_irq_save(flags); 1994 local_irq_save(flags);
1944 hostdata->dma_len = (p & SR_IO) ? 1995 hostdata->dma_len = (p & SR_IO) ?
1945 NCR5380_dma_read_setup(instance, d, c) : 1996 NCR5380_dma_read_setup(instance, d, c) :
1946 NCR5380_dma_write_setup(instance, d, c); 1997 NCR5380_dma_write_setup(instance, d, c);
1947 local_irq_restore(flags); 1998 local_irq_restore(flags);
1948 } 1999 }
1949 2000
1950 if (p & SR_IO) 2001 if (p & SR_IO)
1951 NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0); 2002 NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0);
1952 else { 2003 else {
1953 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA); 2004 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA);
1954 NCR5380_write(START_DMA_SEND_REG, 0); 2005 NCR5380_write(START_DMA_SEND_REG, 0);
1955 } 2006 }
1956 2007
1957 if (!IS_A_TT()) { 2008 if (!IS_A_TT()) {
1958 /* On the Falcon, the DMA setup must be done after the last */ 2009 /* On the Falcon, the DMA setup must be done after the last */
1959 /* NCR access, else the DMA setup gets trashed! 2010 /* NCR access, else the DMA setup gets trashed!
1960 */ 2011 */
1961 local_irq_save(flags); 2012 local_irq_save(flags);
1962 hostdata->dma_len = (p & SR_IO) ? 2013 hostdata->dma_len = (p & SR_IO) ?
1963 NCR5380_dma_read_setup(instance, d, c) : 2014 NCR5380_dma_read_setup(instance, d, c) :
1964 NCR5380_dma_write_setup(instance, d, c); 2015 NCR5380_dma_write_setup(instance, d, c);
1965 local_irq_restore(flags); 2016 local_irq_restore(flags);
1966 } 2017 }
1967 return 0; 2018 return 0;
1968} 2019}
1969#endif /* defined(REAL_DMA) */ 2020#endif /* defined(REAL_DMA) */
1970 2021
1971/* 2022/*
1972 * Function : NCR5380_information_transfer (struct Scsi_Host *instance) 2023 * Function : NCR5380_information_transfer (struct Scsi_Host *instance)
1973 * 2024 *
1974 * Purpose : run through the various SCSI phases and do as the target 2025 * Purpose : run through the various SCSI phases and do as the target
1975 * directs us to. Operates on the currently connected command, 2026 * directs us to. Operates on the currently connected command,
1976 * instance->connected. 2027 * instance->connected.
1977 * 2028 *
1978 * Inputs : instance, instance for which we are doing commands 2029 * Inputs : instance, instance for which we are doing commands
1979 * 2030 *
1980 * Side effects : SCSI things happen, the disconnected queue will be 2031 * Side effects : SCSI things happen, the disconnected queue will be
1981 * modified if a command disconnects, *instance->connected will 2032 * modified if a command disconnects, *instance->connected will
1982 * change. 2033 * change.
1983 * 2034 *
1984 * XXX Note : we need to watch for bus free or a reset condition here 2035 * XXX Note : we need to watch for bus free or a reset condition here
1985 * to recover from an unexpected bus free condition. 2036 * to recover from an unexpected bus free condition.
1986 */ 2037 */
1987 2038
1988static void NCR5380_information_transfer (struct Scsi_Host *instance) 2039static void NCR5380_information_transfer(struct Scsi_Host *instance)
1989{ 2040{
1990 SETUP_HOSTDATA(instance); 2041 SETUP_HOSTDATA(instance);
1991 unsigned long flags; 2042 unsigned long flags;
1992 unsigned char msgout = NOP; 2043 unsigned char msgout = NOP;
1993 int sink = 0; 2044 int sink = 0;
1994 int len; 2045 int len;
1995#if defined(REAL_DMA) 2046#if defined(REAL_DMA)
1996 int transfersize; 2047 int transfersize;
1997#endif 2048#endif
1998 unsigned char *data; 2049 unsigned char *data;
1999 unsigned char phase, tmp, extended_msg[10], old_phase=0xff; 2050 unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
2000 Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; 2051 Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
2052
2053 while (1) {
2054 tmp = NCR5380_read(STATUS_REG);
2055 /* We only have a valid SCSI phase when REQ is asserted */
2056 if (tmp & SR_REQ) {
2057 phase = (tmp & PHASE_MASK);
2058 if (phase != old_phase) {
2059 old_phase = phase;
2060 NCR_PRINT_PHASE(NDEBUG_INFORMATION);
2061 }
2001 2062
2002 while (1) { 2063 if (sink && (phase != PHASE_MSGOUT)) {
2003 tmp = NCR5380_read(STATUS_REG); 2064 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
2004 /* We only have a valid SCSI phase when REQ is asserted */ 2065
2005 if (tmp & SR_REQ) { 2066 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN |
2006 phase = (tmp & PHASE_MASK); 2067 ICR_ASSERT_ACK);
2007 if (phase != old_phase) { 2068 while (NCR5380_read(STATUS_REG) & SR_REQ)
2008 old_phase = phase; 2069 ;
2009 NCR_PRINT_PHASE(NDEBUG_INFORMATION); 2070 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
2010 } 2071 ICR_ASSERT_ATN);
2011 2072 sink = 0;
2012 if (sink && (phase != PHASE_MSGOUT)) { 2073 continue;
2013 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp)); 2074 }
2014 2075
2015 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | 2076 switch (phase) {
2016 ICR_ASSERT_ACK); 2077 case PHASE_DATAOUT:
2017 while (NCR5380_read(STATUS_REG) & SR_REQ);
2018 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
2019 ICR_ASSERT_ATN);
2020 sink = 0;
2021 continue;
2022 }
2023
2024 switch (phase) {
2025 case PHASE_DATAOUT:
2026#if (NDEBUG & NDEBUG_NO_DATAOUT) 2078#if (NDEBUG & NDEBUG_NO_DATAOUT)
2027 printk("scsi%d: NDEBUG_NO_DATAOUT set, attempted DATAOUT " 2079 printk("scsi%d: NDEBUG_NO_DATAOUT set, attempted DATAOUT "
2028 "aborted\n", HOSTNO); 2080 "aborted\n", HOSTNO);
2029 sink = 1; 2081 sink = 1;
2030 do_abort(instance); 2082 do_abort(instance);
2031 cmd->result = DID_ERROR << 16; 2083 cmd->result = DID_ERROR << 16;
2032 cmd->done(cmd); 2084 cmd->done(cmd);
2033 return; 2085 return;
2034#endif 2086#endif
2035 case PHASE_DATAIN: 2087 case PHASE_DATAIN:
2036 /* 2088 /*
2037 * If there is no room left in the current buffer in the 2089 * If there is no room left in the current buffer in the
2038 * scatter-gather list, move onto the next one. 2090 * scatter-gather list, move onto the next one.
2039 */ 2091 */
2040 2092
2041 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { 2093 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
2042 ++cmd->SCp.buffer; 2094 ++cmd->SCp.buffer;
2043 --cmd->SCp.buffers_residual; 2095 --cmd->SCp.buffers_residual;
2044 cmd->SCp.this_residual = cmd->SCp.buffer->length; 2096 cmd->SCp.this_residual = cmd->SCp.buffer->length;
2045 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+ 2097 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) +
2046 cmd->SCp.buffer->offset; 2098 cmd->SCp.buffer->offset;
2047 /* ++roman: Try to merge some scatter-buffers if 2099 /* ++roman: Try to merge some scatter-buffers if
2048 * they are at contiguous physical addresses. 2100 * they are at contiguous physical addresses.
2049 */ 2101 */
2050 merge_contiguous_buffers( cmd ); 2102 merge_contiguous_buffers(cmd);
2051 INF_PRINTK("scsi%d: %d bytes and %d buffers left\n", 2103 INF_PRINTK("scsi%d: %d bytes and %d buffers left\n",
2052 HOSTNO, cmd->SCp.this_residual, 2104 HOSTNO, cmd->SCp.this_residual,
2053 cmd->SCp.buffers_residual); 2105 cmd->SCp.buffers_residual);
2054 } 2106 }
2055 2107
2056 /* 2108 /*
2057 * The preferred transfer method is going to be 2109 * The preferred transfer method is going to be
2058 * PSEUDO-DMA for systems that are strictly PIO, 2110 * PSEUDO-DMA for systems that are strictly PIO,
2059 * since we can let the hardware do the handshaking. 2111 * since we can let the hardware do the handshaking.
2060 * 2112 *
2061 * For this to work, we need to know the transfersize 2113 * For this to work, we need to know the transfersize
2062 * ahead of time, since the pseudo-DMA code will sit 2114 * ahead of time, since the pseudo-DMA code will sit
2063 * in an unconditional loop. 2115 * in an unconditional loop.
2064 */ 2116 */
2065 2117
2066/* ++roman: I suggest, this should be 2118 /* ++roman: I suggest, this should be
2067 * #if def(REAL_DMA) 2119 * #if def(REAL_DMA)
2068 * instead of leaving REAL_DMA out. 2120 * instead of leaving REAL_DMA out.
2069 */ 2121 */
2070 2122
2071#if defined(REAL_DMA) 2123#if defined(REAL_DMA)
2072 if (!cmd->device->borken && 2124 if (!cmd->device->borken &&
2073 (transfersize = NCR5380_dma_xfer_len(instance,cmd,phase)) > 31) { 2125 (transfersize = NCR5380_dma_xfer_len(instance,cmd,phase)) > 31) {
2074 len = transfersize; 2126 len = transfersize;
2075 cmd->SCp.phase = phase; 2127 cmd->SCp.phase = phase;
2076 if (NCR5380_transfer_dma(instance, &phase, 2128 if (NCR5380_transfer_dma(instance, &phase,
2077 &len, (unsigned char **) &cmd->SCp.ptr)) { 2129 &len, (unsigned char **)&cmd->SCp.ptr)) {
2078 /* 2130 /*
2079 * If the watchdog timer fires, all future 2131 * If the watchdog timer fires, all future
2080 * accesses to this device will use the 2132 * accesses to this device will use the
2081 * polled-IO. */ 2133 * polled-IO. */
2082 printk(KERN_NOTICE "scsi%d: switching target %d " 2134 printk(KERN_NOTICE "scsi%d: switching target %d "
2083 "lun %d to slow handshake\n", HOSTNO, 2135 "lun %d to slow handshake\n", HOSTNO,
2084 cmd->device->id, cmd->device->lun); 2136 cmd->device->id, cmd->device->lun);
2085 cmd->device->borken = 1; 2137 cmd->device->borken = 1;
2086 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 2138 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
2087 ICR_ASSERT_ATN); 2139 ICR_ASSERT_ATN);
2088 sink = 1; 2140 sink = 1;
2089 do_abort(instance); 2141 do_abort(instance);
2090 cmd->result = DID_ERROR << 16; 2142 cmd->result = DID_ERROR << 16;
2091 cmd->done(cmd); 2143 cmd->done(cmd);
2092 /* XXX - need to source or sink data here, as appropriate */ 2144 /* XXX - need to source or sink data here, as appropriate */
2093 } else { 2145 } else {
2094#ifdef REAL_DMA 2146#ifdef REAL_DMA
2095 /* ++roman: When using real DMA, 2147 /* ++roman: When using real DMA,
2096 * information_transfer() should return after 2148 * information_transfer() should return after
2097 * starting DMA since it has nothing more to 2149 * starting DMA since it has nothing more to
2098 * do. 2150 * do.
2099 */ 2151 */
2100 return; 2152 return;
2101#else 2153#else
2102 cmd->SCp.this_residual -= transfersize - len; 2154 cmd->SCp.this_residual -= transfersize - len;
2103#endif 2155#endif
2104 } 2156 }
2105 } else 2157 } else
2106#endif /* defined(REAL_DMA) */ 2158#endif /* defined(REAL_DMA) */
2107 NCR5380_transfer_pio(instance, &phase, 2159 NCR5380_transfer_pio(instance, &phase,
2108 (int *) &cmd->SCp.this_residual, (unsigned char **) 2160 (int *)&cmd->SCp.this_residual,
2109 &cmd->SCp.ptr); 2161 (unsigned char **)&cmd->SCp.ptr);
2110 break; 2162 break;
2111 case PHASE_MSGIN: 2163 case PHASE_MSGIN:
2112 len = 1; 2164 len = 1;
2113 data = &tmp; 2165 data = &tmp;
2114 NCR5380_write(SELECT_ENABLE_REG, 0); /* disable reselects */ 2166 NCR5380_write(SELECT_ENABLE_REG, 0); /* disable reselects */
2115 NCR5380_transfer_pio(instance, &phase, &len, &data); 2167 NCR5380_transfer_pio(instance, &phase, &len, &data);
2116 cmd->SCp.Message = tmp; 2168 cmd->SCp.Message = tmp;
2117 2169
2118 switch (tmp) { 2170 switch (tmp) {
2119 /* 2171 /*
2120 * Linking lets us reduce the time required to get the 2172 * Linking lets us reduce the time required to get the
2121 * next command out to the device, hopefully this will 2173 * next command out to the device, hopefully this will
2122 * mean we don't waste another revolution due to the delays 2174 * mean we don't waste another revolution due to the delays
2123 * required by ARBITRATION and another SELECTION. 2175 * required by ARBITRATION and another SELECTION.
2124 * 2176 *
2125 * In the current implementation proposal, low level drivers 2177 * In the current implementation proposal, low level drivers
2126 * merely have to start the next command, pointed to by 2178 * merely have to start the next command, pointed to by
2127 * next_link, done() is called as with unlinked commands. 2179 * next_link, done() is called as with unlinked commands.
2128 */ 2180 */
2129#ifdef LINKED 2181#ifdef LINKED
2130 case LINKED_CMD_COMPLETE: 2182 case LINKED_CMD_COMPLETE:
2131 case LINKED_FLG_CMD_COMPLETE: 2183 case LINKED_FLG_CMD_COMPLETE:
2132 /* Accept message by clearing ACK */ 2184 /* Accept message by clearing ACK */
2133 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2185 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2134 2186
2135 LNK_PRINTK("scsi%d: target %d lun %d linked command " 2187 LNK_PRINTK("scsi%d: target %d lun %d linked command "
2136 "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun); 2188 "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun);
2137 2189
2138 /* Enable reselect interrupts */ 2190 /* Enable reselect interrupts */
2139 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 2191 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
2140 /* 2192 /*
2141 * Sanity check : A linked command should only terminate 2193 * Sanity check : A linked command should only terminate
2142 * with one of these messages if there are more linked 2194 * with one of these messages if there are more linked
2143 * commands available. 2195 * commands available.
2144 */ 2196 */
2145 2197
2146 if (!cmd->next_link) { 2198 if (!cmd->next_link) {
2147 printk(KERN_NOTICE "scsi%d: target %d lun %d " 2199 printk(KERN_NOTICE "scsi%d: target %d lun %d "
2148 "linked command complete, no next_link\n", 2200 "linked command complete, no next_link\n",
2149 HOSTNO, cmd->device->id, cmd->device->lun); 2201 HOSTNO, cmd->device->id, cmd->device->lun);
2150 sink = 1; 2202 sink = 1;
2151 do_abort (instance); 2203 do_abort(instance);
2152 return; 2204 return;
2153 } 2205 }
2154 2206
2155 initialize_SCp(cmd->next_link); 2207 initialize_SCp(cmd->next_link);
2156 /* The next command is still part of this process; copy it 2208 /* The next command is still part of this process; copy it
2157 * and don't free it! */ 2209 * and don't free it! */
2158 cmd->next_link->tag = cmd->tag; 2210 cmd->next_link->tag = cmd->tag;
2159 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); 2211 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
2160 LNK_PRINTK("scsi%d: target %d lun %d linked request " 2212 LNK_PRINTK("scsi%d: target %d lun %d linked request "
2161 "done, calling scsi_done().\n", 2213 "done, calling scsi_done().\n",
2162 HOSTNO, cmd->device->id, cmd->device->lun); 2214 HOSTNO, cmd->device->id, cmd->device->lun);
2163#ifdef NCR5380_STATS 2215#ifdef NCR5380_STATS
2164 collect_stats(hostdata, cmd); 2216 collect_stats(hostdata, cmd);
2165#endif 2217#endif
2166 cmd->scsi_done(cmd); 2218 cmd->scsi_done(cmd);
2167 cmd = hostdata->connected; 2219 cmd = hostdata->connected;
2168 break; 2220 break;
2169#endif /* def LINKED */ 2221#endif /* def LINKED */
2170 case ABORT: 2222 case ABORT:
2171 case COMMAND_COMPLETE: 2223 case COMMAND_COMPLETE:
2172 /* Accept message by clearing ACK */ 2224 /* Accept message by clearing ACK */
2173 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2225 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2174 /* ++guenther: possible race with Falcon locking */ 2226 /* ++guenther: possible race with Falcon locking */
2175 falcon_dont_release++; 2227 falcon_dont_release++;
2176 hostdata->connected = NULL; 2228 hostdata->connected = NULL;
2177 QU_PRINTK("scsi%d: command for target %d, lun %d " 2229 QU_PRINTK("scsi%d: command for target %d, lun %d "
2178 "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); 2230 "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);
2179#ifdef SUPPORT_TAGS 2231#ifdef SUPPORT_TAGS
2180 cmd_free_tag( cmd ); 2232 cmd_free_tag(cmd);
2181 if (status_byte(cmd->SCp.Status) == QUEUE_FULL) { 2233 if (status_byte(cmd->SCp.Status) == QUEUE_FULL) {
2182 /* Turn a QUEUE FULL status into BUSY, I think the 2234 /* Turn a QUEUE FULL status into BUSY, I think the
2183 * mid level cannot handle QUEUE FULL :-( (The 2235 * mid level cannot handle QUEUE FULL :-( (The
2184 * command is retried after BUSY). Also update our 2236 * command is retried after BUSY). Also update our
2185 * queue size to the number of currently issued 2237 * queue size to the number of currently issued
2186 * commands now. 2238 * commands now.
2187 */ 2239 */
2188 /* ++Andreas: the mid level code knows about 2240 /* ++Andreas: the mid level code knows about
2189 QUEUE_FULL now. */ 2241 QUEUE_FULL now. */
2190 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; 2242 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
2191 TAG_PRINTK("scsi%d: target %d lun %d returned " 2243 TAG_PRINTK("scsi%d: target %d lun %d returned "
2192 "QUEUE_FULL after %d commands\n", 2244 "QUEUE_FULL after %d commands\n",
2193 HOSTNO, cmd->device->id, cmd->device->lun, 2245 HOSTNO, cmd->device->id, cmd->device->lun,
2194 ta->nr_allocated); 2246 ta->nr_allocated);
2195 if (ta->queue_size > ta->nr_allocated) 2247 if (ta->queue_size > ta->nr_allocated)
2196 ta->nr_allocated = ta->queue_size; 2248 ta->nr_allocated = ta->queue_size;
2197 } 2249 }
2198#else 2250#else
2199 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); 2251 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2200#endif 2252#endif
2201 /* Enable reselect interrupts */ 2253 /* Enable reselect interrupts */
2202 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 2254 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
2203 2255
2204 /* 2256 /*
2205 * I'm not sure what the correct thing to do here is : 2257 * I'm not sure what the correct thing to do here is :
2206 * 2258 *
2207 * If the command that just executed is NOT a request 2259 * If the command that just executed is NOT a request
2208 * sense, the obvious thing to do is to set the result 2260 * sense, the obvious thing to do is to set the result
2209 * code to the values of the stored parameters. 2261 * code to the values of the stored parameters.
2210 * 2262 *
2211 * If it was a REQUEST SENSE command, we need some way to 2263 * If it was a REQUEST SENSE command, we need some way to
2212 * differentiate between the failure code of the original 2264 * differentiate between the failure code of the original
2213 * and the failure code of the REQUEST sense - the obvious 2265 * and the failure code of the REQUEST sense - the obvious
2214 * case is success, where we fall through and leave the 2266 * case is success, where we fall through and leave the
2215 * result code unchanged. 2267 * result code unchanged.
2216 * 2268 *
2217 * The non-obvious place is where the REQUEST SENSE failed 2269 * The non-obvious place is where the REQUEST SENSE failed
2218 */ 2270 */
2219 2271
2220 if (cmd->cmnd[0] != REQUEST_SENSE) 2272 if (cmd->cmnd[0] != REQUEST_SENSE)
2221 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); 2273 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
2222 else if (status_byte(cmd->SCp.Status) != GOOD) 2274 else if (status_byte(cmd->SCp.Status) != GOOD)
2223 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); 2275 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
2224
2225#ifdef AUTOSENSE
2226 if ((cmd->cmnd[0] != REQUEST_SENSE) &&
2227 (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
2228 ASEN_PRINTK("scsi%d: performing request sense\n",
2229 HOSTNO);
2230 cmd->cmnd[0] = REQUEST_SENSE;
2231 cmd->cmnd[1] &= 0xe0;
2232 cmd->cmnd[2] = 0;
2233 cmd->cmnd[3] = 0;
2234 cmd->cmnd[4] = sizeof(cmd->sense_buffer);
2235 cmd->cmnd[5] = 0;
2236 cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);
2237
2238 cmd->use_sg = 0;
2239 /* this is initialized from initialize_SCp
2240 cmd->SCp.buffer = NULL;
2241 cmd->SCp.buffers_residual = 0;
2242 */
2243 cmd->request_buffer = (char *) cmd->sense_buffer;
2244 cmd->request_bufflen = sizeof(cmd->sense_buffer);
2245 2276
2246 local_irq_save(flags); 2277#ifdef AUTOSENSE
2247 LIST(cmd,hostdata->issue_queue); 2278 if ((cmd->cmnd[0] != REQUEST_SENSE) &&
2248 NEXT(cmd) = hostdata->issue_queue; 2279 (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
2249 hostdata->issue_queue = (Scsi_Cmnd *) cmd; 2280 ASEN_PRINTK("scsi%d: performing request sense\n", HOSTNO);
2250 local_irq_restore(flags); 2281 cmd->cmnd[0] = REQUEST_SENSE;
2251 QU_PRINTK("scsi%d: REQUEST SENSE added to head of " 2282 cmd->cmnd[1] &= 0xe0;
2252 "issue queue\n", H_NO(cmd)); 2283 cmd->cmnd[2] = 0;
2253 } else 2284 cmd->cmnd[3] = 0;
2285 cmd->cmnd[4] = sizeof(cmd->sense_buffer);
2286 cmd->cmnd[5] = 0;
2287 cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);
2288
2289 cmd->use_sg = 0;
2290 /* this is initialized from initialize_SCp
2291 cmd->SCp.buffer = NULL;
2292 cmd->SCp.buffers_residual = 0;
2293 */
2294 cmd->request_buffer = (char *) cmd->sense_buffer;
2295 cmd->request_bufflen = sizeof(cmd->sense_buffer);
2296
2297 local_irq_save(flags);
2298 LIST(cmd,hostdata->issue_queue);
2299 SET_NEXT(cmd, hostdata->issue_queue);
2300 hostdata->issue_queue = (Scsi_Cmnd *) cmd;
2301 local_irq_restore(flags);
2302 QU_PRINTK("scsi%d: REQUEST SENSE added to head of "
2303 "issue queue\n", H_NO(cmd));
2304 } else
2254#endif /* def AUTOSENSE */ 2305#endif /* def AUTOSENSE */
2255 { 2306 {
2256#ifdef NCR5380_STATS 2307#ifdef NCR5380_STATS
2257 collect_stats(hostdata, cmd); 2308 collect_stats(hostdata, cmd);
2258#endif 2309#endif
2259 cmd->scsi_done(cmd); 2310 cmd->scsi_done(cmd);
2260 } 2311 }
2261 2312
2262 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 2313 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
2263 /* 2314 /*
2264 * Restore phase bits to 0 so an interrupted selection, 2315 * Restore phase bits to 0 so an interrupted selection,
2265 * arbitration can resume. 2316 * arbitration can resume.
2266 */ 2317 */
2267 NCR5380_write(TARGET_COMMAND_REG, 0); 2318 NCR5380_write(TARGET_COMMAND_REG, 0);
2268 2319
2269 while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) 2320 while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
2270 barrier(); 2321 barrier();
2271 2322
2272 falcon_dont_release--; 2323 falcon_dont_release--;
2273 /* ++roman: For Falcon SCSI, release the lock on the 2324 /* ++roman: For Falcon SCSI, release the lock on the
2274 * ST-DMA here if no other commands are waiting on the 2325 * ST-DMA here if no other commands are waiting on the
2275 * disconnected queue. 2326 * disconnected queue.
2276 */ 2327 */
2277 falcon_release_lock_if_possible( hostdata ); 2328 falcon_release_lock_if_possible(hostdata);
2278 return; 2329 return;
2279 case MESSAGE_REJECT: 2330 case MESSAGE_REJECT:
2280 /* Accept message by clearing ACK */ 2331 /* Accept message by clearing ACK */
2281 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2332 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2282 /* Enable reselect interrupts */ 2333 /* Enable reselect interrupts */
2283 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 2334 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
2284 switch (hostdata->last_message) { 2335 switch (hostdata->last_message) {
2285 case HEAD_OF_QUEUE_TAG: 2336 case HEAD_OF_QUEUE_TAG:
2286 case ORDERED_QUEUE_TAG: 2337 case ORDERED_QUEUE_TAG:
2287 case SIMPLE_QUEUE_TAG: 2338 case SIMPLE_QUEUE_TAG:
2288 /* The target obviously doesn't support tagged 2339 /* The target obviously doesn't support tagged
2289 * queuing, even though it announced this ability in 2340 * queuing, even though it announced this ability in
2290 * its INQUIRY data ?!? (maybe only this LUN?) Ok, 2341 * its INQUIRY data ?!? (maybe only this LUN?) Ok,
2291 * clear 'tagged_supported' and lock the LUN, since 2342 * clear 'tagged_supported' and lock the LUN, since
2292 * the command is treated as untagged further on. 2343 * the command is treated as untagged further on.
2293 */ 2344 */
2294 cmd->device->tagged_supported = 0; 2345 cmd->device->tagged_supported = 0;
2295 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); 2346 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
2296 cmd->tag = TAG_NONE; 2347 cmd->tag = TAG_NONE;
2297 TAG_PRINTK("scsi%d: target %d lun %d rejected " 2348 TAG_PRINTK("scsi%d: target %d lun %d rejected "
2298 "QUEUE_TAG message; tagged queuing " 2349 "QUEUE_TAG message; tagged queuing "
2299 "disabled\n", 2350 "disabled\n",
2300 HOSTNO, cmd->device->id, cmd->device->lun); 2351 HOSTNO, cmd->device->id, cmd->device->lun);
2301 break; 2352 break;
2302 } 2353 }
2303 break; 2354 break;
2304 case DISCONNECT: 2355 case DISCONNECT:
2305 /* Accept message by clearing ACK */ 2356 /* Accept message by clearing ACK */
2306 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2357 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2307 local_irq_save(flags); 2358 local_irq_save(flags);
2308 cmd->device->disconnect = 1; 2359 cmd->device->disconnect = 1;
2309 LIST(cmd,hostdata->disconnected_queue); 2360 LIST(cmd,hostdata->disconnected_queue);
2310 NEXT(cmd) = hostdata->disconnected_queue; 2361 SET_NEXT(cmd, hostdata->disconnected_queue);
2311 hostdata->connected = NULL; 2362 hostdata->connected = NULL;
2312 hostdata->disconnected_queue = cmd; 2363 hostdata->disconnected_queue = cmd;
2313 local_irq_restore(flags); 2364 local_irq_restore(flags);
2314 QU_PRINTK("scsi%d: command for target %d lun %d was " 2365 QU_PRINTK("scsi%d: command for target %d lun %d was "
2315 "moved from connected to the " 2366 "moved from connected to the "
2316 "disconnected_queue\n", HOSTNO, 2367 "disconnected_queue\n", HOSTNO,
2317 cmd->device->id, cmd->device->lun); 2368 cmd->device->id, cmd->device->lun);
2318 /* 2369 /*
2319 * Restore phase bits to 0 so an interrupted selection, 2370 * Restore phase bits to 0 so an interrupted selection,
2320 * arbitration can resume. 2371 * arbitration can resume.
2321 */ 2372 */
2322 NCR5380_write(TARGET_COMMAND_REG, 0); 2373 NCR5380_write(TARGET_COMMAND_REG, 0);
2323 2374
2324 /* Enable reselect interrupts */ 2375 /* Enable reselect interrupts */
2325 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 2376 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
2326 /* Wait for bus free to avoid nasty timeouts */ 2377 /* Wait for bus free to avoid nasty timeouts */
2327 while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) 2378 while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
2328 barrier(); 2379 barrier();
2329 return; 2380 return;
2330 /* 2381 /*
2331 * The SCSI data pointer is *IMPLICITLY* saved on a disconnect 2382 * The SCSI data pointer is *IMPLICITLY* saved on a disconnect
2332 * operation, in violation of the SCSI spec so we can safely 2383 * operation, in violation of the SCSI spec so we can safely
2333 * ignore SAVE/RESTORE pointers calls. 2384 * ignore SAVE/RESTORE pointers calls.
2334 * 2385 *
2335 * Unfortunately, some disks violate the SCSI spec and 2386 * Unfortunately, some disks violate the SCSI spec and
2336 * don't issue the required SAVE_POINTERS message before 2387 * don't issue the required SAVE_POINTERS message before
2337 * disconnecting, and we have to break spec to remain 2388 * disconnecting, and we have to break spec to remain
2338 * compatible. 2389 * compatible.
2339 */ 2390 */
2340 case SAVE_POINTERS: 2391 case SAVE_POINTERS:
2341 case RESTORE_POINTERS: 2392 case RESTORE_POINTERS:
2342 /* Accept message by clearing ACK */ 2393 /* Accept message by clearing ACK */
2343 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2394 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2344 /* Enable reselect interrupts */ 2395 /* Enable reselect interrupts */
2345 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 2396 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
2346 break; 2397 break;
2347 case EXTENDED_MESSAGE: 2398 case EXTENDED_MESSAGE:
2348/* 2399 /*
2349 * Extended messages are sent in the following format : 2400 * Extended messages are sent in the following format :
2350 * Byte 2401 * Byte
2351 * 0 EXTENDED_MESSAGE == 1 2402 * 0 EXTENDED_MESSAGE == 1
2352 * 1 length (includes one byte for code, doesn't 2403 * 1 length (includes one byte for code, doesn't
2353 * include first two bytes) 2404 * include first two bytes)
2354 * 2 code 2405 * 2 code
2355 * 3..length+1 arguments 2406 * 3..length+1 arguments
2356 * 2407 *
2357 * Start the extended message buffer with the EXTENDED_MESSAGE 2408 * Start the extended message buffer with the EXTENDED_MESSAGE
2358 * byte, since spi_print_msg() wants the whole thing. 2409 * byte, since spi_print_msg() wants the whole thing.
2359 */ 2410 */
2360 extended_msg[0] = EXTENDED_MESSAGE; 2411 extended_msg[0] = EXTENDED_MESSAGE;
2361 /* Accept first byte by clearing ACK */ 2412 /* Accept first byte by clearing ACK */
2362 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2413 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2363 2414
2364 EXT_PRINTK("scsi%d: receiving extended message\n", HOSTNO); 2415 EXT_PRINTK("scsi%d: receiving extended message\n", HOSTNO);
2365 2416
2366 len = 2; 2417 len = 2;
2367 data = extended_msg + 1; 2418 data = extended_msg + 1;
2368 phase = PHASE_MSGIN; 2419 phase = PHASE_MSGIN;
2369 NCR5380_transfer_pio(instance, &phase, &len, &data); 2420 NCR5380_transfer_pio(instance, &phase, &len, &data);
2370 EXT_PRINTK("scsi%d: length=%d, code=0x%02x\n", HOSTNO, 2421 EXT_PRINTK("scsi%d: length=%d, code=0x%02x\n", HOSTNO,
2371 (int)extended_msg[1], (int)extended_msg[2]); 2422 (int)extended_msg[1], (int)extended_msg[2]);
2372 2423
2373 if (!len && extended_msg[1] <= 2424 if (!len && extended_msg[1] <=
2374 (sizeof (extended_msg) - 1)) { 2425 (sizeof(extended_msg) - 1)) {
2375 /* Accept third byte by clearing ACK */ 2426 /* Accept third byte by clearing ACK */
2376 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2427 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2377 len = extended_msg[1] - 1; 2428 len = extended_msg[1] - 1;
2378 data = extended_msg + 3; 2429 data = extended_msg + 3;
2379 phase = PHASE_MSGIN; 2430 phase = PHASE_MSGIN;
2380 2431
2381 NCR5380_transfer_pio(instance, &phase, &len, &data); 2432 NCR5380_transfer_pio(instance, &phase, &len, &data);
2382 EXT_PRINTK("scsi%d: message received, residual %d\n", 2433 EXT_PRINTK("scsi%d: message received, residual %d\n",
2383 HOSTNO, len); 2434 HOSTNO, len);
2384 2435
2385 switch (extended_msg[2]) { 2436 switch (extended_msg[2]) {
2386 case EXTENDED_SDTR: 2437 case EXTENDED_SDTR:
2387 case EXTENDED_WDTR: 2438 case EXTENDED_WDTR:
2388 case EXTENDED_MODIFY_DATA_POINTER: 2439 case EXTENDED_MODIFY_DATA_POINTER:
2389 case EXTENDED_EXTENDED_IDENTIFY: 2440 case EXTENDED_EXTENDED_IDENTIFY:
2390 tmp = 0; 2441 tmp = 0;
2391 } 2442 }
2392 } else if (len) { 2443 } else if (len) {
2393 printk(KERN_NOTICE "scsi%d: error receiving " 2444 printk(KERN_NOTICE "scsi%d: error receiving "
2394 "extended message\n", HOSTNO); 2445 "extended message\n", HOSTNO);
2395 tmp = 0; 2446 tmp = 0;
2396 } else { 2447 } else {
2397 printk(KERN_NOTICE "scsi%d: extended message " 2448 printk(KERN_NOTICE "scsi%d: extended message "
2398 "code %02x length %d is too long\n", 2449 "code %02x length %d is too long\n",
2399 HOSTNO, extended_msg[2], extended_msg[1]); 2450 HOSTNO, extended_msg[2], extended_msg[1]);
2400 tmp = 0; 2451 tmp = 0;
2401 } 2452 }
2402 /* Fall through to reject message */ 2453 /* Fall through to reject message */
2403 2454
2404 /* 2455 /*
2405 * If we get something weird that we aren't expecting, 2456 * If we get something weird that we aren't expecting,
2406 * reject it. 2457 * reject it.
2407 */ 2458 */
2408 default: 2459 default:
2409 if (!tmp) { 2460 if (!tmp) {
2410 printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO); 2461 printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO);
2411 spi_print_msg(extended_msg); 2462 spi_print_msg(extended_msg);
2412 printk("\n"); 2463 printk("\n");
2413 } else if (tmp != EXTENDED_MESSAGE) 2464 } else if (tmp != EXTENDED_MESSAGE)
2414 printk(KERN_DEBUG "scsi%d: rejecting unknown " 2465 printk(KERN_DEBUG "scsi%d: rejecting unknown "
2415 "message %02x from target %d, lun %d\n", 2466 "message %02x from target %d, lun %d\n",
2416 HOSTNO, tmp, cmd->device->id, cmd->device->lun); 2467 HOSTNO, tmp, cmd->device->id, cmd->device->lun);
2417 else 2468 else
2418 printk(KERN_DEBUG "scsi%d: rejecting unknown " 2469 printk(KERN_DEBUG "scsi%d: rejecting unknown "
2419 "extended message " 2470 "extended message "
2420 "code %02x, length %d from target %d, lun %d\n", 2471 "code %02x, length %d from target %d, lun %d\n",
2421 HOSTNO, extended_msg[1], extended_msg[0], 2472 HOSTNO, extended_msg[1], extended_msg[0],
2422 cmd->device->id, cmd->device->lun); 2473 cmd->device->id, cmd->device->lun);
2423 2474
2424 2475
2425 msgout = MESSAGE_REJECT; 2476 msgout = MESSAGE_REJECT;
2426 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 2477 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
2427 ICR_ASSERT_ATN); 2478 break;
2428 break; 2479 } /* switch (tmp) */
2429 } /* switch (tmp) */ 2480 break;
2430 break; 2481 case PHASE_MSGOUT:
2431 case PHASE_MSGOUT: 2482 len = 1;
2432 len = 1; 2483 data = &msgout;
2433 data = &msgout; 2484 hostdata->last_message = msgout;
2434 hostdata->last_message = msgout; 2485 NCR5380_transfer_pio(instance, &phase, &len, &data);
2435 NCR5380_transfer_pio(instance, &phase, &len, &data); 2486 if (msgout == ABORT) {
2436 if (msgout == ABORT) {
2437#ifdef SUPPORT_TAGS 2487#ifdef SUPPORT_TAGS
2438 cmd_free_tag( cmd ); 2488 cmd_free_tag(cmd);
2439#else 2489#else
2440 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); 2490 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2441#endif 2491#endif
2442 hostdata->connected = NULL; 2492 hostdata->connected = NULL;
2443 cmd->result = DID_ERROR << 16; 2493 cmd->result = DID_ERROR << 16;
2444#ifdef NCR5380_STATS 2494#ifdef NCR5380_STATS
2445 collect_stats(hostdata, cmd); 2495 collect_stats(hostdata, cmd);
2446#endif 2496#endif
2447 cmd->scsi_done(cmd); 2497 cmd->scsi_done(cmd);
2448 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); 2498 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
2449 falcon_release_lock_if_possible( hostdata ); 2499 falcon_release_lock_if_possible(hostdata);
2450 return; 2500 return;
2451 } 2501 }
2452 msgout = NOP; 2502 msgout = NOP;
2453 break; 2503 break;
2454 case PHASE_CMDOUT: 2504 case PHASE_CMDOUT:
2455 len = cmd->cmd_len; 2505 len = cmd->cmd_len;
2456 data = cmd->cmnd; 2506 data = cmd->cmnd;
2457 /* 2507 /*
2458 * XXX for performance reasons, on machines with a 2508 * XXX for performance reasons, on machines with a
2459 * PSEUDO-DMA architecture we should probably 2509 * PSEUDO-DMA architecture we should probably
2460 * use the dma transfer function. 2510 * use the dma transfer function.
2461 */ 2511 */
2462 NCR5380_transfer_pio(instance, &phase, &len, 2512 NCR5380_transfer_pio(instance, &phase, &len, &data);
2463 &data); 2513 break;
2464 break; 2514 case PHASE_STATIN:
2465 case PHASE_STATIN: 2515 len = 1;
2466 len = 1; 2516 data = &tmp;
2467 data = &tmp; 2517 NCR5380_transfer_pio(instance, &phase, &len, &data);
2468 NCR5380_transfer_pio(instance, &phase, &len, &data); 2518 cmd->SCp.Status = tmp;
2469 cmd->SCp.Status = tmp; 2519 break;
2470 break; 2520 default:
2471 default: 2521 printk("scsi%d: unknown phase\n", HOSTNO);
2472 printk("scsi%d: unknown phase\n", HOSTNO); 2522 NCR_PRINT(NDEBUG_ANY);
2473 NCR_PRINT(NDEBUG_ANY); 2523 } /* switch(phase) */
2474 } /* switch(phase) */ 2524 } /* if (tmp * SR_REQ) */
2475 } /* if (tmp * SR_REQ) */ 2525 } /* while (1) */
2476 } /* while (1) */
2477} 2526}
2478 2527
2479/* 2528/*
2480 * Function : void NCR5380_reselect (struct Scsi_Host *instance) 2529 * Function : void NCR5380_reselect (struct Scsi_Host *instance)
2481 * 2530 *
2482 * Purpose : does reselection, initializing the instance->connected 2531 * Purpose : does reselection, initializing the instance->connected
2483 * field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q 2532 * field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q
2484 * nexus has been reestablished, 2533 * nexus has been reestablished,
2485 * 2534 *
2486 * Inputs : instance - this instance of the NCR5380. 2535 * Inputs : instance - this instance of the NCR5380.
2487 * 2536 *
2488 */ 2537 */
2489 2538
2490 2539
2491static void NCR5380_reselect (struct Scsi_Host *instance) 2540static void NCR5380_reselect(struct Scsi_Host *instance)
2492{ 2541{
2493 SETUP_HOSTDATA(instance); 2542 SETUP_HOSTDATA(instance);
2494 unsigned char target_mask; 2543 unsigned char target_mask;
2495 unsigned char lun, phase; 2544 unsigned char lun, phase;
2496 int len; 2545 int len;
2497#ifdef SUPPORT_TAGS 2546#ifdef SUPPORT_TAGS
2498 unsigned char tag; 2547 unsigned char tag;
2499#endif 2548#endif
2500 unsigned char msg[3]; 2549 unsigned char msg[3];
2501 unsigned char *data; 2550 unsigned char *data;
2502 Scsi_Cmnd *tmp = NULL, *prev; 2551 Scsi_Cmnd *tmp = NULL, *prev;
2503/* unsigned long flags; */ 2552/* unsigned long flags; */
2504 2553
2505 /* 2554 /*
2506 * Disable arbitration, etc. since the host adapter obviously 2555 * Disable arbitration, etc. since the host adapter obviously
2507 * lost, and tell an interrupted NCR5380_select() to restart. 2556 * lost, and tell an interrupted NCR5380_select() to restart.
2508 */ 2557 */
2509 2558
2510 NCR5380_write(MODE_REG, MR_BASE); 2559 NCR5380_write(MODE_REG, MR_BASE);
2511 hostdata->restart_select = 1; 2560 hostdata->restart_select = 1;
2512 2561
2513 target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); 2562 target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask);
2514 2563
2515 RSL_PRINTK("scsi%d: reselect\n", HOSTNO); 2564 RSL_PRINTK("scsi%d: reselect\n", HOSTNO);
2516 2565
2517 /* 2566 /*
2518 * At this point, we have detected that our SCSI ID is on the bus, 2567 * At this point, we have detected that our SCSI ID is on the bus,
2519 * SEL is true and BSY was false for at least one bus settle delay 2568 * SEL is true and BSY was false for at least one bus settle delay
2520 * (400 ns). 2569 * (400 ns).
2521 * 2570 *
2522 * We must assert BSY ourselves, until the target drops the SEL 2571 * We must assert BSY ourselves, until the target drops the SEL
2523 * signal. 2572 * signal.
2524 */ 2573 */
2525 2574
2526 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_BSY); 2575 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_BSY);
2527 2576
2528 while (NCR5380_read(STATUS_REG) & SR_SEL); 2577 while (NCR5380_read(STATUS_REG) & SR_SEL)
2529 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2578 ;
2530 2579 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2531 /* 2580
2532 * Wait for target to go into MSGIN. 2581 /*
2533 */ 2582 * Wait for target to go into MSGIN.
2534 2583 */
2535 while (!(NCR5380_read(STATUS_REG) & SR_REQ)); 2584
2536 2585 while (!(NCR5380_read(STATUS_REG) & SR_REQ))
2537 len = 1; 2586 ;
2538 data = msg; 2587
2539 phase = PHASE_MSGIN; 2588 len = 1;
2540 NCR5380_transfer_pio(instance, &phase, &len, &data); 2589 data = msg;
2541 2590 phase = PHASE_MSGIN;
2542 if (!(msg[0] & 0x80)) { 2591 NCR5380_transfer_pio(instance, &phase, &len, &data);
2543 printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO); 2592
2544 spi_print_msg(msg); 2593 if (!(msg[0] & 0x80)) {
2545 do_abort(instance); 2594 printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO);
2546 return; 2595 spi_print_msg(msg);
2547 } 2596 do_abort(instance);
2548 lun = (msg[0] & 0x07); 2597 return;
2598 }
2599 lun = (msg[0] & 0x07);
2549 2600
2550#ifdef SUPPORT_TAGS 2601#ifdef SUPPORT_TAGS
2551 /* If the phase is still MSGIN, the target wants to send some more 2602 /* If the phase is still MSGIN, the target wants to send some more
2552 * messages. In case it supports tagged queuing, this is probably a 2603 * messages. In case it supports tagged queuing, this is probably a
2553 * SIMPLE_QUEUE_TAG for the I_T_L_Q nexus. 2604 * SIMPLE_QUEUE_TAG for the I_T_L_Q nexus.
2554 */ 2605 */
2555 tag = TAG_NONE; 2606 tag = TAG_NONE;
2556 if (phase == PHASE_MSGIN && setup_use_tagged_queuing) { 2607 if (phase == PHASE_MSGIN && setup_use_tagged_queuing) {
2557 /* Accept previous IDENTIFY message by clearing ACK */ 2608 /* Accept previous IDENTIFY message by clearing ACK */
2558 NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE ); 2609 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2559 len = 2; 2610 len = 2;
2560 data = msg+1; 2611 data = msg + 1;
2561 if (!NCR5380_transfer_pio(instance, &phase, &len, &data) && 2612 if (!NCR5380_transfer_pio(instance, &phase, &len, &data) &&
2562 msg[1] == SIMPLE_QUEUE_TAG) 2613 msg[1] == SIMPLE_QUEUE_TAG)
2563 tag = msg[2]; 2614 tag = msg[2];
2564 TAG_PRINTK("scsi%d: target mask %02x, lun %d sent tag %d at " 2615 TAG_PRINTK("scsi%d: target mask %02x, lun %d sent tag %d at "
2565 "reselection\n", HOSTNO, target_mask, lun, tag); 2616 "reselection\n", HOSTNO, target_mask, lun, tag);
2566 } 2617 }
2567#endif 2618#endif
2568 2619
2569 /* 2620 /*
2570 * Find the command corresponding to the I_T_L or I_T_L_Q nexus we 2621 * Find the command corresponding to the I_T_L or I_T_L_Q nexus we
2571 * just reestablished, and remove it from the disconnected queue. 2622 * just reestablished, and remove it from the disconnected queue.
2572 */ 2623 */
2573 2624
2574 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; 2625 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL;
2575 tmp; prev = tmp, tmp = NEXT(tmp) ) { 2626 tmp; prev = tmp, tmp = NEXT(tmp)) {
2576 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun) 2627 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun)
2577#ifdef SUPPORT_TAGS 2628#ifdef SUPPORT_TAGS
2578 && (tag == tmp->tag) 2629 && (tag == tmp->tag)
2579#endif 2630#endif
2580 ) { 2631 ) {
2581 /* ++guenther: prevent race with falcon_release_lock */ 2632 /* ++guenther: prevent race with falcon_release_lock */
2582 falcon_dont_release++; 2633 falcon_dont_release++;
2583 if (prev) { 2634 if (prev) {
2584 REMOVE(prev, NEXT(prev), tmp, NEXT(tmp)); 2635 REMOVE(prev, NEXT(prev), tmp, NEXT(tmp));
2585 NEXT(prev) = NEXT(tmp); 2636 SET_NEXT(prev, NEXT(tmp));
2586 } else { 2637 } else {
2587 REMOVE(-1, hostdata->disconnected_queue, tmp, NEXT(tmp)); 2638 REMOVE(-1, hostdata->disconnected_queue, tmp, NEXT(tmp));
2588 hostdata->disconnected_queue = NEXT(tmp); 2639 hostdata->disconnected_queue = NEXT(tmp);
2589 } 2640 }
2590 NEXT(tmp) = NULL; 2641 SET_NEXT(tmp, NULL);
2591 break; 2642 break;
2643 }
2592 } 2644 }
2593 } 2645
2594 2646 if (!tmp) {
2595 if (!tmp) { 2647 printk(KERN_WARNING "scsi%d: warning: target bitmask %02x lun %d "
2596 printk(KERN_WARNING "scsi%d: warning: target bitmask %02x lun %d "
2597#ifdef SUPPORT_TAGS 2648#ifdef SUPPORT_TAGS
2598 "tag %d " 2649 "tag %d "
2599#endif 2650#endif
2600 "not in disconnected_queue.\n", 2651 "not in disconnected_queue.\n",
2601 HOSTNO, target_mask, lun 2652 HOSTNO, target_mask, lun
2602#ifdef SUPPORT_TAGS 2653#ifdef SUPPORT_TAGS
2603 , tag 2654 , tag
2604#endif 2655#endif
2605 ); 2656 );
2606 /* 2657 /*
2607 * Since we have an established nexus that we can't do anything 2658 * Since we have an established nexus that we can't do anything
2608 * with, we must abort it. 2659 * with, we must abort it.
2609 */ 2660 */
2610 do_abort(instance); 2661 do_abort(instance);
2611 return; 2662 return;
2612 } 2663 }
2613 2664
2614 /* Accept message by clearing ACK */ 2665 /* Accept message by clearing ACK */
2615 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2666 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2616 2667
2617 hostdata->connected = tmp; 2668 hostdata->connected = tmp;
2618 RSL_PRINTK("scsi%d: nexus established, target = %d, lun = %d, tag = %d\n", 2669 RSL_PRINTK("scsi%d: nexus established, target = %d, lun = %d, tag = %d\n",
2619 HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag); 2670 HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag);
2620 falcon_dont_release--; 2671 falcon_dont_release--;
2621} 2672}
2622 2673
2623 2674
@@ -2626,362 +2677,361 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2626 * 2677 *
2627 * Purpose : abort a command 2678 * Purpose : abort a command
2628 * 2679 *
2629 * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the 2680 * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the
2630 * host byte of the result field to, if zero DID_ABORTED is 2681 * host byte of the result field to, if zero DID_ABORTED is
2631 * used. 2682 * used.
2632 * 2683 *
2633 * Returns : 0 - success, -1 on failure. 2684 * Returns : 0 - success, -1 on failure.
2634 * 2685 *
2635 * XXX - there is no way to abort the command that is currently 2686 * XXX - there is no way to abort the command that is currently
2636 * connected, you have to wait for it to complete. If this is 2687 * connected, you have to wait for it to complete. If this is
2637 * a problem, we could implement longjmp() / setjmp(), setjmp() 2688 * a problem, we could implement longjmp() / setjmp(), setjmp()
2638 * called where the loop started in NCR5380_main(). 2689 * called where the loop started in NCR5380_main().
2639 */ 2690 */
2640 2691
2641static 2692static
2642int NCR5380_abort (Scsi_Cmnd *cmd) 2693int NCR5380_abort(Scsi_Cmnd *cmd)
2643{ 2694{
2644 struct Scsi_Host *instance = cmd->device->host; 2695 struct Scsi_Host *instance = cmd->device->host;
2645 SETUP_HOSTDATA(instance); 2696 SETUP_HOSTDATA(instance);
2646 Scsi_Cmnd *tmp, **prev; 2697 Scsi_Cmnd *tmp, **prev;
2647 unsigned long flags; 2698 unsigned long flags;
2699
2700 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO);
2701 scsi_print_command(cmd);
2648 2702
2649 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO); 2703 NCR5380_print_status(instance);
2650 scsi_print_command(cmd);
2651 2704
2652 NCR5380_print_status (instance); 2705 local_irq_save(flags);
2653 2706
2654 local_irq_save(flags); 2707 if (!IS_A_TT() && !falcon_got_lock)
2655 2708 printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_abort\n",
2656 if (!IS_A_TT() && !falcon_got_lock) 2709 HOSTNO);
2657 printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_abort\n",
2658 HOSTNO);
2659 2710
2660 ABRT_PRINTK("scsi%d: abort called basr 0x%02x, sr 0x%02x\n", HOSTNO, 2711 ABRT_PRINTK("scsi%d: abort called basr 0x%02x, sr 0x%02x\n", HOSTNO,
2661 NCR5380_read(BUS_AND_STATUS_REG), 2712 NCR5380_read(BUS_AND_STATUS_REG),
2662 NCR5380_read(STATUS_REG)); 2713 NCR5380_read(STATUS_REG));
2663 2714
2664#if 1 2715#if 1
2665/* 2716 /*
2666 * Case 1 : If the command is the currently executing command, 2717 * Case 1 : If the command is the currently executing command,
2667 * we'll set the aborted flag and return control so that 2718 * we'll set the aborted flag and return control so that
2668 * information transfer routine can exit cleanly. 2719 * information transfer routine can exit cleanly.
2669 */ 2720 */
2670 2721
2671 if (hostdata->connected == cmd) { 2722 if (hostdata->connected == cmd) {
2672 2723
2673 ABRT_PRINTK("scsi%d: aborting connected command\n", HOSTNO); 2724 ABRT_PRINTK("scsi%d: aborting connected command\n", HOSTNO);
2674/* 2725 /*
2675 * We should perform BSY checking, and make sure we haven't slipped 2726 * We should perform BSY checking, and make sure we haven't slipped
2676 * into BUS FREE. 2727 * into BUS FREE.
2677 */ 2728 */
2678 2729
2679/* NCR5380_write(INITIATOR_COMMAND_REG, ICR_ASSERT_ATN); */ 2730 /* NCR5380_write(INITIATOR_COMMAND_REG, ICR_ASSERT_ATN); */
2680/* 2731 /*
2681 * Since we can't change phases until we've completed the current 2732 * Since we can't change phases until we've completed the current
2682 * handshake, we have to source or sink a byte of data if the current 2733 * handshake, we have to source or sink a byte of data if the current
2683 * phase is not MSGOUT. 2734 * phase is not MSGOUT.
2684 */ 2735 */
2685 2736
2686/* 2737 /*
2687 * Return control to the executing NCR drive so we can clear the 2738 * Return control to the executing NCR drive so we can clear the
2688 * aborted flag and get back into our main loop. 2739 * aborted flag and get back into our main loop.
2689 */ 2740 */
2690 2741
2691 if (do_abort(instance) == 0) { 2742 if (do_abort(instance) == 0) {
2692 hostdata->aborted = 1; 2743 hostdata->aborted = 1;
2693 hostdata->connected = NULL; 2744 hostdata->connected = NULL;
2694 cmd->result = DID_ABORT << 16; 2745 cmd->result = DID_ABORT << 16;
2695#ifdef SUPPORT_TAGS 2746#ifdef SUPPORT_TAGS
2696 cmd_free_tag( cmd ); 2747 cmd_free_tag(cmd);
2697#else 2748#else
2698 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); 2749 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2699#endif 2750#endif
2700 local_irq_restore(flags); 2751 local_irq_restore(flags);
2701 cmd->scsi_done(cmd); 2752 cmd->scsi_done(cmd);
2702 falcon_release_lock_if_possible( hostdata ); 2753 falcon_release_lock_if_possible(hostdata);
2703 return SCSI_ABORT_SUCCESS; 2754 return SCSI_ABORT_SUCCESS;
2704 } else { 2755 } else {
2705/* local_irq_restore(flags); */ 2756/* local_irq_restore(flags); */
2706 printk("scsi%d: abort of connected command failed!\n", HOSTNO); 2757 printk("scsi%d: abort of connected command failed!\n", HOSTNO);
2707 return SCSI_ABORT_ERROR; 2758 return SCSI_ABORT_ERROR;
2708 } 2759 }
2709 } 2760 }
2710#endif 2761#endif
2711 2762
2712/* 2763 /*
2713 * Case 2 : If the command hasn't been issued yet, we simply remove it 2764 * Case 2 : If the command hasn't been issued yet, we simply remove it
2714 * from the issue queue. 2765 * from the issue queue.
2715 */ 2766 */
2716 for (prev = (Scsi_Cmnd **) &(hostdata->issue_queue), 2767 for (prev = (Scsi_Cmnd **)&(hostdata->issue_queue),
2717 tmp = (Scsi_Cmnd *) hostdata->issue_queue; 2768 tmp = (Scsi_Cmnd *)hostdata->issue_queue;
2718 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2769 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) {
2719 if (cmd == tmp) { 2770 if (cmd == tmp) {
2720 REMOVE(5, *prev, tmp, NEXT(tmp)); 2771 REMOVE(5, *prev, tmp, NEXT(tmp));
2721 (*prev) = NEXT(tmp); 2772 (*prev) = NEXT(tmp);
2722 NEXT(tmp) = NULL; 2773 SET_NEXT(tmp, NULL);
2723 tmp->result = DID_ABORT << 16; 2774 tmp->result = DID_ABORT << 16;
2724 local_irq_restore(flags); 2775 local_irq_restore(flags);
2725 ABRT_PRINTK("scsi%d: abort removed command from issue queue.\n", 2776 ABRT_PRINTK("scsi%d: abort removed command from issue queue.\n",
2726 HOSTNO); 2777 HOSTNO);
2727 /* Tagged queuing note: no tag to free here, hasn't been assigned 2778 /* Tagged queuing note: no tag to free here, hasn't been assigned
2728 * yet... */ 2779 * yet... */
2729 tmp->scsi_done(tmp); 2780 tmp->scsi_done(tmp);
2730 falcon_release_lock_if_possible( hostdata ); 2781 falcon_release_lock_if_possible(hostdata);
2731 return SCSI_ABORT_SUCCESS; 2782 return SCSI_ABORT_SUCCESS;
2783 }
2732 } 2784 }
2733 2785
2734/* 2786 /*
2735 * Case 3 : If any commands are connected, we're going to fail the abort 2787 * Case 3 : If any commands are connected, we're going to fail the abort
2736 * and let the high level SCSI driver retry at a later time or 2788 * and let the high level SCSI driver retry at a later time or
2737 * issue a reset. 2789 * issue a reset.
2738 * 2790 *
2739 * Timeouts, and therefore aborted commands, will be highly unlikely 2791 * Timeouts, and therefore aborted commands, will be highly unlikely
2740 * and handling them cleanly in this situation would make the common 2792 * and handling them cleanly in this situation would make the common
2741 * case of noresets less efficient, and would pollute our code. So, 2793 * case of noresets less efficient, and would pollute our code. So,
2742 * we fail. 2794 * we fail.
2743 */ 2795 */
2744 2796
2745 if (hostdata->connected) { 2797 if (hostdata->connected) {
2746 local_irq_restore(flags); 2798 local_irq_restore(flags);
2747 ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO); 2799 ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
2748 return SCSI_ABORT_SNOOZE; 2800 return SCSI_ABORT_SNOOZE;
2749 } 2801 }
2750 2802
2751/* 2803 /*
2752 * Case 4: If the command is currently disconnected from the bus, and 2804 * Case 4: If the command is currently disconnected from the bus, and
2753 * there are no connected commands, we reconnect the I_T_L or 2805 * there are no connected commands, we reconnect the I_T_L or
2754 * I_T_L_Q nexus associated with it, go into message out, and send 2806 * I_T_L_Q nexus associated with it, go into message out, and send
2755 * an abort message. 2807 * an abort message.
2756 * 2808 *
2757 * This case is especially ugly. In order to reestablish the nexus, we 2809 * This case is especially ugly. In order to reestablish the nexus, we
2758 * need to call NCR5380_select(). The easiest way to implement this 2810 * need to call NCR5380_select(). The easiest way to implement this
2759 * function was to abort if the bus was busy, and let the interrupt 2811 * function was to abort if the bus was busy, and let the interrupt
2760 * handler triggered on the SEL for reselect take care of lost arbitrations 2812 * handler triggered on the SEL for reselect take care of lost arbitrations
2761 * where necessary, meaning interrupts need to be enabled. 2813 * where necessary, meaning interrupts need to be enabled.
2762 * 2814 *
2763 * When interrupts are enabled, the queues may change - so we 2815 * When interrupts are enabled, the queues may change - so we
2764 * can't remove it from the disconnected queue before selecting it 2816 * can't remove it from the disconnected queue before selecting it
2765 * because that could cause a failure in hashing the nexus if that 2817 * because that could cause a failure in hashing the nexus if that
2766 * device reselected. 2818 * device reselected.
2767 * 2819 *
2768 * Since the queues may change, we can't use the pointers from when we 2820 * Since the queues may change, we can't use the pointers from when we
2769 * first locate it. 2821 * first locate it.
2770 * 2822 *
2771 * So, we must first locate the command, and if NCR5380_select() 2823 * So, we must first locate the command, and if NCR5380_select()
2772 * succeeds, then issue the abort, relocate the command and remove 2824 * succeeds, then issue the abort, relocate the command and remove
2773 * it from the disconnected queue. 2825 * it from the disconnected queue.
2774 */ 2826 */
2827
2828 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp;
2829 tmp = NEXT(tmp)) {
2830 if (cmd == tmp) {
2831 local_irq_restore(flags);
2832 ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
2775 2833
2776 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; 2834 if (NCR5380_select(instance, cmd, (int)cmd->tag))
2777 tmp = NEXT(tmp)) 2835 return SCSI_ABORT_BUSY;
2778 if (cmd == tmp) { 2836
2779 local_irq_restore(flags); 2837 ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
2780 ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO); 2838
2781 2839 do_abort(instance);
2782 if (NCR5380_select (instance, cmd, (int) cmd->tag)) 2840
2783 return SCSI_ABORT_BUSY; 2841 local_irq_save(flags);
2784 2842 for (prev = (Scsi_Cmnd **)&(hostdata->disconnected_queue),
2785 ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO); 2843 tmp = (Scsi_Cmnd *)hostdata->disconnected_queue;
2786 2844 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) {
2787 do_abort (instance); 2845 if (cmd == tmp) {
2788 2846 REMOVE(5, *prev, tmp, NEXT(tmp));
2789 local_irq_save(flags); 2847 *prev = NEXT(tmp);
2790 for (prev = (Scsi_Cmnd **) &(hostdata->disconnected_queue), 2848 SET_NEXT(tmp, NULL);
2791 tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; 2849 tmp->result = DID_ABORT << 16;
2792 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2850 /* We must unlock the tag/LUN immediately here, since the
2793 if (cmd == tmp) { 2851 * target goes to BUS FREE and doesn't send us another
2794 REMOVE(5, *prev, tmp, NEXT(tmp)); 2852 * message (COMMAND_COMPLETE or the like)
2795 *prev = NEXT(tmp); 2853 */
2796 NEXT(tmp) = NULL;
2797 tmp->result = DID_ABORT << 16;
2798 /* We must unlock the tag/LUN immediately here, since the
2799 * target goes to BUS FREE and doesn't send us another
2800 * message (COMMAND_COMPLETE or the like)
2801 */
2802#ifdef SUPPORT_TAGS 2854#ifdef SUPPORT_TAGS
2803 cmd_free_tag( tmp ); 2855 cmd_free_tag(tmp);
2804#else 2856#else
2805 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); 2857 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2806#endif 2858#endif
2807 local_irq_restore(flags); 2859 local_irq_restore(flags);
2808 tmp->scsi_done(tmp); 2860 tmp->scsi_done(tmp);
2809 falcon_release_lock_if_possible( hostdata ); 2861 falcon_release_lock_if_possible(hostdata);
2810 return SCSI_ABORT_SUCCESS; 2862 return SCSI_ABORT_SUCCESS;
2863 }
2864 }
2811 } 2865 }
2812 } 2866 }
2813 2867
2814/* 2868 /*
2815 * Case 5 : If we reached this point, the command was not found in any of 2869 * Case 5 : If we reached this point, the command was not found in any of
2816 * the queues. 2870 * the queues.
2817 * 2871 *
2818 * We probably reached this point because of an unlikely race condition 2872 * We probably reached this point because of an unlikely race condition
2819 * between the command completing successfully and the abortion code, 2873 * between the command completing successfully and the abortion code,
2820 * so we won't panic, but we will notify the user in case something really 2874 * so we won't panic, but we will notify the user in case something really
2821 * broke. 2875 * broke.
2822 */ 2876 */
2823 2877
2824 local_irq_restore(flags); 2878 local_irq_restore(flags);
2825 printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully\n" 2879 printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully\n"
2826 KERN_INFO " before abortion\n", HOSTNO); 2880 KERN_INFO " before abortion\n", HOSTNO);
2827 2881
2828/* Maybe it is sufficient just to release the ST-DMA lock... (if 2882 /* Maybe it is sufficient just to release the ST-DMA lock... (if
2829 * possible at all) At least, we should check if the lock could be 2883 * possible at all) At least, we should check if the lock could be
2830 * released after the abort, in case it is kept due to some bug. 2884 * released after the abort, in case it is kept due to some bug.
2831 */ 2885 */
2832 falcon_release_lock_if_possible( hostdata ); 2886 falcon_release_lock_if_possible(hostdata);
2833 2887
2834 return SCSI_ABORT_NOT_RUNNING; 2888 return SCSI_ABORT_NOT_RUNNING;
2835} 2889}
2836 2890
2837 2891
2838/* 2892/*
2839 * Function : int NCR5380_reset (Scsi_Cmnd *cmd) 2893 * Function : int NCR5380_reset (Scsi_Cmnd *cmd)
2840 * 2894 *
2841 * Purpose : reset the SCSI bus. 2895 * Purpose : reset the SCSI bus.
2842 * 2896 *
2843 * Returns : SCSI_RESET_WAKEUP 2897 * Returns : SCSI_RESET_WAKEUP
2844 * 2898 *
2845 */ 2899 */
2846 2900
2847static int NCR5380_bus_reset( Scsi_Cmnd *cmd) 2901static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
2848{ 2902{
2849 SETUP_HOSTDATA(cmd->device->host); 2903 SETUP_HOSTDATA(cmd->device->host);
2850 int i; 2904 int i;
2851 unsigned long flags; 2905 unsigned long flags;
2852#if 1 2906#if 1
2853 Scsi_Cmnd *connected, *disconnected_queue; 2907 Scsi_Cmnd *connected, *disconnected_queue;
2854#endif 2908#endif
2855 2909
2856 if (!IS_A_TT() && !falcon_got_lock) 2910 if (!IS_A_TT() && !falcon_got_lock)
2857 printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_reset\n", 2911 printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_reset\n",
2858 H_NO(cmd) ); 2912 H_NO(cmd));
2859 2913
2860 NCR5380_print_status (cmd->device->host); 2914 NCR5380_print_status(cmd->device->host);
2861 2915
2862 /* get in phase */ 2916 /* get in phase */
2863 NCR5380_write( TARGET_COMMAND_REG, 2917 NCR5380_write(TARGET_COMMAND_REG,
2864 PHASE_SR_TO_TCR( NCR5380_read(STATUS_REG) )); 2918 PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG)));
2865 /* assert RST */ 2919 /* assert RST */
2866 NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST ); 2920 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST);
2867 udelay (40); 2921 udelay(40);
2868 /* reset NCR registers */ 2922 /* reset NCR registers */
2869 NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE ); 2923 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2870 NCR5380_write( MODE_REG, MR_BASE ); 2924 NCR5380_write(MODE_REG, MR_BASE);
2871 NCR5380_write( TARGET_COMMAND_REG, 0 ); 2925 NCR5380_write(TARGET_COMMAND_REG, 0);
2872 NCR5380_write( SELECT_ENABLE_REG, 0 ); 2926 NCR5380_write(SELECT_ENABLE_REG, 0);
2873 /* ++roman: reset interrupt condition! otherwise no interrupts don't get 2927 /* ++roman: reset interrupt condition! otherwise no interrupts don't get
2874 * through anymore ... */ 2928 * through anymore ... */
2875 (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG ); 2929 (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
2876 2930
2877#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */ 2931#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */
2878 /* XXX see below XXX */ 2932 /* XXX see below XXX */
2879 2933
2880 /* MSch: old-style reset: actually abort all command processing here */ 2934 /* MSch: old-style reset: actually abort all command processing here */
2881 2935
2882 /* After the reset, there are no more connected or disconnected commands 2936 /* After the reset, there are no more connected or disconnected commands
2883 * and no busy units; to avoid problems with re-inserting the commands 2937 * and no busy units; to avoid problems with re-inserting the commands
2884 * into the issue_queue (via scsi_done()), the aborted commands are 2938 * into the issue_queue (via scsi_done()), the aborted commands are
2885 * remembered in local variables first. 2939 * remembered in local variables first.
2886 */ 2940 */
2887 local_irq_save(flags); 2941 local_irq_save(flags);
2888 connected = (Scsi_Cmnd *)hostdata->connected; 2942 connected = (Scsi_Cmnd *)hostdata->connected;
2889 hostdata->connected = NULL; 2943 hostdata->connected = NULL;
2890 disconnected_queue = (Scsi_Cmnd *)hostdata->disconnected_queue; 2944 disconnected_queue = (Scsi_Cmnd *)hostdata->disconnected_queue;
2891 hostdata->disconnected_queue = NULL; 2945 hostdata->disconnected_queue = NULL;
2892#ifdef SUPPORT_TAGS 2946#ifdef SUPPORT_TAGS
2893 free_all_tags(); 2947 free_all_tags();
2894#endif 2948#endif
2895 for( i = 0; i < 8; ++i ) 2949 for (i = 0; i < 8; ++i)
2896 hostdata->busy[i] = 0; 2950 hostdata->busy[i] = 0;
2897#ifdef REAL_DMA 2951#ifdef REAL_DMA
2898 hostdata->dma_len = 0; 2952 hostdata->dma_len = 0;
2899#endif 2953#endif
2900 local_irq_restore(flags); 2954 local_irq_restore(flags);
2901 2955
2902 /* In order to tell the mid-level code which commands were aborted, 2956 /* In order to tell the mid-level code which commands were aborted,
2903 * set the command status to DID_RESET and call scsi_done() !!! 2957 * set the command status to DID_RESET and call scsi_done() !!!
2904 * This ultimately aborts processing of these commands in the mid-level. 2958 * This ultimately aborts processing of these commands in the mid-level.
2905 */ 2959 */
2906 2960
2907 if ((cmd = connected)) { 2961 if ((cmd = connected)) {
2908 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); 2962 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd));
2909 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16); 2963 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16);
2910 cmd->scsi_done( cmd ); 2964 cmd->scsi_done(cmd);
2911 } 2965 }
2912
2913 for (i = 0; (cmd = disconnected_queue); ++i) {
2914 disconnected_queue = NEXT(cmd);
2915 NEXT(cmd) = NULL;
2916 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16);
2917 cmd->scsi_done( cmd );
2918 }
2919 if (i > 0)
2920 ABRT_PRINTK("scsi: reset aborted %d disconnected command(s)\n", i);
2921
2922/* The Falcon lock should be released after a reset...
2923 */
2924/* ++guenther: moved to atari_scsi_reset(), to prevent a race between
2925 * unlocking and enabling dma interrupt.
2926 */
2927/* falcon_release_lock_if_possible( hostdata );*/
2928 2966
2929 /* since all commands have been explicitly terminated, we need to tell 2967 for (i = 0; (cmd = disconnected_queue); ++i) {
2930 * the midlevel code that the reset was SUCCESSFUL, and there is no 2968 disconnected_queue = NEXT(cmd);
2931 * need to 'wake up' the commands by a request_sense 2969 SET_NEXT(cmd, NULL);
2932 */ 2970 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16);
2933 return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET; 2971 cmd->scsi_done(cmd);
2972 }
2973 if (i > 0)
2974 ABRT_PRINTK("scsi: reset aborted %d disconnected command(s)\n", i);
2975
2976 /* The Falcon lock should be released after a reset...
2977 */
2978 /* ++guenther: moved to atari_scsi_reset(), to prevent a race between
2979 * unlocking and enabling dma interrupt.
2980 */
2981/* falcon_release_lock_if_possible( hostdata );*/
2982
2983 /* since all commands have been explicitly terminated, we need to tell
2984 * the midlevel code that the reset was SUCCESSFUL, and there is no
2985 * need to 'wake up' the commands by a request_sense
2986 */
2987 return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
2934#else /* 1 */ 2988#else /* 1 */
2935 2989
2936 /* MSch: new-style reset handling: let the mid-level do what it can */ 2990 /* MSch: new-style reset handling: let the mid-level do what it can */
2937 2991
2938 /* ++guenther: MID-LEVEL IS STILL BROKEN. 2992 /* ++guenther: MID-LEVEL IS STILL BROKEN.
2939 * Mid-level is supposed to requeue all commands that were active on the 2993 * Mid-level is supposed to requeue all commands that were active on the
2940 * various low-level queues. In fact it does this, but that's not enough 2994 * various low-level queues. In fact it does this, but that's not enough
2941 * because all these commands are subject to timeout. And if a timeout 2995 * because all these commands are subject to timeout. And if a timeout
2942 * happens for any removed command, *_abort() is called but all queues 2996 * happens for any removed command, *_abort() is called but all queues
2943 * are now empty. Abort then gives up the falcon lock, which is fatal, 2997 * are now empty. Abort then gives up the falcon lock, which is fatal,
2944 * since the mid-level will queue more commands and must have the lock 2998 * since the mid-level will queue more commands and must have the lock
2945 * (it's all happening inside timer interrupt handler!!). 2999 * (it's all happening inside timer interrupt handler!!).
2946 * Even worse, abort will return NOT_RUNNING for all those commands not 3000 * Even worse, abort will return NOT_RUNNING for all those commands not
2947 * on any queue, so they won't be retried ... 3001 * on any queue, so they won't be retried ...
2948 * 3002 *
2949 * Conclusion: either scsi.c disables timeout for all resetted commands 3003 * Conclusion: either scsi.c disables timeout for all resetted commands
2950 * immediately, or we lose! As of linux-2.0.20 it doesn't. 3004 * immediately, or we lose! As of linux-2.0.20 it doesn't.
2951 */ 3005 */
2952 3006
2953 /* After the reset, there are no more connected or disconnected commands 3007 /* After the reset, there are no more connected or disconnected commands
2954 * and no busy units; so clear the low-level status here to avoid 3008 * and no busy units; so clear the low-level status here to avoid
2955 * conflicts when the mid-level code tries to wake up the affected 3009 * conflicts when the mid-level code tries to wake up the affected
2956 * commands! 3010 * commands!
2957 */ 3011 */
2958 3012
2959 if (hostdata->issue_queue) 3013 if (hostdata->issue_queue)
2960 ABRT_PRINTK("scsi%d: reset aborted issued command(s)\n", H_NO(cmd)); 3014 ABRT_PRINTK("scsi%d: reset aborted issued command(s)\n", H_NO(cmd));
2961 if (hostdata->connected) 3015 if (hostdata->connected)
2962 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); 3016 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd));
2963 if (hostdata->disconnected_queue) 3017 if (hostdata->disconnected_queue)
2964 ABRT_PRINTK("scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd)); 3018 ABRT_PRINTK("scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd));
2965 3019
2966 local_irq_save(flags); 3020 local_irq_save(flags);
2967 hostdata->issue_queue = NULL; 3021 hostdata->issue_queue = NULL;
2968 hostdata->connected = NULL; 3022 hostdata->connected = NULL;
2969 hostdata->disconnected_queue = NULL; 3023 hostdata->disconnected_queue = NULL;
2970#ifdef SUPPORT_TAGS 3024#ifdef SUPPORT_TAGS
2971 free_all_tags(); 3025 free_all_tags();
2972#endif 3026#endif
2973 for( i = 0; i < 8; ++i ) 3027 for (i = 0; i < 8; ++i)
2974 hostdata->busy[i] = 0; 3028 hostdata->busy[i] = 0;
2975#ifdef REAL_DMA 3029#ifdef REAL_DMA
2976 hostdata->dma_len = 0; 3030 hostdata->dma_len = 0;
2977#endif 3031#endif
2978 local_irq_restore(flags); 3032 local_irq_restore(flags);
2979 3033
2980 /* we did no complete reset of all commands, so a wakeup is required */ 3034 /* we did no complete reset of all commands, so a wakeup is required */
2981 return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET; 3035 return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
2982#endif /* 1 */ 3036#endif /* 1 */
2983} 3037}
2984
2985/* Local Variables: */
2986/* tab-width: 8 */
2987/* End: */
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index 642de7b2b7a2..6f8403b82ba1 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -69,9 +69,9 @@
69 69
70#define NDEBUG (0) 70#define NDEBUG (0)
71 71
72#define NDEBUG_ABORT 0x800000 72#define NDEBUG_ABORT 0x00100000
73#define NDEBUG_TAGS 0x1000000 73#define NDEBUG_TAGS 0x00200000
74#define NDEBUG_MERGING 0x2000000 74#define NDEBUG_MERGING 0x00400000
75 75
76#define AUTOSENSE 76#define AUTOSENSE
77/* For the Atari version, use only polled IO or REAL_DMA */ 77/* For the Atari version, use only polled IO or REAL_DMA */
@@ -186,38 +186,37 @@ static inline void DISABLE_IRQ(void)
186/***************************** Prototypes *****************************/ 186/***************************** Prototypes *****************************/
187 187
188#ifdef REAL_DMA 188#ifdef REAL_DMA
189static int scsi_dma_is_ignored_buserr( unsigned char dma_stat ); 189static int scsi_dma_is_ignored_buserr(unsigned char dma_stat);
190static void atari_scsi_fetch_restbytes( void ); 190static void atari_scsi_fetch_restbytes(void);
191static long atari_scsi_dma_residual( struct Scsi_Host *instance ); 191static long atari_scsi_dma_residual(struct Scsi_Host *instance);
192static int falcon_classify_cmd( Scsi_Cmnd *cmd ); 192static int falcon_classify_cmd(Scsi_Cmnd *cmd);
193static unsigned long atari_dma_xfer_len( unsigned long wanted_len, 193static unsigned long atari_dma_xfer_len(unsigned long wanted_len,
194 Scsi_Cmnd *cmd, int write_flag ); 194 Scsi_Cmnd *cmd, int write_flag);
195#endif 195#endif
196static irqreturn_t scsi_tt_intr( int irq, void *dummy); 196static irqreturn_t scsi_tt_intr(int irq, void *dummy);
197static irqreturn_t scsi_falcon_intr( int irq, void *dummy); 197static irqreturn_t scsi_falcon_intr(int irq, void *dummy);
198static void falcon_release_lock_if_possible( struct NCR5380_hostdata * 198static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata);
199 hostdata ); 199static void falcon_get_lock(void);
200static void falcon_get_lock( void );
201#ifdef CONFIG_ATARI_SCSI_RESET_BOOT 200#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
202static void atari_scsi_reset_boot( void ); 201static void atari_scsi_reset_boot(void);
203#endif 202#endif
204static unsigned char atari_scsi_tt_reg_read( unsigned char reg ); 203static unsigned char atari_scsi_tt_reg_read(unsigned char reg);
205static void atari_scsi_tt_reg_write( unsigned char reg, unsigned char value); 204static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value);
206static unsigned char atari_scsi_falcon_reg_read( unsigned char reg ); 205static unsigned char atari_scsi_falcon_reg_read(unsigned char reg);
207static void atari_scsi_falcon_reg_write( unsigned char reg, unsigned char value ); 206static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value);
208 207
209/************************* End of Prototypes **************************/ 208/************************* End of Prototypes **************************/
210 209
211 210
212static struct Scsi_Host *atari_scsi_host = NULL; 211static struct Scsi_Host *atari_scsi_host;
213static unsigned char (*atari_scsi_reg_read)( unsigned char reg ); 212static unsigned char (*atari_scsi_reg_read)(unsigned char reg);
214static void (*atari_scsi_reg_write)( unsigned char reg, unsigned char value ); 213static void (*atari_scsi_reg_write)(unsigned char reg, unsigned char value);
215 214
216#ifdef REAL_DMA 215#ifdef REAL_DMA
217static unsigned long atari_dma_residual, atari_dma_startaddr; 216static unsigned long atari_dma_residual, atari_dma_startaddr;
218static short atari_dma_active; 217static short atari_dma_active;
219/* pointer to the dribble buffer */ 218/* pointer to the dribble buffer */
220static char *atari_dma_buffer = NULL; 219static char *atari_dma_buffer;
221/* precalculated physical address of the dribble buffer */ 220/* precalculated physical address of the dribble buffer */
222static unsigned long atari_dma_phys_buffer; 221static unsigned long atari_dma_phys_buffer;
223/* != 0 tells the Falcon int handler to copy data from the dribble buffer */ 222/* != 0 tells the Falcon int handler to copy data from the dribble buffer */
@@ -233,7 +232,7 @@ static char *atari_dma_orig_addr;
233static unsigned long atari_dma_stram_mask; 232static unsigned long atari_dma_stram_mask;
234#define STRAM_ADDR(a) (((a) & atari_dma_stram_mask) == 0) 233#define STRAM_ADDR(a) (((a) & atari_dma_stram_mask) == 0)
235/* number of bytes to cut from a transfer to handle NCR overruns */ 234/* number of bytes to cut from a transfer to handle NCR overruns */
236static int atari_read_overruns = 0; 235static int atari_read_overruns;
237#endif 236#endif
238 237
239static int setup_can_queue = -1; 238static int setup_can_queue = -1;
@@ -256,10 +255,10 @@ module_param(setup_hostid, int, 0);
256 255
257#if defined(REAL_DMA) 256#if defined(REAL_DMA)
258 257
259static int scsi_dma_is_ignored_buserr( unsigned char dma_stat ) 258static int scsi_dma_is_ignored_buserr(unsigned char dma_stat)
260{ 259{
261 int i; 260 int i;
262 unsigned long addr = SCSI_DMA_READ_P( dma_addr ), end_addr; 261 unsigned long addr = SCSI_DMA_READ_P(dma_addr), end_addr;
263 262
264 if (dma_stat & 0x01) { 263 if (dma_stat & 0x01) {
265 264
@@ -267,15 +266,14 @@ static int scsi_dma_is_ignored_buserr( unsigned char dma_stat )
267 * physical memory chunk (DMA prefetch!), but that doesn't hurt. 266 * physical memory chunk (DMA prefetch!), but that doesn't hurt.
268 * Check for this case: 267 * Check for this case:
269 */ 268 */
270 269
271 for( i = 0; i < m68k_num_memory; ++i ) { 270 for (i = 0; i < m68k_num_memory; ++i) {
272 end_addr = m68k_memory[i].addr + 271 end_addr = m68k_memory[i].addr + m68k_memory[i].size;
273 m68k_memory[i].size;
274 if (end_addr <= addr && addr <= end_addr + 4) 272 if (end_addr <= addr && addr <= end_addr + 4)
275 return( 1 ); 273 return 1;
276 } 274 }
277 } 275 }
278 return( 0 ); 276 return 0;
279} 277}
280 278
281 279
@@ -284,28 +282,27 @@ static int scsi_dma_is_ignored_buserr( unsigned char dma_stat )
284 * end-of-DMA, both SCSI ints are triggered simultaneously, so the NCR int has 282 * end-of-DMA, both SCSI ints are triggered simultaneously, so the NCR int has
285 * to clear the DMA int pending bit before it allows other level 6 interrupts. 283 * to clear the DMA int pending bit before it allows other level 6 interrupts.
286 */ 284 */
287static void scsi_dma_buserr (int irq, void *dummy) 285static void scsi_dma_buserr(int irq, void *dummy)
288{ 286{
289 unsigned char dma_stat = tt_scsi_dma.dma_ctrl; 287 unsigned char dma_stat = tt_scsi_dma.dma_ctrl;
290 288
291 /* Don't do anything if a NCR interrupt is pending. Probably it's just 289 /* Don't do anything if a NCR interrupt is pending. Probably it's just
292 * masked... */ 290 * masked... */
293 if (atari_irq_pending( IRQ_TT_MFP_SCSI )) 291 if (atari_irq_pending(IRQ_TT_MFP_SCSI))
294 return; 292 return;
295 293
296 printk("Bad SCSI DMA interrupt! dma_addr=0x%08lx dma_stat=%02x dma_cnt=%08lx\n", 294 printk("Bad SCSI DMA interrupt! dma_addr=0x%08lx dma_stat=%02x dma_cnt=%08lx\n",
297 SCSI_DMA_READ_P(dma_addr), dma_stat, SCSI_DMA_READ_P(dma_cnt)); 295 SCSI_DMA_READ_P(dma_addr), dma_stat, SCSI_DMA_READ_P(dma_cnt));
298 if (dma_stat & 0x80) { 296 if (dma_stat & 0x80) {
299 if (!scsi_dma_is_ignored_buserr( dma_stat )) 297 if (!scsi_dma_is_ignored_buserr(dma_stat))
300 printk( "SCSI DMA bus error -- bad DMA programming!\n" ); 298 printk("SCSI DMA bus error -- bad DMA programming!\n");
301 } 299 } else {
302 else {
303 /* Under normal circumstances we never should get to this point, 300 /* Under normal circumstances we never should get to this point,
304 * since both interrupts are triggered simultaneously and the 5380 301 * since both interrupts are triggered simultaneously and the 5380
305 * int has higher priority. When this irq is handled, that DMA 302 * int has higher priority. When this irq is handled, that DMA
306 * interrupt is cleared. So a warning message is printed here. 303 * interrupt is cleared. So a warning message is printed here.
307 */ 304 */
308 printk( "SCSI DMA intr ?? -- this shouldn't happen!\n" ); 305 printk("SCSI DMA intr ?? -- this shouldn't happen!\n");
309 } 306 }
310} 307}
311#endif 308#endif
@@ -313,7 +310,7 @@ static void scsi_dma_buserr (int irq, void *dummy)
313#endif 310#endif
314 311
315 312
316static irqreturn_t scsi_tt_intr (int irq, void *dummy) 313static irqreturn_t scsi_tt_intr(int irq, void *dummy)
317{ 314{
318#ifdef REAL_DMA 315#ifdef REAL_DMA
319 int dma_stat; 316 int dma_stat;
@@ -327,7 +324,7 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy)
327 * is that a bus error occurred... 324 * is that a bus error occurred...
328 */ 325 */
329 if (dma_stat & 0x80) { 326 if (dma_stat & 0x80) {
330 if (!scsi_dma_is_ignored_buserr( dma_stat )) { 327 if (!scsi_dma_is_ignored_buserr(dma_stat)) {
331 printk(KERN_ERR "SCSI DMA caused bus error near 0x%08lx\n", 328 printk(KERN_ERR "SCSI DMA caused bus error near 0x%08lx\n",
332 SCSI_DMA_READ_P(dma_addr)); 329 SCSI_DMA_READ_P(dma_addr));
333 printk(KERN_CRIT "SCSI DMA bus error -- bad DMA programming!"); 330 printk(KERN_CRIT "SCSI DMA bus error -- bad DMA programming!");
@@ -344,8 +341,7 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy)
344 * data reg! 341 * data reg!
345 */ 342 */
346 if ((dma_stat & 0x02) && !(dma_stat & 0x40)) { 343 if ((dma_stat & 0x02) && !(dma_stat & 0x40)) {
347 atari_dma_residual = HOSTDATA_DMALEN - (SCSI_DMA_READ_P( dma_addr ) - 344 atari_dma_residual = HOSTDATA_DMALEN - (SCSI_DMA_READ_P(dma_addr) - atari_dma_startaddr);
348 atari_dma_startaddr);
349 345
350 DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n", 346 DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n",
351 atari_dma_residual); 347 atari_dma_residual);
@@ -353,28 +349,30 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy)
353 if ((signed int)atari_dma_residual < 0) 349 if ((signed int)atari_dma_residual < 0)
354 atari_dma_residual = 0; 350 atari_dma_residual = 0;
355 if ((dma_stat & 1) == 0) { 351 if ((dma_stat & 1) == 0) {
356 /* After read operations, we maybe have to 352 /*
357 transport some rest bytes */ 353 * After read operations, we maybe have to
354 * transport some rest bytes
355 */
358 atari_scsi_fetch_restbytes(); 356 atari_scsi_fetch_restbytes();
359 } 357 } else {
360 else { 358 /*
361 /* There seems to be a nasty bug in some SCSI-DMA/NCR 359 * There seems to be a nasty bug in some SCSI-DMA/NCR
362 combinations: If a target disconnects while a write 360 * combinations: If a target disconnects while a write
363 operation is going on, the address register of the 361 * operation is going on, the address register of the
364 DMA may be a few bytes farer than it actually read. 362 * DMA may be a few bytes farer than it actually read.
365 This is probably due to DMA prefetching and a delay 363 * This is probably due to DMA prefetching and a delay
366 between DMA and NCR. Experiments showed that the 364 * between DMA and NCR. Experiments showed that the
367 dma_addr is 9 bytes to high, but this could vary. 365 * dma_addr is 9 bytes to high, but this could vary.
368 The problem is, that the residual is thus calculated 366 * The problem is, that the residual is thus calculated
369 wrong and the next transfer will start behind where 367 * wrong and the next transfer will start behind where
370 it should. So we round up the residual to the next 368 * it should. So we round up the residual to the next
371 multiple of a sector size, if it isn't already a 369 * multiple of a sector size, if it isn't already a
372 multiple and the originally expected transfer size 370 * multiple and the originally expected transfer size
373 was. The latter condition is there to ensure that 371 * was. The latter condition is there to ensure that
374 the correction is taken only for "real" data 372 * the correction is taken only for "real" data
375 transfers and not for, e.g., the parameters of some 373 * transfers and not for, e.g., the parameters of some
376 other command. These shouldn't disconnect anyway. 374 * other command. These shouldn't disconnect anyway.
377 */ 375 */
378 if (atari_dma_residual & 0x1ff) { 376 if (atari_dma_residual & 0x1ff) {
379 DMA_PRINTK("SCSI DMA: DMA bug corrected, " 377 DMA_PRINTK("SCSI DMA: DMA bug corrected, "
380 "difference %ld bytes\n", 378 "difference %ld bytes\n",
@@ -394,18 +392,18 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy)
394 } 392 }
395 393
396#endif /* REAL_DMA */ 394#endif /* REAL_DMA */
397 395
398 NCR5380_intr (0, 0, 0); 396 NCR5380_intr(0, 0);
399 397
400#if 0 398#if 0
401 /* To be sure the int is not masked */ 399 /* To be sure the int is not masked */
402 atari_enable_irq( IRQ_TT_MFP_SCSI ); 400 atari_enable_irq(IRQ_TT_MFP_SCSI);
403#endif 401#endif
404 return IRQ_HANDLED; 402 return IRQ_HANDLED;
405} 403}
406 404
407 405
408static irqreturn_t scsi_falcon_intr (int irq, void *dummy) 406static irqreturn_t scsi_falcon_intr(int irq, void *dummy)
409{ 407{
410#ifdef REAL_DMA 408#ifdef REAL_DMA
411 int dma_stat; 409 int dma_stat;
@@ -430,7 +428,7 @@ static irqreturn_t scsi_falcon_intr (int irq, void *dummy)
430 * bytes are stuck in the ST-DMA fifo (there's no way to reach them!) 428 * bytes are stuck in the ST-DMA fifo (there's no way to reach them!)
431 */ 429 */
432 if (atari_dma_active && (dma_stat & 0x02)) { 430 if (atari_dma_active && (dma_stat & 0x02)) {
433 unsigned long transferred; 431 unsigned long transferred;
434 432
435 transferred = SCSI_DMA_GETADR() - atari_dma_startaddr; 433 transferred = SCSI_DMA_GETADR() - atari_dma_startaddr;
436 /* The ST-DMA address is incremented in 2-byte steps, but the 434 /* The ST-DMA address is incremented in 2-byte steps, but the
@@ -445,8 +443,7 @@ static irqreturn_t scsi_falcon_intr (int irq, void *dummy)
445 atari_dma_residual = HOSTDATA_DMALEN - transferred; 443 atari_dma_residual = HOSTDATA_DMALEN - transferred;
446 DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n", 444 DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n",
447 atari_dma_residual); 445 atari_dma_residual);
448 } 446 } else
449 else
450 atari_dma_residual = 0; 447 atari_dma_residual = 0;
451 atari_dma_active = 0; 448 atari_dma_active = 0;
452 449
@@ -461,13 +458,13 @@ static irqreturn_t scsi_falcon_intr (int irq, void *dummy)
461 458
462#endif /* REAL_DMA */ 459#endif /* REAL_DMA */
463 460
464 NCR5380_intr (0, 0, 0); 461 NCR5380_intr(0, 0);
465 return IRQ_HANDLED; 462 return IRQ_HANDLED;
466} 463}
467 464
468 465
469#ifdef REAL_DMA 466#ifdef REAL_DMA
470static void atari_scsi_fetch_restbytes( void ) 467static void atari_scsi_fetch_restbytes(void)
471{ 468{
472 int nr; 469 int nr;
473 char *src, *dst; 470 char *src, *dst;
@@ -505,19 +502,17 @@ static int falcon_dont_release = 0;
505 * again (but others waiting longer more probably will win). 502 * again (but others waiting longer more probably will win).
506 */ 503 */
507 504
508static void 505static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata)
509falcon_release_lock_if_possible( struct NCR5380_hostdata * hostdata )
510{ 506{
511 unsigned long flags; 507 unsigned long flags;
512 508
513 if (IS_A_TT()) return; 509 if (IS_A_TT())
514 510 return;
511
515 local_irq_save(flags); 512 local_irq_save(flags);
516 513
517 if (falcon_got_lock && 514 if (falcon_got_lock && !hostdata->disconnected_queue &&
518 !hostdata->disconnected_queue && 515 !hostdata->issue_queue && !hostdata->connected) {
519 !hostdata->issue_queue &&
520 !hostdata->connected) {
521 516
522 if (falcon_dont_release) { 517 if (falcon_dont_release) {
523#if 0 518#if 0
@@ -528,7 +523,7 @@ falcon_release_lock_if_possible( struct NCR5380_hostdata * hostdata )
528 } 523 }
529 falcon_got_lock = 0; 524 falcon_got_lock = 0;
530 stdma_release(); 525 stdma_release();
531 wake_up( &falcon_fairness_wait ); 526 wake_up(&falcon_fairness_wait);
532 } 527 }
533 528
534 local_irq_restore(flags); 529 local_irq_restore(flags);
@@ -549,31 +544,31 @@ falcon_release_lock_if_possible( struct NCR5380_hostdata * hostdata )
549 * Complicated, complicated.... Sigh... 544 * Complicated, complicated.... Sigh...
550 */ 545 */
551 546
552static void falcon_get_lock( void ) 547static void falcon_get_lock(void)
553{ 548{
554 unsigned long flags; 549 unsigned long flags;
555 550
556 if (IS_A_TT()) return; 551 if (IS_A_TT())
552 return;
557 553
558 local_irq_save(flags); 554 local_irq_save(flags);
559 555
560 while( !in_interrupt() && falcon_got_lock && stdma_others_waiting() ) 556 while (!in_irq() && falcon_got_lock && stdma_others_waiting())
561 sleep_on( &falcon_fairness_wait ); 557 sleep_on(&falcon_fairness_wait);
562 558
563 while (!falcon_got_lock) { 559 while (!falcon_got_lock) {
564 if (in_interrupt()) 560 if (in_irq())
565 panic( "Falcon SCSI hasn't ST-DMA lock in interrupt" ); 561 panic("Falcon SCSI hasn't ST-DMA lock in interrupt");
566 if (!falcon_trying_lock) { 562 if (!falcon_trying_lock) {
567 falcon_trying_lock = 1; 563 falcon_trying_lock = 1;
568 stdma_lock(scsi_falcon_intr, NULL); 564 stdma_lock(scsi_falcon_intr, NULL);
569 falcon_got_lock = 1; 565 falcon_got_lock = 1;
570 falcon_trying_lock = 0; 566 falcon_trying_lock = 0;
571 wake_up( &falcon_try_wait ); 567 wake_up(&falcon_try_wait);
572 } 568 } else {
573 else { 569 sleep_on(&falcon_try_wait);
574 sleep_on( &falcon_try_wait );
575 } 570 }
576 } 571 }
577 572
578 local_irq_restore(flags); 573 local_irq_restore(flags);
579 if (!falcon_got_lock) 574 if (!falcon_got_lock)
@@ -587,18 +582,18 @@ static void falcon_get_lock( void )
587 */ 582 */
588 583
589#if 0 584#if 0
590int atari_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) 585int atari_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
591{ 586{
592 /* falcon_get_lock(); 587 /* falcon_get_lock();
593 * ++guenther: moved to NCR5380_queue_command() to prevent 588 * ++guenther: moved to NCR5380_queue_command() to prevent
594 * race condition, see there for an explanation. 589 * race condition, see there for an explanation.
595 */ 590 */
596 return( NCR5380_queue_command( cmd, done ) ); 591 return NCR5380_queue_command(cmd, done);
597} 592}
598#endif 593#endif
599 594
600 595
601int atari_scsi_detect (struct scsi_host_template *host) 596int atari_scsi_detect(struct scsi_host_template *host)
602{ 597{
603 static int called = 0; 598 static int called = 0;
604 struct Scsi_Host *instance; 599 struct Scsi_Host *instance;
@@ -606,7 +601,7 @@ int atari_scsi_detect (struct scsi_host_template *host)
606 if (!MACH_IS_ATARI || 601 if (!MACH_IS_ATARI ||
607 (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) || 602 (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) ||
608 called) 603 called)
609 return( 0 ); 604 return 0;
610 605
611 host->proc_name = "Atari"; 606 host->proc_name = "Atari";
612 607
@@ -655,32 +650,33 @@ int atari_scsi_detect (struct scsi_host_template *host)
655 !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) { 650 !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) {
656 atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI"); 651 atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
657 if (!atari_dma_buffer) { 652 if (!atari_dma_buffer) {
658 printk( KERN_ERR "atari_scsi_detect: can't allocate ST-RAM " 653 printk(KERN_ERR "atari_scsi_detect: can't allocate ST-RAM "
659 "double buffer\n" ); 654 "double buffer\n");
660 return( 0 ); 655 return 0;
661 } 656 }
662 atari_dma_phys_buffer = virt_to_phys( atari_dma_buffer ); 657 atari_dma_phys_buffer = virt_to_phys(atari_dma_buffer);
663 atari_dma_orig_addr = 0; 658 atari_dma_orig_addr = 0;
664 } 659 }
665#endif 660#endif
666 instance = scsi_register (host, sizeof (struct NCR5380_hostdata)); 661 instance = scsi_register(host, sizeof(struct NCR5380_hostdata));
667 if(instance == NULL) 662 if (instance == NULL) {
668 {
669 atari_stram_free(atari_dma_buffer); 663 atari_stram_free(atari_dma_buffer);
670 atari_dma_buffer = 0; 664 atari_dma_buffer = 0;
671 return 0; 665 return 0;
672 } 666 }
673 atari_scsi_host = instance; 667 atari_scsi_host = instance;
674 /* Set irq to 0, to avoid that the mid-level code disables our interrupt 668 /*
675 * during queue_command calls. This is completely unnecessary, and even 669 * Set irq to 0, to avoid that the mid-level code disables our interrupt
676 * worse causes bad problems on the Falcon, where the int is shared with 670 * during queue_command calls. This is completely unnecessary, and even
677 * IDE and floppy! */ 671 * worse causes bad problems on the Falcon, where the int is shared with
672 * IDE and floppy!
673 */
678 instance->irq = 0; 674 instance->irq = 0;
679 675
680#ifdef CONFIG_ATARI_SCSI_RESET_BOOT 676#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
681 atari_scsi_reset_boot(); 677 atari_scsi_reset_boot();
682#endif 678#endif
683 NCR5380_init (instance, 0); 679 NCR5380_init(instance, 0);
684 680
685 if (IS_A_TT()) { 681 if (IS_A_TT()) {
686 682
@@ -727,11 +723,10 @@ int atari_scsi_detect (struct scsi_host_template *host)
727 * the rest data bug is fixed, this can be lowered to 1. 723 * the rest data bug is fixed, this can be lowered to 1.
728 */ 724 */
729 atari_read_overruns = 4; 725 atari_read_overruns = 4;
730 } 726 }
731#endif /*REAL_DMA*/ 727#endif /*REAL_DMA*/
732 } 728 } else { /* ! IS_A_TT */
733 else { /* ! IS_A_TT */ 729
734
735 /* Nothing to do for the interrupt: the ST-DMA is initialized 730 /* Nothing to do for the interrupt: the ST-DMA is initialized
736 * already by atari_init_INTS() 731 * already by atari_init_INTS()
737 */ 732 */
@@ -756,23 +751,21 @@ int atari_scsi_detect (struct scsi_host_template *host)
756 setup_use_tagged_queuing ? "yes" : "no", 751 setup_use_tagged_queuing ? "yes" : "no",
757#endif 752#endif
758 instance->hostt->this_id ); 753 instance->hostt->this_id );
759 NCR5380_print_options (instance); 754 NCR5380_print_options(instance);
760 printk ("\n"); 755 printk("\n");
761 756
762 called = 1; 757 called = 1;
763 return( 1 ); 758 return 1;
764} 759}
765 760
766#ifdef MODULE 761int atari_scsi_release(struct Scsi_Host *sh)
767int atari_scsi_release (struct Scsi_Host *sh)
768{ 762{
769 if (IS_A_TT()) 763 if (IS_A_TT())
770 free_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr); 764 free_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr);
771 if (atari_dma_buffer) 765 if (atari_dma_buffer)
772 atari_stram_free (atari_dma_buffer); 766 atari_stram_free(atari_dma_buffer);
773 return 1; 767 return 1;
774} 768}
775#endif
776 769
777void __init atari_scsi_setup(char *str, int *ints) 770void __init atari_scsi_setup(char *str, int *ints)
778{ 771{
@@ -781,9 +774,9 @@ void __init atari_scsi_setup(char *str, int *ints)
781 * Defaults depend on TT or Falcon, hostid determined at run time. 774 * Defaults depend on TT or Falcon, hostid determined at run time.
782 * Negative values mean don't change. 775 * Negative values mean don't change.
783 */ 776 */
784 777
785 if (ints[0] < 1) { 778 if (ints[0] < 1) {
786 printk( "atari_scsi_setup: no arguments!\n" ); 779 printk("atari_scsi_setup: no arguments!\n");
787 return; 780 return;
788 } 781 }
789 782
@@ -809,7 +802,7 @@ void __init atari_scsi_setup(char *str, int *ints)
809 if (ints[4] >= 0 && ints[4] <= 7) 802 if (ints[4] >= 0 && ints[4] <= 7)
810 setup_hostid = ints[4]; 803 setup_hostid = ints[4];
811 else if (ints[4] > 7) 804 else if (ints[4] > 7)
812 printk( "atari_scsi_setup: invalid host ID %d !\n", ints[4] ); 805 printk("atari_scsi_setup: invalid host ID %d !\n", ints[4]);
813 } 806 }
814#ifdef SUPPORT_TAGS 807#ifdef SUPPORT_TAGS
815 if (ints[0] >= 5) { 808 if (ints[0] >= 5) {
@@ -821,7 +814,7 @@ void __init atari_scsi_setup(char *str, int *ints)
821 814
822int atari_scsi_bus_reset(Scsi_Cmnd *cmd) 815int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
823{ 816{
824 int rv; 817 int rv;
825 struct NCR5380_hostdata *hostdata = 818 struct NCR5380_hostdata *hostdata =
826 (struct NCR5380_hostdata *)cmd->device->host->hostdata; 819 (struct NCR5380_hostdata *)cmd->device->host->hostdata;
827 820
@@ -831,13 +824,12 @@ int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
831 */ 824 */
832 /* And abort a maybe active DMA transfer */ 825 /* And abort a maybe active DMA transfer */
833 if (IS_A_TT()) { 826 if (IS_A_TT()) {
834 atari_turnoff_irq( IRQ_TT_MFP_SCSI ); 827 atari_turnoff_irq(IRQ_TT_MFP_SCSI);
835#ifdef REAL_DMA 828#ifdef REAL_DMA
836 tt_scsi_dma.dma_ctrl = 0; 829 tt_scsi_dma.dma_ctrl = 0;
837#endif /* REAL_DMA */ 830#endif /* REAL_DMA */
838 } 831 } else {
839 else { 832 atari_turnoff_irq(IRQ_MFP_FSCSI);
840 atari_turnoff_irq( IRQ_MFP_FSCSI );
841#ifdef REAL_DMA 833#ifdef REAL_DMA
842 st_dma.dma_mode_status = 0x90; 834 st_dma.dma_mode_status = 0x90;
843 atari_dma_active = 0; 835 atari_dma_active = 0;
@@ -849,52 +841,51 @@ int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
849 841
850 /* Re-enable ints */ 842 /* Re-enable ints */
851 if (IS_A_TT()) { 843 if (IS_A_TT()) {
852 atari_turnon_irq( IRQ_TT_MFP_SCSI ); 844 atari_turnon_irq(IRQ_TT_MFP_SCSI);
853 } 845 } else {
854 else { 846 atari_turnon_irq(IRQ_MFP_FSCSI);
855 atari_turnon_irq( IRQ_MFP_FSCSI );
856 } 847 }
857 if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS) 848 if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
858 falcon_release_lock_if_possible(hostdata); 849 falcon_release_lock_if_possible(hostdata);
859 850
860 return( rv ); 851 return rv;
861} 852}
862 853
863 854
864#ifdef CONFIG_ATARI_SCSI_RESET_BOOT 855#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
865static void __init atari_scsi_reset_boot(void) 856static void __init atari_scsi_reset_boot(void)
866{ 857{
867 unsigned long end; 858 unsigned long end;
868 859
869 /* 860 /*
870 * Do a SCSI reset to clean up the bus during initialization. No messing 861 * Do a SCSI reset to clean up the bus during initialization. No messing
871 * with the queues, interrupts, or locks necessary here. 862 * with the queues, interrupts, or locks necessary here.
872 */ 863 */
873 864
874 printk( "Atari SCSI: resetting the SCSI bus..." ); 865 printk("Atari SCSI: resetting the SCSI bus...");
875 866
876 /* get in phase */ 867 /* get in phase */
877 NCR5380_write( TARGET_COMMAND_REG, 868 NCR5380_write(TARGET_COMMAND_REG,
878 PHASE_SR_TO_TCR( NCR5380_read(STATUS_REG) )); 869 PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG)));
879 870
880 /* assert RST */ 871 /* assert RST */
881 NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST ); 872 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST);
882 /* The min. reset hold time is 25us, so 40us should be enough */ 873 /* The min. reset hold time is 25us, so 40us should be enough */
883 udelay( 50 ); 874 udelay(50);
884 /* reset RST and interrupt */ 875 /* reset RST and interrupt */
885 NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE ); 876 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
886 NCR5380_read( RESET_PARITY_INTERRUPT_REG ); 877 NCR5380_read(RESET_PARITY_INTERRUPT_REG);
887 878
888 end = jiffies + AFTER_RESET_DELAY; 879 end = jiffies + AFTER_RESET_DELAY;
889 while (time_before(jiffies, end)) 880 while (time_before(jiffies, end))
890 barrier(); 881 barrier();
891 882
892 printk( " done\n" ); 883 printk(" done\n");
893} 884}
894#endif 885#endif
895 886
896 887
897const char * atari_scsi_info (struct Scsi_Host *host) 888const char *atari_scsi_info(struct Scsi_Host *host)
898{ 889{
899 /* atari_scsi_detect() is verbose enough... */ 890 /* atari_scsi_detect() is verbose enough... */
900 static const char string[] = "Atari native SCSI"; 891 static const char string[] = "Atari native SCSI";
@@ -904,10 +895,10 @@ const char * atari_scsi_info (struct Scsi_Host *host)
904 895
905#if defined(REAL_DMA) 896#if defined(REAL_DMA)
906 897
907unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data, 898unsigned long atari_scsi_dma_setup(struct Scsi_Host *instance, void *data,
908 unsigned long count, int dir ) 899 unsigned long count, int dir)
909{ 900{
910 unsigned long addr = virt_to_phys( data ); 901 unsigned long addr = virt_to_phys(data);
911 902
912 DMA_PRINTK("scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, " 903 DMA_PRINTK("scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, "
913 "dir = %d\n", instance->host_no, data, addr, count, dir); 904 "dir = %d\n", instance->host_no, data, addr, count, dir);
@@ -919,38 +910,37 @@ unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data,
919 * wanted address. 910 * wanted address.
920 */ 911 */
921 if (dir) 912 if (dir)
922 memcpy( atari_dma_buffer, data, count ); 913 memcpy(atari_dma_buffer, data, count);
923 else 914 else
924 atari_dma_orig_addr = data; 915 atari_dma_orig_addr = data;
925 addr = atari_dma_phys_buffer; 916 addr = atari_dma_phys_buffer;
926 } 917 }
927 918
928 atari_dma_startaddr = addr; /* Needed for calculating residual later. */ 919 atari_dma_startaddr = addr; /* Needed for calculating residual later. */
929 920
930 /* Cache cleanup stuff: On writes, push any dirty cache out before sending 921 /* Cache cleanup stuff: On writes, push any dirty cache out before sending
931 * it to the peripheral. (Must be done before DMA setup, since at least 922 * it to the peripheral. (Must be done before DMA setup, since at least
932 * the ST-DMA begins to fill internal buffers right after setup. For 923 * the ST-DMA begins to fill internal buffers right after setup. For
933 * reads, invalidate any cache, may be altered after DMA without CPU 924 * reads, invalidate any cache, may be altered after DMA without CPU
934 * knowledge. 925 * knowledge.
935 * 926 *
936 * ++roman: For the Medusa, there's no need at all for that cache stuff, 927 * ++roman: For the Medusa, there's no need at all for that cache stuff,
937 * because the hardware does bus snooping (fine!). 928 * because the hardware does bus snooping (fine!).
938 */ 929 */
939 dma_cache_maintenance( addr, count, dir ); 930 dma_cache_maintenance(addr, count, dir);
940 931
941 if (count == 0) 932 if (count == 0)
942 printk(KERN_NOTICE "SCSI warning: DMA programmed for 0 bytes !\n"); 933 printk(KERN_NOTICE "SCSI warning: DMA programmed for 0 bytes !\n");
943 934
944 if (IS_A_TT()) { 935 if (IS_A_TT()) {
945 tt_scsi_dma.dma_ctrl = dir; 936 tt_scsi_dma.dma_ctrl = dir;
946 SCSI_DMA_WRITE_P( dma_addr, addr ); 937 SCSI_DMA_WRITE_P(dma_addr, addr);
947 SCSI_DMA_WRITE_P( dma_cnt, count ); 938 SCSI_DMA_WRITE_P(dma_cnt, count);
948 tt_scsi_dma.dma_ctrl = dir | 2; 939 tt_scsi_dma.dma_ctrl = dir | 2;
949 } 940 } else { /* ! IS_A_TT */
950 else { /* ! IS_A_TT */ 941
951
952 /* set address */ 942 /* set address */
953 SCSI_DMA_SETADR( addr ); 943 SCSI_DMA_SETADR(addr);
954 944
955 /* toggle direction bit to clear FIFO and set DMA direction */ 945 /* toggle direction bit to clear FIFO and set DMA direction */
956 dir <<= 8; 946 dir <<= 8;
@@ -968,13 +958,13 @@ unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data,
968 atari_dma_active = 1; 958 atari_dma_active = 1;
969 } 959 }
970 960
971 return( count ); 961 return count;
972} 962}
973 963
974 964
975static long atari_scsi_dma_residual( struct Scsi_Host *instance ) 965static long atari_scsi_dma_residual(struct Scsi_Host *instance)
976{ 966{
977 return( atari_dma_residual ); 967 return atari_dma_residual;
978} 968}
979 969
980 970
@@ -982,13 +972,13 @@ static long atari_scsi_dma_residual( struct Scsi_Host *instance )
982#define CMD_SURELY_BYTE_MODE 1 972#define CMD_SURELY_BYTE_MODE 1
983#define CMD_MODE_UNKNOWN 2 973#define CMD_MODE_UNKNOWN 2
984 974
985static int falcon_classify_cmd( Scsi_Cmnd *cmd ) 975static int falcon_classify_cmd(Scsi_Cmnd *cmd)
986{ 976{
987 unsigned char opcode = cmd->cmnd[0]; 977 unsigned char opcode = cmd->cmnd[0];
988 978
989 if (opcode == READ_DEFECT_DATA || opcode == READ_LONG || 979 if (opcode == READ_DEFECT_DATA || opcode == READ_LONG ||
990 opcode == READ_BUFFER) 980 opcode == READ_BUFFER)
991 return( CMD_SURELY_BYTE_MODE ); 981 return CMD_SURELY_BYTE_MODE;
992 else if (opcode == READ_6 || opcode == READ_10 || 982 else if (opcode == READ_6 || opcode == READ_10 ||
993 opcode == 0xa8 /* READ_12 */ || opcode == READ_REVERSE || 983 opcode == 0xa8 /* READ_12 */ || opcode == READ_REVERSE ||
994 opcode == RECOVER_BUFFERED_DATA) { 984 opcode == RECOVER_BUFFERED_DATA) {
@@ -996,12 +986,11 @@ static int falcon_classify_cmd( Scsi_Cmnd *cmd )
996 * needed here: The transfer is block-mode only if the 'fixed' bit is 986 * needed here: The transfer is block-mode only if the 'fixed' bit is
997 * set! */ 987 * set! */
998 if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1)) 988 if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1))
999 return( CMD_SURELY_BYTE_MODE ); 989 return CMD_SURELY_BYTE_MODE;
1000 else 990 else
1001 return( CMD_SURELY_BLOCK_MODE ); 991 return CMD_SURELY_BLOCK_MODE;
1002 } 992 } else
1003 else 993 return CMD_MODE_UNKNOWN;
1004 return( CMD_MODE_UNKNOWN );
1005} 994}
1006 995
1007 996
@@ -1014,19 +1003,18 @@ static int falcon_classify_cmd( Scsi_Cmnd *cmd )
1014 * the overrun problem, so this question is academic :-) 1003 * the overrun problem, so this question is academic :-)
1015 */ 1004 */
1016 1005
1017static unsigned long atari_dma_xfer_len( unsigned long wanted_len, 1006static unsigned long atari_dma_xfer_len(unsigned long wanted_len,
1018 Scsi_Cmnd *cmd, 1007 Scsi_Cmnd *cmd, int write_flag)
1019 int write_flag )
1020{ 1008{
1021 unsigned long possible_len, limit; 1009 unsigned long possible_len, limit;
1022#ifndef CONFIG_TT_DMA_EMUL 1010#ifndef CONFIG_TT_DMA_EMUL
1023 if (MACH_IS_HADES) 1011 if (MACH_IS_HADES)
1024 /* Hades has no SCSI DMA at all :-( Always force use of PIO */ 1012 /* Hades has no SCSI DMA at all :-( Always force use of PIO */
1025 return( 0 ); 1013 return 0;
1026#endif 1014#endif
1027 if (IS_A_TT()) 1015 if (IS_A_TT())
1028 /* TT SCSI DMA can transfer arbitrary #bytes */ 1016 /* TT SCSI DMA can transfer arbitrary #bytes */
1029 return( wanted_len ); 1017 return wanted_len;
1030 1018
1031 /* ST DMA chip is stupid -- only multiples of 512 bytes! (and max. 1019 /* ST DMA chip is stupid -- only multiples of 512 bytes! (and max.
1032 * 255*512 bytes, but this should be enough) 1020 * 255*512 bytes, but this should be enough)
@@ -1062,8 +1050,7 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len,
1062 * this). 1050 * this).
1063 */ 1051 */
1064 possible_len = wanted_len; 1052 possible_len = wanted_len;
1065 } 1053 } else {
1066 else {
1067 /* Read operations: if the wanted transfer length is not a multiple of 1054 /* Read operations: if the wanted transfer length is not a multiple of
1068 * 512, we cannot use DMA, since the ST-DMA cannot split transfers 1055 * 512, we cannot use DMA, since the ST-DMA cannot split transfers
1069 * (no interrupt on DMA finished!) 1056 * (no interrupt on DMA finished!)
@@ -1073,15 +1060,15 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len,
1073 else { 1060 else {
1074 /* Now classify the command (see above) and decide whether it is 1061 /* Now classify the command (see above) and decide whether it is
1075 * allowed to do DMA at all */ 1062 * allowed to do DMA at all */
1076 switch( falcon_classify_cmd( cmd )) { 1063 switch (falcon_classify_cmd(cmd)) {
1077 case CMD_SURELY_BLOCK_MODE: 1064 case CMD_SURELY_BLOCK_MODE:
1078 possible_len = wanted_len; 1065 possible_len = wanted_len;
1079 break; 1066 break;
1080 case CMD_SURELY_BYTE_MODE: 1067 case CMD_SURELY_BYTE_MODE:
1081 possible_len = 0; /* DMA prohibited */ 1068 possible_len = 0; /* DMA prohibited */
1082 break; 1069 break;
1083 case CMD_MODE_UNKNOWN: 1070 case CMD_MODE_UNKNOWN:
1084 default: 1071 default:
1085 /* For unknown commands assume block transfers if the transfer 1072 /* For unknown commands assume block transfers if the transfer
1086 * size/allocation length is >= 1024 */ 1073 * size/allocation length is >= 1024 */
1087 possible_len = (wanted_len < 1024) ? 0 : wanted_len; 1074 possible_len = (wanted_len < 1024) ? 0 : wanted_len;
@@ -1089,9 +1076,9 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len,
1089 } 1076 }
1090 } 1077 }
1091 } 1078 }
1092 1079
1093 /* Last step: apply the hard limit on DMA transfers */ 1080 /* Last step: apply the hard limit on DMA transfers */
1094 limit = (atari_dma_buffer && !STRAM_ADDR( virt_to_phys(cmd->SCp.ptr) )) ? 1081 limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(cmd->SCp.ptr))) ?
1095 STRAM_BUFFER_SIZE : 255*512; 1082 STRAM_BUFFER_SIZE : 255*512;
1096 if (possible_len > limit) 1083 if (possible_len > limit)
1097 possible_len = limit; 1084 possible_len = limit;
@@ -1100,7 +1087,7 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len,
1100 DMA_PRINTK("Sorry, must cut DMA transfer size to %ld bytes " 1087 DMA_PRINTK("Sorry, must cut DMA transfer size to %ld bytes "
1101 "instead of %ld\n", possible_len, wanted_len); 1088 "instead of %ld\n", possible_len, wanted_len);
1102 1089
1103 return( possible_len ); 1090 return possible_len;
1104} 1091}
1105 1092
1106 1093
@@ -1114,23 +1101,23 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len,
1114 * NCR5380_write call these functions via function pointers. 1101 * NCR5380_write call these functions via function pointers.
1115 */ 1102 */
1116 1103
1117static unsigned char atari_scsi_tt_reg_read( unsigned char reg ) 1104static unsigned char atari_scsi_tt_reg_read(unsigned char reg)
1118{ 1105{
1119 return( tt_scsi_regp[reg * 2] ); 1106 return tt_scsi_regp[reg * 2];
1120} 1107}
1121 1108
1122static void atari_scsi_tt_reg_write( unsigned char reg, unsigned char value ) 1109static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value)
1123{ 1110{
1124 tt_scsi_regp[reg * 2] = value; 1111 tt_scsi_regp[reg * 2] = value;
1125} 1112}
1126 1113
1127static unsigned char atari_scsi_falcon_reg_read( unsigned char reg ) 1114static unsigned char atari_scsi_falcon_reg_read(unsigned char reg)
1128{ 1115{
1129 dma_wd.dma_mode_status= (u_short)(0x88 + reg); 1116 dma_wd.dma_mode_status= (u_short)(0x88 + reg);
1130 return( (u_char)dma_wd.fdc_acces_seccount ); 1117 return (u_char)dma_wd.fdc_acces_seccount;
1131} 1118}
1132 1119
1133static void atari_scsi_falcon_reg_write( unsigned char reg, unsigned char value ) 1120static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value)
1134{ 1121{
1135 dma_wd.dma_mode_status = (u_short)(0x88 + reg); 1122 dma_wd.dma_mode_status = (u_short)(0x88 + reg);
1136 dma_wd.fdc_acces_seccount = (u_short)value; 1123 dma_wd.fdc_acces_seccount = (u_short)value;
diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h
index f917bdd09b41..efadb8d567c2 100644
--- a/drivers/scsi/atari_scsi.h
+++ b/drivers/scsi/atari_scsi.h
@@ -21,11 +21,7 @@
21int atari_scsi_detect (struct scsi_host_template *); 21int atari_scsi_detect (struct scsi_host_template *);
22const char *atari_scsi_info (struct Scsi_Host *); 22const char *atari_scsi_info (struct Scsi_Host *);
23int atari_scsi_reset (Scsi_Cmnd *, unsigned int); 23int atari_scsi_reset (Scsi_Cmnd *, unsigned int);
24#ifdef MODULE
25int atari_scsi_release (struct Scsi_Host *); 24int atari_scsi_release (struct Scsi_Host *);
26#else
27#define atari_scsi_release NULL
28#endif
29 25
30/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. Higher 26/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. Higher
31 * values should work, too; try it! (but cmd_per_lun costs memory!) */ 27 * values should work, too; try it! (but cmd_per_lun costs memory!) */
@@ -63,6 +59,32 @@ int atari_scsi_release (struct Scsi_Host *);
63#define NCR5380_dma_xfer_len(i,cmd,phase) \ 59#define NCR5380_dma_xfer_len(i,cmd,phase) \
64 atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1) 60 atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
65 61
62/* former generic SCSI error handling stuff */
63
64#define SCSI_ABORT_SNOOZE 0
65#define SCSI_ABORT_SUCCESS 1
66#define SCSI_ABORT_PENDING 2
67#define SCSI_ABORT_BUSY 3
68#define SCSI_ABORT_NOT_RUNNING 4
69#define SCSI_ABORT_ERROR 5
70
71#define SCSI_RESET_SNOOZE 0
72#define SCSI_RESET_PUNT 1
73#define SCSI_RESET_SUCCESS 2
74#define SCSI_RESET_PENDING 3
75#define SCSI_RESET_WAKEUP 4
76#define SCSI_RESET_NOT_RUNNING 5
77#define SCSI_RESET_ERROR 6
78
79#define SCSI_RESET_SYNCHRONOUS 0x01
80#define SCSI_RESET_ASYNCHRONOUS 0x02
81#define SCSI_RESET_SUGGEST_BUS_RESET 0x04
82#define SCSI_RESET_SUGGEST_HOST_RESET 0x08
83
84#define SCSI_RESET_BUS_RESET 0x100
85#define SCSI_RESET_HOST_RESET 0x200
86#define SCSI_RESET_ACTION 0xff
87
66/* Debugging printk definitions: 88/* Debugging printk definitions:
67 * 89 *
68 * ARB -> arbitration 90 * ARB -> arbitration
@@ -91,144 +113,58 @@ int atari_scsi_release (struct Scsi_Host *);
91 * 113 *
92 */ 114 */
93 115
94#if NDEBUG & NDEBUG_ARBITRATION 116#define dprint(flg, format...) \
117({ \
118 if (NDEBUG & (flg)) \
119 printk(KERN_DEBUG format); \
120})
121
95#define ARB_PRINTK(format, args...) \ 122#define ARB_PRINTK(format, args...) \
96 printk(KERN_DEBUG format , ## args) 123 dprint(NDEBUG_ARBITRATION, format , ## args)
97#else
98#define ARB_PRINTK(format, args...)
99#endif
100#if NDEBUG & NDEBUG_AUTOSENSE
101#define ASEN_PRINTK(format, args...) \ 124#define ASEN_PRINTK(format, args...) \
102 printk(KERN_DEBUG format , ## args) 125 dprint(NDEBUG_AUTOSENSE, format , ## args)
103#else
104#define ASEN_PRINTK(format, args...)
105#endif
106#if NDEBUG & NDEBUG_DMA
107#define DMA_PRINTK(format, args...) \ 126#define DMA_PRINTK(format, args...) \
108 printk(KERN_DEBUG format , ## args) 127 dprint(NDEBUG_DMA, format , ## args)
109#else
110#define DMA_PRINTK(format, args...)
111#endif
112#if NDEBUG & NDEBUG_HANDSHAKE
113#define HSH_PRINTK(format, args...) \ 128#define HSH_PRINTK(format, args...) \
114 printk(KERN_DEBUG format , ## args) 129 dprint(NDEBUG_HANDSHAKE, format , ## args)
115#else
116#define HSH_PRINTK(format, args...)
117#endif
118#if NDEBUG & NDEBUG_INFORMATION
119#define INF_PRINTK(format, args...) \ 130#define INF_PRINTK(format, args...) \
120 printk(KERN_DEBUG format , ## args) 131 dprint(NDEBUG_INFORMATION, format , ## args)
121#else
122#define INF_PRINTK(format, args...)
123#endif
124#if NDEBUG & NDEBUG_INIT
125#define INI_PRINTK(format, args...) \ 132#define INI_PRINTK(format, args...) \
126 printk(KERN_DEBUG format , ## args) 133 dprint(NDEBUG_INIT, format , ## args)
127#else
128#define INI_PRINTK(format, args...)
129#endif
130#if NDEBUG & NDEBUG_INTR
131#define INT_PRINTK(format, args...) \ 134#define INT_PRINTK(format, args...) \
132 printk(KERN_DEBUG format , ## args) 135 dprint(NDEBUG_INTR, format , ## args)
133#else
134#define INT_PRINTK(format, args...)
135#endif
136#if NDEBUG & NDEBUG_LINKED
137#define LNK_PRINTK(format, args...) \ 136#define LNK_PRINTK(format, args...) \
138 printk(KERN_DEBUG format , ## args) 137 dprint(NDEBUG_LINKED, format , ## args)
139#else
140#define LNK_PRINTK(format, args...)
141#endif
142#if NDEBUG & NDEBUG_MAIN
143#define MAIN_PRINTK(format, args...) \ 138#define MAIN_PRINTK(format, args...) \
144 printk(KERN_DEBUG format , ## args) 139 dprint(NDEBUG_MAIN, format , ## args)
145#else
146#define MAIN_PRINTK(format, args...)
147#endif
148#if NDEBUG & NDEBUG_NO_DATAOUT
149#define NDAT_PRINTK(format, args...) \ 140#define NDAT_PRINTK(format, args...) \
150 printk(KERN_DEBUG format , ## args) 141 dprint(NDEBUG_NO_DATAOUT, format , ## args)
151#else
152#define NDAT_PRINTK(format, args...)
153#endif
154#if NDEBUG & NDEBUG_NO_WRITE
155#define NWR_PRINTK(format, args...) \ 142#define NWR_PRINTK(format, args...) \
156 printk(KERN_DEBUG format , ## args) 143 dprint(NDEBUG_NO_WRITE, format , ## args)
157#else
158#define NWR_PRINTK(format, args...)
159#endif
160#if NDEBUG & NDEBUG_PIO
161#define PIO_PRINTK(format, args...) \ 144#define PIO_PRINTK(format, args...) \
162 printk(KERN_DEBUG format , ## args) 145 dprint(NDEBUG_PIO, format , ## args)
163#else
164#define PIO_PRINTK(format, args...)
165#endif
166#if NDEBUG & NDEBUG_PSEUDO_DMA
167#define PDMA_PRINTK(format, args...) \ 146#define PDMA_PRINTK(format, args...) \
168 printk(KERN_DEBUG format , ## args) 147 dprint(NDEBUG_PSEUDO_DMA, format , ## args)
169#else
170#define PDMA_PRINTK(format, args...)
171#endif
172#if NDEBUG & NDEBUG_QUEUES
173#define QU_PRINTK(format, args...) \ 148#define QU_PRINTK(format, args...) \
174 printk(KERN_DEBUG format , ## args) 149 dprint(NDEBUG_QUEUES, format , ## args)
175#else
176#define QU_PRINTK(format, args...)
177#endif
178#if NDEBUG & NDEBUG_RESELECTION
179#define RSL_PRINTK(format, args...) \ 150#define RSL_PRINTK(format, args...) \
180 printk(KERN_DEBUG format , ## args) 151 dprint(NDEBUG_RESELECTION, format , ## args)
181#else
182#define RSL_PRINTK(format, args...)
183#endif
184#if NDEBUG & NDEBUG_SELECTION
185#define SEL_PRINTK(format, args...) \ 152#define SEL_PRINTK(format, args...) \
186 printk(KERN_DEBUG format , ## args) 153 dprint(NDEBUG_SELECTION, format , ## args)
187#else
188#define SEL_PRINTK(format, args...)
189#endif
190#if NDEBUG & NDEBUG_USLEEP
191#define USL_PRINTK(format, args...) \ 154#define USL_PRINTK(format, args...) \
192 printk(KERN_DEBUG format , ## args) 155 dprint(NDEBUG_USLEEP, format , ## args)
193#else
194#define USL_PRINTK(format, args...)
195#endif
196#if NDEBUG & NDEBUG_LAST_BYTE_SENT
197#define LBS_PRINTK(format, args...) \ 156#define LBS_PRINTK(format, args...) \
198 printk(KERN_DEBUG format , ## args) 157 dprint(NDEBUG_LAST_BYTE_SENT, format , ## args)
199#else
200#define LBS_PRINTK(format, args...)
201#endif
202#if NDEBUG & NDEBUG_RESTART_SELECT
203#define RSS_PRINTK(format, args...) \ 158#define RSS_PRINTK(format, args...) \
204 printk(KERN_DEBUG format , ## args) 159 dprint(NDEBUG_RESTART_SELECT, format , ## args)
205#else
206#define RSS_PRINTK(format, args...)
207#endif
208#if NDEBUG & NDEBUG_EXTENDED
209#define EXT_PRINTK(format, args...) \ 160#define EXT_PRINTK(format, args...) \
210 printk(KERN_DEBUG format , ## args) 161 dprint(NDEBUG_EXTENDED, format , ## args)
211#else
212#define EXT_PRINTK(format, args...)
213#endif
214#if NDEBUG & NDEBUG_ABORT
215#define ABRT_PRINTK(format, args...) \ 162#define ABRT_PRINTK(format, args...) \
216 printk(KERN_DEBUG format , ## args) 163 dprint(NDEBUG_ABORT, format , ## args)
217#else
218#define ABRT_PRINTK(format, args...)
219#endif
220#if NDEBUG & NDEBUG_TAGS
221#define TAG_PRINTK(format, args...) \ 164#define TAG_PRINTK(format, args...) \
222 printk(KERN_DEBUG format , ## args) 165 dprint(NDEBUG_TAGS, format , ## args)
223#else
224#define TAG_PRINTK(format, args...)
225#endif
226#if NDEBUG & NDEBUG_MERGING
227#define MER_PRINTK(format, args...) \ 166#define MER_PRINTK(format, args...) \
228 printk(KERN_DEBUG format , ## args) 167 dprint(NDEBUG_MERGING, format , ## args)
229#else
230#define MER_PRINTK(format, args...)
231#endif
232 168
233/* conditional macros for NCR5380_print_{,phase,status} */ 169/* conditional macros for NCR5380_print_{,phase,status} */
234 170
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 61f6024b61ba..2a458d66b6ff 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -202,31 +202,29 @@ static const char * get_sa_name(const struct value_name_pair * arr,
202} 202}
203 203
204/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */ 204/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
205static void print_opcode_name(unsigned char * cdbp, int cdb_len, 205static void print_opcode_name(unsigned char * cdbp, int cdb_len)
206 int start_of_line)
207{ 206{
208 int sa, len, cdb0; 207 int sa, len, cdb0;
209 const char * name; 208 const char * name;
210 const char * leadin = start_of_line ? KERN_INFO : "";
211 209
212 cdb0 = cdbp[0]; 210 cdb0 = cdbp[0];
213 switch(cdb0) { 211 switch(cdb0) {
214 case VARIABLE_LENGTH_CMD: 212 case VARIABLE_LENGTH_CMD:
215 len = cdbp[7] + 8; 213 len = cdbp[7] + 8;
216 if (len < 10) { 214 if (len < 10) {
217 printk("%sshort variable length command, " 215 printk("short variable length command, "
218 "len=%d ext_len=%d", leadin, len, cdb_len); 216 "len=%d ext_len=%d", len, cdb_len);
219 break; 217 break;
220 } 218 }
221 sa = (cdbp[8] << 8) + cdbp[9]; 219 sa = (cdbp[8] << 8) + cdbp[9];
222 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); 220 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
223 if (name) { 221 if (name) {
224 printk("%s%s", leadin, name); 222 printk("%s", name);
225 if ((cdb_len > 0) && (len != cdb_len)) 223 if ((cdb_len > 0) && (len != cdb_len))
226 printk(", in_cdb_len=%d, ext_len=%d", 224 printk(", in_cdb_len=%d, ext_len=%d",
227 len, cdb_len); 225 len, cdb_len);
228 } else { 226 } else {
229 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 227 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
230 if ((cdb_len > 0) && (len != cdb_len)) 228 if ((cdb_len > 0) && (len != cdb_len))
231 printk(", in_cdb_len=%d, ext_len=%d", 229 printk(", in_cdb_len=%d, ext_len=%d",
232 len, cdb_len); 230 len, cdb_len);
@@ -236,83 +234,80 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len,
236 sa = cdbp[1] & 0x1f; 234 sa = cdbp[1] & 0x1f;
237 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); 235 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
238 if (name) 236 if (name)
239 printk("%s%s", leadin, name); 237 printk("%s", name);
240 else 238 else
241 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 239 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
242 break; 240 break;
243 case MAINTENANCE_OUT: 241 case MAINTENANCE_OUT:
244 sa = cdbp[1] & 0x1f; 242 sa = cdbp[1] & 0x1f;
245 name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa); 243 name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa);
246 if (name) 244 if (name)
247 printk("%s%s", leadin, name); 245 printk("%s", name);
248 else 246 else
249 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 247 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
250 break; 248 break;
251 case SERVICE_ACTION_IN_12: 249 case SERVICE_ACTION_IN_12:
252 sa = cdbp[1] & 0x1f; 250 sa = cdbp[1] & 0x1f;
253 name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa); 251 name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa);
254 if (name) 252 if (name)
255 printk("%s%s", leadin, name); 253 printk("%s", name);
256 else 254 else
257 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 255 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
258 break; 256 break;
259 case SERVICE_ACTION_OUT_12: 257 case SERVICE_ACTION_OUT_12:
260 sa = cdbp[1] & 0x1f; 258 sa = cdbp[1] & 0x1f;
261 name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa); 259 name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa);
262 if (name) 260 if (name)
263 printk("%s%s", leadin, name); 261 printk("%s", name);
264 else 262 else
265 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 263 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
266 break; 264 break;
267 case SERVICE_ACTION_IN_16: 265 case SERVICE_ACTION_IN_16:
268 sa = cdbp[1] & 0x1f; 266 sa = cdbp[1] & 0x1f;
269 name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa); 267 name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa);
270 if (name) 268 if (name)
271 printk("%s%s", leadin, name); 269 printk("%s", name);
272 else 270 else
273 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 271 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
274 break; 272 break;
275 case SERVICE_ACTION_OUT_16: 273 case SERVICE_ACTION_OUT_16:
276 sa = cdbp[1] & 0x1f; 274 sa = cdbp[1] & 0x1f;
277 name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa); 275 name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa);
278 if (name) 276 if (name)
279 printk("%s%s", leadin, name); 277 printk("%s", name);
280 else 278 else
281 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 279 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
282 break; 280 break;
283 default: 281 default:
284 if (cdb0 < 0xc0) { 282 if (cdb0 < 0xc0) {
285 name = cdb_byte0_names[cdb0]; 283 name = cdb_byte0_names[cdb0];
286 if (name) 284 if (name)
287 printk("%s%s", leadin, name); 285 printk("%s", name);
288 else 286 else
289 printk("%scdb[0]=0x%x (reserved)", 287 printk("cdb[0]=0x%x (reserved)", cdb0);
290 leadin, cdb0);
291 } else 288 } else
292 printk("%scdb[0]=0x%x (vendor)", leadin, cdb0); 289 printk("cdb[0]=0x%x (vendor)", cdb0);
293 break; 290 break;
294 } 291 }
295} 292}
296 293
297#else /* ifndef CONFIG_SCSI_CONSTANTS */ 294#else /* ifndef CONFIG_SCSI_CONSTANTS */
298 295
299static void print_opcode_name(unsigned char * cdbp, int cdb_len, 296static void print_opcode_name(unsigned char * cdbp, int cdb_len)
300 int start_of_line)
301{ 297{
302 int sa, len, cdb0; 298 int sa, len, cdb0;
303 const char * leadin = start_of_line ? KERN_INFO : "";
304 299
305 cdb0 = cdbp[0]; 300 cdb0 = cdbp[0];
306 switch(cdb0) { 301 switch(cdb0) {
307 case VARIABLE_LENGTH_CMD: 302 case VARIABLE_LENGTH_CMD:
308 len = cdbp[7] + 8; 303 len = cdbp[7] + 8;
309 if (len < 10) { 304 if (len < 10) {
310 printk("%sshort opcode=0x%x command, len=%d " 305 printk("short opcode=0x%x command, len=%d "
311 "ext_len=%d", leadin, cdb0, len, cdb_len); 306 "ext_len=%d", cdb0, len, cdb_len);
312 break; 307 break;
313 } 308 }
314 sa = (cdbp[8] << 8) + cdbp[9]; 309 sa = (cdbp[8] << 8) + cdbp[9];
315 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 310 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
316 if (len != cdb_len) 311 if (len != cdb_len)
317 printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len); 312 printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
318 break; 313 break;
@@ -323,49 +318,48 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len,
323 case SERVICE_ACTION_IN_16: 318 case SERVICE_ACTION_IN_16:
324 case SERVICE_ACTION_OUT_16: 319 case SERVICE_ACTION_OUT_16:
325 sa = cdbp[1] & 0x1f; 320 sa = cdbp[1] & 0x1f;
326 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 321 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
327 break; 322 break;
328 default: 323 default:
329 if (cdb0 < 0xc0) 324 if (cdb0 < 0xc0)
330 printk("%scdb[0]=0x%x", leadin, cdb0); 325 printk("cdb[0]=0x%x", cdb0);
331 else 326 else
332 printk("%scdb[0]=0x%x (vendor)", leadin, cdb0); 327 printk("cdb[0]=0x%x (vendor)", cdb0);
333 break; 328 break;
334 } 329 }
335} 330}
336#endif 331#endif
337 332
338void __scsi_print_command(unsigned char *command) 333void __scsi_print_command(unsigned char *cdb)
339{ 334{
340 int k, len; 335 int k, len;
341 336
342 print_opcode_name(command, 0, 1); 337 print_opcode_name(cdb, 0);
343 if (VARIABLE_LENGTH_CMD == command[0]) 338 if (VARIABLE_LENGTH_CMD == cdb[0])
344 len = command[7] + 8; 339 len = cdb[7] + 8;
345 else 340 else
346 len = COMMAND_SIZE(command[0]); 341 len = COMMAND_SIZE(cdb[0]);
347 /* print out all bytes in cdb */ 342 /* print out all bytes in cdb */
348 for (k = 0; k < len; ++k) 343 for (k = 0; k < len; ++k)
349 printk(" %02x", command[k]); 344 printk(" %02x", cdb[k]);
350 printk("\n"); 345 printk("\n");
351} 346}
352EXPORT_SYMBOL(__scsi_print_command); 347EXPORT_SYMBOL(__scsi_print_command);
353 348
354/* This function (perhaps with the addition of peripheral device type) 349void scsi_print_command(struct scsi_cmnd *cmd)
355 * is more approriate than __scsi_print_command(). Perhaps that static
356 * can be dropped later if it replaces the __scsi_print_command version.
357 */
358static void scsi_print_cdb(unsigned char *cdb, int cdb_len, int start_of_line)
359{ 350{
360 int k; 351 int k;
361 352
362 print_opcode_name(cdb, cdb_len, start_of_line); 353 scmd_printk(KERN_INFO, cmd, "CDB: ");
354 print_opcode_name(cmd->cmnd, cmd->cmd_len);
355
363 /* print out all bytes in cdb */ 356 /* print out all bytes in cdb */
364 printk(":"); 357 printk(":");
365 for (k = 0; k < cdb_len; ++k) 358 for (k = 0; k < cmd->cmd_len; ++k)
366 printk(" %02x", cdb[k]); 359 printk(" %02x", cmd->cmnd[k]);
367 printk("\n"); 360 printk("\n");
368} 361}
362EXPORT_SYMBOL(scsi_print_command);
369 363
370/** 364/**
371 * 365 *
@@ -410,7 +404,11 @@ struct error_info {
410 const char * text; 404 const char * text;
411}; 405};
412 406
413static struct error_info additional[] = 407/*
408 * The canonical list of T10 Additional Sense Codes is available at:
409 * http://www.t10.org/lists/asc-num.txt
410 */
411static const struct error_info additional[] =
414{ 412{
415 {0x0000, "No additional sense information"}, 413 {0x0000, "No additional sense information"},
416 {0x0001, "Filemark detected"}, 414 {0x0001, "Filemark detected"},
@@ -714,6 +712,7 @@ static struct error_info additional[] =
714 712
715 {0x2F00, "Commands cleared by another initiator"}, 713 {0x2F00, "Commands cleared by another initiator"},
716 {0x2F01, "Commands cleared by power loss notification"}, 714 {0x2F01, "Commands cleared by power loss notification"},
715 {0x2F02, "Commands cleared by device server"},
717 716
718 {0x3000, "Incompatible medium installed"}, 717 {0x3000, "Incompatible medium installed"},
719 {0x3001, "Cannot read medium - unknown format"}, 718 {0x3001, "Cannot read medium - unknown format"},
@@ -1176,67 +1175,77 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
1176} 1175}
1177EXPORT_SYMBOL(scsi_extd_sense_format); 1176EXPORT_SYMBOL(scsi_extd_sense_format);
1178 1177
1179/* Print extended sense information; no leadin, no linefeed */ 1178void
1180static void
1181scsi_show_extd_sense(unsigned char asc, unsigned char ascq) 1179scsi_show_extd_sense(unsigned char asc, unsigned char ascq)
1182{ 1180{
1183 const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); 1181 const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq);
1184 1182
1185 if (extd_sense_fmt) { 1183 if (extd_sense_fmt) {
1186 if (strstr(extd_sense_fmt, "%x")) { 1184 if (strstr(extd_sense_fmt, "%x")) {
1187 printk("Additional sense: "); 1185 printk("Add. Sense: ");
1188 printk(extd_sense_fmt, ascq); 1186 printk(extd_sense_fmt, ascq);
1189 } else 1187 } else
1190 printk("Additional sense: %s", extd_sense_fmt); 1188 printk("Add. Sense: %s", extd_sense_fmt);
1191 } else { 1189 } else {
1192 if (asc >= 0x80) 1190 if (asc >= 0x80)
1193 printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc, ascq); 1191 printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc,
1192 ascq);
1194 if (ascq >= 0x80) 1193 if (ascq >= 0x80)
1195 printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc, ascq); 1194 printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc,
1195 ascq);
1196 else 1196 else
1197 printk("ASC=0x%x ASCQ=0x%x", asc, ascq); 1197 printk("ASC=0x%x ASCQ=0x%x", asc, ascq);
1198 } 1198 }
1199
1200 printk("\n");
1199} 1201}
1202EXPORT_SYMBOL(scsi_show_extd_sense);
1200 1203
1201void 1204void
1202scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) 1205scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr)
1203{ 1206{
1204 const char *sense_txt; 1207 const char *sense_txt;
1205 /* An example of deferred is when an earlier write to disk cache
1206 * succeeded, but now the disk discovers that it cannot write the
1207 * data to the magnetic media.
1208 */
1209 const char *error = scsi_sense_is_deferred(sshdr) ?
1210 "<<DEFERRED>>" : "Current";
1211 printk(KERN_INFO "%s: %s", name, error);
1212 if (sshdr->response_code >= 0x72)
1213 printk(" [descriptor]");
1214 1208
1215 sense_txt = scsi_sense_key_string(sshdr->sense_key); 1209 sense_txt = scsi_sense_key_string(sshdr->sense_key);
1216 if (sense_txt) 1210 if (sense_txt)
1217 printk(": sense key: %s\n", sense_txt); 1211 printk("Sense Key : %s ", sense_txt);
1218 else 1212 else
1219 printk(": sense key=0x%x\n", sshdr->sense_key); 1213 printk("Sense Key : 0x%x ", sshdr->sense_key);
1220 printk(KERN_INFO " "); 1214
1221 scsi_show_extd_sense(sshdr->asc, sshdr->ascq); 1215 printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " :
1216 "[current] ");
1217
1218 if (sshdr->response_code >= 0x72)
1219 printk("[descriptor]");
1220
1222 printk("\n"); 1221 printk("\n");
1223} 1222}
1223EXPORT_SYMBOL(scsi_show_sense_hdr);
1224
1225/*
1226 * Print normalized SCSI sense header with a prefix.
1227 */
1228void
1229scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr)
1230{
1231 printk(KERN_INFO "%s: ", name);
1232 scsi_show_sense_hdr(sshdr);
1233 printk(KERN_INFO "%s: ", name);
1234 scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
1235}
1224EXPORT_SYMBOL(scsi_print_sense_hdr); 1236EXPORT_SYMBOL(scsi_print_sense_hdr);
1225 1237
1226/* Print sense information */
1227void 1238void
1228__scsi_print_sense(const char *name, const unsigned char *sense_buffer, 1239scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
1229 int sense_len) 1240 struct scsi_sense_hdr *sshdr)
1230{ 1241{
1231 int k, num, res; 1242 int k, num, res;
1232 unsigned int info;
1233 struct scsi_sense_hdr ssh;
1234 1243
1235 res = scsi_normalize_sense(sense_buffer, sense_len, &ssh); 1244 res = scsi_normalize_sense(sense_buffer, sense_len, sshdr);
1236 if (0 == res) { 1245 if (0 == res) {
1237 /* this may be SCSI-1 sense data */ 1246 /* this may be SCSI-1 sense data */
1238 num = (sense_len < 32) ? sense_len : 32; 1247 num = (sense_len < 32) ? sense_len : 32;
1239 printk(KERN_INFO "Unrecognized sense data (in hex):"); 1248 printk("Unrecognized sense data (in hex):");
1240 for (k = 0; k < num; ++k) { 1249 for (k = 0; k < num; ++k) {
1241 if (0 == (k % 16)) { 1250 if (0 == (k % 16)) {
1242 printk("\n"); 1251 printk("\n");
@@ -1247,11 +1256,20 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1247 printk("\n"); 1256 printk("\n");
1248 return; 1257 return;
1249 } 1258 }
1250 scsi_print_sense_hdr(name, &ssh); 1259}
1251 if (ssh.response_code < 0x72) { 1260
1261void
1262scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
1263 struct scsi_sense_hdr *sshdr)
1264{
1265 int k, num, res;
1266
1267 if (sshdr->response_code < 0x72)
1268 {
1252 /* only decode extras for "fixed" format now */ 1269 /* only decode extras for "fixed" format now */
1253 char buff[80]; 1270 char buff[80];
1254 int blen, fixed_valid; 1271 int blen, fixed_valid;
1272 unsigned int info;
1255 1273
1256 fixed_valid = sense_buffer[0] & 0x80; 1274 fixed_valid = sense_buffer[0] & 0x80;
1257 info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) | 1275 info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
@@ -1281,13 +1299,13 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1281 res += snprintf(buff + res, blen - res, "ILI"); 1299 res += snprintf(buff + res, blen - res, "ILI");
1282 } 1300 }
1283 if (res > 0) 1301 if (res > 0)
1284 printk(KERN_INFO "%s\n", buff); 1302 printk("%s\n", buff);
1285 } else if (ssh.additional_length > 0) { 1303 } else if (sshdr->additional_length > 0) {
1286 /* descriptor format with sense descriptors */ 1304 /* descriptor format with sense descriptors */
1287 num = 8 + ssh.additional_length; 1305 num = 8 + sshdr->additional_length;
1288 num = (sense_len < num) ? sense_len : num; 1306 num = (sense_len < num) ? sense_len : num;
1289 printk(KERN_INFO "Descriptor sense data with sense " 1307 printk("Descriptor sense data with sense descriptors "
1290 "descriptors (in hex):"); 1308 "(in hex):");
1291 for (k = 0; k < num; ++k) { 1309 for (k = 0; k < num; ++k) {
1292 if (0 == (k % 16)) { 1310 if (0 == (k % 16)) {
1293 printk("\n"); 1311 printk("\n");
@@ -1295,29 +1313,42 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1295 } 1313 }
1296 printk("%02x ", sense_buffer[k]); 1314 printk("%02x ", sense_buffer[k]);
1297 } 1315 }
1316
1298 printk("\n"); 1317 printk("\n");
1299 } 1318 }
1319
1300} 1320}
1301EXPORT_SYMBOL(__scsi_print_sense);
1302 1321
1303void scsi_print_sense(const char *devclass, struct scsi_cmnd *cmd) 1322/* Normalize and print sense buffer with name prefix */
1323void __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1324 int sense_len)
1304{ 1325{
1305 const char *name = devclass; 1326 struct scsi_sense_hdr sshdr;
1306 1327
1307 if (cmd->request->rq_disk) 1328 printk(KERN_INFO "%s: ", name);
1308 name = cmd->request->rq_disk->disk_name; 1329 scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
1309 __scsi_print_sense(name, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); 1330 scsi_show_sense_hdr(&sshdr);
1331 scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
1332 printk(KERN_INFO "%s: ", name);
1333 scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
1310} 1334}
1311EXPORT_SYMBOL(scsi_print_sense); 1335EXPORT_SYMBOL(__scsi_print_sense);
1312 1336
1313void scsi_print_command(struct scsi_cmnd *cmd) 1337/* Normalize and print sense buffer in SCSI command */
1338void scsi_print_sense(char *name, struct scsi_cmnd *cmd)
1314{ 1339{
1315 /* Assume appended output (i.e. not at start of line) */ 1340 struct scsi_sense_hdr sshdr;
1316 sdev_printk("", cmd->device, "\n"); 1341
1317 printk(KERN_INFO " command: "); 1342 scmd_printk(KERN_INFO, cmd, "");
1318 scsi_print_cdb(cmd->cmnd, cmd->cmd_len, 0); 1343 scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
1344 &sshdr);
1345 scsi_show_sense_hdr(&sshdr);
1346 scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
1347 &sshdr);
1348 scmd_printk(KERN_INFO, cmd, "");
1349 scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
1319} 1350}
1320EXPORT_SYMBOL(scsi_print_command); 1351EXPORT_SYMBOL(scsi_print_sense);
1321 1352
1322#ifdef CONFIG_SCSI_CONSTANTS 1353#ifdef CONFIG_SCSI_CONSTANTS
1323 1354
@@ -1327,25 +1358,6 @@ static const char * const hostbyte_table[]={
1327"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; 1358"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
1328#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) 1359#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
1329 1360
1330void scsi_print_hostbyte(int scsiresult)
1331{
1332 int hb = host_byte(scsiresult);
1333
1334 printk("Hostbyte=0x%02x", hb);
1335 if (hb < NUM_HOSTBYTE_STRS)
1336 printk("(%s) ", hostbyte_table[hb]);
1337 else
1338 printk("is invalid ");
1339}
1340#else
1341void scsi_print_hostbyte(int scsiresult)
1342{
1343 printk("Hostbyte=0x%02x ", host_byte(scsiresult));
1344}
1345#endif
1346
1347#ifdef CONFIG_SCSI_CONSTANTS
1348
1349static const char * const driverbyte_table[]={ 1361static const char * const driverbyte_table[]={
1350"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 1362"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1351"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 1363"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
@@ -1356,19 +1368,35 @@ static const char * const driversuggest_table[]={"SUGGEST_OK",
1356"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; 1368"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
1357#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table) 1369#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table)
1358 1370
1359void scsi_print_driverbyte(int scsiresult) 1371void scsi_show_result(int result)
1360{ 1372{
1361 int dr = (driver_byte(scsiresult) & DRIVER_MASK); 1373 int hb = host_byte(result);
1362 int su = ((driver_byte(scsiresult) & SUGGEST_MASK) >> 4); 1374 int db = (driver_byte(result) & DRIVER_MASK);
1375 int su = ((driver_byte(result) & SUGGEST_MASK) >> 4);
1363 1376
1364 printk("Driverbyte=0x%02x ", driver_byte(scsiresult)); 1377 printk("Result: hostbyte=%s driverbyte=%s,%s\n",
1365 printk("(%s,%s) ", 1378 (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb] : "invalid"),
1366 (dr < NUM_DRIVERBYTE_STRS ? driverbyte_table[dr] : "invalid"), 1379 (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"),
1367 (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid")); 1380 (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid"));
1368} 1381}
1382
1369#else 1383#else
1370void scsi_print_driverbyte(int scsiresult) 1384
1385void scsi_show_result(int result)
1371{ 1386{
1372 printk("Driverbyte=0x%02x ", driver_byte(scsiresult)); 1387 printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
1388 host_byte(result), driver_byte(result));
1373} 1389}
1390
1374#endif 1391#endif
1392EXPORT_SYMBOL(scsi_show_result);
1393
1394
1395void scsi_print_result(struct scsi_cmnd *cmd)
1396{
1397 scmd_printk(KERN_INFO, cmd, "");
1398 scsi_show_result(cmd->result);
1399}
1400EXPORT_SYMBOL(scsi_print_result);
1401
1402
diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h
index 5a49216fe4cf..100b49baca7f 100644
--- a/drivers/scsi/dpt/dpti_i2o.h
+++ b/drivers/scsi/dpt/dpti_i2o.h
@@ -31,7 +31,7 @@
31 * Tunable parameters first 31 * Tunable parameters first
32 */ 32 */
33 33
34/* How many different OSM's are we allowing */ 34/* How many different OSM's are we allowing */
35#define MAX_I2O_MODULES 64 35#define MAX_I2O_MODULES 64
36 36
37#define I2O_EVT_CAPABILITY_OTHER 0x01 37#define I2O_EVT_CAPABILITY_OTHER 0x01
@@ -63,7 +63,7 @@ struct i2o_message
63 u16 size; 63 u16 size;
64 u32 target_tid:12; 64 u32 target_tid:12;
65 u32 init_tid:12; 65 u32 init_tid:12;
66 u32 function:8; 66 u32 function:8;
67 u32 initiator_context; 67 u32 initiator_context;
68 /* List follows */ 68 /* List follows */
69}; 69};
@@ -77,7 +77,7 @@ struct i2o_device
77 77
78 char dev_name[8]; /* linux /dev name if available */ 78 char dev_name[8]; /* linux /dev name if available */
79 i2o_lct_entry lct_data;/* Device LCT information */ 79 i2o_lct_entry lct_data;/* Device LCT information */
80 u32 flags; 80 u32 flags;
81 struct proc_dir_entry* proc_entry; /* /proc dir */ 81 struct proc_dir_entry* proc_entry; /* /proc dir */
82 struct adpt_device *owner; 82 struct adpt_device *owner;
83 struct _adpt_hba *controller; /* Controlling IOP */ 83 struct _adpt_hba *controller; /* Controlling IOP */
@@ -86,7 +86,7 @@ struct i2o_device
86/* 86/*
87 * Each I2O controller has one of these objects 87 * Each I2O controller has one of these objects
88 */ 88 */
89 89
90struct i2o_controller 90struct i2o_controller
91{ 91{
92 char name[16]; 92 char name[16];
@@ -111,9 +111,9 @@ struct i2o_sys_tbl_entry
111 u32 iop_id:12; 111 u32 iop_id:12;
112 u32 reserved2:20; 112 u32 reserved2:20;
113 u16 seg_num:12; 113 u16 seg_num:12;
114 u16 i2o_version:4; 114 u16 i2o_version:4;
115 u8 iop_state; 115 u8 iop_state;
116 u8 msg_type; 116 u8 msg_type;
117 u16 frame_size; 117 u16 frame_size;
118 u16 reserved3; 118 u16 reserved3;
119 u32 last_changed; 119 u32 last_changed;
@@ -124,14 +124,14 @@ struct i2o_sys_tbl_entry
124 124
125struct i2o_sys_tbl 125struct i2o_sys_tbl
126{ 126{
127 u8 num_entries; 127 u8 num_entries;
128 u8 version; 128 u8 version;
129 u16 reserved1; 129 u16 reserved1;
130 u32 change_ind; 130 u32 change_ind;
131 u32 reserved2; 131 u32 reserved2;
132 u32 reserved3; 132 u32 reserved3;
133 struct i2o_sys_tbl_entry iops[0]; 133 struct i2o_sys_tbl_entry iops[0];
134}; 134};
135 135
136/* 136/*
137 * I2O classes / subclasses 137 * I2O classes / subclasses
@@ -146,7 +146,7 @@ struct i2o_sys_tbl
146/* Class code names 146/* Class code names
147 * (from v1.5 Table 6-1 Class Code Assignments.) 147 * (from v1.5 Table 6-1 Class Code Assignments.)
148 */ 148 */
149 149
150#define I2O_CLASS_EXECUTIVE 0x000 150#define I2O_CLASS_EXECUTIVE 0x000
151#define I2O_CLASS_DDM 0x001 151#define I2O_CLASS_DDM 0x001
152#define I2O_CLASS_RANDOM_BLOCK_STORAGE 0x010 152#define I2O_CLASS_RANDOM_BLOCK_STORAGE 0x010
@@ -166,7 +166,7 @@ struct i2o_sys_tbl
166 166
167/* Rest of 0x092 - 0x09f reserved for peer-to-peer classes 167/* Rest of 0x092 - 0x09f reserved for peer-to-peer classes
168 */ 168 */
169 169
170#define I2O_CLASS_MATCH_ANYCLASS 0xffffffff 170#define I2O_CLASS_MATCH_ANYCLASS 0xffffffff
171 171
172/* Subclasses 172/* Subclasses
@@ -175,7 +175,7 @@ struct i2o_sys_tbl
175#define I2O_SUBCLASS_i960 0x001 175#define I2O_SUBCLASS_i960 0x001
176#define I2O_SUBCLASS_HDM 0x020 176#define I2O_SUBCLASS_HDM 0x020
177#define I2O_SUBCLASS_ISM 0x021 177#define I2O_SUBCLASS_ISM 0x021
178 178
179/* Operation functions */ 179/* Operation functions */
180 180
181#define I2O_PARAMS_FIELD_GET 0x0001 181#define I2O_PARAMS_FIELD_GET 0x0001
@@ -219,7 +219,7 @@ struct i2o_sys_tbl
219/* 219/*
220 * Messaging API values 220 * Messaging API values
221 */ 221 */
222 222
223#define I2O_CMD_ADAPTER_ASSIGN 0xB3 223#define I2O_CMD_ADAPTER_ASSIGN 0xB3
224#define I2O_CMD_ADAPTER_READ 0xB2 224#define I2O_CMD_ADAPTER_READ 0xB2
225#define I2O_CMD_ADAPTER_RELEASE 0xB5 225#define I2O_CMD_ADAPTER_RELEASE 0xB5
@@ -284,16 +284,16 @@ struct i2o_sys_tbl
284#define I2O_PRIVATE_MSG 0xFF 284#define I2O_PRIVATE_MSG 0xFF
285 285
286/* 286/*
287 * Init Outbound Q status 287 * Init Outbound Q status
288 */ 288 */
289 289
290#define I2O_CMD_OUTBOUND_INIT_IN_PROGRESS 0x01 290#define I2O_CMD_OUTBOUND_INIT_IN_PROGRESS 0x01
291#define I2O_CMD_OUTBOUND_INIT_REJECTED 0x02 291#define I2O_CMD_OUTBOUND_INIT_REJECTED 0x02
292#define I2O_CMD_OUTBOUND_INIT_FAILED 0x03 292#define I2O_CMD_OUTBOUND_INIT_FAILED 0x03
293#define I2O_CMD_OUTBOUND_INIT_COMPLETE 0x04 293#define I2O_CMD_OUTBOUND_INIT_COMPLETE 0x04
294 294
295/* 295/*
296 * I2O Get Status State values 296 * I2O Get Status State values
297 */ 297 */
298 298
299#define ADAPTER_STATE_INITIALIZING 0x01 299#define ADAPTER_STATE_INITIALIZING 0x01
@@ -303,7 +303,7 @@ struct i2o_sys_tbl
303#define ADAPTER_STATE_OPERATIONAL 0x08 303#define ADAPTER_STATE_OPERATIONAL 0x08
304#define ADAPTER_STATE_FAILED 0x10 304#define ADAPTER_STATE_FAILED 0x10
305#define ADAPTER_STATE_FAULTED 0x11 305#define ADAPTER_STATE_FAULTED 0x11
306 306
307/* I2O API function return values */ 307/* I2O API function return values */
308 308
309#define I2O_RTN_NO_ERROR 0 309#define I2O_RTN_NO_ERROR 0
@@ -321,9 +321,9 @@ struct i2o_sys_tbl
321 321
322/* Reply message status defines for all messages */ 322/* Reply message status defines for all messages */
323 323
324#define I2O_REPLY_STATUS_SUCCESS 0x00 324#define I2O_REPLY_STATUS_SUCCESS 0x00
325#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01 325#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
326#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 326#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
327#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03 327#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
328#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04 328#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
329#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05 329#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
@@ -338,7 +338,7 @@ struct i2o_sys_tbl
338 338
339#define I2O_PARAMS_STATUS_SUCCESS 0x00 339#define I2O_PARAMS_STATUS_SUCCESS 0x00
340#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01 340#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01
341#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02 341#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02
342#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03 342#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03
343#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04 343#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04
344#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05 344#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05
@@ -390,7 +390,7 @@ struct i2o_sys_tbl
390#define I2O_CLAIM_MANAGEMENT 0x02000000 390#define I2O_CLAIM_MANAGEMENT 0x02000000
391#define I2O_CLAIM_AUTHORIZED 0x03000000 391#define I2O_CLAIM_AUTHORIZED 0x03000000
392#define I2O_CLAIM_SECONDARY 0x04000000 392#define I2O_CLAIM_SECONDARY 0x04000000
393 393
394/* Message header defines for VersionOffset */ 394/* Message header defines for VersionOffset */
395#define I2OVER15 0x0001 395#define I2OVER15 0x0001
396#define I2OVER20 0x0002 396#define I2OVER20 0x0002
diff --git a/drivers/scsi/dpt/dpti_ioctl.h b/drivers/scsi/dpt/dpti_ioctl.h
index 82d24864be0c..cc784e8f6e9d 100644
--- a/drivers/scsi/dpt/dpti_ioctl.h
+++ b/drivers/scsi/dpt/dpti_ioctl.h
@@ -99,7 +99,7 @@ typedef struct {
99 uCHAR eataVersion; /* EATA Version */ 99 uCHAR eataVersion; /* EATA Version */
100 uLONG cpLength; /* EATA Command Packet Length */ 100 uLONG cpLength; /* EATA Command Packet Length */
101 uLONG spLength; /* EATA Status Packet Length */ 101 uLONG spLength; /* EATA Status Packet Length */
102 uCHAR drqNum; /* DRQ Index (0,5,6,7) */ 102 uCHAR drqNum; /* DRQ Index (0,5,6,7) */
103 uCHAR flag1; /* EATA Flags 1 (Byte 9) */ 103 uCHAR flag1; /* EATA Flags 1 (Byte 9) */
104 uCHAR flag2; /* EATA Flags 2 (Byte 30) */ 104 uCHAR flag2; /* EATA Flags 2 (Byte 30) */
105} CtrlInfo; 105} CtrlInfo;
diff --git a/drivers/scsi/dpt/dptsig.h b/drivers/scsi/dpt/dptsig.h
index 4bf447792129..94bc894d1200 100644
--- a/drivers/scsi/dpt/dptsig.h
+++ b/drivers/scsi/dpt/dptsig.h
@@ -145,8 +145,8 @@ typedef unsigned long sigLONG;
145#define FT_LOGGER 12 /* Event Logger */ 145#define FT_LOGGER 12 /* Event Logger */
146#define FT_INSTALL 13 /* An Install Program */ 146#define FT_INSTALL 13 /* An Install Program */
147#define FT_LIBRARY 14 /* Storage Manager Real-Mode Calls */ 147#define FT_LIBRARY 14 /* Storage Manager Real-Mode Calls */
148#define FT_RESOURCE 15 /* Storage Manager Resource File */ 148#define FT_RESOURCE 15 /* Storage Manager Resource File */
149#define FT_MODEM_DB 16 /* Storage Manager Modem Database */ 149#define FT_MODEM_DB 16 /* Storage Manager Modem Database */
150 150
151/* Filetype flags - sigBYTE dsFiletypeFlags; FLAG BITS */ 151/* Filetype flags - sigBYTE dsFiletypeFlags; FLAG BITS */
152/* ------------------------------------------------------------------ */ 152/* ------------------------------------------------------------------ */
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index cd36e81b2d93..f7b9dbd64a96 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -195,8 +195,6 @@ static int adpt_detect(struct scsi_host_template* sht)
195 pci_dev_get(pDev); 195 pci_dev_get(pDev);
196 } 196 }
197 } 197 }
198 if (pDev)
199 pci_dev_put(pDev);
200 198
201 /* In INIT state, Activate IOPs */ 199 /* In INIT state, Activate IOPs */
202 for (pHba = hba_chain; pHba; pHba = pHba->next) { 200 for (pHba = hba_chain; pHba; pHba = pHba->next) {
diff --git a/drivers/scsi/eata_generic.h b/drivers/scsi/eata_generic.h
index 635c14861f86..5016af5cf860 100644
--- a/drivers/scsi/eata_generic.h
+++ b/drivers/scsi/eata_generic.h
@@ -18,13 +18,6 @@
18 * Misc. definitions * 18 * Misc. definitions *
19 *********************************************/ 19 *********************************************/
20 20
21#ifndef TRUE
22#define TRUE 1
23#endif
24#ifndef FALSE
25#define FALSE 0
26#endif
27
28#define R_LIMIT 0x20000 21#define R_LIMIT 0x20000
29 22
30#define MAXISA 4 23#define MAXISA 4
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index fbc1d5c3b0a7..b10eefe735c5 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -85,7 +85,7 @@
85static int max_id = 64; 85static int max_id = 64;
86static int max_channel = 3; 86static int max_channel = 3;
87static int init_timeout = 5; 87static int init_timeout = 5;
88static int max_requests = 50; 88static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT;
89 89
90#define IBMVSCSI_VERSION "1.5.8" 90#define IBMVSCSI_VERSION "1.5.8"
91 91
@@ -538,7 +538,8 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
538 int request_status; 538 int request_status;
539 int rc; 539 int rc;
540 540
541 /* If we have exhausted our request limit, just fail this request. 541 /* If we have exhausted our request limit, just fail this request,
542 * unless it is for a reset or abort.
542 * Note that there are rare cases involving driver generated requests 543 * Note that there are rare cases involving driver generated requests
543 * (such as task management requests) that the mid layer may think we 544 * (such as task management requests) that the mid layer may think we
544 * can handle more requests (can_queue) when we actually can't 545 * can handle more requests (can_queue) when we actually can't
@@ -551,9 +552,30 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
551 */ 552 */
552 if (request_status < -1) 553 if (request_status < -1)
553 goto send_error; 554 goto send_error;
554 /* Otherwise, if we have run out of requests */ 555 /* Otherwise, we may have run out of requests. */
555 else if (request_status < 0) 556 /* Abort and reset calls should make it through.
556 goto send_busy; 557 * Nothing except abort and reset should use the last two
558 * slots unless we had two or less to begin with.
559 */
560 else if (request_status < 2 &&
561 evt_struct->iu.srp.cmd.opcode != SRP_TSK_MGMT) {
562 /* In the case that we have less than two requests
563 * available, check the server limit as a combination
564 * of the request limit and the number of requests
565 * in-flight (the size of the send list). If the
566 * server limit is greater than 2, return busy so
567 * that the last two are reserved for reset and abort.
568 */
569 int server_limit = request_status;
570 struct srp_event_struct *tmp_evt;
571
572 list_for_each_entry(tmp_evt, &hostdata->sent, list) {
573 server_limit++;
574 }
575
576 if (server_limit > 2)
577 goto send_busy;
578 }
557 } 579 }
558 580
559 /* Copy the IU into the transfer area */ 581 /* Copy the IU into the transfer area */
@@ -572,6 +594,7 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
572 594
573 printk(KERN_ERR "ibmvscsi: send error %d\n", 595 printk(KERN_ERR "ibmvscsi: send error %d\n",
574 rc); 596 rc);
597 atomic_inc(&hostdata->request_limit);
575 goto send_error; 598 goto send_error;
576 } 599 }
577 600
@@ -581,7 +604,8 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
581 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); 604 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);
582 605
583 free_event_struct(&hostdata->pool, evt_struct); 606 free_event_struct(&hostdata->pool, evt_struct);
584 return SCSI_MLQUEUE_HOST_BUSY; 607 atomic_inc(&hostdata->request_limit);
608 return SCSI_MLQUEUE_HOST_BUSY;
585 609
586 send_error: 610 send_error:
587 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); 611 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);
@@ -831,23 +855,16 @@ static void login_rsp(struct srp_event_struct *evt_struct)
831 855
832 printk(KERN_INFO "ibmvscsi: SRP_LOGIN succeeded\n"); 856 printk(KERN_INFO "ibmvscsi: SRP_LOGIN succeeded\n");
833 857
834 if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta > 858 if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta < 0)
835 (max_requests - 2)) 859 printk(KERN_ERR "ibmvscsi: Invalid request_limit.\n");
836 evt_struct->xfer_iu->srp.login_rsp.req_lim_delta =
837 max_requests - 2;
838 860
839 /* Now we know what the real request-limit is */ 861 /* Now we know what the real request-limit is.
862 * This value is set rather than added to request_limit because
863 * request_limit could have been set to -1 by this client.
864 */
840 atomic_set(&hostdata->request_limit, 865 atomic_set(&hostdata->request_limit,
841 evt_struct->xfer_iu->srp.login_rsp.req_lim_delta); 866 evt_struct->xfer_iu->srp.login_rsp.req_lim_delta);
842 867
843 hostdata->host->can_queue =
844 evt_struct->xfer_iu->srp.login_rsp.req_lim_delta - 2;
845
846 if (hostdata->host->can_queue < 1) {
847 printk(KERN_ERR "ibmvscsi: Invalid request_limit_delta\n");
848 return;
849 }
850
851 /* If we had any pending I/Os, kick them */ 868 /* If we had any pending I/Os, kick them */
852 scsi_unblock_requests(hostdata->host); 869 scsi_unblock_requests(hostdata->host);
853 870
@@ -1337,6 +1354,27 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata,
1337 return rc; 1354 return rc;
1338} 1355}
1339 1356
1357/**
1358 * ibmvscsi_slave_configure: Set the "allow_restart" flag for each disk.
1359 * @sdev: struct scsi_device device to configure
1360 *
1361 * Enable allow_restart for a device if it is a disk. Adjust the
1362 * queue_depth here also as is required by the documentation for
1363 * struct scsi_host_template.
1364 */
1365static int ibmvscsi_slave_configure(struct scsi_device *sdev)
1366{
1367 struct Scsi_Host *shost = sdev->host;
1368 unsigned long lock_flags = 0;
1369
1370 spin_lock_irqsave(shost->host_lock, lock_flags);
1371 if (sdev->type == TYPE_DISK)
1372 sdev->allow_restart = 1;
1373 scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun);
1374 spin_unlock_irqrestore(shost->host_lock, lock_flags);
1375 return 0;
1376}
1377
1340/* ------------------------------------------------------------ 1378/* ------------------------------------------------------------
1341 * sysfs attributes 1379 * sysfs attributes
1342 */ 1380 */
@@ -1482,8 +1520,9 @@ static struct scsi_host_template driver_template = {
1482 .queuecommand = ibmvscsi_queuecommand, 1520 .queuecommand = ibmvscsi_queuecommand,
1483 .eh_abort_handler = ibmvscsi_eh_abort_handler, 1521 .eh_abort_handler = ibmvscsi_eh_abort_handler,
1484 .eh_device_reset_handler = ibmvscsi_eh_device_reset_handler, 1522 .eh_device_reset_handler = ibmvscsi_eh_device_reset_handler,
1523 .slave_configure = ibmvscsi_slave_configure,
1485 .cmd_per_lun = 16, 1524 .cmd_per_lun = 16,
1486 .can_queue = 1, /* Updated after SRP_LOGIN */ 1525 .can_queue = IBMVSCSI_MAX_REQUESTS_DEFAULT,
1487 .this_id = -1, 1526 .this_id = -1,
1488 .sg_tablesize = SG_ALL, 1527 .sg_tablesize = SG_ALL,
1489 .use_clustering = ENABLE_CLUSTERING, 1528 .use_clustering = ENABLE_CLUSTERING,
@@ -1503,6 +1542,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1503 1542
1504 vdev->dev.driver_data = NULL; 1543 vdev->dev.driver_data = NULL;
1505 1544
1545 driver_template.can_queue = max_requests;
1506 host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); 1546 host = scsi_host_alloc(&driver_template, sizeof(*hostdata));
1507 if (!host) { 1547 if (!host) {
1508 printk(KERN_ERR "ibmvscsi: couldn't allocate host data\n"); 1548 printk(KERN_ERR "ibmvscsi: couldn't allocate host data\n");
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.h b/drivers/scsi/ibmvscsi/ibmvscsi.h
index 5c6d93582929..77cc1d40f5bb 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.h
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.h
@@ -44,6 +44,8 @@ struct Scsi_Host;
44 */ 44 */
45#define MAX_INDIRECT_BUFS 10 45#define MAX_INDIRECT_BUFS 10
46 46
47#define IBMVSCSI_MAX_REQUESTS_DEFAULT 100
48
47/* ------------------------------------------------------------ 49/* ------------------------------------------------------------
48 * Data Structures 50 * Data Structures
49 */ 51 */
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index a39a478bb39a..6d223dd76440 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -35,7 +35,7 @@
35#include "ibmvscsi.h" 35#include "ibmvscsi.h"
36 36
37#define INITIAL_SRP_LIMIT 16 37#define INITIAL_SRP_LIMIT 16
38#define DEFAULT_MAX_SECTORS 512 38#define DEFAULT_MAX_SECTORS 256
39 39
40#define TGT_NAME "ibmvstgt" 40#define TGT_NAME "ibmvstgt"
41 41
@@ -248,8 +248,8 @@ static int ibmvstgt_rdma(struct scsi_cmnd *sc, struct scatterlist *sg, int nsg,
248 md[i].va + mdone); 248 md[i].va + mdone);
249 249
250 if (err != H_SUCCESS) { 250 if (err != H_SUCCESS) {
251 eprintk("rdma error %d %d\n", dir, slen); 251 eprintk("rdma error %d %d %ld\n", dir, slen, err);
252 goto out; 252 return -EIO;
253 } 253 }
254 254
255 mlen -= slen; 255 mlen -= slen;
@@ -265,45 +265,35 @@ static int ibmvstgt_rdma(struct scsi_cmnd *sc, struct scatterlist *sg, int nsg,
265 if (sidx > nsg) { 265 if (sidx > nsg) {
266 eprintk("out of sg %p %d %d\n", 266 eprintk("out of sg %p %d %d\n",
267 iue, sidx, nsg); 267 iue, sidx, nsg);
268 goto out; 268 return -EIO;
269 } 269 }
270 } 270 }
271 }; 271 };
272 272
273 rest -= mlen; 273 rest -= mlen;
274 } 274 }
275out:
276
277 return 0; 275 return 0;
278} 276}
279 277
280static int ibmvstgt_transfer_data(struct scsi_cmnd *sc,
281 void (*done)(struct scsi_cmnd *))
282{
283 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
284 int err;
285
286 err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);
287
288 done(sc);
289
290 return err;
291}
292
293static int ibmvstgt_cmd_done(struct scsi_cmnd *sc, 278static int ibmvstgt_cmd_done(struct scsi_cmnd *sc,
294 void (*done)(struct scsi_cmnd *)) 279 void (*done)(struct scsi_cmnd *))
295{ 280{
296 unsigned long flags; 281 unsigned long flags;
297 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr; 282 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
298 struct srp_target *target = iue->target; 283 struct srp_target *target = iue->target;
284 int err = 0;
299 285
300 dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]); 286 dprintk("%p %p %x %u\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0],
287 cmd->usg_sg);
288
289 if (sc->use_sg)
290 err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);
301 291
302 spin_lock_irqsave(&target->lock, flags); 292 spin_lock_irqsave(&target->lock, flags);
303 list_del(&iue->ilist); 293 list_del(&iue->ilist);
304 spin_unlock_irqrestore(&target->lock, flags); 294 spin_unlock_irqrestore(&target->lock, flags);
305 295
306 if (sc->result != SAM_STAT_GOOD) { 296 if (err|| sc->result != SAM_STAT_GOOD) {
307 eprintk("operation failed %p %d %x\n", 297 eprintk("operation failed %p %d %x\n",
308 iue, sc->result, vio_iu(iue)->srp.cmd.cdb[0]); 298 iue, sc->result, vio_iu(iue)->srp.cmd.cdb[0]);
309 send_rsp(iue, sc, HARDWARE_ERROR, 0x00); 299 send_rsp(iue, sc, HARDWARE_ERROR, 0x00);
@@ -503,7 +493,8 @@ static void process_iu(struct viosrp_crq *crq, struct srp_target *target)
503{ 493{
504 struct vio_port *vport = target_to_port(target); 494 struct vio_port *vport = target_to_port(target);
505 struct iu_entry *iue; 495 struct iu_entry *iue;
506 long err, done; 496 long err;
497 int done = 1;
507 498
508 iue = srp_iu_get(target); 499 iue = srp_iu_get(target);
509 if (!iue) { 500 if (!iue) {
@@ -518,7 +509,6 @@ static void process_iu(struct viosrp_crq *crq, struct srp_target *target)
518 509
519 if (err != H_SUCCESS) { 510 if (err != H_SUCCESS) {
520 eprintk("%ld transferring data error %p\n", err, iue); 511 eprintk("%ld transferring data error %p\n", err, iue);
521 done = 1;
522 goto out; 512 goto out;
523 } 513 }
524 514
@@ -794,7 +784,6 @@ static struct scsi_host_template ibmvstgt_sht = {
794 .use_clustering = DISABLE_CLUSTERING, 784 .use_clustering = DISABLE_CLUSTERING,
795 .max_sectors = DEFAULT_MAX_SECTORS, 785 .max_sectors = DEFAULT_MAX_SECTORS,
796 .transfer_response = ibmvstgt_cmd_done, 786 .transfer_response = ibmvstgt_cmd_done,
797 .transfer_data = ibmvstgt_transfer_data,
798 .eh_abort_handler = ibmvstgt_eh_abort_handler, 787 .eh_abort_handler = ibmvstgt_eh_abort_handler,
799 .tsk_mgmt_response = ibmvstgt_tsk_mgmt_response, 788 .tsk_mgmt_response = ibmvstgt_tsk_mgmt_response,
800 .shost_attrs = ibmvstgt_attrs, 789 .shost_attrs = ibmvstgt_attrs,
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index e9bd29975db4..2c7b77e833f9 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -89,10 +89,9 @@ static unsigned int ipr_log_level = IPR_DEFAULT_LOG_LEVEL;
89static unsigned int ipr_max_speed = 1; 89static unsigned int ipr_max_speed = 1;
90static int ipr_testmode = 0; 90static int ipr_testmode = 0;
91static unsigned int ipr_fastfail = 0; 91static unsigned int ipr_fastfail = 0;
92static unsigned int ipr_transop_timeout = IPR_OPERATIONAL_TIMEOUT; 92static unsigned int ipr_transop_timeout = 0;
93static unsigned int ipr_enable_cache = 1; 93static unsigned int ipr_enable_cache = 1;
94static unsigned int ipr_debug = 0; 94static unsigned int ipr_debug = 0;
95static int ipr_auto_create = 1;
96static DEFINE_SPINLOCK(ipr_driver_lock); 95static DEFINE_SPINLOCK(ipr_driver_lock);
97 96
98/* This table describes the differences between DMA controller chips */ 97/* This table describes the differences between DMA controller chips */
@@ -159,15 +158,13 @@ module_param_named(enable_cache, ipr_enable_cache, int, 0);
159MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)"); 158MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)");
160module_param_named(debug, ipr_debug, int, 0); 159module_param_named(debug, ipr_debug, int, 0);
161MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)"); 160MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)");
162module_param_named(auto_create, ipr_auto_create, int, 0);
163MODULE_PARM_DESC(auto_create, "Auto-create single device RAID 0 arrays when initialized (default: 1)");
164MODULE_LICENSE("GPL"); 161MODULE_LICENSE("GPL");
165MODULE_VERSION(IPR_DRIVER_VERSION); 162MODULE_VERSION(IPR_DRIVER_VERSION);
166 163
167/* A constant array of IOASCs/URCs/Error Messages */ 164/* A constant array of IOASCs/URCs/Error Messages */
168static const 165static const
169struct ipr_error_table_t ipr_error_table[] = { 166struct ipr_error_table_t ipr_error_table[] = {
170 {0x00000000, 1, 1, 167 {0x00000000, 1, IPR_DEFAULT_LOG_LEVEL,
171 "8155: An unknown error was received"}, 168 "8155: An unknown error was received"},
172 {0x00330000, 0, 0, 169 {0x00330000, 0, 0,
173 "Soft underlength error"}, 170 "Soft underlength error"},
@@ -175,37 +172,37 @@ struct ipr_error_table_t ipr_error_table[] = {
175 "Command to be cancelled not found"}, 172 "Command to be cancelled not found"},
176 {0x00808000, 0, 0, 173 {0x00808000, 0, 0,
177 "Qualified success"}, 174 "Qualified success"},
178 {0x01080000, 1, 1, 175 {0x01080000, 1, IPR_DEFAULT_LOG_LEVEL,
179 "FFFE: Soft device bus error recovered by the IOA"}, 176 "FFFE: Soft device bus error recovered by the IOA"},
180 {0x01088100, 0, 1, 177 {0x01088100, 0, IPR_DEFAULT_LOG_LEVEL,
181 "4101: Soft device bus fabric error"}, 178 "4101: Soft device bus fabric error"},
182 {0x01170600, 0, 1, 179 {0x01170600, 0, IPR_DEFAULT_LOG_LEVEL,
183 "FFF9: Device sector reassign successful"}, 180 "FFF9: Device sector reassign successful"},
184 {0x01170900, 0, 1, 181 {0x01170900, 0, IPR_DEFAULT_LOG_LEVEL,
185 "FFF7: Media error recovered by device rewrite procedures"}, 182 "FFF7: Media error recovered by device rewrite procedures"},
186 {0x01180200, 0, 1, 183 {0x01180200, 0, IPR_DEFAULT_LOG_LEVEL,
187 "7001: IOA sector reassignment successful"}, 184 "7001: IOA sector reassignment successful"},
188 {0x01180500, 0, 1, 185 {0x01180500, 0, IPR_DEFAULT_LOG_LEVEL,
189 "FFF9: Soft media error. Sector reassignment recommended"}, 186 "FFF9: Soft media error. Sector reassignment recommended"},
190 {0x01180600, 0, 1, 187 {0x01180600, 0, IPR_DEFAULT_LOG_LEVEL,
191 "FFF7: Media error recovered by IOA rewrite procedures"}, 188 "FFF7: Media error recovered by IOA rewrite procedures"},
192 {0x01418000, 0, 1, 189 {0x01418000, 0, IPR_DEFAULT_LOG_LEVEL,
193 "FF3D: Soft PCI bus error recovered by the IOA"}, 190 "FF3D: Soft PCI bus error recovered by the IOA"},
194 {0x01440000, 1, 1, 191 {0x01440000, 1, IPR_DEFAULT_LOG_LEVEL,
195 "FFF6: Device hardware error recovered by the IOA"}, 192 "FFF6: Device hardware error recovered by the IOA"},
196 {0x01448100, 0, 1, 193 {0x01448100, 0, IPR_DEFAULT_LOG_LEVEL,
197 "FFF6: Device hardware error recovered by the device"}, 194 "FFF6: Device hardware error recovered by the device"},
198 {0x01448200, 1, 1, 195 {0x01448200, 1, IPR_DEFAULT_LOG_LEVEL,
199 "FF3D: Soft IOA error recovered by the IOA"}, 196 "FF3D: Soft IOA error recovered by the IOA"},
200 {0x01448300, 0, 1, 197 {0x01448300, 0, IPR_DEFAULT_LOG_LEVEL,
201 "FFFA: Undefined device response recovered by the IOA"}, 198 "FFFA: Undefined device response recovered by the IOA"},
202 {0x014A0000, 1, 1, 199 {0x014A0000, 1, IPR_DEFAULT_LOG_LEVEL,
203 "FFF6: Device bus error, message or command phase"}, 200 "FFF6: Device bus error, message or command phase"},
204 {0x014A8000, 0, 1, 201 {0x014A8000, 0, IPR_DEFAULT_LOG_LEVEL,
205 "FFFE: Task Management Function failed"}, 202 "FFFE: Task Management Function failed"},
206 {0x015D0000, 0, 1, 203 {0x015D0000, 0, IPR_DEFAULT_LOG_LEVEL,
207 "FFF6: Failure prediction threshold exceeded"}, 204 "FFF6: Failure prediction threshold exceeded"},
208 {0x015D9200, 0, 1, 205 {0x015D9200, 0, IPR_DEFAULT_LOG_LEVEL,
209 "8009: Impending cache battery pack failure"}, 206 "8009: Impending cache battery pack failure"},
210 {0x02040400, 0, 0, 207 {0x02040400, 0, 0,
211 "34FF: Disk device format in progress"}, 208 "34FF: Disk device format in progress"},
@@ -215,85 +212,85 @@ struct ipr_error_table_t ipr_error_table[] = {
215 "No ready, IOA shutdown"}, 212 "No ready, IOA shutdown"},
216 {0x025A0000, 0, 0, 213 {0x025A0000, 0, 0,
217 "Not ready, IOA has been shutdown"}, 214 "Not ready, IOA has been shutdown"},
218 {0x02670100, 0, 1, 215 {0x02670100, 0, IPR_DEFAULT_LOG_LEVEL,
219 "3020: Storage subsystem configuration error"}, 216 "3020: Storage subsystem configuration error"},
220 {0x03110B00, 0, 0, 217 {0x03110B00, 0, 0,
221 "FFF5: Medium error, data unreadable, recommend reassign"}, 218 "FFF5: Medium error, data unreadable, recommend reassign"},
222 {0x03110C00, 0, 0, 219 {0x03110C00, 0, 0,
223 "7000: Medium error, data unreadable, do not reassign"}, 220 "7000: Medium error, data unreadable, do not reassign"},
224 {0x03310000, 0, 1, 221 {0x03310000, 0, IPR_DEFAULT_LOG_LEVEL,
225 "FFF3: Disk media format bad"}, 222 "FFF3: Disk media format bad"},
226 {0x04050000, 0, 1, 223 {0x04050000, 0, IPR_DEFAULT_LOG_LEVEL,
227 "3002: Addressed device failed to respond to selection"}, 224 "3002: Addressed device failed to respond to selection"},
228 {0x04080000, 1, 1, 225 {0x04080000, 1, IPR_DEFAULT_LOG_LEVEL,
229 "3100: Device bus error"}, 226 "3100: Device bus error"},
230 {0x04080100, 0, 1, 227 {0x04080100, 0, IPR_DEFAULT_LOG_LEVEL,
231 "3109: IOA timed out a device command"}, 228 "3109: IOA timed out a device command"},
232 {0x04088000, 0, 0, 229 {0x04088000, 0, 0,
233 "3120: SCSI bus is not operational"}, 230 "3120: SCSI bus is not operational"},
234 {0x04088100, 0, 1, 231 {0x04088100, 0, IPR_DEFAULT_LOG_LEVEL,
235 "4100: Hard device bus fabric error"}, 232 "4100: Hard device bus fabric error"},
236 {0x04118000, 0, 1, 233 {0x04118000, 0, IPR_DEFAULT_LOG_LEVEL,
237 "9000: IOA reserved area data check"}, 234 "9000: IOA reserved area data check"},
238 {0x04118100, 0, 1, 235 {0x04118100, 0, IPR_DEFAULT_LOG_LEVEL,
239 "9001: IOA reserved area invalid data pattern"}, 236 "9001: IOA reserved area invalid data pattern"},
240 {0x04118200, 0, 1, 237 {0x04118200, 0, IPR_DEFAULT_LOG_LEVEL,
241 "9002: IOA reserved area LRC error"}, 238 "9002: IOA reserved area LRC error"},
242 {0x04320000, 0, 1, 239 {0x04320000, 0, IPR_DEFAULT_LOG_LEVEL,
243 "102E: Out of alternate sectors for disk storage"}, 240 "102E: Out of alternate sectors for disk storage"},
244 {0x04330000, 1, 1, 241 {0x04330000, 1, IPR_DEFAULT_LOG_LEVEL,
245 "FFF4: Data transfer underlength error"}, 242 "FFF4: Data transfer underlength error"},
246 {0x04338000, 1, 1, 243 {0x04338000, 1, IPR_DEFAULT_LOG_LEVEL,
247 "FFF4: Data transfer overlength error"}, 244 "FFF4: Data transfer overlength error"},
248 {0x043E0100, 0, 1, 245 {0x043E0100, 0, IPR_DEFAULT_LOG_LEVEL,
249 "3400: Logical unit failure"}, 246 "3400: Logical unit failure"},
250 {0x04408500, 0, 1, 247 {0x04408500, 0, IPR_DEFAULT_LOG_LEVEL,
251 "FFF4: Device microcode is corrupt"}, 248 "FFF4: Device microcode is corrupt"},
252 {0x04418000, 1, 1, 249 {0x04418000, 1, IPR_DEFAULT_LOG_LEVEL,
253 "8150: PCI bus error"}, 250 "8150: PCI bus error"},
254 {0x04430000, 1, 0, 251 {0x04430000, 1, 0,
255 "Unsupported device bus message received"}, 252 "Unsupported device bus message received"},
256 {0x04440000, 1, 1, 253 {0x04440000, 1, IPR_DEFAULT_LOG_LEVEL,
257 "FFF4: Disk device problem"}, 254 "FFF4: Disk device problem"},
258 {0x04448200, 1, 1, 255 {0x04448200, 1, IPR_DEFAULT_LOG_LEVEL,
259 "8150: Permanent IOA failure"}, 256 "8150: Permanent IOA failure"},
260 {0x04448300, 0, 1, 257 {0x04448300, 0, IPR_DEFAULT_LOG_LEVEL,
261 "3010: Disk device returned wrong response to IOA"}, 258 "3010: Disk device returned wrong response to IOA"},
262 {0x04448400, 0, 1, 259 {0x04448400, 0, IPR_DEFAULT_LOG_LEVEL,
263 "8151: IOA microcode error"}, 260 "8151: IOA microcode error"},
264 {0x04448500, 0, 0, 261 {0x04448500, 0, 0,
265 "Device bus status error"}, 262 "Device bus status error"},
266 {0x04448600, 0, 1, 263 {0x04448600, 0, IPR_DEFAULT_LOG_LEVEL,
267 "8157: IOA error requiring IOA reset to recover"}, 264 "8157: IOA error requiring IOA reset to recover"},
268 {0x04448700, 0, 0, 265 {0x04448700, 0, 0,
269 "ATA device status error"}, 266 "ATA device status error"},
270 {0x04490000, 0, 0, 267 {0x04490000, 0, 0,
271 "Message reject received from the device"}, 268 "Message reject received from the device"},
272 {0x04449200, 0, 1, 269 {0x04449200, 0, IPR_DEFAULT_LOG_LEVEL,
273 "8008: A permanent cache battery pack failure occurred"}, 270 "8008: A permanent cache battery pack failure occurred"},
274 {0x0444A000, 0, 1, 271 {0x0444A000, 0, IPR_DEFAULT_LOG_LEVEL,
275 "9090: Disk unit has been modified after the last known status"}, 272 "9090: Disk unit has been modified after the last known status"},
276 {0x0444A200, 0, 1, 273 {0x0444A200, 0, IPR_DEFAULT_LOG_LEVEL,
277 "9081: IOA detected device error"}, 274 "9081: IOA detected device error"},
278 {0x0444A300, 0, 1, 275 {0x0444A300, 0, IPR_DEFAULT_LOG_LEVEL,
279 "9082: IOA detected device error"}, 276 "9082: IOA detected device error"},
280 {0x044A0000, 1, 1, 277 {0x044A0000, 1, IPR_DEFAULT_LOG_LEVEL,
281 "3110: Device bus error, message or command phase"}, 278 "3110: Device bus error, message or command phase"},
282 {0x044A8000, 1, 1, 279 {0x044A8000, 1, IPR_DEFAULT_LOG_LEVEL,
283 "3110: SAS Command / Task Management Function failed"}, 280 "3110: SAS Command / Task Management Function failed"},
284 {0x04670400, 0, 1, 281 {0x04670400, 0, IPR_DEFAULT_LOG_LEVEL,
285 "9091: Incorrect hardware configuration change has been detected"}, 282 "9091: Incorrect hardware configuration change has been detected"},
286 {0x04678000, 0, 1, 283 {0x04678000, 0, IPR_DEFAULT_LOG_LEVEL,
287 "9073: Invalid multi-adapter configuration"}, 284 "9073: Invalid multi-adapter configuration"},
288 {0x04678100, 0, 1, 285 {0x04678100, 0, IPR_DEFAULT_LOG_LEVEL,
289 "4010: Incorrect connection between cascaded expanders"}, 286 "4010: Incorrect connection between cascaded expanders"},
290 {0x04678200, 0, 1, 287 {0x04678200, 0, IPR_DEFAULT_LOG_LEVEL,
291 "4020: Connections exceed IOA design limits"}, 288 "4020: Connections exceed IOA design limits"},
292 {0x04678300, 0, 1, 289 {0x04678300, 0, IPR_DEFAULT_LOG_LEVEL,
293 "4030: Incorrect multipath connection"}, 290 "4030: Incorrect multipath connection"},
294 {0x04679000, 0, 1, 291 {0x04679000, 0, IPR_DEFAULT_LOG_LEVEL,
295 "4110: Unsupported enclosure function"}, 292 "4110: Unsupported enclosure function"},
296 {0x046E0000, 0, 1, 293 {0x046E0000, 0, IPR_DEFAULT_LOG_LEVEL,
297 "FFF4: Command to logical unit failed"}, 294 "FFF4: Command to logical unit failed"},
298 {0x05240000, 1, 0, 295 {0x05240000, 1, 0,
299 "Illegal request, invalid request type or request packet"}, 296 "Illegal request, invalid request type or request packet"},
@@ -313,101 +310,103 @@ struct ipr_error_table_t ipr_error_table[] = {
313 "Illegal request, command sequence error"}, 310 "Illegal request, command sequence error"},
314 {0x052C8000, 1, 0, 311 {0x052C8000, 1, 0,
315 "Illegal request, dual adapter support not enabled"}, 312 "Illegal request, dual adapter support not enabled"},
316 {0x06040500, 0, 1, 313 {0x06040500, 0, IPR_DEFAULT_LOG_LEVEL,
317 "9031: Array protection temporarily suspended, protection resuming"}, 314 "9031: Array protection temporarily suspended, protection resuming"},
318 {0x06040600, 0, 1, 315 {0x06040600, 0, IPR_DEFAULT_LOG_LEVEL,
319 "9040: Array protection temporarily suspended, protection resuming"}, 316 "9040: Array protection temporarily suspended, protection resuming"},
320 {0x06288000, 0, 1, 317 {0x06288000, 0, IPR_DEFAULT_LOG_LEVEL,
321 "3140: Device bus not ready to ready transition"}, 318 "3140: Device bus not ready to ready transition"},
322 {0x06290000, 0, 1, 319 {0x06290000, 0, IPR_DEFAULT_LOG_LEVEL,
323 "FFFB: SCSI bus was reset"}, 320 "FFFB: SCSI bus was reset"},
324 {0x06290500, 0, 0, 321 {0x06290500, 0, 0,
325 "FFFE: SCSI bus transition to single ended"}, 322 "FFFE: SCSI bus transition to single ended"},
326 {0x06290600, 0, 0, 323 {0x06290600, 0, 0,
327 "FFFE: SCSI bus transition to LVD"}, 324 "FFFE: SCSI bus transition to LVD"},
328 {0x06298000, 0, 1, 325 {0x06298000, 0, IPR_DEFAULT_LOG_LEVEL,
329 "FFFB: SCSI bus was reset by another initiator"}, 326 "FFFB: SCSI bus was reset by another initiator"},
330 {0x063F0300, 0, 1, 327 {0x063F0300, 0, IPR_DEFAULT_LOG_LEVEL,
331 "3029: A device replacement has occurred"}, 328 "3029: A device replacement has occurred"},
332 {0x064C8000, 0, 1, 329 {0x064C8000, 0, IPR_DEFAULT_LOG_LEVEL,
333 "9051: IOA cache data exists for a missing or failed device"}, 330 "9051: IOA cache data exists for a missing or failed device"},
334 {0x064C8100, 0, 1, 331 {0x064C8100, 0, IPR_DEFAULT_LOG_LEVEL,
335 "9055: Auxiliary cache IOA contains cache data needed by the primary IOA"}, 332 "9055: Auxiliary cache IOA contains cache data needed by the primary IOA"},
336 {0x06670100, 0, 1, 333 {0x06670100, 0, IPR_DEFAULT_LOG_LEVEL,
337 "9025: Disk unit is not supported at its physical location"}, 334 "9025: Disk unit is not supported at its physical location"},
338 {0x06670600, 0, 1, 335 {0x06670600, 0, IPR_DEFAULT_LOG_LEVEL,
339 "3020: IOA detected a SCSI bus configuration error"}, 336 "3020: IOA detected a SCSI bus configuration error"},
340 {0x06678000, 0, 1, 337 {0x06678000, 0, IPR_DEFAULT_LOG_LEVEL,
341 "3150: SCSI bus configuration error"}, 338 "3150: SCSI bus configuration error"},
342 {0x06678100, 0, 1, 339 {0x06678100, 0, IPR_DEFAULT_LOG_LEVEL,
343 "9074: Asymmetric advanced function disk configuration"}, 340 "9074: Asymmetric advanced function disk configuration"},
344 {0x06678300, 0, 1, 341 {0x06678300, 0, IPR_DEFAULT_LOG_LEVEL,
345 "4040: Incomplete multipath connection between IOA and enclosure"}, 342 "4040: Incomplete multipath connection between IOA and enclosure"},
346 {0x06678400, 0, 1, 343 {0x06678400, 0, IPR_DEFAULT_LOG_LEVEL,
347 "4041: Incomplete multipath connection between enclosure and device"}, 344 "4041: Incomplete multipath connection between enclosure and device"},
348 {0x06678500, 0, 1, 345 {0x06678500, 0, IPR_DEFAULT_LOG_LEVEL,
349 "9075: Incomplete multipath connection between IOA and remote IOA"}, 346 "9075: Incomplete multipath connection between IOA and remote IOA"},
350 {0x06678600, 0, 1, 347 {0x06678600, 0, IPR_DEFAULT_LOG_LEVEL,
351 "9076: Configuration error, missing remote IOA"}, 348 "9076: Configuration error, missing remote IOA"},
352 {0x06679100, 0, 1, 349 {0x06679100, 0, IPR_DEFAULT_LOG_LEVEL,
353 "4050: Enclosure does not support a required multipath function"}, 350 "4050: Enclosure does not support a required multipath function"},
354 {0x06690200, 0, 1, 351 {0x06690200, 0, IPR_DEFAULT_LOG_LEVEL,
355 "9041: Array protection temporarily suspended"}, 352 "9041: Array protection temporarily suspended"},
356 {0x06698200, 0, 1, 353 {0x06698200, 0, IPR_DEFAULT_LOG_LEVEL,
357 "9042: Corrupt array parity detected on specified device"}, 354 "9042: Corrupt array parity detected on specified device"},
358 {0x066B0200, 0, 1, 355 {0x066B0200, 0, IPR_DEFAULT_LOG_LEVEL,
359 "9030: Array no longer protected due to missing or failed disk unit"}, 356 "9030: Array no longer protected due to missing or failed disk unit"},
360 {0x066B8000, 0, 1, 357 {0x066B8000, 0, IPR_DEFAULT_LOG_LEVEL,
361 "9071: Link operational transition"}, 358 "9071: Link operational transition"},
362 {0x066B8100, 0, 1, 359 {0x066B8100, 0, IPR_DEFAULT_LOG_LEVEL,
363 "9072: Link not operational transition"}, 360 "9072: Link not operational transition"},
364 {0x066B8200, 0, 1, 361 {0x066B8200, 0, IPR_DEFAULT_LOG_LEVEL,
365 "9032: Array exposed but still protected"}, 362 "9032: Array exposed but still protected"},
366 {0x066B9100, 0, 1, 363 {0x066B8300, 0, IPR_DEFAULT_LOG_LEVEL + 1,
364 "70DD: Device forced failed by disrupt device command"},
365 {0x066B9100, 0, IPR_DEFAULT_LOG_LEVEL,
367 "4061: Multipath redundancy level got better"}, 366 "4061: Multipath redundancy level got better"},
368 {0x066B9200, 0, 1, 367 {0x066B9200, 0, IPR_DEFAULT_LOG_LEVEL,
369 "4060: Multipath redundancy level got worse"}, 368 "4060: Multipath redundancy level got worse"},
370 {0x07270000, 0, 0, 369 {0x07270000, 0, 0,
371 "Failure due to other device"}, 370 "Failure due to other device"},
372 {0x07278000, 0, 1, 371 {0x07278000, 0, IPR_DEFAULT_LOG_LEVEL,
373 "9008: IOA does not support functions expected by devices"}, 372 "9008: IOA does not support functions expected by devices"},
374 {0x07278100, 0, 1, 373 {0x07278100, 0, IPR_DEFAULT_LOG_LEVEL,
375 "9010: Cache data associated with attached devices cannot be found"}, 374 "9010: Cache data associated with attached devices cannot be found"},
376 {0x07278200, 0, 1, 375 {0x07278200, 0, IPR_DEFAULT_LOG_LEVEL,
377 "9011: Cache data belongs to devices other than those attached"}, 376 "9011: Cache data belongs to devices other than those attached"},
378 {0x07278400, 0, 1, 377 {0x07278400, 0, IPR_DEFAULT_LOG_LEVEL,
379 "9020: Array missing 2 or more devices with only 1 device present"}, 378 "9020: Array missing 2 or more devices with only 1 device present"},
380 {0x07278500, 0, 1, 379 {0x07278500, 0, IPR_DEFAULT_LOG_LEVEL,
381 "9021: Array missing 2 or more devices with 2 or more devices present"}, 380 "9021: Array missing 2 or more devices with 2 or more devices present"},
382 {0x07278600, 0, 1, 381 {0x07278600, 0, IPR_DEFAULT_LOG_LEVEL,
383 "9022: Exposed array is missing a required device"}, 382 "9022: Exposed array is missing a required device"},
384 {0x07278700, 0, 1, 383 {0x07278700, 0, IPR_DEFAULT_LOG_LEVEL,
385 "9023: Array member(s) not at required physical locations"}, 384 "9023: Array member(s) not at required physical locations"},
386 {0x07278800, 0, 1, 385 {0x07278800, 0, IPR_DEFAULT_LOG_LEVEL,
387 "9024: Array not functional due to present hardware configuration"}, 386 "9024: Array not functional due to present hardware configuration"},
388 {0x07278900, 0, 1, 387 {0x07278900, 0, IPR_DEFAULT_LOG_LEVEL,
389 "9026: Array not functional due to present hardware configuration"}, 388 "9026: Array not functional due to present hardware configuration"},
390 {0x07278A00, 0, 1, 389 {0x07278A00, 0, IPR_DEFAULT_LOG_LEVEL,
391 "9027: Array is missing a device and parity is out of sync"}, 390 "9027: Array is missing a device and parity is out of sync"},
392 {0x07278B00, 0, 1, 391 {0x07278B00, 0, IPR_DEFAULT_LOG_LEVEL,
393 "9028: Maximum number of arrays already exist"}, 392 "9028: Maximum number of arrays already exist"},
394 {0x07278C00, 0, 1, 393 {0x07278C00, 0, IPR_DEFAULT_LOG_LEVEL,
395 "9050: Required cache data cannot be located for a disk unit"}, 394 "9050: Required cache data cannot be located for a disk unit"},
396 {0x07278D00, 0, 1, 395 {0x07278D00, 0, IPR_DEFAULT_LOG_LEVEL,
397 "9052: Cache data exists for a device that has been modified"}, 396 "9052: Cache data exists for a device that has been modified"},
398 {0x07278F00, 0, 1, 397 {0x07278F00, 0, IPR_DEFAULT_LOG_LEVEL,
399 "9054: IOA resources not available due to previous problems"}, 398 "9054: IOA resources not available due to previous problems"},
400 {0x07279100, 0, 1, 399 {0x07279100, 0, IPR_DEFAULT_LOG_LEVEL,
401 "9092: Disk unit requires initialization before use"}, 400 "9092: Disk unit requires initialization before use"},
402 {0x07279200, 0, 1, 401 {0x07279200, 0, IPR_DEFAULT_LOG_LEVEL,
403 "9029: Incorrect hardware configuration change has been detected"}, 402 "9029: Incorrect hardware configuration change has been detected"},
404 {0x07279600, 0, 1, 403 {0x07279600, 0, IPR_DEFAULT_LOG_LEVEL,
405 "9060: One or more disk pairs are missing from an array"}, 404 "9060: One or more disk pairs are missing from an array"},
406 {0x07279700, 0, 1, 405 {0x07279700, 0, IPR_DEFAULT_LOG_LEVEL,
407 "9061: One or more disks are missing from an array"}, 406 "9061: One or more disks are missing from an array"},
408 {0x07279800, 0, 1, 407 {0x07279800, 0, IPR_DEFAULT_LOG_LEVEL,
409 "9062: One or more disks are missing from an array"}, 408 "9062: One or more disks are missing from an array"},
410 {0x07279900, 0, 1, 409 {0x07279900, 0, IPR_DEFAULT_LOG_LEVEL,
411 "9063: Maximum number of functional arrays has been exceeded"}, 410 "9063: Maximum number of functional arrays has been exceeded"},
412 {0x0B260000, 0, 0, 411 {0x0B260000, 0, 0,
413 "Aborted command, invalid descriptor"}, 412 "Aborted command, invalid descriptor"},
@@ -481,12 +480,16 @@ static void ipr_reinit_ipr_cmnd(struct ipr_cmnd *ipr_cmd)
481{ 480{
482 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; 481 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
483 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa; 482 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa;
483 dma_addr_t dma_addr = be32_to_cpu(ioarcb->ioarcb_host_pci_addr);
484 484
485 memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt)); 485 memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt));
486 ioarcb->write_data_transfer_length = 0; 486 ioarcb->write_data_transfer_length = 0;
487 ioarcb->read_data_transfer_length = 0; 487 ioarcb->read_data_transfer_length = 0;
488 ioarcb->write_ioadl_len = 0; 488 ioarcb->write_ioadl_len = 0;
489 ioarcb->read_ioadl_len = 0; 489 ioarcb->read_ioadl_len = 0;
490 ioarcb->write_ioadl_addr =
491 cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl));
492 ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr;
490 ioasa->ioasc = 0; 493 ioasa->ioasc = 0;
491 ioasa->residual_data_len = 0; 494 ioasa->residual_data_len = 0;
492 ioasa->u.gata.status = 0; 495 ioasa->u.gata.status = 0;
@@ -1610,7 +1613,7 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
1610 /* Set indication we have logged an error */ 1613 /* Set indication we have logged an error */
1611 ioa_cfg->errors_logged++; 1614 ioa_cfg->errors_logged++;
1612 1615
1613 if (ioa_cfg->log_level < IPR_DEFAULT_LOG_LEVEL) 1616 if (ioa_cfg->log_level < ipr_error_table[error_index].log_hcam)
1614 return; 1617 return;
1615 if (be32_to_cpu(hostrcb->hcam.length) > sizeof(hostrcb->hcam.u.raw)) 1618 if (be32_to_cpu(hostrcb->hcam.length) > sizeof(hostrcb->hcam.u.raw))
1616 hostrcb->hcam.length = cpu_to_be32(sizeof(hostrcb->hcam.u.raw)); 1619 hostrcb->hcam.length = cpu_to_be32(sizeof(hostrcb->hcam.u.raw));
@@ -3850,6 +3853,8 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
3850 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) { 3853 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) {
3851 if (ipr_cmd->scsi_cmd) 3854 if (ipr_cmd->scsi_cmd)
3852 ipr_cmd->done = ipr_scsi_eh_done; 3855 ipr_cmd->done = ipr_scsi_eh_done;
3856 if (ipr_cmd->qc)
3857 ipr_cmd->done = ipr_sata_eh_done;
3853 if (ipr_cmd->qc && !(ipr_cmd->qc->flags & ATA_QCFLAG_FAILED)) { 3858 if (ipr_cmd->qc && !(ipr_cmd->qc->flags & ATA_QCFLAG_FAILED)) {
3854 ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT; 3859 ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT;
3855 ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED; 3860 ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED;
@@ -4230,6 +4235,14 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg,
4230 4235
4231 sglist = scsi_cmd->request_buffer; 4236 sglist = scsi_cmd->request_buffer;
4232 4237
4238 if (ipr_cmd->dma_use_sg <= ARRAY_SIZE(ioarcb->add_data.u.ioadl)) {
4239 ioadl = ioarcb->add_data.u.ioadl;
4240 ioarcb->write_ioadl_addr =
4241 cpu_to_be32(be32_to_cpu(ioarcb->ioarcb_host_pci_addr) +
4242 offsetof(struct ipr_ioarcb, add_data));
4243 ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr;
4244 }
4245
4233 for (i = 0; i < ipr_cmd->dma_use_sg; i++) { 4246 for (i = 0; i < ipr_cmd->dma_use_sg; i++) {
4234 ioadl[i].flags_and_data_len = 4247 ioadl[i].flags_and_data_len =
4235 cpu_to_be32(ioadl_flags | sg_dma_len(&sglist[i])); 4248 cpu_to_be32(ioadl_flags | sg_dma_len(&sglist[i]));
@@ -4260,6 +4273,11 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg,
4260 scsi_cmd->sc_data_direction); 4273 scsi_cmd->sc_data_direction);
4261 4274
4262 if (likely(!pci_dma_mapping_error(ipr_cmd->dma_handle))) { 4275 if (likely(!pci_dma_mapping_error(ipr_cmd->dma_handle))) {
4276 ioadl = ioarcb->add_data.u.ioadl;
4277 ioarcb->write_ioadl_addr =
4278 cpu_to_be32(be32_to_cpu(ioarcb->ioarcb_host_pci_addr) +
4279 offsetof(struct ipr_ioarcb, add_data));
4280 ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr;
4263 ipr_cmd->dma_use_sg = 1; 4281 ipr_cmd->dma_use_sg = 1;
4264 ioadl[0].flags_and_data_len = 4282 ioadl[0].flags_and_data_len =
4265 cpu_to_be32(ioadl_flags | length | IPR_IOADL_FLAGS_LAST); 4283 cpu_to_be32(ioadl_flags | length | IPR_IOADL_FLAGS_LAST);
@@ -4346,11 +4364,9 @@ static void ipr_erp_done(struct ipr_cmnd *ipr_cmd)
4346 **/ 4364 **/
4347static void ipr_reinit_ipr_cmnd_for_erp(struct ipr_cmnd *ipr_cmd) 4365static void ipr_reinit_ipr_cmnd_for_erp(struct ipr_cmnd *ipr_cmd)
4348{ 4366{
4349 struct ipr_ioarcb *ioarcb; 4367 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
4350 struct ipr_ioasa *ioasa; 4368 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa;
4351 4369 dma_addr_t dma_addr = be32_to_cpu(ioarcb->ioarcb_host_pci_addr);
4352 ioarcb = &ipr_cmd->ioarcb;
4353 ioasa = &ipr_cmd->ioasa;
4354 4370
4355 memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt)); 4371 memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt));
4356 ioarcb->write_data_transfer_length = 0; 4372 ioarcb->write_data_transfer_length = 0;
@@ -4359,6 +4375,9 @@ static void ipr_reinit_ipr_cmnd_for_erp(struct ipr_cmnd *ipr_cmd)
4359 ioarcb->read_ioadl_len = 0; 4375 ioarcb->read_ioadl_len = 0;
4360 ioasa->ioasc = 0; 4376 ioasa->ioasc = 0;
4361 ioasa->residual_data_len = 0; 4377 ioasa->residual_data_len = 0;
4378 ioarcb->write_ioadl_addr =
4379 cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl));
4380 ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr;
4362} 4381}
4363 4382
4364/** 4383/**
@@ -4457,12 +4476,13 @@ static void ipr_dump_ioasa(struct ipr_ioa_cfg *ioa_cfg,
4457{ 4476{
4458 int i; 4477 int i;
4459 u16 data_len; 4478 u16 data_len;
4460 u32 ioasc; 4479 u32 ioasc, fd_ioasc;
4461 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa; 4480 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa;
4462 __be32 *ioasa_data = (__be32 *)ioasa; 4481 __be32 *ioasa_data = (__be32 *)ioasa;
4463 int error_index; 4482 int error_index;
4464 4483
4465 ioasc = be32_to_cpu(ioasa->ioasc) & IPR_IOASC_IOASC_MASK; 4484 ioasc = be32_to_cpu(ioasa->ioasc) & IPR_IOASC_IOASC_MASK;
4485 fd_ioasc = be32_to_cpu(ioasa->fd_ioasc) & IPR_IOASC_IOASC_MASK;
4466 4486
4467 if (0 == ioasc) 4487 if (0 == ioasc)
4468 return; 4488 return;
@@ -4470,13 +4490,19 @@ static void ipr_dump_ioasa(struct ipr_ioa_cfg *ioa_cfg,
4470 if (ioa_cfg->log_level < IPR_DEFAULT_LOG_LEVEL) 4490 if (ioa_cfg->log_level < IPR_DEFAULT_LOG_LEVEL)
4471 return; 4491 return;
4472 4492
4473 error_index = ipr_get_error(ioasc); 4493 if (ioasc == IPR_IOASC_BUS_WAS_RESET && fd_ioasc)
4494 error_index = ipr_get_error(fd_ioasc);
4495 else
4496 error_index = ipr_get_error(ioasc);
4474 4497
4475 if (ioa_cfg->log_level < IPR_MAX_LOG_LEVEL) { 4498 if (ioa_cfg->log_level < IPR_MAX_LOG_LEVEL) {
4476 /* Don't log an error if the IOA already logged one */ 4499 /* Don't log an error if the IOA already logged one */
4477 if (ioasa->ilid != 0) 4500 if (ioasa->ilid != 0)
4478 return; 4501 return;
4479 4502
4503 if (!ipr_is_gscsi(res))
4504 return;
4505
4480 if (ipr_error_table[error_index].log_ioasa == 0) 4506 if (ipr_error_table[error_index].log_ioasa == 0)
4481 return; 4507 return;
4482 } 4508 }
@@ -4636,11 +4662,11 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
4636 return; 4662 return;
4637 } 4663 }
4638 4664
4639 if (ipr_is_gscsi(res)) 4665 if (!ipr_is_gscsi(res))
4640 ipr_dump_ioasa(ioa_cfg, ipr_cmd, res);
4641 else
4642 ipr_gen_sense(ipr_cmd); 4666 ipr_gen_sense(ipr_cmd);
4643 4667
4668 ipr_dump_ioasa(ioa_cfg, ipr_cmd, res);
4669
4644 switch (ioasc & IPR_IOASC_IOASC_MASK) { 4670 switch (ioasc & IPR_IOASC_IOASC_MASK) {
4645 case IPR_IOASC_ABORTED_CMD_TERM_BY_HOST: 4671 case IPR_IOASC_ABORTED_CMD_TERM_BY_HOST:
4646 if (ipr_is_naca_model(res)) 4672 if (ipr_is_naca_model(res))
@@ -5121,7 +5147,7 @@ static unsigned int ipr_qc_issue(struct ata_queued_cmd *qc)
5121 struct ipr_ioarcb_ata_regs *regs; 5147 struct ipr_ioarcb_ata_regs *regs;
5122 5148
5123 if (unlikely(!ioa_cfg->allow_cmds || ioa_cfg->ioa_is_dead)) 5149 if (unlikely(!ioa_cfg->allow_cmds || ioa_cfg->ioa_is_dead))
5124 return -EIO; 5150 return AC_ERR_SYSTEM;
5125 5151
5126 ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); 5152 ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg);
5127 ioarcb = &ipr_cmd->ioarcb; 5153 ioarcb = &ipr_cmd->ioarcb;
@@ -5166,7 +5192,7 @@ static unsigned int ipr_qc_issue(struct ata_queued_cmd *qc)
5166 5192
5167 default: 5193 default:
5168 WARN_ON(1); 5194 WARN_ON(1);
5169 return -1; 5195 return AC_ERR_INVALID;
5170 } 5196 }
5171 5197
5172 mb(); 5198 mb();
@@ -6188,7 +6214,7 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd)
6188 dev_info(&ioa_cfg->pdev->dev, "Initializing IOA.\n"); 6214 dev_info(&ioa_cfg->pdev->dev, "Initializing IOA.\n");
6189 6215
6190 ipr_cmd->timer.data = (unsigned long) ipr_cmd; 6216 ipr_cmd->timer.data = (unsigned long) ipr_cmd;
6191 ipr_cmd->timer.expires = jiffies + (ipr_transop_timeout * HZ); 6217 ipr_cmd->timer.expires = jiffies + (ioa_cfg->transop_timeout * HZ);
6192 ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout; 6218 ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout;
6193 ipr_cmd->done = ipr_reset_ioa_job; 6219 ipr_cmd->done = ipr_reset_ioa_job;
6194 add_timer(&ipr_cmd->timer); 6220 add_timer(&ipr_cmd->timer);
@@ -6385,6 +6411,7 @@ static int ipr_reset_start_bist(struct ipr_cmnd *ipr_cmd)
6385 rc = pci_write_config_byte(ioa_cfg->pdev, PCI_BIST, PCI_BIST_START); 6411 rc = pci_write_config_byte(ioa_cfg->pdev, PCI_BIST, PCI_BIST_START);
6386 6412
6387 if (rc != PCIBIOS_SUCCESSFUL) { 6413 if (rc != PCIBIOS_SUCCESSFUL) {
6414 pci_unblock_user_cfg_access(ipr_cmd->ioa_cfg->pdev);
6388 ipr_cmd->ioasa.ioasc = cpu_to_be32(IPR_IOASC_PCI_ACCESS_ERROR); 6415 ipr_cmd->ioasa.ioasc = cpu_to_be32(IPR_IOASC_PCI_ACCESS_ERROR);
6389 rc = IPR_RC_JOB_CONTINUE; 6416 rc = IPR_RC_JOB_CONTINUE;
6390 } else { 6417 } else {
@@ -7117,8 +7144,6 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
7117 ioa_cfg->pdev = pdev; 7144 ioa_cfg->pdev = pdev;
7118 ioa_cfg->log_level = ipr_log_level; 7145 ioa_cfg->log_level = ipr_log_level;
7119 ioa_cfg->doorbell = IPR_DOORBELL; 7146 ioa_cfg->doorbell = IPR_DOORBELL;
7120 if (!ipr_auto_create)
7121 ioa_cfg->doorbell |= IPR_RUNTIME_RESET;
7122 sprintf(ioa_cfg->eye_catcher, IPR_EYECATCHER); 7147 sprintf(ioa_cfg->eye_catcher, IPR_EYECATCHER);
7123 sprintf(ioa_cfg->trace_start, IPR_TRACE_START_LABEL); 7148 sprintf(ioa_cfg->trace_start, IPR_TRACE_START_LABEL);
7124 sprintf(ioa_cfg->ipr_free_label, IPR_FREEQ_LABEL); 7149 sprintf(ioa_cfg->ipr_free_label, IPR_FREEQ_LABEL);
@@ -7233,6 +7258,13 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
7233 goto out_scsi_host_put; 7258 goto out_scsi_host_put;
7234 } 7259 }
7235 7260
7261 if (ipr_transop_timeout)
7262 ioa_cfg->transop_timeout = ipr_transop_timeout;
7263 else if (dev_id->driver_data & IPR_USE_LONG_TRANSOP_TIMEOUT)
7264 ioa_cfg->transop_timeout = IPR_LONG_OPERATIONAL_TIMEOUT;
7265 else
7266 ioa_cfg->transop_timeout = IPR_OPERATIONAL_TIMEOUT;
7267
7236 ipr_regs_pci = pci_resource_start(pdev, 0); 7268 ipr_regs_pci = pci_resource_start(pdev, 0);
7237 7269
7238 rc = pci_request_regions(pdev, IPR_NAME); 7270 rc = pci_request_regions(pdev, IPR_NAME);
@@ -7540,29 +7572,45 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = {
7540 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, 7572 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE,
7541 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571A, 0, 0, 0 }, 7573 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571A, 0, 0, 0 },
7542 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, 7574 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE,
7543 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575B, 0, 0, 0 }, 7575 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575B, 0, 0,
7576 IPR_USE_LONG_TRANSOP_TIMEOUT },
7544 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7577 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
7545 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 0, 0, 0 }, 7578 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 0, 0, 0 },
7546 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7579 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
7547 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 0, 0, 0 }, 7580 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 0, 0, 0 },
7548 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7581 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
7549 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 0 }, 7582 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0,
7583 IPR_USE_LONG_TRANSOP_TIMEOUT },
7550 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7584 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7551 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 0, 0, 0 }, 7585 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 0, 0, 0 },
7552 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7586 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7553 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 0, 0, 0 }, 7587 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 0, 0, 0 },
7554 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7588 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7555 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 0 }, 7589 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0,
7590 IPR_USE_LONG_TRANSOP_TIMEOUT },
7591 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
7592 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_574E, 0, 0, 0 },
7593 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
7594 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575D, 0, 0,
7595 IPR_USE_LONG_TRANSOP_TIMEOUT },
7596 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
7597 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B3, 0, 0, 0 },
7556 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, 7598 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
7557 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0, 0 }, 7599 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0,
7600 IPR_USE_LONG_TRANSOP_TIMEOUT },
7558 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, 7601 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE,
7559 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 0, 0, 0 }, 7602 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 0, 0, 0 },
7560 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7603 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
7561 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571E, 0, 0, 0 }, 7604 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571E, 0, 0, 0 },
7562 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7605 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
7563 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F, 0, 0, 0 }, 7606 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F, 0, 0,
7607 IPR_USE_LONG_TRANSOP_TIMEOUT },
7564 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7608 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
7565 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F, 0, 0, 0 }, 7609 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F, 0, 0,
7610 IPR_USE_LONG_TRANSOP_TIMEOUT },
7611 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SCAMP_E,
7612 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_574D, 0, 0,
7613 IPR_USE_LONG_TRANSOP_TIMEOUT },
7566 { } 7614 { }
7567}; 7615};
7568MODULE_DEVICE_TABLE(pci, ipr_pci_table); 7616MODULE_DEVICE_TABLE(pci, ipr_pci_table);
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 88f285de97bb..bc53d7cebe0a 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -37,8 +37,8 @@
37/* 37/*
38 * Literals 38 * Literals
39 */ 39 */
40#define IPR_DRIVER_VERSION "2.3.1" 40#define IPR_DRIVER_VERSION "2.3.2"
41#define IPR_DRIVER_DATE "(January 23, 2007)" 41#define IPR_DRIVER_DATE "(March 23, 2007)"
42 42
43/* 43/*
44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding 44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
@@ -55,6 +55,7 @@
55#define IPR_NUM_BASE_CMD_BLKS 100 55#define IPR_NUM_BASE_CMD_BLKS 100
56 56
57#define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339 57#define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339
58#define PCI_DEVICE_ID_IBM_SCAMP_E 0x034A
58 59
59#define IPR_SUBS_DEV_ID_2780 0x0264 60#define IPR_SUBS_DEV_ID_2780 0x0264
60#define IPR_SUBS_DEV_ID_5702 0x0266 61#define IPR_SUBS_DEV_ID_5702 0x0266
@@ -69,8 +70,12 @@
69#define IPR_SUBS_DEV_ID_572A 0x02C1 70#define IPR_SUBS_DEV_ID_572A 0x02C1
70#define IPR_SUBS_DEV_ID_572B 0x02C2 71#define IPR_SUBS_DEV_ID_572B 0x02C2
71#define IPR_SUBS_DEV_ID_572F 0x02C3 72#define IPR_SUBS_DEV_ID_572F 0x02C3
73#define IPR_SUBS_DEV_ID_574D 0x030B
74#define IPR_SUBS_DEV_ID_574E 0x030A
72#define IPR_SUBS_DEV_ID_575B 0x030D 75#define IPR_SUBS_DEV_ID_575B 0x030D
73#define IPR_SUBS_DEV_ID_575C 0x0338 76#define IPR_SUBS_DEV_ID_575C 0x0338
77#define IPR_SUBS_DEV_ID_575D 0x033E
78#define IPR_SUBS_DEV_ID_57B3 0x033A
74#define IPR_SUBS_DEV_ID_57B7 0x0360 79#define IPR_SUBS_DEV_ID_57B7 0x0360
75#define IPR_SUBS_DEV_ID_57B8 0x02C2 80#define IPR_SUBS_DEV_ID_57B8 0x02C2
76 81
@@ -104,6 +109,9 @@
104#define IPR_IOASC_IOA_WAS_RESET 0x10000001 109#define IPR_IOASC_IOA_WAS_RESET 0x10000001
105#define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002 110#define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002
106 111
112/* Driver data flags */
113#define IPR_USE_LONG_TRANSOP_TIMEOUT 0x00000001
114
107#define IPR_DEFAULT_MAX_ERROR_DUMP 984 115#define IPR_DEFAULT_MAX_ERROR_DUMP 984
108#define IPR_NUM_LOG_HCAMS 2 116#define IPR_NUM_LOG_HCAMS 2
109#define IPR_NUM_CFG_CHG_HCAMS 2 117#define IPR_NUM_CFG_CHG_HCAMS 2
@@ -179,6 +187,7 @@
179#define IPR_SET_SUP_DEVICE_TIMEOUT (2 * 60 * HZ) 187#define IPR_SET_SUP_DEVICE_TIMEOUT (2 * 60 * HZ)
180#define IPR_REQUEST_SENSE_TIMEOUT (10 * HZ) 188#define IPR_REQUEST_SENSE_TIMEOUT (10 * HZ)
181#define IPR_OPERATIONAL_TIMEOUT (5 * 60) 189#define IPR_OPERATIONAL_TIMEOUT (5 * 60)
190#define IPR_LONG_OPERATIONAL_TIMEOUT (12 * 60)
182#define IPR_WAIT_FOR_RESET_TIMEOUT (2 * HZ) 191#define IPR_WAIT_FOR_RESET_TIMEOUT (2 * HZ)
183#define IPR_CHECK_FOR_RESET_TIMEOUT (HZ / 10) 192#define IPR_CHECK_FOR_RESET_TIMEOUT (HZ / 10)
184#define IPR_WAIT_FOR_BIST_TIMEOUT (2 * HZ) 193#define IPR_WAIT_FOR_BIST_TIMEOUT (2 * HZ)
@@ -413,9 +422,25 @@ struct ipr_ioarcb_ata_regs {
413 u8 ctl; 422 u8 ctl;
414}__attribute__ ((packed, aligned(4))); 423}__attribute__ ((packed, aligned(4)));
415 424
425struct ipr_ioadl_desc {
426 __be32 flags_and_data_len;
427#define IPR_IOADL_FLAGS_MASK 0xff000000
428#define IPR_IOADL_GET_FLAGS(x) (be32_to_cpu(x) & IPR_IOADL_FLAGS_MASK)
429#define IPR_IOADL_DATA_LEN_MASK 0x00ffffff
430#define IPR_IOADL_GET_DATA_LEN(x) (be32_to_cpu(x) & IPR_IOADL_DATA_LEN_MASK)
431#define IPR_IOADL_FLAGS_READ 0x48000000
432#define IPR_IOADL_FLAGS_READ_LAST 0x49000000
433#define IPR_IOADL_FLAGS_WRITE 0x68000000
434#define IPR_IOADL_FLAGS_WRITE_LAST 0x69000000
435#define IPR_IOADL_FLAGS_LAST 0x01000000
436
437 __be32 address;
438}__attribute__((packed, aligned (8)));
439
416struct ipr_ioarcb_add_data { 440struct ipr_ioarcb_add_data {
417 union { 441 union {
418 struct ipr_ioarcb_ata_regs regs; 442 struct ipr_ioarcb_ata_regs regs;
443 struct ipr_ioadl_desc ioadl[5];
419 __be32 add_cmd_parms[10]; 444 __be32 add_cmd_parms[10];
420 }u; 445 }u;
421}__attribute__ ((packed, aligned(4))); 446}__attribute__ ((packed, aligned(4)));
@@ -447,21 +472,6 @@ struct ipr_ioarcb {
447 struct ipr_ioarcb_add_data add_data; 472 struct ipr_ioarcb_add_data add_data;
448}__attribute__((packed, aligned (4))); 473}__attribute__((packed, aligned (4)));
449 474
450struct ipr_ioadl_desc {
451 __be32 flags_and_data_len;
452#define IPR_IOADL_FLAGS_MASK 0xff000000
453#define IPR_IOADL_GET_FLAGS(x) (be32_to_cpu(x) & IPR_IOADL_FLAGS_MASK)
454#define IPR_IOADL_DATA_LEN_MASK 0x00ffffff
455#define IPR_IOADL_GET_DATA_LEN(x) (be32_to_cpu(x) & IPR_IOADL_DATA_LEN_MASK)
456#define IPR_IOADL_FLAGS_READ 0x48000000
457#define IPR_IOADL_FLAGS_READ_LAST 0x49000000
458#define IPR_IOADL_FLAGS_WRITE 0x68000000
459#define IPR_IOADL_FLAGS_WRITE_LAST 0x69000000
460#define IPR_IOADL_FLAGS_LAST 0x01000000
461
462 __be32 address;
463}__attribute__((packed, aligned (8)));
464
465struct ipr_ioasa_vset { 475struct ipr_ioasa_vset {
466 __be32 failing_lba_hi; 476 __be32 failing_lba_hi;
467 __be32 failing_lba_lo; 477 __be32 failing_lba_lo;
@@ -1119,6 +1129,7 @@ struct ipr_ioa_cfg {
1119 1129
1120 struct ipr_bus_attributes bus_attr[IPR_MAX_NUM_BUSES]; 1130 struct ipr_bus_attributes bus_attr[IPR_MAX_NUM_BUSES];
1121 1131
1132 unsigned int transop_timeout;
1122 const struct ipr_chip_cfg_t *chip_cfg; 1133 const struct ipr_chip_cfg_t *chip_cfg;
1123 1134
1124 void __iomem *hdw_dma_regs; /* iomapped PCI memory space */ 1135 void __iomem *hdw_dma_regs; /* iomapped PCI memory space */
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 8f55e1431433..c9a3abf9e7b6 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -527,12 +527,12 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn)
527 * than 8K, but there are no targets that currently do this. 527 * than 8K, but there are no targets that currently do this.
528 * For now we fail until we find a vendor that needs it 528 * For now we fail until we find a vendor that needs it
529 */ 529 */
530 if (DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH < 530 if (ISCSI_DEF_MAX_RECV_SEG_LEN <
531 tcp_conn->in.datalen) { 531 tcp_conn->in.datalen) {
532 printk(KERN_ERR "iscsi_tcp: received buffer of len %u " 532 printk(KERN_ERR "iscsi_tcp: received buffer of len %u "
533 "but conn buffer is only %u (opcode %0x)\n", 533 "but conn buffer is only %u (opcode %0x)\n",
534 tcp_conn->in.datalen, 534 tcp_conn->in.datalen,
535 DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, opcode); 535 ISCSI_DEF_MAX_RECV_SEG_LEN, opcode);
536 rc = ISCSI_ERR_PROTO; 536 rc = ISCSI_ERR_PROTO;
537 break; 537 break;
538 } 538 }
@@ -1762,7 +1762,7 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1762 * due to strange issues with iser these are not set 1762 * due to strange issues with iser these are not set
1763 * in iscsi_conn_setup 1763 * in iscsi_conn_setup
1764 */ 1764 */
1765 conn->max_recv_dlength = DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH; 1765 conn->max_recv_dlength = ISCSI_DEF_MAX_RECV_SEG_LEN;
1766 1766
1767 tcp_conn = kzalloc(sizeof(*tcp_conn), GFP_KERNEL); 1767 tcp_conn = kzalloc(sizeof(*tcp_conn), GFP_KERNEL);
1768 if (!tcp_conn) 1768 if (!tcp_conn)
@@ -1777,14 +1777,24 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1777 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0, 1777 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
1778 CRYPTO_ALG_ASYNC); 1778 CRYPTO_ALG_ASYNC);
1779 tcp_conn->tx_hash.flags = 0; 1779 tcp_conn->tx_hash.flags = 0;
1780 if (IS_ERR(tcp_conn->tx_hash.tfm)) 1780 if (IS_ERR(tcp_conn->tx_hash.tfm)) {
1781 printk(KERN_ERR "Could not create connection due to crc32c "
1782 "loading error %ld. Make sure the crc32c module is "
1783 "built as a module or into the kernel\n",
1784 PTR_ERR(tcp_conn->tx_hash.tfm));
1781 goto free_tcp_conn; 1785 goto free_tcp_conn;
1786 }
1782 1787
1783 tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0, 1788 tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
1784 CRYPTO_ALG_ASYNC); 1789 CRYPTO_ALG_ASYNC);
1785 tcp_conn->rx_hash.flags = 0; 1790 tcp_conn->rx_hash.flags = 0;
1786 if (IS_ERR(tcp_conn->rx_hash.tfm)) 1791 if (IS_ERR(tcp_conn->rx_hash.tfm)) {
1792 printk(KERN_ERR "Could not create connection due to crc32c "
1793 "loading error %ld. Make sure the crc32c module is "
1794 "built as a module or into the kernel\n",
1795 PTR_ERR(tcp_conn->rx_hash.tfm));
1787 goto free_tx_tfm; 1796 goto free_tx_tfm;
1797 }
1788 1798
1789 return cls_conn; 1799 return cls_conn;
1790 1800
@@ -2138,6 +2148,7 @@ static struct scsi_host_template iscsi_sht = {
2138 .change_queue_depth = iscsi_change_queue_depth, 2148 .change_queue_depth = iscsi_change_queue_depth,
2139 .can_queue = ISCSI_XMIT_CMDS_MAX - 1, 2149 .can_queue = ISCSI_XMIT_CMDS_MAX - 1,
2140 .sg_tablesize = ISCSI_SG_TABLESIZE, 2150 .sg_tablesize = ISCSI_SG_TABLESIZE,
2151 .max_sectors = 0xFFFF,
2141 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, 2152 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,
2142 .eh_abort_handler = iscsi_eh_abort, 2153 .eh_abort_handler = iscsi_eh_abort,
2143 .eh_host_reset_handler = iscsi_eh_host_reset, 2154 .eh_host_reset_handler = iscsi_eh_host_reset,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 7c75771c77ff..3f5b9b445b29 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -25,6 +25,7 @@
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/kfifo.h> 26#include <linux/kfifo.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <asm/unaligned.h>
28#include <net/tcp.h> 29#include <net/tcp.h>
29#include <scsi/scsi_cmnd.h> 30#include <scsi/scsi_cmnd.h>
30#include <scsi/scsi_device.h> 31#include <scsi/scsi_device.h>
@@ -269,14 +270,14 @@ invalid_datalen:
269 goto out; 270 goto out;
270 } 271 }
271 272
272 senselen = be16_to_cpu(*(__be16 *)data); 273 senselen = be16_to_cpu(get_unaligned((__be16 *) data));
273 if (datalen < senselen) 274 if (datalen < senselen)
274 goto invalid_datalen; 275 goto invalid_datalen;
275 276
276 memcpy(sc->sense_buffer, data + 2, 277 memcpy(sc->sense_buffer, data + 2,
277 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE)); 278 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
278 debug_scsi("copied %d bytes of sense\n", 279 debug_scsi("copied %d bytes of sense\n",
279 min(senselen, SCSI_SENSE_BUFFERSIZE)); 280 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
280 } 281 }
281 282
282 if (sc->sc_data_direction == DMA_TO_DEVICE) 283 if (sc->sc_data_direction == DMA_TO_DEVICE)
@@ -577,7 +578,7 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
577} 578}
578EXPORT_SYMBOL_GPL(iscsi_conn_failure); 579EXPORT_SYMBOL_GPL(iscsi_conn_failure);
579 580
580static int iscsi_xmit_imm_task(struct iscsi_conn *conn) 581static int iscsi_xmit_mtask(struct iscsi_conn *conn)
581{ 582{
582 struct iscsi_hdr *hdr = conn->mtask->hdr; 583 struct iscsi_hdr *hdr = conn->mtask->hdr;
583 int rc, was_logout = 0; 584 int rc, was_logout = 0;
@@ -591,6 +592,9 @@ static int iscsi_xmit_imm_task(struct iscsi_conn *conn)
591 if (rc) 592 if (rc)
592 return rc; 593 return rc;
593 594
595 /* done with this in-progress mtask */
596 conn->mtask = NULL;
597
594 if (was_logout) { 598 if (was_logout) {
595 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); 599 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
596 return -ENODATA; 600 return -ENODATA;
@@ -643,11 +647,9 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
643 conn->ctask = NULL; 647 conn->ctask = NULL;
644 } 648 }
645 if (conn->mtask) { 649 if (conn->mtask) {
646 rc = iscsi_xmit_imm_task(conn); 650 rc = iscsi_xmit_mtask(conn);
647 if (rc) 651 if (rc)
648 goto again; 652 goto again;
649 /* done with this in-progress mtask */
650 conn->mtask = NULL;
651 } 653 }
652 654
653 /* process immediate first */ 655 /* process immediate first */
@@ -658,12 +660,10 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
658 list_add_tail(&conn->mtask->running, 660 list_add_tail(&conn->mtask->running,
659 &conn->mgmt_run_list); 661 &conn->mgmt_run_list);
660 spin_unlock_bh(&conn->session->lock); 662 spin_unlock_bh(&conn->session->lock);
661 rc = iscsi_xmit_imm_task(conn); 663 rc = iscsi_xmit_mtask(conn);
662 if (rc) 664 if (rc)
663 goto again; 665 goto again;
664 } 666 }
665 /* done with this mtask */
666 conn->mtask = NULL;
667 } 667 }
668 668
669 /* process command queue */ 669 /* process command queue */
@@ -701,12 +701,10 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
701 list_add_tail(&conn->mtask->running, 701 list_add_tail(&conn->mtask->running,
702 &conn->mgmt_run_list); 702 &conn->mgmt_run_list);
703 spin_unlock_bh(&conn->session->lock); 703 spin_unlock_bh(&conn->session->lock);
704 rc = tt->xmit_mgmt_task(conn, conn->mtask); 704 rc = iscsi_xmit_mtask(conn);
705 if (rc) 705 if (rc)
706 goto again; 706 goto again;
707 } 707 }
708 /* done with this mtask */
709 conn->mtask = NULL;
710 } 708 }
711 709
712 return -ENODATA; 710 return -ENODATA;
@@ -1523,7 +1521,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1523 } 1521 }
1524 spin_unlock_bh(&session->lock); 1522 spin_unlock_bh(&session->lock);
1525 1523
1526 data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, GFP_KERNEL); 1524 data = kmalloc(ISCSI_DEF_MAX_RECV_SEG_LEN, GFP_KERNEL);
1527 if (!data) 1525 if (!data)
1528 goto login_mtask_data_alloc_fail; 1526 goto login_mtask_data_alloc_fail;
1529 conn->login_mtask->data = conn->data = data; 1527 conn->login_mtask->data = conn->data = data;
@@ -1597,6 +1595,9 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
1597 wake_up(&conn->ehwait); 1595 wake_up(&conn->ehwait);
1598 } 1596 }
1599 1597
1598 /* flush queued up work because we free the connection below */
1599 scsi_flush_work(session->host);
1600
1600 spin_lock_bh(&session->lock); 1601 spin_lock_bh(&session->lock);
1601 kfree(conn->data); 1602 kfree(conn->data);
1602 kfree(conn->persistent_address); 1603 kfree(conn->persistent_address);
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index dc70c180e115..e34442e405e8 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <linux/pci.h>
26#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
27 26
28#include "sas_internal.h" 27#include "sas_internal.h"
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 89403b00e042..5631c199a8eb 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -22,7 +22,6 @@
22#include <linux/kfifo.h> 22#include <linux/kfifo.h>
23#include <linux/scatterlist.h> 23#include <linux/scatterlist.h>
24#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
25#include <linux/pci.h>
26#include <scsi/scsi.h> 25#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h> 26#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_tcq.h> 27#include <scsi/scsi_tcq.h>
@@ -225,8 +224,7 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
225 struct srp_direct_buf *md = NULL; 224 struct srp_direct_buf *md = NULL;
226 struct scatterlist dummy, *sg = NULL; 225 struct scatterlist dummy, *sg = NULL;
227 dma_addr_t token = 0; 226 dma_addr_t token = 0;
228 long err; 227 int err = 0;
229 unsigned int done = 0;
230 int nmd, nsg = 0, len; 228 int nmd, nsg = 0, len;
231 229
232 if (dma_map || ext_desc) { 230 if (dma_map || ext_desc) {
@@ -258,8 +256,8 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
258 sg_dma_address(&dummy) = token; 256 sg_dma_address(&dummy) = token;
259 err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE, 257 err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE,
260 id->table_desc.len); 258 id->table_desc.len);
261 if (err < 0) { 259 if (err) {
262 eprintk("Error copying indirect table %ld\n", err); 260 eprintk("Error copying indirect table %d\n", err);
263 goto free_mem; 261 goto free_mem;
264 } 262 }
265 } else { 263 } else {
@@ -272,6 +270,7 @@ rdma:
272 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL); 270 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL);
273 if (!nsg) { 271 if (!nsg) {
274 eprintk("fail to map %p %d\n", iue, sc->use_sg); 272 eprintk("fail to map %p %d\n", iue, sc->use_sg);
273 err = -EIO;
275 goto free_mem; 274 goto free_mem;
276 } 275 }
277 len = min(sc->request_bufflen, id->len); 276 len = min(sc->request_bufflen, id->len);
@@ -287,7 +286,7 @@ free_mem:
287 if (token && dma_map) 286 if (token && dma_map)
288 dma_free_coherent(iue->target->dev, id->table_desc.len, md, token); 287 dma_free_coherent(iue->target->dev, id->table_desc.len, md, token);
289 288
290 return done; 289 return err;
291} 290}
292 291
293static int data_out_desc_size(struct srp_cmd *cmd) 292static int data_out_desc_size(struct srp_cmd *cmd)
@@ -352,7 +351,7 @@ int srp_transfer_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
352 break; 351 break;
353 default: 352 default:
354 eprintk("Unknown format %d %x\n", dir, format); 353 eprintk("Unknown format %d %x\n", dir, format);
355 break; 354 err = -EINVAL;
356 } 355 }
357 356
358 return err; 357 return err;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 057fd7e0e379..dcf6106f557a 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -671,7 +671,7 @@ static int
671lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len) 671lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
672{ 672{
673 uint8_t lenlo, lenhi; 673 uint8_t lenlo, lenhi;
674 uint32_t Length; 674 int Length;
675 int i, j; 675 int i, j;
676 int finished = 0; 676 int finished = 0;
677 int index = 0; 677 int index = 0;
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 0aa3304f6b9b..7fc6e06ea7e1 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2088,7 +2088,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
2088static inline int 2088static inline int
2089make_local_pdev(adapter_t *adapter, struct pci_dev **pdev) 2089make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
2090{ 2090{
2091 *pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 2091 *pdev = alloc_pci_dev();
2092 2092
2093 if( *pdev == NULL ) return -1; 2093 if( *pdev == NULL ) return -1;
2094 2094
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index a967fadb7439..08060fb478b6 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -87,6 +87,7 @@ MODULE_AUTHOR("Willem Riede");
87MODULE_DESCRIPTION("OnStream {DI-|FW-|SC-|USB}{30|50} Tape Driver"); 87MODULE_DESCRIPTION("OnStream {DI-|FW-|SC-|USB}{30|50} Tape Driver");
88MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
89MODULE_ALIAS_CHARDEV_MAJOR(OSST_MAJOR); 89MODULE_ALIAS_CHARDEV_MAJOR(OSST_MAJOR);
90MODULE_ALIAS_SCSI_DEVICE(TYPE_TAPE);
90 91
91module_param(max_dev, int, 0444); 92module_param(max_dev, int, 0444);
92MODULE_PARM_DESC(max_dev, "Maximum number of OnStream Tape Drives to attach (4)"); 93MODULE_PARM_DESC(max_dev, "Maximum number of OnStream Tape Drives to attach (4)");
diff --git a/drivers/scsi/pci2000.h b/drivers/scsi/pci2000.h
deleted file mode 100644
index 0ebd8ce9e1de..000000000000
--- a/drivers/scsi/pci2000.h
+++ /dev/null
@@ -1,197 +0,0 @@
1/****************************************************************************
2 * Perceptive Solutions, Inc. PCI-2000 device driver for Linux.
3 *
4 * pci2000.h - Linux Host Driver for PCI-2000 IntelliCache SCSI Adapters
5 *
6 * Copyright (c) 1997-1999 Perceptive Solutions, Inc.
7 * All Rights Reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that redistributions of source
11 * code retain the above copyright notice and this comment without
12 * modification.
13 *
14 * Technical updates and product information at:
15 * http://www.psidisk.com
16 *
17 * Please send questions, comments, bug reports to:
18 * tech@psidisk.com Technical Support
19 *
20 ****************************************************************************/
21#ifndef _PCI2000_H
22#define _PCI2000_H
23
24#include <linux/types.h>
25
26#ifndef PSI_EIDE_SCSIOP
27#define PSI_EIDE_SCSIOP 1
28
29#define LINUXVERSION(v,p,s) (((v)<<16) + ((p)<<8) + (s))
30
31/************************************************/
32/* definition of standard data types */
33/************************************************/
34#define CHAR char
35#define UCHAR unsigned char
36#define SHORT short
37#define USHORT unsigned short
38#define BOOL long
39#define LONG long
40#define ULONG unsigned long
41#define VOID void
42
43typedef CHAR *PCHAR;
44typedef UCHAR *PUCHAR;
45typedef SHORT *PSHORT;
46typedef USHORT *PUSHORT;
47typedef BOOL *PBOOL;
48typedef LONG *PLONG;
49typedef ULONG *PULONG;
50typedef VOID *PVOID;
51
52
53/************************************************/
54/* Misc. macros */
55/************************************************/
56#define ANY2SCSI(up, p) \
57((UCHAR *)up)[0] = (((ULONG)(p)) >> 8); \
58((UCHAR *)up)[1] = ((ULONG)(p));
59
60#define SCSI2LONG(up) \
61( (((long)*(((UCHAR *)up))) << 16) \
62+ (((long)(((UCHAR *)up)[1])) << 8) \
63+ ((long)(((UCHAR *)up)[2])) )
64
65#define XANY2SCSI(up, p) \
66((UCHAR *)up)[0] = ((long)(p)) >> 24; \
67((UCHAR *)up)[1] = ((long)(p)) >> 16; \
68((UCHAR *)up)[2] = ((long)(p)) >> 8; \
69((UCHAR *)up)[3] = ((long)(p));
70
71#define XSCSI2LONG(up) \
72( (((long)(((UCHAR *)up)[0])) << 24) \
73+ (((long)(((UCHAR *)up)[1])) << 16) \
74+ (((long)(((UCHAR *)up)[2])) << 8) \
75+ ((long)(((UCHAR *)up)[3])) )
76
77/************************************************/
78/* SCSI CDB operation codes */
79/************************************************/
80#define SCSIOP_TEST_UNIT_READY 0x00
81#define SCSIOP_REZERO_UNIT 0x01
82#define SCSIOP_REWIND 0x01
83#define SCSIOP_REQUEST_BLOCK_ADDR 0x02
84#define SCSIOP_REQUEST_SENSE 0x03
85#define SCSIOP_FORMAT_UNIT 0x04
86#define SCSIOP_READ_BLOCK_LIMITS 0x05
87#define SCSIOP_REASSIGN_BLOCKS 0x07
88#define SCSIOP_READ6 0x08
89#define SCSIOP_RECEIVE 0x08
90#define SCSIOP_WRITE6 0x0A
91#define SCSIOP_PRINT 0x0A
92#define SCSIOP_SEND 0x0A
93#define SCSIOP_SEEK6 0x0B
94#define SCSIOP_TRACK_SELECT 0x0B
95#define SCSIOP_SLEW_PRINT 0x0B
96#define SCSIOP_SEEK_BLOCK 0x0C
97#define SCSIOP_PARTITION 0x0D
98#define SCSIOP_READ_REVERSE 0x0F
99#define SCSIOP_WRITE_FILEMARKS 0x10
100#define SCSIOP_FLUSH_BUFFER 0x10
101#define SCSIOP_SPACE 0x11
102#define SCSIOP_INQUIRY 0x12
103#define SCSIOP_VERIFY6 0x13
104#define SCSIOP_RECOVER_BUF_DATA 0x14
105#define SCSIOP_MODE_SELECT 0x15
106#define SCSIOP_RESERVE_UNIT 0x16
107#define SCSIOP_RELEASE_UNIT 0x17
108#define SCSIOP_COPY 0x18
109#define SCSIOP_ERASE 0x19
110#define SCSIOP_MODE_SENSE 0x1A
111#define SCSIOP_START_STOP_UNIT 0x1B
112#define SCSIOP_STOP_PRINT 0x1B
113#define SCSIOP_LOAD_UNLOAD 0x1B
114#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
115#define SCSIOP_SEND_DIAGNOSTIC 0x1D
116#define SCSIOP_MEDIUM_REMOVAL 0x1E
117#define SCSIOP_READ_CAPACITY 0x25
118#define SCSIOP_READ 0x28
119#define SCSIOP_WRITE 0x2A
120#define SCSIOP_SEEK 0x2B
121#define SCSIOP_LOCATE 0x2B
122#define SCSIOP_WRITE_VERIFY 0x2E
123#define SCSIOP_VERIFY 0x2F
124#define SCSIOP_SEARCH_DATA_HIGH 0x30
125#define SCSIOP_SEARCH_DATA_EQUAL 0x31
126#define SCSIOP_SEARCH_DATA_LOW 0x32
127#define SCSIOP_SET_LIMITS 0x33
128#define SCSIOP_READ_POSITION 0x34
129#define SCSIOP_SYNCHRONIZE_CACHE 0x35
130#define SCSIOP_COMPARE 0x39
131#define SCSIOP_COPY_COMPARE 0x3A
132#define SCSIOP_WRITE_DATA_BUFF 0x3B
133#define SCSIOP_READ_DATA_BUFF 0x3C
134#define SCSIOP_CHANGE_DEFINITION 0x40
135#define SCSIOP_READ_SUB_CHANNEL 0x42
136#define SCSIOP_READ_TOC 0x43
137#define SCSIOP_READ_HEADER 0x44
138#define SCSIOP_PLAY_AUDIO 0x45
139#define SCSIOP_PLAY_AUDIO_MSF 0x47
140#define SCSIOP_PLAY_TRACK_INDEX 0x48
141#define SCSIOP_PLAY_TRACK_RELATIVE 0x49
142#define SCSIOP_PAUSE_RESUME 0x4B
143#define SCSIOP_LOG_SELECT 0x4C
144#define SCSIOP_LOG_SENSE 0x4D
145#define SCSIOP_MODE_SELECT10 0x55
146#define SCSIOP_MODE_SENSE10 0x5A
147#define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
148#define SCSIOP_MECHANISM_STATUS 0xBD
149#define SCSIOP_READ_CD 0xBE
150
151// SCSI read capacity structure
152typedef struct _READ_CAPACITY_DATA
153 {
154 ULONG blks; /* total blocks (converted to little endian) */
155 ULONG blksiz; /* size of each (converted to little endian) */
156 } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
157
158// SCSI inquiry data
159typedef struct _INQUIRYDATA
160 {
161 UCHAR DeviceType :5;
162 UCHAR DeviceTypeQualifier :3;
163 UCHAR DeviceTypeModifier :7;
164 UCHAR RemovableMedia :1;
165 UCHAR Versions;
166 UCHAR ResponseDataFormat;
167 UCHAR AdditionalLength;
168 UCHAR Reserved[2];
169 UCHAR SoftReset :1;
170 UCHAR CommandQueue :1;
171 UCHAR Reserved2 :1;
172 UCHAR LinkedCommands :1;
173 UCHAR Synchronous :1;
174 UCHAR Wide16Bit :1;
175 UCHAR Wide32Bit :1;
176 UCHAR RelativeAddressing :1;
177 UCHAR VendorId[8];
178 UCHAR ProductId[16];
179 UCHAR ProductRevisionLevel[4];
180 UCHAR VendorSpecific[20];
181 UCHAR Reserved3[40];
182 } INQUIRYDATA, *PINQUIRYDATA;
183
184#endif
185
186// function prototypes
187int Pci2000_Detect (struct scsi_host_template *tpnt);
188int Pci2000_Command (Scsi_Cmnd *SCpnt);
189int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
190int Pci2000_Abort (Scsi_Cmnd *SCpnt);
191int Pci2000_Reset (Scsi_Cmnd *SCpnt, unsigned int flags);
192int Pci2000_Release (struct Scsi_Host *pshost);
193int Pci2000_BiosParam (struct scsi_device *sdev,
194 struct block_device *bdev,
195 sector_t capacity, int geom[]);
196
197#endif
diff --git a/drivers/scsi/pcmcia/Kconfig b/drivers/scsi/pcmcia/Kconfig
index eac8e179cfff..7dd787f6ab27 100644
--- a/drivers/scsi/pcmcia/Kconfig
+++ b/drivers/scsi/pcmcia/Kconfig
@@ -3,11 +3,11 @@
3# 3#
4 4
5menu "PCMCIA SCSI adapter support" 5menu "PCMCIA SCSI adapter support"
6 depends on SCSI!=n && PCMCIA!=n && MODULES 6 depends on SCSI!=n && PCMCIA!=n
7 7
8config PCMCIA_AHA152X 8config PCMCIA_AHA152X
9 tristate "Adaptec AHA152X PCMCIA support" 9 tristate "Adaptec AHA152X PCMCIA support"
10 depends on m && !64BIT 10 depends on !64BIT
11 select SCSI_SPI_ATTRS 11 select SCSI_SPI_ATTRS
12 help 12 help
13 Say Y here if you intend to attach this type of PCMCIA SCSI host 13 Say Y here if you intend to attach this type of PCMCIA SCSI host
@@ -18,7 +18,6 @@ config PCMCIA_AHA152X
18 18
19config PCMCIA_FDOMAIN 19config PCMCIA_FDOMAIN
20 tristate "Future Domain PCMCIA support" 20 tristate "Future Domain PCMCIA support"
21 depends on m
22 help 21 help
23 Say Y here if you intend to attach this type of PCMCIA SCSI host 22 Say Y here if you intend to attach this type of PCMCIA SCSI host
24 adapter to your computer. 23 adapter to your computer.
@@ -28,7 +27,7 @@ config PCMCIA_FDOMAIN
28 27
29config PCMCIA_NINJA_SCSI 28config PCMCIA_NINJA_SCSI
30 tristate "NinjaSCSI-3 / NinjaSCSI-32Bi (16bit) PCMCIA support" 29 tristate "NinjaSCSI-3 / NinjaSCSI-32Bi (16bit) PCMCIA support"
31 depends on m && !64BIT 30 depends on !64BIT
32 help 31 help
33 If you intend to attach this type of PCMCIA SCSI host adapter to 32 If you intend to attach this type of PCMCIA SCSI host adapter to
34 your computer, say Y here and read 33 your computer, say Y here and read
@@ -62,7 +61,6 @@ config PCMCIA_NINJA_SCSI
62 61
63config PCMCIA_QLOGIC 62config PCMCIA_QLOGIC
64 tristate "Qlogic PCMCIA support" 63 tristate "Qlogic PCMCIA support"
65 depends on m
66 help 64 help
67 Say Y here if you intend to attach this type of PCMCIA SCSI host 65 Say Y here if you intend to attach this type of PCMCIA SCSI host
68 adapter to your computer. 66 adapter to your computer.
@@ -72,7 +70,6 @@ config PCMCIA_QLOGIC
72 70
73config PCMCIA_SYM53C500 71config PCMCIA_SYM53C500
74 tristate "Symbios 53c500 PCMCIA support" 72 tristate "Symbios 53c500 PCMCIA support"
75 depends on m
76 help 73 help
77 Say Y here if you have a New Media Bus Toaster or other PCMCIA 74 Say Y here if you have a New Media Bus Toaster or other PCMCIA
78 SCSI adapter based on the Symbios 53c500 controller. 75 SCSI adapter based on the Symbios 53c500 controller.
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 05f4f2a378eb..e8948b679f5b 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1478,14 +1478,17 @@ typedef union {
1478 uint32_t b24 : 24; 1478 uint32_t b24 : 24;
1479 1479
1480 struct { 1480 struct {
1481 uint8_t d_id[3]; 1481#ifdef __BIG_ENDIAN
1482 uint8_t rsvd_1; 1482 uint8_t domain;
1483 } r; 1483 uint8_t area;
1484 1484 uint8_t al_pa;
1485 struct { 1485#elif __LITTLE_ENDIAN
1486 uint8_t al_pa; 1486 uint8_t al_pa;
1487 uint8_t area; 1487 uint8_t area;
1488 uint8_t domain; 1488 uint8_t domain;
1489#else
1490#error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!"
1491#endif
1489 uint8_t rsvd_1; 1492 uint8_t rsvd_1;
1490 } b; 1493 } b;
1491} port_id_t; 1494} port_id_t;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 98c01cd5e1a8..3e296ab845b6 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -11,6 +11,11 @@
11 11
12#include "qla_devtbl.h" 12#include "qla_devtbl.h"
13 13
14#ifdef CONFIG_SPARC
15#include <asm/prom.h>
16#include <asm/pbm.h>
17#endif
18
14/* XXX(hch): this is ugly, but we don't want to pull in exioctl.h */ 19/* XXX(hch): this is ugly, but we don't want to pull in exioctl.h */
15#ifndef EXT_IS_LUN_BIT_SET 20#ifndef EXT_IS_LUN_BIT_SET
16#define EXT_IS_LUN_BIT_SET(P,L) \ 21#define EXT_IS_LUN_BIT_SET(P,L) \
@@ -88,12 +93,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
88 93
89 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); 94 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
90 95
91 rval = ha->isp_ops.nvram_config(ha); 96 ha->isp_ops.nvram_config(ha);
92 if (rval) {
93 DEBUG2(printk("scsi(%ld): Unable to verify NVRAM data.\n",
94 ha->host_no));
95 return rval;
96 }
97 97
98 if (ha->flags.disable_serdes) { 98 if (ha->flags.disable_serdes) {
99 /* Mask HBA via NVRAM settings? */ 99 /* Mask HBA via NVRAM settings? */
@@ -1393,6 +1393,28 @@ qla2x00_set_model_info(scsi_qla_host_t *ha, uint8_t *model, size_t len, char *de
1393 } 1393 }
1394} 1394}
1395 1395
1396/* On sparc systems, obtain port and node WWN from firmware
1397 * properties.
1398 */
1399static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, nvram_t *nv)
1400{
1401#ifdef CONFIG_SPARC
1402 struct pci_dev *pdev = ha->pdev;
1403 struct pcidev_cookie *pcp = pdev->sysdata;
1404 struct device_node *dp = pcp->prom_node;
1405 u8 *val;
1406 int len;
1407
1408 val = of_get_property(dp, "port-wwn", &len);
1409 if (val && len >= WWN_SIZE)
1410 memcpy(nv->port_name, val, WWN_SIZE);
1411
1412 val = of_get_property(dp, "node-wwn", &len);
1413 if (val && len >= WWN_SIZE)
1414 memcpy(nv->node_name, val, WWN_SIZE);
1415#endif
1416}
1417
1396/* 1418/*
1397* NVRAM configuration for ISP 2xxx 1419* NVRAM configuration for ISP 2xxx
1398* 1420*
@@ -1409,6 +1431,7 @@ qla2x00_set_model_info(scsi_qla_host_t *ha, uint8_t *model, size_t len, char *de
1409int 1431int
1410qla2x00_nvram_config(scsi_qla_host_t *ha) 1432qla2x00_nvram_config(scsi_qla_host_t *ha)
1411{ 1433{
1434 int rval;
1412 uint8_t chksum = 0; 1435 uint8_t chksum = 0;
1413 uint16_t cnt; 1436 uint16_t cnt;
1414 uint8_t *dptr1, *dptr2; 1437 uint8_t *dptr1, *dptr2;
@@ -1417,6 +1440,8 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1417 uint8_t *ptr = (uint8_t *)ha->request_ring; 1440 uint8_t *ptr = (uint8_t *)ha->request_ring;
1418 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1441 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1419 1442
1443 rval = QLA_SUCCESS;
1444
1420 /* Determine NVRAM starting address. */ 1445 /* Determine NVRAM starting address. */
1421 ha->nvram_size = sizeof(nvram_t); 1446 ha->nvram_size = sizeof(nvram_t);
1422 ha->nvram_base = 0; 1447 ha->nvram_base = 0;
@@ -1440,7 +1465,57 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1440 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: " 1465 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
1441 "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0], 1466 "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0],
1442 nv->nvram_version); 1467 nv->nvram_version);
1443 return QLA_FUNCTION_FAILED; 1468 qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
1469 "invalid -- WWPN) defaults.\n");
1470
1471 /*
1472 * Set default initialization control block.
1473 */
1474 memset(nv, 0, ha->nvram_size);
1475 nv->parameter_block_version = ICB_VERSION;
1476
1477 if (IS_QLA23XX(ha)) {
1478 nv->firmware_options[0] = BIT_2 | BIT_1;
1479 nv->firmware_options[1] = BIT_7 | BIT_5;
1480 nv->add_firmware_options[0] = BIT_5;
1481 nv->add_firmware_options[1] = BIT_5 | BIT_4;
1482 nv->frame_payload_size = __constant_cpu_to_le16(2048);
1483 nv->special_options[1] = BIT_7;
1484 } else if (IS_QLA2200(ha)) {
1485 nv->firmware_options[0] = BIT_2 | BIT_1;
1486 nv->firmware_options[1] = BIT_7 | BIT_5;
1487 nv->add_firmware_options[0] = BIT_5;
1488 nv->add_firmware_options[1] = BIT_5 | BIT_4;
1489 nv->frame_payload_size = __constant_cpu_to_le16(1024);
1490 } else if (IS_QLA2100(ha)) {
1491 nv->firmware_options[0] = BIT_3 | BIT_1;
1492 nv->firmware_options[1] = BIT_5;
1493 nv->frame_payload_size = __constant_cpu_to_le16(1024);
1494 }
1495
1496 nv->max_iocb_allocation = __constant_cpu_to_le16(256);
1497 nv->execution_throttle = __constant_cpu_to_le16(16);
1498 nv->retry_count = 8;
1499 nv->retry_delay = 1;
1500
1501 nv->port_name[0] = 33;
1502 nv->port_name[3] = 224;
1503 nv->port_name[4] = 139;
1504
1505 qla2xxx_nvram_wwn_from_ofw(ha, nv);
1506
1507 nv->login_timeout = 4;
1508
1509 /*
1510 * Set default host adapter parameters
1511 */
1512 nv->host_p[1] = BIT_2;
1513 nv->reset_delay = 5;
1514 nv->port_down_retry_count = 8;
1515 nv->max_luns_per_target = __constant_cpu_to_le16(8);
1516 nv->link_down_timeout = 60;
1517
1518 rval = 1;
1444 } 1519 }
1445 1520
1446#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) 1521#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
@@ -1653,7 +1728,11 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1653 } 1728 }
1654 } 1729 }
1655 1730
1656 return QLA_SUCCESS; 1731 if (rval) {
1732 DEBUG2_3(printk(KERN_WARNING
1733 "scsi(%ld): NVRAM configuration failed!\n", ha->host_no));
1734 }
1735 return (rval);
1657} 1736}
1658 1737
1659static void 1738static void
@@ -3071,9 +3150,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3071 3150
3072 ha->isp_ops.get_flash_version(ha, ha->request_ring); 3151 ha->isp_ops.get_flash_version(ha, ha->request_ring);
3073 3152
3074 rval = ha->isp_ops.nvram_config(ha); 3153 ha->isp_ops.nvram_config(ha);
3075 if (rval)
3076 goto isp_abort_retry;
3077 3154
3078 if (!qla2x00_restart_isp(ha)) { 3155 if (!qla2x00_restart_isp(ha)) {
3079 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 3156 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
@@ -3103,7 +3180,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3103 } 3180 }
3104 } 3181 }
3105 } else { /* failed the ISP abort */ 3182 } else { /* failed the ISP abort */
3106isp_abort_retry:
3107 ha->flags.online = 1; 3183 ha->flags.online = 1;
3108 if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) { 3184 if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) {
3109 if (ha->isp_abort_cnt == 0) { 3185 if (ha->isp_abort_cnt == 0) {
@@ -3290,9 +3366,32 @@ qla24xx_reset_adapter(scsi_qla_host_t *ha)
3290 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3366 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3291} 3367}
3292 3368
3369/* On sparc systems, obtain port and node WWN from firmware
3370 * properties.
3371 */
3372static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, struct nvram_24xx *nv)
3373{
3374#ifdef CONFIG_SPARC
3375 struct pci_dev *pdev = ha->pdev;
3376 struct pcidev_cookie *pcp = pdev->sysdata;
3377 struct device_node *dp = pcp->prom_node;
3378 u8 *val;
3379 int len;
3380
3381 val = of_get_property(dp, "port-wwn", &len);
3382 if (val && len >= WWN_SIZE)
3383 memcpy(nv->port_name, val, WWN_SIZE);
3384
3385 val = of_get_property(dp, "node-wwn", &len);
3386 if (val && len >= WWN_SIZE)
3387 memcpy(nv->node_name, val, WWN_SIZE);
3388#endif
3389}
3390
3293int 3391int
3294qla24xx_nvram_config(scsi_qla_host_t *ha) 3392qla24xx_nvram_config(scsi_qla_host_t *ha)
3295{ 3393{
3394 int rval;
3296 struct init_cb_24xx *icb; 3395 struct init_cb_24xx *icb;
3297 struct nvram_24xx *nv; 3396 struct nvram_24xx *nv;
3298 uint32_t *dptr; 3397 uint32_t *dptr;
@@ -3300,6 +3399,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3300 uint32_t chksum; 3399 uint32_t chksum;
3301 uint16_t cnt; 3400 uint16_t cnt;
3302 3401
3402 rval = QLA_SUCCESS;
3303 icb = (struct init_cb_24xx *)ha->init_cb; 3403 icb = (struct init_cb_24xx *)ha->init_cb;
3304 nv = (struct nvram_24xx *)ha->request_ring; 3404 nv = (struct nvram_24xx *)ha->request_ring;
3305 3405
@@ -3332,7 +3432,52 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3332 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: " 3432 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
3333 "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0], 3433 "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0],
3334 le16_to_cpu(nv->nvram_version)); 3434 le16_to_cpu(nv->nvram_version));
3335 return QLA_FUNCTION_FAILED; 3435 qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
3436 "invalid -- WWPN) defaults.\n");
3437
3438 /*
3439 * Set default initialization control block.
3440 */
3441 memset(nv, 0, ha->nvram_size);
3442 nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION);
3443 nv->version = __constant_cpu_to_le16(ICB_VERSION);
3444 nv->frame_payload_size = __constant_cpu_to_le16(2048);
3445 nv->execution_throttle = __constant_cpu_to_le16(0xFFFF);
3446 nv->exchange_count = __constant_cpu_to_le16(0);
3447 nv->hard_address = __constant_cpu_to_le16(124);
3448 nv->port_name[0] = 0x21;
3449 nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn);
3450 nv->port_name[2] = 0x00;
3451 nv->port_name[3] = 0xe0;
3452 nv->port_name[4] = 0x8b;
3453 nv->port_name[5] = 0x1c;
3454 nv->port_name[6] = 0x55;
3455 nv->port_name[7] = 0x86;
3456 nv->node_name[0] = 0x20;
3457 nv->node_name[1] = 0x00;
3458 nv->node_name[2] = 0x00;
3459 nv->node_name[3] = 0xe0;
3460 nv->node_name[4] = 0x8b;
3461 nv->node_name[5] = 0x1c;
3462 nv->node_name[6] = 0x55;
3463 nv->node_name[7] = 0x86;
3464 qla24xx_nvram_wwn_from_ofw(ha, nv);
3465 nv->login_retry_count = __constant_cpu_to_le16(8);
3466 nv->interrupt_delay_timer = __constant_cpu_to_le16(0);
3467 nv->login_timeout = __constant_cpu_to_le16(0);
3468 nv->firmware_options_1 =
3469 __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1);
3470 nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4);
3471 nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12);
3472 nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13);
3473 nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10);
3474 nv->efi_parameters = __constant_cpu_to_le32(0);
3475 nv->reset_delay = 5;
3476 nv->max_luns_per_target = __constant_cpu_to_le16(128);
3477 nv->port_down_retry_count = __constant_cpu_to_le16(30);
3478 nv->link_down_timeout = __constant_cpu_to_le16(30);
3479
3480 rval = 1;
3336 } 3481 }
3337 3482
3338 /* Reset Initialization control block */ 3483 /* Reset Initialization control block */
@@ -3479,7 +3624,11 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3479 ha->flags.process_response_queue = 1; 3624 ha->flags.process_response_queue = 1;
3480 } 3625 }
3481 3626
3482 return QLA_SUCCESS; 3627 if (rval) {
3628 DEBUG2_3(printk(KERN_WARNING
3629 "scsi(%ld): NVRAM configuration failed!\n", ha->host_no));
3630 }
3631 return (rval);
3483} 3632}
3484 3633
3485static int 3634static int
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 83376f6ac3db..71e32a248528 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1280,14 +1280,14 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1280 } else { 1280 } else {
1281 if (name != NULL) { 1281 if (name != NULL) {
1282 /* This function returns name in big endian. */ 1282 /* This function returns name in big endian. */
1283 name[0] = LSB(mcp->mb[2]); 1283 name[0] = MSB(mcp->mb[2]);
1284 name[1] = MSB(mcp->mb[2]); 1284 name[1] = LSB(mcp->mb[2]);
1285 name[2] = LSB(mcp->mb[3]); 1285 name[2] = MSB(mcp->mb[3]);
1286 name[3] = MSB(mcp->mb[3]); 1286 name[3] = LSB(mcp->mb[3]);
1287 name[4] = LSB(mcp->mb[6]); 1287 name[4] = MSB(mcp->mb[6]);
1288 name[5] = MSB(mcp->mb[6]); 1288 name[5] = LSB(mcp->mb[6]);
1289 name[6] = LSB(mcp->mb[7]); 1289 name[6] = MSB(mcp->mb[7]);
1290 name[7] = MSB(mcp->mb[7]); 1290 name[7] = LSB(mcp->mb[7]);
1291 } 1291 }
1292 1292
1293 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n", 1293 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 68f5d24b938b..b78919a318e2 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -62,7 +62,7 @@ MODULE_PARM_DESC(ql2xallocfwdump,
62 "vary by ISP type. Default is 1 - allocate memory."); 62 "vary by ISP type. Default is 1 - allocate memory.");
63 63
64int ql2xextended_error_logging; 64int ql2xextended_error_logging;
65module_param(ql2xextended_error_logging, int, S_IRUGO|S_IRUSR); 65module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR);
66MODULE_PARM_DESC(ql2xextended_error_logging, 66MODULE_PARM_DESC(ql2xextended_error_logging,
67 "Option to enable extended error logging, " 67 "Option to enable extended error logging, "
68 "Default is 0 - no logging. 1 - log errors."); 68 "Default is 0 - no logging. 1 - log errors.");
@@ -157,6 +157,8 @@ static struct scsi_host_template qla24xx_driver_template = {
157 157
158 .slave_alloc = qla2xxx_slave_alloc, 158 .slave_alloc = qla2xxx_slave_alloc,
159 .slave_destroy = qla2xxx_slave_destroy, 159 .slave_destroy = qla2xxx_slave_destroy,
160 .scan_finished = qla2xxx_scan_finished,
161 .scan_start = qla2xxx_scan_start,
160 .change_queue_depth = qla2x00_change_queue_depth, 162 .change_queue_depth = qla2x00_change_queue_depth,
161 .change_queue_type = qla2x00_change_queue_type, 163 .change_queue_type = qla2x00_change_queue_type,
162 .this_id = -1, 164 .this_id = -1,
@@ -1705,6 +1707,7 @@ qla2x00_remove_one(struct pci_dev *pdev)
1705 1707
1706 scsi_host_put(ha->host); 1708 scsi_host_put(ha->host);
1707 1709
1710 pci_disable_device(pdev);
1708 pci_set_drvdata(pdev, NULL); 1711 pci_set_drvdata(pdev, NULL);
1709} 1712}
1710 1713
@@ -1747,8 +1750,6 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1747 if (ha->iobase) 1750 if (ha->iobase)
1748 iounmap(ha->iobase); 1751 iounmap(ha->iobase);
1749 pci_release_regions(ha->pdev); 1752 pci_release_regions(ha->pdev);
1750
1751 pci_disable_device(ha->pdev);
1752} 1753}
1753 1754
1754static inline void 1755static inline void
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index ff1dd4175a7f..206bda093da2 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -466,6 +466,7 @@ qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr)
466 udelay(10); 466 udelay(10);
467 else 467 else
468 rval = QLA_FUNCTION_TIMEOUT; 468 rval = QLA_FUNCTION_TIMEOUT;
469 cond_resched();
469 } 470 }
470 471
471 /* TODO: What happens if we time out? */ 472 /* TODO: What happens if we time out? */
@@ -508,6 +509,7 @@ qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data)
508 udelay(10); 509 udelay(10);
509 else 510 else
510 rval = QLA_FUNCTION_TIMEOUT; 511 rval = QLA_FUNCTION_TIMEOUT;
512 cond_resched();
511 } 513 }
512 return rval; 514 return rval;
513} 515}
@@ -1255,6 +1257,7 @@ qla2x00_poll_flash(scsi_qla_host_t *ha, uint32_t addr, uint8_t poll_data,
1255 } 1257 }
1256 udelay(10); 1258 udelay(10);
1257 barrier(); 1259 barrier();
1260 cond_resched();
1258 } 1261 }
1259 return status; 1262 return status;
1260} 1263}
@@ -1403,6 +1406,7 @@ qla2x00_read_flash_data(scsi_qla_host_t *ha, uint8_t *tmp_buf, uint32_t saddr,
1403 if (saddr % 100) 1406 if (saddr % 100)
1404 udelay(10); 1407 udelay(10);
1405 *tmp_buf = data; 1408 *tmp_buf = data;
1409 cond_resched();
1406 } 1410 }
1407} 1411}
1408 1412
@@ -1449,7 +1453,6 @@ uint8_t *
1449qla2x00_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, 1453qla2x00_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1450 uint32_t offset, uint32_t length) 1454 uint32_t offset, uint32_t length)
1451{ 1455{
1452 unsigned long flags;
1453 uint32_t addr, midpoint; 1456 uint32_t addr, midpoint;
1454 uint8_t *data; 1457 uint8_t *data;
1455 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1458 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -1458,7 +1461,6 @@ qla2x00_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1458 qla2x00_suspend_hba(ha); 1461 qla2x00_suspend_hba(ha);
1459 1462
1460 /* Go with read. */ 1463 /* Go with read. */
1461 spin_lock_irqsave(&ha->hardware_lock, flags);
1462 midpoint = ha->optrom_size / 2; 1464 midpoint = ha->optrom_size / 2;
1463 1465
1464 qla2x00_flash_enable(ha); 1466 qla2x00_flash_enable(ha);
@@ -1473,7 +1475,6 @@ qla2x00_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1473 *data = qla2x00_read_flash_byte(ha, addr); 1475 *data = qla2x00_read_flash_byte(ha, addr);
1474 } 1476 }
1475 qla2x00_flash_disable(ha); 1477 qla2x00_flash_disable(ha);
1476 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1477 1478
1478 /* Resume HBA. */ 1479 /* Resume HBA. */
1479 qla2x00_resume_hba(ha); 1480 qla2x00_resume_hba(ha);
@@ -1487,7 +1488,6 @@ qla2x00_write_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1487{ 1488{
1488 1489
1489 int rval; 1490 int rval;
1490 unsigned long flags;
1491 uint8_t man_id, flash_id, sec_number, data; 1491 uint8_t man_id, flash_id, sec_number, data;
1492 uint16_t wd; 1492 uint16_t wd;
1493 uint32_t addr, liter, sec_mask, rest_addr; 1493 uint32_t addr, liter, sec_mask, rest_addr;
@@ -1500,7 +1500,6 @@ qla2x00_write_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1500 sec_number = 0; 1500 sec_number = 0;
1501 1501
1502 /* Reset ISP chip. */ 1502 /* Reset ISP chip. */
1503 spin_lock_irqsave(&ha->hardware_lock, flags);
1504 WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET); 1503 WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
1505 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); 1504 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
1506 1505
@@ -1689,10 +1688,10 @@ update_flash:
1689 rval = QLA_FUNCTION_FAILED; 1688 rval = QLA_FUNCTION_FAILED;
1690 break; 1689 break;
1691 } 1690 }
1691 cond_resched();
1692 } 1692 }
1693 } while (0); 1693 } while (0);
1694 qla2x00_flash_disable(ha); 1694 qla2x00_flash_disable(ha);
1695 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1696 1695
1697 /* Resume HBA. */ 1696 /* Resume HBA. */
1698 qla2x00_resume_hba(ha); 1697 qla2x00_resume_hba(ha);
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 61347aee55ce..dc85495c337f 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.01.07-k5" 10#define QLA2XXX_VERSION "8.01.07-k6"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 1 13#define QLA_DRIVER_MINOR_VER 1
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1c89ee3e69ba..4c1e31334765 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -344,7 +344,6 @@ void scsi_destroy_command_freelist(struct Scsi_Host *shost)
344void scsi_log_send(struct scsi_cmnd *cmd) 344void scsi_log_send(struct scsi_cmnd *cmd)
345{ 345{
346 unsigned int level; 346 unsigned int level;
347 struct scsi_device *sdev;
348 347
349 /* 348 /*
350 * If ML QUEUE log level is greater than or equal to: 349 * If ML QUEUE log level is greater than or equal to:
@@ -361,22 +360,17 @@ void scsi_log_send(struct scsi_cmnd *cmd)
361 level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, 360 level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT,
362 SCSI_LOG_MLQUEUE_BITS); 361 SCSI_LOG_MLQUEUE_BITS);
363 if (level > 1) { 362 if (level > 1) {
364 sdev = cmd->device; 363 scmd_printk(KERN_INFO, cmd, "Send: ");
365 sdev_printk(KERN_INFO, sdev, "send ");
366 if (level > 2) 364 if (level > 2)
367 printk("0x%p ", cmd); 365 printk("0x%p ", cmd);
368 /* 366 printk("\n");
369 * spaces to match disposition and cmd->result
370 * output in scsi_log_completion.
371 */
372 printk(" ");
373 scsi_print_command(cmd); 367 scsi_print_command(cmd);
374 if (level > 3) { 368 if (level > 3) {
375 printk(KERN_INFO "buffer = 0x%p, bufflen = %d," 369 printk(KERN_INFO "buffer = 0x%p, bufflen = %d,"
376 " done = 0x%p, queuecommand 0x%p\n", 370 " done = 0x%p, queuecommand 0x%p\n",
377 cmd->request_buffer, cmd->request_bufflen, 371 cmd->request_buffer, cmd->request_bufflen,
378 cmd->done, 372 cmd->done,
379 sdev->host->hostt->queuecommand); 373 cmd->device->host->hostt->queuecommand);
380 374
381 } 375 }
382 } 376 }
@@ -386,7 +380,6 @@ void scsi_log_send(struct scsi_cmnd *cmd)
386void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) 380void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
387{ 381{
388 unsigned int level; 382 unsigned int level;
389 struct scsi_device *sdev;
390 383
391 /* 384 /*
392 * If ML COMPLETE log level is greater than or equal to: 385 * If ML COMPLETE log level is greater than or equal to:
@@ -405,8 +398,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
405 SCSI_LOG_MLCOMPLETE_BITS); 398 SCSI_LOG_MLCOMPLETE_BITS);
406 if (((level > 0) && (cmd->result || disposition != SUCCESS)) || 399 if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
407 (level > 1)) { 400 (level > 1)) {
408 sdev = cmd->device; 401 scmd_printk(KERN_INFO, cmd, "Done: ");
409 sdev_printk(KERN_INFO, sdev, "done ");
410 if (level > 2) 402 if (level > 2)
411 printk("0x%p ", cmd); 403 printk("0x%p ", cmd);
412 /* 404 /*
@@ -415,40 +407,35 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
415 */ 407 */
416 switch (disposition) { 408 switch (disposition) {
417 case SUCCESS: 409 case SUCCESS:
418 printk("SUCCESS"); 410 printk("SUCCESS\n");
419 break; 411 break;
420 case NEEDS_RETRY: 412 case NEEDS_RETRY:
421 printk("RETRY "); 413 printk("RETRY\n");
422 break; 414 break;
423 case ADD_TO_MLQUEUE: 415 case ADD_TO_MLQUEUE:
424 printk("MLQUEUE"); 416 printk("MLQUEUE\n");
425 break; 417 break;
426 case FAILED: 418 case FAILED:
427 printk("FAILED "); 419 printk("FAILED\n");
428 break; 420 break;
429 case TIMEOUT_ERROR: 421 case TIMEOUT_ERROR:
430 /* 422 /*
431 * If called via scsi_times_out. 423 * If called via scsi_times_out.
432 */ 424 */
433 printk("TIMEOUT"); 425 printk("TIMEOUT\n");
434 break; 426 break;
435 default: 427 default:
436 printk("UNKNOWN"); 428 printk("UNKNOWN\n");
437 } 429 }
438 printk(" %8x ", cmd->result); 430 scsi_print_result(cmd);
439 scsi_print_command(cmd); 431 scsi_print_command(cmd);
440 if (status_byte(cmd->result) & CHECK_CONDITION) { 432 if (status_byte(cmd->result) & CHECK_CONDITION)
441 /*
442 * XXX The scsi_print_sense formatting/prefix
443 * doesn't match this function.
444 */
445 scsi_print_sense("", cmd); 433 scsi_print_sense("", cmd);
446 } 434 if (level > 3)
447 if (level > 3) { 435 scmd_printk(KERN_INFO, cmd,
448 printk(KERN_INFO "scsi host busy %d failed %d\n", 436 "scsi host busy %d failed %d\n",
449 sdev->host->host_busy, 437 cmd->device->host->host_busy,
450 sdev->host->host_failed); 438 cmd->device->host->host_failed);
451 }
452 } 439 }
453 } 440 }
454} 441}
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 918bb6019540..3963e7013bd9 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -184,10 +184,19 @@ int scsi_delete_timer(struct scsi_cmnd *scmd)
184 **/ 184 **/
185void scsi_times_out(struct scsi_cmnd *scmd) 185void scsi_times_out(struct scsi_cmnd *scmd)
186{ 186{
187 enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *);
188
187 scsi_log_completion(scmd, TIMEOUT_ERROR); 189 scsi_log_completion(scmd, TIMEOUT_ERROR);
188 190
189 if (scmd->device->host->transportt->eh_timed_out) 191 if (scmd->device->host->transportt->eh_timed_out)
190 switch (scmd->device->host->transportt->eh_timed_out(scmd)) { 192 eh_timed_out = scmd->device->host->transportt->eh_timed_out;
193 else if (scmd->device->host->hostt->eh_timed_out)
194 eh_timed_out = scmd->device->host->hostt->eh_timed_out;
195 else
196 eh_timed_out = NULL;
197
198 if (eh_timed_out)
199 switch (eh_timed_out(scmd)) {
191 case EH_HANDLED: 200 case EH_HANDLED:
192 __scsi_done(scmd); 201 __scsi_done(scmd);
193 return; 202 return;
@@ -923,10 +932,12 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
923 static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0}; 932 static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0};
924 933
925 if (scmd->device->allow_restart) { 934 if (scmd->device->allow_restart) {
926 int rtn; 935 int i, rtn = NEEDS_RETRY;
936
937 for (i = 0; rtn == NEEDS_RETRY && i < 2; i++)
938 rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
939 START_UNIT_TIMEOUT, 0);
927 940
928 rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
929 START_UNIT_TIMEOUT, 0);
930 if (rtn == SUCCESS) 941 if (rtn == SUCCESS)
931 return 0; 942 return 0;
932 } 943 }
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 05d79af5ab90..61fbcdcbb009 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -848,8 +848,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
848 memcpy(req->sense, cmd->sense_buffer, len); 848 memcpy(req->sense, cmd->sense_buffer, len);
849 req->sense_len = len; 849 req->sense_len = len;
850 } 850 }
851 } else 851 }
852 req->data_len = cmd->resid; 852 req->data_len = cmd->resid;
853 } 853 }
854 854
855 /* 855 /*
@@ -968,9 +968,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
968 } 968 }
969 if (result) { 969 if (result) {
970 if (!(req->cmd_flags & REQ_QUIET)) { 970 if (!(req->cmd_flags & REQ_QUIET)) {
971 scmd_printk(KERN_INFO, cmd, 971 scsi_print_result(cmd);
972 "SCSI error: return code = 0x%08x\n",
973 result);
974 if (driver_byte(result) & DRIVER_SENSE) 972 if (driver_byte(result) & DRIVER_SENSE)
975 scsi_print_sense("", cmd); 973 scsi_print_sense("", cmd);
976 } 974 }
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 0949145304ea..a67f315244d7 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -181,10 +181,8 @@ int scsi_complete_async_scans(void)
181 return 0; 181 return 0;
182} 182}
183 183
184#ifdef MODULE
185/* Only exported for the benefit of scsi_wait_scan */ 184/* Only exported for the benefit of scsi_wait_scan */
186EXPORT_SYMBOL_GPL(scsi_complete_async_scans); 185EXPORT_SYMBOL_GPL(scsi_complete_async_scans);
187#endif
188 186
189/** 187/**
190 * scsi_unlock_floptical - unlock device via a special MODE SENSE command 188 * scsi_unlock_floptical - unlock device via a special MODE SENSE command
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 939de0de18bc..67a38a1409ba 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -276,8 +276,22 @@ static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
276 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; 276 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
277} 277}
278 278
279static int scsi_bus_uevent(struct device *dev, char **envp, int num_envp,
280 char *buffer, int buffer_size)
281{
282 struct scsi_device *sdev = to_scsi_device(dev);
283 int i = 0;
284 int length = 0;
285
286 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
287 "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
288 envp[i] = NULL;
289 return 0;
290}
291
279static int scsi_bus_suspend(struct device * dev, pm_message_t state) 292static int scsi_bus_suspend(struct device * dev, pm_message_t state)
280{ 293{
294 struct device_driver *drv = dev->driver;
281 struct scsi_device *sdev = to_scsi_device(dev); 295 struct scsi_device *sdev = to_scsi_device(dev);
282 struct scsi_host_template *sht = sdev->host->hostt; 296 struct scsi_host_template *sht = sdev->host->hostt;
283 int err; 297 int err;
@@ -286,28 +300,51 @@ static int scsi_bus_suspend(struct device * dev, pm_message_t state)
286 if (err) 300 if (err)
287 return err; 301 return err;
288 302
289 if (sht->suspend) 303 /* call HLD suspend first */
304 if (drv && drv->suspend) {
305 err = drv->suspend(dev, state);
306 if (err)
307 return err;
308 }
309
310 /* then, call host suspend */
311 if (sht->suspend) {
290 err = sht->suspend(sdev, state); 312 err = sht->suspend(sdev, state);
313 if (err) {
314 if (drv && drv->resume)
315 drv->resume(dev);
316 return err;
317 }
318 }
291 319
292 return err; 320 return 0;
293} 321}
294 322
295static int scsi_bus_resume(struct device * dev) 323static int scsi_bus_resume(struct device * dev)
296{ 324{
325 struct device_driver *drv = dev->driver;
297 struct scsi_device *sdev = to_scsi_device(dev); 326 struct scsi_device *sdev = to_scsi_device(dev);
298 struct scsi_host_template *sht = sdev->host->hostt; 327 struct scsi_host_template *sht = sdev->host->hostt;
299 int err = 0; 328 int err = 0, err2 = 0;
300 329
330 /* call host resume first */
301 if (sht->resume) 331 if (sht->resume)
302 err = sht->resume(sdev); 332 err = sht->resume(sdev);
303 333
334 /* then, call HLD resume */
335 if (drv && drv->resume)
336 err2 = drv->resume(dev);
337
304 scsi_device_resume(sdev); 338 scsi_device_resume(sdev);
305 return err; 339
340 /* favor LLD failure */
341 return err ? err : err2;;
306} 342}
307 343
308struct bus_type scsi_bus_type = { 344struct bus_type scsi_bus_type = {
309 .name = "scsi", 345 .name = "scsi",
310 .match = scsi_bus_match, 346 .match = scsi_bus_match,
347 .uevent = scsi_bus_uevent,
311 .suspend = scsi_bus_suspend, 348 .suspend = scsi_bus_suspend,
312 .resume = scsi_bus_resume, 349 .resume = scsi_bus_resume,
313}; 350};
@@ -547,6 +584,14 @@ show_sdev_iostat(iorequest_cnt);
547show_sdev_iostat(iodone_cnt); 584show_sdev_iostat(iodone_cnt);
548show_sdev_iostat(ioerr_cnt); 585show_sdev_iostat(ioerr_cnt);
549 586
587static ssize_t
588sdev_show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
589{
590 struct scsi_device *sdev;
591 sdev = to_scsi_device(dev);
592 return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type);
593}
594static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL);
550 595
551/* Default template for device attributes. May NOT be modified */ 596/* Default template for device attributes. May NOT be modified */
552static struct device_attribute *scsi_sysfs_sdev_attrs[] = { 597static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
@@ -566,6 +611,7 @@ static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
566 &dev_attr_iorequest_cnt, 611 &dev_attr_iorequest_cnt,
567 &dev_attr_iodone_cnt, 612 &dev_attr_iodone_cnt,
568 &dev_attr_ioerr_cnt, 613 &dev_attr_ioerr_cnt,
614 &dev_attr_modalias,
569 NULL 615 NULL
570}; 616};
571 617
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c
index 0e08817fdecf..ca22ddf81746 100644
--- a/drivers/scsi/scsi_tgt_if.c
+++ b/drivers/scsi/scsi_tgt_if.c
@@ -179,10 +179,12 @@ static int event_recv_msg(struct tgt_event *ev)
179 switch (ev->hdr.type) { 179 switch (ev->hdr.type) {
180 case TGT_UEVENT_CMD_RSP: 180 case TGT_UEVENT_CMD_RSP:
181 err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no, 181 err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no,
182 ev->p.cmd_rsp.tag,
183 ev->p.cmd_rsp.result, 182 ev->p.cmd_rsp.result,
184 ev->p.cmd_rsp.len, 183 ev->p.cmd_rsp.tag,
185 ev->p.cmd_rsp.uaddr, 184 ev->p.cmd_rsp.uaddr,
185 ev->p.cmd_rsp.len,
186 ev->p.cmd_rsp.sense_uaddr,
187 ev->p.cmd_rsp.sense_len,
186 ev->p.cmd_rsp.rw); 188 ev->p.cmd_rsp.rw);
187 break; 189 break;
188 case TGT_UEVENT_TSK_MGMT_RSP: 190 case TGT_UEVENT_TSK_MGMT_RSP:
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
index d402aff5f314..2570f48a69c7 100644
--- a/drivers/scsi/scsi_tgt_lib.c
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -28,7 +28,6 @@
28#include <scsi/scsi_device.h> 28#include <scsi/scsi_device.h>
29#include <scsi/scsi_host.h> 29#include <scsi/scsi_host.h>
30#include <scsi/scsi_tgt.h> 30#include <scsi/scsi_tgt.h>
31#include <../drivers/md/dm-bio-list.h>
32 31
33#include "scsi_tgt_priv.h" 32#include "scsi_tgt_priv.h"
34 33
@@ -42,16 +41,12 @@ static struct kmem_cache *scsi_tgt_cmd_cache;
42struct scsi_tgt_cmd { 41struct scsi_tgt_cmd {
43 /* TODO replace work with James b's code */ 42 /* TODO replace work with James b's code */
44 struct work_struct work; 43 struct work_struct work;
45 /* TODO replace the lists with a large bio */ 44 /* TODO fix limits of some drivers */
46 struct bio_list xfer_done_list; 45 struct bio *bio;
47 struct bio_list xfer_list;
48 46
49 struct list_head hash_list; 47 struct list_head hash_list;
50 struct request *rq; 48 struct request *rq;
51 u64 tag; 49 u64 tag;
52
53 void *buffer;
54 unsigned bufflen;
55}; 50};
56 51
57#define TGT_HASH_ORDER 4 52#define TGT_HASH_ORDER 4
@@ -93,7 +88,12 @@ struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost,
93 if (!tcmd) 88 if (!tcmd)
94 goto put_dev; 89 goto put_dev;
95 90
96 rq = blk_get_request(shost->uspace_req_q, write, gfp_mask); 91 /*
92 * The blk helpers are used to the READ/WRITE requests
93 * transfering data from a initiator point of view. Since
94 * we are in target mode we want the opposite.
95 */
96 rq = blk_get_request(shost->uspace_req_q, !write, gfp_mask);
97 if (!rq) 97 if (!rq)
98 goto free_tcmd; 98 goto free_tcmd;
99 99
@@ -111,8 +111,6 @@ struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost,
111 rq->cmd_flags |= REQ_TYPE_BLOCK_PC; 111 rq->cmd_flags |= REQ_TYPE_BLOCK_PC;
112 rq->end_io_data = tcmd; 112 rq->end_io_data = tcmd;
113 113
114 bio_list_init(&tcmd->xfer_list);
115 bio_list_init(&tcmd->xfer_done_list);
116 tcmd->rq = rq; 114 tcmd->rq = rq;
117 115
118 return cmd; 116 return cmd;
@@ -157,22 +155,6 @@ void scsi_host_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
157} 155}
158EXPORT_SYMBOL_GPL(scsi_host_put_command); 156EXPORT_SYMBOL_GPL(scsi_host_put_command);
159 157
160static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd)
161{
162 struct bio *bio;
163
164 /* must call bio_endio in case bio was bounced */
165 while ((bio = bio_list_pop(&tcmd->xfer_done_list))) {
166 bio_endio(bio, bio->bi_size, 0);
167 bio_unmap_user(bio);
168 }
169
170 while ((bio = bio_list_pop(&tcmd->xfer_list))) {
171 bio_endio(bio, bio->bi_size, 0);
172 bio_unmap_user(bio);
173 }
174}
175
176static void cmd_hashlist_del(struct scsi_cmnd *cmd) 158static void cmd_hashlist_del(struct scsi_cmnd *cmd)
177{ 159{
178 struct request_queue *q = cmd->request->q; 160 struct request_queue *q = cmd->request->q;
@@ -185,6 +167,11 @@ static void cmd_hashlist_del(struct scsi_cmnd *cmd)
185 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 167 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
186} 168}
187 169
170static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd)
171{
172 blk_rq_unmap_user(tcmd->bio);
173}
174
188static void scsi_tgt_cmd_destroy(struct work_struct *work) 175static void scsi_tgt_cmd_destroy(struct work_struct *work)
189{ 176{
190 struct scsi_tgt_cmd *tcmd = 177 struct scsi_tgt_cmd *tcmd =
@@ -193,16 +180,6 @@ static void scsi_tgt_cmd_destroy(struct work_struct *work)
193 180
194 dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction, 181 dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction,
195 rq_data_dir(cmd->request)); 182 rq_data_dir(cmd->request));
196 /*
197 * We fix rq->cmd_flags here since when we told bio_map_user
198 * to write vm for WRITE commands, blk_rq_bio_prep set
199 * rq_data_dir the flags to READ.
200 */
201 if (cmd->sc_data_direction == DMA_TO_DEVICE)
202 cmd->request->cmd_flags |= REQ_RW;
203 else
204 cmd->request->cmd_flags &= ~REQ_RW;
205
206 scsi_unmap_user_pages(tcmd); 183 scsi_unmap_user_pages(tcmd);
207 scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd); 184 scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd);
208} 185}
@@ -215,6 +192,7 @@ static void init_scsi_tgt_cmd(struct request *rq, struct scsi_tgt_cmd *tcmd,
215 struct list_head *head; 192 struct list_head *head;
216 193
217 tcmd->tag = tag; 194 tcmd->tag = tag;
195 tcmd->bio = NULL;
218 INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy); 196 INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy);
219 spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 197 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
220 head = &qdata->cmd_hash[cmd_hashfn(tag)]; 198 head = &qdata->cmd_hash[cmd_hashfn(tag)];
@@ -349,10 +327,14 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
349 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request)); 327 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request));
350 328
351 scsi_tgt_uspace_send_status(cmd, tcmd->tag); 329 scsi_tgt_uspace_send_status(cmd, tcmd->tag);
330
331 if (cmd->request_buffer)
332 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
333
352 queue_work(scsi_tgtd, &tcmd->work); 334 queue_work(scsi_tgtd, &tcmd->work);
353} 335}
354 336
355static int __scsi_tgt_transfer_response(struct scsi_cmnd *cmd) 337static int scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
356{ 338{
357 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 339 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
358 int err; 340 int err;
@@ -365,30 +347,12 @@ static int __scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
365 case SCSI_MLQUEUE_DEVICE_BUSY: 347 case SCSI_MLQUEUE_DEVICE_BUSY:
366 return -EAGAIN; 348 return -EAGAIN;
367 } 349 }
368
369 return 0; 350 return 0;
370} 351}
371 352
372static void scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
373{
374 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
375 int err;
376
377 err = __scsi_tgt_transfer_response(cmd);
378 if (!err)
379 return;
380
381 cmd->result = DID_BUS_BUSY << 16;
382 err = scsi_tgt_uspace_send_status(cmd, tcmd->tag);
383 if (err <= 0)
384 /* the eh will have to pick this up */
385 printk(KERN_ERR "Could not send cmd %p status\n", cmd);
386}
387
388static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask) 353static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)
389{ 354{
390 struct request *rq = cmd->request; 355 struct request *rq = cmd->request;
391 struct scsi_tgt_cmd *tcmd = rq->end_io_data;
392 int count; 356 int count;
393 357
394 cmd->use_sg = rq->nr_phys_segments; 358 cmd->use_sg = rq->nr_phys_segments;
@@ -398,143 +362,54 @@ static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)
398 362
399 cmd->request_bufflen = rq->data_len; 363 cmd->request_bufflen = rq->data_len;
400 364
401 dprintk("cmd %p addr %p cnt %d %lu\n", cmd, tcmd->buffer, cmd->use_sg, 365 dprintk("cmd %p cnt %d %lu\n", cmd, cmd->use_sg, rq_data_dir(rq));
402 rq_data_dir(rq));
403 count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer); 366 count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer);
404 if (likely(count <= cmd->use_sg)) { 367 if (likely(count <= cmd->use_sg)) {
405 cmd->use_sg = count; 368 cmd->use_sg = count;
406 return 0; 369 return 0;
407 } 370 }
408 371
409 eprintk("cmd %p addr %p cnt %d\n", cmd, tcmd->buffer, cmd->use_sg); 372 eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg);
410 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); 373 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
411 return -EINVAL; 374 return -EINVAL;
412} 375}
413 376
414/* TODO: test this crap and replace bio_map_user with new interface maybe */ 377/* TODO: test this crap and replace bio_map_user with new interface maybe */
415static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd, 378static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
416 int rw) 379 unsigned long uaddr, unsigned int len, int rw)
417{ 380{
418 struct request_queue *q = cmd->request->q; 381 struct request_queue *q = cmd->request->q;
419 struct request *rq = cmd->request; 382 struct request *rq = cmd->request;
420 void *uaddr = tcmd->buffer;
421 unsigned int len = tcmd->bufflen;
422 struct bio *bio;
423 int err; 383 int err;
424 384
425 while (len > 0) { 385 dprintk("%lx %u\n", uaddr, len);
426 dprintk("%lx %u\n", (unsigned long) uaddr, len); 386 err = blk_rq_map_user(q, rq, (void *)uaddr, len);
427 bio = bio_map_user(q, NULL, (unsigned long) uaddr, len, rw); 387 if (err) {
428 if (IS_ERR(bio)) {
429 err = PTR_ERR(bio);
430 dprintk("fail to map %lx %u %d %x\n",
431 (unsigned long) uaddr, len, err, cmd->cmnd[0]);
432 goto unmap_bios;
433 }
434
435 uaddr += bio->bi_size;
436 len -= bio->bi_size;
437
438 /* 388 /*
439 * The first bio is added and merged. We could probably 389 * TODO: need to fixup sg_tablesize, max_segment_size,
440 * try to add others using scsi_merge_bio() but for now 390 * max_sectors, etc for modern HW and software drivers
441 * we keep it simple. The first bio should be pretty large 391 * where this value is bogus.
442 * (either hitting the 1 MB bio pages limit or a queue limit) 392 *
443 * already but for really large IO we may want to try and 393 * TODO2: we can alloc a reserve buffer of max size
444 * merge these. 394 * we can handle and do the slow copy path for really large
395 * IO.
445 */ 396 */
446 if (!rq->bio) { 397 eprintk("Could not handle request of size %u.\n", len);
447 blk_rq_bio_prep(q, rq, bio); 398 return err;
448 rq->data_len = bio->bi_size;
449 } else
450 /* put list of bios to transfer in next go around */
451 bio_list_add(&tcmd->xfer_list, bio);
452 } 399 }
453 400
454 cmd->offset = 0; 401 tcmd->bio = rq->bio;
455 err = scsi_tgt_init_cmd(cmd, GFP_KERNEL); 402 err = scsi_tgt_init_cmd(cmd, GFP_KERNEL);
456 if (err) 403 if (err)
457 goto unmap_bios; 404 goto unmap_rq;
458 405
459 return 0; 406 return 0;
460 407
461unmap_bios: 408unmap_rq:
462 if (rq->bio) { 409 scsi_unmap_user_pages(tcmd);
463 bio_unmap_user(rq->bio);
464 while ((bio = bio_list_pop(&tcmd->xfer_list)))
465 bio_unmap_user(bio);
466 }
467
468 return err; 410 return err;
469} 411}
470 412
471static int scsi_tgt_transfer_data(struct scsi_cmnd *);
472
473static void scsi_tgt_data_transfer_done(struct scsi_cmnd *cmd)
474{
475 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
476 struct bio *bio;
477 int err;
478
479 /* should we free resources here on error ? */
480 if (cmd->result) {
481send_uspace_err:
482 err = scsi_tgt_uspace_send_status(cmd, tcmd->tag);
483 if (err <= 0)
484 /* the tgt uspace eh will have to pick this up */
485 printk(KERN_ERR "Could not send cmd %p status\n", cmd);
486 return;
487 }
488
489 dprintk("cmd %p request_bufflen %u bufflen %u\n",
490 cmd, cmd->request_bufflen, tcmd->bufflen);
491
492 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
493 bio_list_add(&tcmd->xfer_done_list, cmd->request->bio);
494
495 tcmd->buffer += cmd->request_bufflen;
496 cmd->offset += cmd->request_bufflen;
497
498 if (!tcmd->xfer_list.head) {
499 scsi_tgt_transfer_response(cmd);
500 return;
501 }
502
503 dprintk("cmd2 %p request_bufflen %u bufflen %u\n",
504 cmd, cmd->request_bufflen, tcmd->bufflen);
505
506 bio = bio_list_pop(&tcmd->xfer_list);
507 BUG_ON(!bio);
508
509 blk_rq_bio_prep(cmd->request->q, cmd->request, bio);
510 cmd->request->data_len = bio->bi_size;
511 err = scsi_tgt_init_cmd(cmd, GFP_ATOMIC);
512 if (err) {
513 cmd->result = DID_ERROR << 16;
514 goto send_uspace_err;
515 }
516
517 if (scsi_tgt_transfer_data(cmd)) {
518 cmd->result = DID_NO_CONNECT << 16;
519 goto send_uspace_err;
520 }
521}
522
523static int scsi_tgt_transfer_data(struct scsi_cmnd *cmd)
524{
525 int err;
526 struct Scsi_Host *host = scsi_tgt_cmd_to_host(cmd);
527
528 err = host->hostt->transfer_data(cmd, scsi_tgt_data_transfer_done);
529 switch (err) {
530 case SCSI_MLQUEUE_HOST_BUSY:
531 case SCSI_MLQUEUE_DEVICE_BUSY:
532 return -EAGAIN;
533 default:
534 return 0;
535 }
536}
537
538static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr, 413static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr,
539 unsigned len) 414 unsigned len)
540{ 415{
@@ -584,8 +459,9 @@ static struct request *tgt_cmd_hash_lookup(struct request_queue *q, u64 tag)
584 return rq; 459 return rq;
585} 460}
586 461
587int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len, 462int scsi_tgt_kspace_exec(int host_no, int result, u64 tag,
588 unsigned long uaddr, u8 rw) 463 unsigned long uaddr, u32 len, unsigned long sense_uaddr,
464 u32 sense_len, u8 rw)
589{ 465{
590 struct Scsi_Host *shost; 466 struct Scsi_Host *shost;
591 struct scsi_cmnd *cmd; 467 struct scsi_cmnd *cmd;
@@ -617,8 +493,9 @@ int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len,
617 } 493 }
618 cmd = rq->special; 494 cmd = rq->special;
619 495
620 dprintk("cmd %p result %d len %d bufflen %u %lu %x\n", cmd, 496 dprintk("cmd %p scb %x result %d len %d bufflen %u %lu %x\n",
621 result, len, cmd->request_bufflen, rq_data_dir(rq), cmd->cmnd[0]); 497 cmd, cmd->cmnd[0], result, len, cmd->request_bufflen,
498 rq_data_dir(rq), cmd->cmnd[0]);
622 499
623 if (result == TASK_ABORTED) { 500 if (result == TASK_ABORTED) {
624 scsi_tgt_abort_cmd(shost, cmd); 501 scsi_tgt_abort_cmd(shost, cmd);
@@ -629,36 +506,36 @@ int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len,
629 * in the request_* values 506 * in the request_* values
630 */ 507 */
631 tcmd = cmd->request->end_io_data; 508 tcmd = cmd->request->end_io_data;
632 tcmd->buffer = (void *)uaddr;
633 tcmd->bufflen = len;
634 cmd->result = result; 509 cmd->result = result;
635 510
636 if (!tcmd->bufflen || cmd->request_buffer) { 511 if (cmd->result == SAM_STAT_CHECK_CONDITION)
637 err = __scsi_tgt_transfer_response(cmd); 512 scsi_tgt_copy_sense(cmd, sense_uaddr, sense_len);
638 goto done;
639 }
640 513
641 /* 514 if (len) {
642 * TODO: Do we need to handle case where request does not 515 err = scsi_map_user_pages(rq->end_io_data, cmd, uaddr, len, rw);
643 * align with LLD. 516 if (err) {
644 */ 517 /*
645 err = scsi_map_user_pages(rq->end_io_data, cmd, rw); 518 * user-space daemon bugs or OOM
646 if (err) { 519 * TODO: we can do better for OOM.
647 eprintk("%p %d\n", cmd, err); 520 */
648 err = -EAGAIN; 521 struct scsi_tgt_queuedata *qdata;
649 goto done; 522 struct list_head *head;
650 } 523 unsigned long flags;
651 524
652 /* userspace failure */ 525 eprintk("cmd %p ret %d uaddr %lx len %d rw %d\n",
653 if (cmd->result) { 526 cmd, err, uaddr, len, rw);
654 if (status_byte(cmd->result) == CHECK_CONDITION) 527
655 scsi_tgt_copy_sense(cmd, uaddr, len); 528 qdata = shost->uspace_req_q->queuedata;
656 err = __scsi_tgt_transfer_response(cmd); 529 head = &qdata->cmd_hash[cmd_hashfn(tcmd->tag)];
657 goto done; 530
658 } 531 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
659 /* ask the target LLD to transfer the data to the buffer */ 532 list_add(&tcmd->hash_list, head);
660 err = scsi_tgt_transfer_data(cmd); 533 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
661 534
535 goto done;
536 }
537 }
538 err = scsi_tgt_transfer_response(cmd);
662done: 539done:
663 scsi_host_put(shost); 540 scsi_host_put(shost);
664 return err; 541 return err;
diff --git a/drivers/scsi/scsi_tgt_priv.h b/drivers/scsi/scsi_tgt_priv.h
index 84488c51ff62..e9e6db1c417f 100644
--- a/drivers/scsi/scsi_tgt_priv.h
+++ b/drivers/scsi/scsi_tgt_priv.h
@@ -18,8 +18,9 @@ extern int scsi_tgt_if_init(void);
18extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun, 18extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun,
19 u64 tag); 19 u64 tag);
20extern int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag); 20extern int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag);
21extern int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len, 21extern int scsi_tgt_kspace_exec(int host_no, int result, u64 tag,
22 unsigned long uaddr, u8 rw); 22 unsigned long uaddr, u32 len, unsigned long sense_uaddr,
23 u32 sense_len, u8 rw);
23extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag, 24extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag,
24 struct scsi_lun *scsilun, void *data); 25 struct scsi_lun *scsilun, void *data);
25extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result); 26extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 58afdb401703..14c4f065b2b8 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -200,6 +200,8 @@ static const struct {
200 { FC_PORTSPEED_2GBIT, "2 Gbit" }, 200 { FC_PORTSPEED_2GBIT, "2 Gbit" },
201 { FC_PORTSPEED_4GBIT, "4 Gbit" }, 201 { FC_PORTSPEED_4GBIT, "4 Gbit" },
202 { FC_PORTSPEED_10GBIT, "10 Gbit" }, 202 { FC_PORTSPEED_10GBIT, "10 Gbit" },
203 { FC_PORTSPEED_8GBIT, "8 Gbit" },
204 { FC_PORTSPEED_16GBIT, "16 Gbit" },
203 { FC_PORTSPEED_NOT_NEGOTIATED, "Not Negotiated" }, 205 { FC_PORTSPEED_NOT_NEGOTIATED, "Not Negotiated" },
204}; 206};
205fc_bitfield_name_search(port_speed, fc_port_speed_names) 207fc_bitfield_name_search(port_speed, fc_port_speed_names)
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index aabaa0576ab4..caf1836bbeca 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -49,7 +49,7 @@ struct iscsi_internal {
49 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; 49 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
50}; 50};
51 51
52static int iscsi_session_nr; /* sysfs session id for next new session */ 52static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
53 53
54/* 54/*
55 * list of registered transports and lock that must 55 * list of registered transports and lock that must
@@ -300,7 +300,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
300 int err; 300 int err;
301 301
302 ihost = shost->shost_data; 302 ihost = shost->shost_data;
303 session->sid = iscsi_session_nr++; 303 session->sid = atomic_add_return(1, &iscsi_session_nr);
304 session->target_id = target_id; 304 session->target_id = target_id;
305 305
306 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", 306 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",
@@ -1419,6 +1419,8 @@ static __init int iscsi_transport_init(void)
1419 printk(KERN_INFO "Loading iSCSI transport class v%s.\n", 1419 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
1420 ISCSI_TRANSPORT_VERSION); 1420 ISCSI_TRANSPORT_VERSION);
1421 1421
1422 atomic_set(&iscsi_session_nr, 0);
1423
1422 err = class_register(&iscsi_transport_class); 1424 err = class_register(&iscsi_transport_class);
1423 if (err) 1425 if (err)
1424 return err; 1426 return err;
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 5a8f55fea5ff..00e46662296f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -58,16 +58,10 @@
58#include <scsi/scsi_host.h> 58#include <scsi/scsi_host.h>
59#include <scsi/scsi_ioctl.h> 59#include <scsi/scsi_ioctl.h>
60#include <scsi/scsicam.h> 60#include <scsi/scsicam.h>
61#include <scsi/sd.h>
61 62
62#include "scsi_logging.h" 63#include "scsi_logging.h"
63 64
64/*
65 * More than enough for everybody ;) The huge number of majors
66 * is a leftover from 16bit dev_t days, we don't really need that
67 * much numberspace.
68 */
69#define SD_MAJORS 16
70
71MODULE_AUTHOR("Eric Youngdale"); 65MODULE_AUTHOR("Eric Youngdale");
72MODULE_DESCRIPTION("SCSI disk (sd) driver"); 66MODULE_DESCRIPTION("SCSI disk (sd) driver");
73MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
@@ -88,45 +82,9 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK12_MAJOR);
88MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK13_MAJOR); 82MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK13_MAJOR);
89MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK14_MAJOR); 83MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK14_MAJOR);
90MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR); 84MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR);
91 85MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK);
92/* 86MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD);
93 * This is limited by the naming scheme enforced in sd_probe, 87MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
94 * add another character to it if you really need more disks.
95 */
96#define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26)
97
98/*
99 * Time out in seconds for disks and Magneto-opticals (which are slower).
100 */
101#define SD_TIMEOUT (30 * HZ)
102#define SD_MOD_TIMEOUT (75 * HZ)
103
104/*
105 * Number of allowed retries
106 */
107#define SD_MAX_RETRIES 5
108#define SD_PASSTHROUGH_RETRIES 1
109
110/*
111 * Size of the initial data buffer for mode and read capacity data
112 */
113#define SD_BUF_SIZE 512
114
115struct scsi_disk {
116 struct scsi_driver *driver; /* always &sd_template */
117 struct scsi_device *device;
118 struct class_device cdev;
119 struct gendisk *disk;
120 unsigned int openers; /* protected by BKL for now, yuck */
121 sector_t capacity; /* size in 512-byte sectors */
122 u32 index;
123 u8 media_present;
124 u8 write_prot;
125 unsigned WCE : 1; /* state of disk WCE bit */
126 unsigned RCD : 1; /* state of disk RCD bit, unused */
127 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
128};
129#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
130 88
131static DEFINE_IDR(sd_index_idr); 89static DEFINE_IDR(sd_index_idr);
132static DEFINE_SPINLOCK(sd_index_lock); 90static DEFINE_SPINLOCK(sd_index_lock);
@@ -136,20 +94,6 @@ static DEFINE_SPINLOCK(sd_index_lock);
136 * object after last put) */ 94 * object after last put) */
137static DEFINE_MUTEX(sd_ref_mutex); 95static DEFINE_MUTEX(sd_ref_mutex);
138 96
139static int sd_revalidate_disk(struct gendisk *disk);
140static void sd_rw_intr(struct scsi_cmnd * SCpnt);
141
142static int sd_probe(struct device *);
143static int sd_remove(struct device *);
144static void sd_shutdown(struct device *dev);
145static void sd_rescan(struct device *);
146static int sd_init_command(struct scsi_cmnd *);
147static int sd_issue_flush(struct device *, sector_t *);
148static void sd_prepare_flush(request_queue_t *, struct request *);
149static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
150 unsigned char *buffer);
151static void scsi_disk_release(struct class_device *cdev);
152
153static const char *sd_cache_types[] = { 97static const char *sd_cache_types[] = {
154 "write through", "none", "write back", 98 "write through", "none", "write back",
155 "write back, no read (daft)" 99 "write back, no read (daft)"
@@ -199,13 +143,27 @@ static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf,
199 if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT, 143 if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT,
200 SD_MAX_RETRIES, &data, &sshdr)) { 144 SD_MAX_RETRIES, &data, &sshdr)) {
201 if (scsi_sense_valid(&sshdr)) 145 if (scsi_sense_valid(&sshdr))
202 scsi_print_sense_hdr(sdkp->disk->disk_name, &sshdr); 146 sd_print_sense_hdr(sdkp, &sshdr);
203 return -EINVAL; 147 return -EINVAL;
204 } 148 }
205 sd_revalidate_disk(sdkp->disk); 149 sd_revalidate_disk(sdkp->disk);
206 return count; 150 return count;
207} 151}
208 152
153static ssize_t sd_store_manage_start_stop(struct class_device *cdev,
154 const char *buf, size_t count)
155{
156 struct scsi_disk *sdkp = to_scsi_disk(cdev);
157 struct scsi_device *sdp = sdkp->device;
158
159 if (!capable(CAP_SYS_ADMIN))
160 return -EACCES;
161
162 sdp->manage_start_stop = simple_strtoul(buf, NULL, 10);
163
164 return count;
165}
166
209static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf, 167static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf,
210 size_t count) 168 size_t count)
211{ 169{
@@ -238,6 +196,14 @@ static ssize_t sd_show_fua(struct class_device *cdev, char *buf)
238 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); 196 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA);
239} 197}
240 198
199static ssize_t sd_show_manage_start_stop(struct class_device *cdev, char *buf)
200{
201 struct scsi_disk *sdkp = to_scsi_disk(cdev);
202 struct scsi_device *sdp = sdkp->device;
203
204 return snprintf(buf, 20, "%u\n", sdp->manage_start_stop);
205}
206
241static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf) 207static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf)
242{ 208{
243 struct scsi_disk *sdkp = to_scsi_disk(cdev); 209 struct scsi_disk *sdkp = to_scsi_disk(cdev);
@@ -251,6 +217,8 @@ static struct class_device_attribute sd_disk_attrs[] = {
251 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), 217 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL),
252 __ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart, 218 __ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart,
253 sd_store_allow_restart), 219 sd_store_allow_restart),
220 __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop,
221 sd_store_manage_start_stop),
254 __ATTR_NULL, 222 __ATTR_NULL,
255}; 223};
256 224
@@ -267,6 +235,8 @@ static struct scsi_driver sd_template = {
267 .name = "sd", 235 .name = "sd",
268 .probe = sd_probe, 236 .probe = sd_probe,
269 .remove = sd_remove, 237 .remove = sd_remove,
238 .suspend = sd_suspend,
239 .resume = sd_resume,
270 .shutdown = sd_shutdown, 240 .shutdown = sd_shutdown,
271 }, 241 },
272 .rescan = sd_rescan, 242 .rescan = sd_rescan,
@@ -371,15 +341,19 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
371 unsigned int this_count = SCpnt->request_bufflen >> 9; 341 unsigned int this_count = SCpnt->request_bufflen >> 9;
372 unsigned int timeout = sdp->timeout; 342 unsigned int timeout = sdp->timeout;
373 343
374 SCSI_LOG_HLQUEUE(1, printk("sd_init_command: disk=%s, block=%llu, " 344 SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt,
375 "count=%d\n", disk->disk_name, 345 "sd_init_command: block=%llu, "
376 (unsigned long long)block, this_count)); 346 "count=%d\n",
347 (unsigned long long)block,
348 this_count));
377 349
378 if (!sdp || !scsi_device_online(sdp) || 350 if (!sdp || !scsi_device_online(sdp) ||
379 block + rq->nr_sectors > get_capacity(disk)) { 351 block + rq->nr_sectors > get_capacity(disk)) {
380 SCSI_LOG_HLQUEUE(2, printk("Finishing %ld sectors\n", 352 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
381 rq->nr_sectors)); 353 "Finishing %ld sectors\n",
382 SCSI_LOG_HLQUEUE(2, printk("Retry with 0x%p\n", SCpnt)); 354 rq->nr_sectors));
355 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
356 "Retry with 0x%p\n", SCpnt));
383 return 0; 357 return 0;
384 } 358 }
385 359
@@ -391,8 +365,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
391 /* printk("SCSI disk has been changed. Prohibiting further I/O.\n"); */ 365 /* printk("SCSI disk has been changed. Prohibiting further I/O.\n"); */
392 return 0; 366 return 0;
393 } 367 }
394 SCSI_LOG_HLQUEUE(2, printk("%s : block=%llu\n", 368 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n",
395 disk->disk_name, (unsigned long long)block)); 369 (unsigned long long)block));
396 370
397 /* 371 /*
398 * If we have a 1K hardware sectorsize, prevent access to single 372 * If we have a 1K hardware sectorsize, prevent access to single
@@ -407,7 +381,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
407 */ 381 */
408 if (sdp->sector_size == 1024) { 382 if (sdp->sector_size == 1024) {
409 if ((block & 1) || (rq->nr_sectors & 1)) { 383 if ((block & 1) || (rq->nr_sectors & 1)) {
410 printk(KERN_ERR "sd: Bad block number requested"); 384 scmd_printk(KERN_ERR, SCpnt,
385 "Bad block number requested\n");
411 return 0; 386 return 0;
412 } else { 387 } else {
413 block = block >> 1; 388 block = block >> 1;
@@ -416,7 +391,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
416 } 391 }
417 if (sdp->sector_size == 2048) { 392 if (sdp->sector_size == 2048) {
418 if ((block & 3) || (rq->nr_sectors & 3)) { 393 if ((block & 3) || (rq->nr_sectors & 3)) {
419 printk(KERN_ERR "sd: Bad block number requested"); 394 scmd_printk(KERN_ERR, SCpnt,
395 "Bad block number requested\n");
420 return 0; 396 return 0;
421 } else { 397 } else {
422 block = block >> 2; 398 block = block >> 2;
@@ -425,7 +401,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
425 } 401 }
426 if (sdp->sector_size == 4096) { 402 if (sdp->sector_size == 4096) {
427 if ((block & 7) || (rq->nr_sectors & 7)) { 403 if ((block & 7) || (rq->nr_sectors & 7)) {
428 printk(KERN_ERR "sd: Bad block number requested"); 404 scmd_printk(KERN_ERR, SCpnt,
405 "Bad block number requested\n");
429 return 0; 406 return 0;
430 } else { 407 } else {
431 block = block >> 3; 408 block = block >> 3;
@@ -442,13 +419,15 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
442 SCpnt->cmnd[0] = READ_6; 419 SCpnt->cmnd[0] = READ_6;
443 SCpnt->sc_data_direction = DMA_FROM_DEVICE; 420 SCpnt->sc_data_direction = DMA_FROM_DEVICE;
444 } else { 421 } else {
445 printk(KERN_ERR "sd: Unknown command %x\n", rq->cmd_flags); 422 scmd_printk(KERN_ERR, SCpnt, "Unknown command %x\n", rq->cmd_flags);
446 return 0; 423 return 0;
447 } 424 }
448 425
449 SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%ld 512 byte blocks.\n", 426 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
450 disk->disk_name, (rq_data_dir(rq) == WRITE) ? 427 "%s %d/%ld 512 byte blocks.\n",
451 "writing" : "reading", this_count, rq->nr_sectors)); 428 (rq_data_dir(rq) == WRITE) ?
429 "writing" : "reading", this_count,
430 rq->nr_sectors));
452 431
453 SCpnt->cmnd[1] = 0; 432 SCpnt->cmnd[1] = 0;
454 433
@@ -490,7 +469,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
490 * during operation and thus turned off 469 * during operation and thus turned off
491 * use_10_for_rw. 470 * use_10_for_rw.
492 */ 471 */
493 printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n"); 472 scmd_printk(KERN_ERR, SCpnt,
473 "FUA write on READ/WRITE(6) drive\n");
494 return 0; 474 return 0;
495 } 475 }
496 476
@@ -549,7 +529,7 @@ static int sd_open(struct inode *inode, struct file *filp)
549 return -ENXIO; 529 return -ENXIO;
550 530
551 531
552 SCSI_LOG_HLQUEUE(3, printk("sd_open: disk=%s\n", disk->disk_name)); 532 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n"));
553 533
554 sdev = sdkp->device; 534 sdev = sdkp->device;
555 535
@@ -619,7 +599,7 @@ static int sd_release(struct inode *inode, struct file *filp)
619 struct scsi_disk *sdkp = scsi_disk(disk); 599 struct scsi_disk *sdkp = scsi_disk(disk);
620 struct scsi_device *sdev = sdkp->device; 600 struct scsi_device *sdev = sdkp->device;
621 601
622 SCSI_LOG_HLQUEUE(3, printk("sd_release: disk=%s\n", disk->disk_name)); 602 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n"));
623 603
624 if (!--sdkp->openers && sdev->removable) { 604 if (!--sdkp->openers && sdev->removable) {
625 if (scsi_block_when_processing_errors(sdev)) 605 if (scsi_block_when_processing_errors(sdev))
@@ -732,8 +712,7 @@ static int sd_media_changed(struct gendisk *disk)
732 struct scsi_device *sdp = sdkp->device; 712 struct scsi_device *sdp = sdkp->device;
733 int retval; 713 int retval;
734 714
735 SCSI_LOG_HLQUEUE(3, printk("sd_media_changed: disk=%s\n", 715 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_media_changed\n"));
736 disk->disk_name));
737 716
738 if (!sdp->removable) 717 if (!sdp->removable)
739 return 0; 718 return 0;
@@ -786,9 +765,10 @@ not_present:
786 return 1; 765 return 1;
787} 766}
788 767
789static int sd_sync_cache(struct scsi_device *sdp) 768static int sd_sync_cache(struct scsi_disk *sdkp)
790{ 769{
791 int retries, res; 770 int retries, res;
771 struct scsi_device *sdp = sdkp->device;
792 struct scsi_sense_hdr sshdr; 772 struct scsi_sense_hdr sshdr;
793 773
794 if (!scsi_device_online(sdp)) 774 if (!scsi_device_online(sdp))
@@ -809,28 +789,27 @@ static int sd_sync_cache(struct scsi_device *sdp)
809 break; 789 break;
810 } 790 }
811 791
812 if (res) { printk(KERN_WARNING "FAILED\n status = %x, message = %02x, " 792 if (res) {
813 "host = %d, driver = %02x\n ", 793 sd_print_result(sdkp, res);
814 status_byte(res), msg_byte(res), 794 if (driver_byte(res) & DRIVER_SENSE)
815 host_byte(res), driver_byte(res)); 795 sd_print_sense_hdr(sdkp, &sshdr);
816 if (driver_byte(res) & DRIVER_SENSE)
817 scsi_print_sense_hdr("sd", &sshdr);
818 } 796 }
819 797
820 return res; 798 if (res)
799 return -EIO;
800 return 0;
821} 801}
822 802
823static int sd_issue_flush(struct device *dev, sector_t *error_sector) 803static int sd_issue_flush(struct device *dev, sector_t *error_sector)
824{ 804{
825 int ret = 0; 805 int ret = 0;
826 struct scsi_device *sdp = to_scsi_device(dev);
827 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 806 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
828 807
829 if (!sdkp) 808 if (!sdkp)
830 return -ENODEV; 809 return -ENODEV;
831 810
832 if (sdkp->WCE) 811 if (sdkp->WCE)
833 ret = sd_sync_cache(sdp); 812 ret = sd_sync_cache(sdkp);
834 scsi_disk_put(sdkp); 813 scsi_disk_put(sdkp);
835 return ret; 814 return ret;
836} 815}
@@ -928,12 +907,14 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt)
928 sense_deferred = scsi_sense_is_deferred(&sshdr); 907 sense_deferred = scsi_sense_is_deferred(&sshdr);
929 } 908 }
930#ifdef CONFIG_SCSI_LOGGING 909#ifdef CONFIG_SCSI_LOGGING
931 SCSI_LOG_HLCOMPLETE(1, printk("sd_rw_intr: %s: res=0x%x\n", 910 SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt));
932 SCpnt->request->rq_disk->disk_name, result));
933 if (sense_valid) { 911 if (sense_valid) {
934 SCSI_LOG_HLCOMPLETE(1, printk("sd_rw_intr: sb[respc,sk,asc," 912 SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
935 "ascq]=%x,%x,%x,%x\n", sshdr.response_code, 913 "sd_rw_intr: sb[respc,sk,asc,"
936 sshdr.sense_key, sshdr.asc, sshdr.ascq)); 914 "ascq]=%x,%x,%x,%x\n",
915 sshdr.response_code,
916 sshdr.sense_key, sshdr.asc,
917 sshdr.ascq));
937 } 918 }
938#endif 919#endif
939 if (driver_byte(result) != DRIVER_SENSE && 920 if (driver_byte(result) != DRIVER_SENSE &&
@@ -1025,7 +1006,7 @@ static int media_not_present(struct scsi_disk *sdkp,
1025 * spinup disk - called only in sd_revalidate_disk() 1006 * spinup disk - called only in sd_revalidate_disk()
1026 */ 1007 */
1027static void 1008static void
1028sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) 1009sd_spinup_disk(struct scsi_disk *sdkp)
1029{ 1010{
1030 unsigned char cmd[10]; 1011 unsigned char cmd[10];
1031 unsigned long spintime_expire = 0; 1012 unsigned long spintime_expire = 0;
@@ -1069,9 +1050,10 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1069 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { 1050 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
1070 /* no sense, TUR either succeeded or failed 1051 /* no sense, TUR either succeeded or failed
1071 * with a status error */ 1052 * with a status error */
1072 if(!spintime && !scsi_status_is_good(the_result)) 1053 if(!spintime && !scsi_status_is_good(the_result)) {
1073 printk(KERN_NOTICE "%s: Unit Not Ready, " 1054 sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
1074 "error = 0x%x\n", diskname, the_result); 1055 sd_print_result(sdkp, the_result);
1056 }
1075 break; 1057 break;
1076 } 1058 }
1077 1059
@@ -1096,8 +1078,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1096 */ 1078 */
1097 } else if (sense_valid && sshdr.sense_key == NOT_READY) { 1079 } else if (sense_valid && sshdr.sense_key == NOT_READY) {
1098 if (!spintime) { 1080 if (!spintime) {
1099 printk(KERN_NOTICE "%s: Spinning up disk...", 1081 sd_printk(KERN_NOTICE, sdkp, "Spinning up disk...");
1100 diskname);
1101 cmd[0] = START_STOP; 1082 cmd[0] = START_STOP;
1102 cmd[1] = 1; /* Return immediately */ 1083 cmd[1] = 1; /* Return immediately */
1103 memset((void *) &cmd[2], 0, 8); 1084 memset((void *) &cmd[2], 0, 8);
@@ -1130,9 +1111,8 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1130 /* we don't understand the sense code, so it's 1111 /* we don't understand the sense code, so it's
1131 * probably pointless to loop */ 1112 * probably pointless to loop */
1132 if(!spintime) { 1113 if(!spintime) {
1133 printk(KERN_NOTICE "%s: Unit Not Ready, " 1114 sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
1134 "sense:\n", diskname); 1115 sd_print_sense_hdr(sdkp, &sshdr);
1135 scsi_print_sense_hdr("", &sshdr);
1136 } 1116 }
1137 break; 1117 break;
1138 } 1118 }
@@ -1151,8 +1131,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1151 * read disk capacity 1131 * read disk capacity
1152 */ 1132 */
1153static void 1133static void
1154sd_read_capacity(struct scsi_disk *sdkp, char *diskname, 1134sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
1155 unsigned char *buffer)
1156{ 1135{
1157 unsigned char cmd[16]; 1136 unsigned char cmd[16];
1158 int the_result, retries; 1137 int the_result, retries;
@@ -1191,18 +1170,12 @@ repeat:
1191 } while (the_result && retries); 1170 } while (the_result && retries);
1192 1171
1193 if (the_result && !longrc) { 1172 if (the_result && !longrc) {
1194 printk(KERN_NOTICE "%s : READ CAPACITY failed.\n" 1173 sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY failed\n");
1195 "%s : status=%x, message=%02x, host=%d, driver=%02x \n", 1174 sd_print_result(sdkp, the_result);
1196 diskname, diskname,
1197 status_byte(the_result),
1198 msg_byte(the_result),
1199 host_byte(the_result),
1200 driver_byte(the_result));
1201
1202 if (driver_byte(the_result) & DRIVER_SENSE) 1175 if (driver_byte(the_result) & DRIVER_SENSE)
1203 scsi_print_sense_hdr("sd", &sshdr); 1176 sd_print_sense_hdr(sdkp, &sshdr);
1204 else 1177 else
1205 printk("%s : sense not available. \n", diskname); 1178 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n");
1206 1179
1207 /* Set dirty bit for removable devices if not ready - 1180 /* Set dirty bit for removable devices if not ready -
1208 * sometimes drives will not report this properly. */ 1181 * sometimes drives will not report this properly. */
@@ -1218,16 +1191,10 @@ repeat:
1218 return; 1191 return;
1219 } else if (the_result && longrc) { 1192 } else if (the_result && longrc) {
1220 /* READ CAPACITY(16) has been failed */ 1193 /* READ CAPACITY(16) has been failed */
1221 printk(KERN_NOTICE "%s : READ CAPACITY(16) failed.\n" 1194 sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n");
1222 "%s : status=%x, message=%02x, host=%d, driver=%02x \n", 1195 sd_print_result(sdkp, the_result);
1223 diskname, diskname, 1196 sd_printk(KERN_NOTICE, sdkp, "Use 0xffffffff as device size\n");
1224 status_byte(the_result), 1197
1225 msg_byte(the_result),
1226 host_byte(the_result),
1227 driver_byte(the_result));
1228 printk(KERN_NOTICE "%s : use 0xffffffff as device size\n",
1229 diskname);
1230
1231 sdkp->capacity = 1 + (sector_t) 0xffffffff; 1198 sdkp->capacity = 1 + (sector_t) 0xffffffff;
1232 goto got_data; 1199 goto got_data;
1233 } 1200 }
@@ -1238,14 +1205,14 @@ repeat:
1238 if (buffer[0] == 0xff && buffer[1] == 0xff && 1205 if (buffer[0] == 0xff && buffer[1] == 0xff &&
1239 buffer[2] == 0xff && buffer[3] == 0xff) { 1206 buffer[2] == 0xff && buffer[3] == 0xff) {
1240 if(sizeof(sdkp->capacity) > 4) { 1207 if(sizeof(sdkp->capacity) > 4) {
1241 printk(KERN_NOTICE "%s : very big device. try to use" 1208 sd_printk(KERN_NOTICE, sdkp, "Very big device. "
1242 " READ CAPACITY(16).\n", diskname); 1209 "Trying to use READ CAPACITY(16).\n");
1243 longrc = 1; 1210 longrc = 1;
1244 goto repeat; 1211 goto repeat;
1245 } 1212 }
1246 printk(KERN_ERR "%s: too big for this kernel. Use a " 1213 sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use "
1247 "kernel compiled with support for large block " 1214 "a kernel compiled with support for large "
1248 "devices.\n", diskname); 1215 "block devices.\n");
1249 sdkp->capacity = 0; 1216 sdkp->capacity = 0;
1250 goto got_data; 1217 goto got_data;
1251 } 1218 }
@@ -1284,8 +1251,8 @@ repeat:
1284got_data: 1251got_data:
1285 if (sector_size == 0) { 1252 if (sector_size == 0) {
1286 sector_size = 512; 1253 sector_size = 512;
1287 printk(KERN_NOTICE "%s : sector size 0 reported, " 1254 sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, "
1288 "assuming 512.\n", diskname); 1255 "assuming 512.\n");
1289 } 1256 }
1290 1257
1291 if (sector_size != 512 && 1258 if (sector_size != 512 &&
@@ -1293,8 +1260,8 @@ got_data:
1293 sector_size != 2048 && 1260 sector_size != 2048 &&
1294 sector_size != 4096 && 1261 sector_size != 4096 &&
1295 sector_size != 256) { 1262 sector_size != 256) {
1296 printk(KERN_NOTICE "%s : unsupported sector size " 1263 sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
1297 "%d.\n", diskname, sector_size); 1264 sector_size);
1298 /* 1265 /*
1299 * The user might want to re-format the drive with 1266 * The user might want to re-format the drive with
1300 * a supported sectorsize. Once this happens, it 1267 * a supported sectorsize. Once this happens, it
@@ -1327,10 +1294,10 @@ got_data:
1327 mb -= sz - 974; 1294 mb -= sz - 974;
1328 sector_div(mb, 1950); 1295 sector_div(mb, 1950);
1329 1296
1330 printk(KERN_NOTICE "SCSI device %s: " 1297 sd_printk(KERN_NOTICE, sdkp,
1331 "%llu %d-byte hdwr sectors (%llu MB)\n", 1298 "%llu %d-byte hardware sectors (%llu MB)\n",
1332 diskname, (unsigned long long)sdkp->capacity, 1299 (unsigned long long)sdkp->capacity,
1333 hard_sector, (unsigned long long)mb); 1300 hard_sector, (unsigned long long)mb);
1334 } 1301 }
1335 1302
1336 /* Rescale capacity to 512-byte units */ 1303 /* Rescale capacity to 512-byte units */
@@ -1362,8 +1329,7 @@ sd_do_mode_sense(struct scsi_device *sdp, int dbd, int modepage,
1362 * called with buffer of length SD_BUF_SIZE 1329 * called with buffer of length SD_BUF_SIZE
1363 */ 1330 */
1364static void 1331static void
1365sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, 1332sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
1366 unsigned char *buffer)
1367{ 1333{
1368 int res; 1334 int res;
1369 struct scsi_device *sdp = sdkp->device; 1335 struct scsi_device *sdp = sdkp->device;
@@ -1371,7 +1337,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
1371 1337
1372 set_disk_ro(sdkp->disk, 0); 1338 set_disk_ro(sdkp->disk, 0);
1373 if (sdp->skip_ms_page_3f) { 1339 if (sdp->skip_ms_page_3f) {
1374 printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); 1340 sd_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n");
1375 return; 1341 return;
1376 } 1342 }
1377 1343
@@ -1403,15 +1369,16 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
1403 } 1369 }
1404 1370
1405 if (!scsi_status_is_good(res)) { 1371 if (!scsi_status_is_good(res)) {
1406 printk(KERN_WARNING 1372 sd_printk(KERN_WARNING, sdkp,
1407 "%s: test WP failed, assume Write Enabled\n", diskname); 1373 "Test WP failed, assume Write Enabled\n");
1408 } else { 1374 } else {
1409 sdkp->write_prot = ((data.device_specific & 0x80) != 0); 1375 sdkp->write_prot = ((data.device_specific & 0x80) != 0);
1410 set_disk_ro(sdkp->disk, sdkp->write_prot); 1376 set_disk_ro(sdkp->disk, sdkp->write_prot);
1411 printk(KERN_NOTICE "%s: Write Protect is %s\n", diskname, 1377 sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
1412 sdkp->write_prot ? "on" : "off"); 1378 sdkp->write_prot ? "on" : "off");
1413 printk(KERN_DEBUG "%s: Mode Sense: %02x %02x %02x %02x\n", 1379 sd_printk(KERN_DEBUG, sdkp,
1414 diskname, buffer[0], buffer[1], buffer[2], buffer[3]); 1380 "Mode Sense: %02x %02x %02x %02x\n",
1381 buffer[0], buffer[1], buffer[2], buffer[3]);
1415 } 1382 }
1416} 1383}
1417 1384
@@ -1420,8 +1387,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
1420 * called with buffer of length SD_BUF_SIZE 1387 * called with buffer of length SD_BUF_SIZE
1421 */ 1388 */
1422static void 1389static void
1423sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, 1390sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
1424 unsigned char *buffer)
1425{ 1391{
1426 int len = 0, res; 1392 int len = 0, res;
1427 struct scsi_device *sdp = sdkp->device; 1393 struct scsi_device *sdp = sdkp->device;
@@ -1450,8 +1416,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1450 1416
1451 if (!data.header_length) { 1417 if (!data.header_length) {
1452 modepage = 6; 1418 modepage = 6;
1453 printk(KERN_ERR "%s: missing header in MODE_SENSE response\n", 1419 sd_printk(KERN_ERR, sdkp, "Missing header in MODE_SENSE response\n");
1454 diskname);
1455 } 1420 }
1456 1421
1457 /* that went OK, now ask for the proper length */ 1422 /* that went OK, now ask for the proper length */
@@ -1478,13 +1443,12 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1478 int offset = data.header_length + data.block_descriptor_length; 1443 int offset = data.header_length + data.block_descriptor_length;
1479 1444
1480 if (offset >= SD_BUF_SIZE - 2) { 1445 if (offset >= SD_BUF_SIZE - 2) {
1481 printk(KERN_ERR "%s: malformed MODE SENSE response", 1446 sd_printk(KERN_ERR, sdkp, "Malformed MODE SENSE response\n");
1482 diskname);
1483 goto defaults; 1447 goto defaults;
1484 } 1448 }
1485 1449
1486 if ((buffer[offset] & 0x3f) != modepage) { 1450 if ((buffer[offset] & 0x3f) != modepage) {
1487 printk(KERN_ERR "%s: got wrong page\n", diskname); 1451 sd_printk(KERN_ERR, sdkp, "Got wrong page\n");
1488 goto defaults; 1452 goto defaults;
1489 } 1453 }
1490 1454
@@ -1498,14 +1462,13 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1498 1462
1499 sdkp->DPOFUA = (data.device_specific & 0x10) != 0; 1463 sdkp->DPOFUA = (data.device_specific & 0x10) != 0;
1500 if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) { 1464 if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
1501 printk(KERN_NOTICE "SCSI device %s: uses " 1465 sd_printk(KERN_NOTICE, sdkp,
1502 "READ/WRITE(6), disabling FUA\n", diskname); 1466 "Uses READ/WRITE(6), disabling FUA\n");
1503 sdkp->DPOFUA = 0; 1467 sdkp->DPOFUA = 0;
1504 } 1468 }
1505 1469
1506 printk(KERN_NOTICE "SCSI device %s: " 1470 sd_printk(KERN_NOTICE, sdkp,
1507 "write cache: %s, read cache: %s, %s\n", 1471 "Write cache: %s, read cache: %s, %s\n",
1508 diskname,
1509 sdkp->WCE ? "enabled" : "disabled", 1472 sdkp->WCE ? "enabled" : "disabled",
1510 sdkp->RCD ? "disabled" : "enabled", 1473 sdkp->RCD ? "disabled" : "enabled",
1511 sdkp->DPOFUA ? "supports DPO and FUA" 1474 sdkp->DPOFUA ? "supports DPO and FUA"
@@ -1518,15 +1481,13 @@ bad_sense:
1518 if (scsi_sense_valid(&sshdr) && 1481 if (scsi_sense_valid(&sshdr) &&
1519 sshdr.sense_key == ILLEGAL_REQUEST && 1482 sshdr.sense_key == ILLEGAL_REQUEST &&
1520 sshdr.asc == 0x24 && sshdr.ascq == 0x0) 1483 sshdr.asc == 0x24 && sshdr.ascq == 0x0)
1521 printk(KERN_NOTICE "%s: cache data unavailable\n", 1484 /* Invalid field in CDB */
1522 diskname); /* Invalid field in CDB */ 1485 sd_printk(KERN_NOTICE, sdkp, "Cache data unavailable\n");
1523 else 1486 else
1524 printk(KERN_ERR "%s: asking for cache data failed\n", 1487 sd_printk(KERN_ERR, sdkp, "Asking for cache data failed\n");
1525 diskname);
1526 1488
1527defaults: 1489defaults:
1528 printk(KERN_ERR "%s: assuming drive cache: write through\n", 1490 sd_printk(KERN_ERR, sdkp, "Assuming drive cache: write through\n");
1529 diskname);
1530 sdkp->WCE = 0; 1491 sdkp->WCE = 0;
1531 sdkp->RCD = 0; 1492 sdkp->RCD = 0;
1532 sdkp->DPOFUA = 0; 1493 sdkp->DPOFUA = 0;
@@ -1544,7 +1505,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
1544 unsigned char *buffer; 1505 unsigned char *buffer;
1545 unsigned ordered; 1506 unsigned ordered;
1546 1507
1547 SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); 1508 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
1509 "sd_revalidate_disk\n"));
1548 1510
1549 /* 1511 /*
1550 * If the device is offline, don't try and read capacity or any 1512 * If the device is offline, don't try and read capacity or any
@@ -1555,8 +1517,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
1555 1517
1556 buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL | __GFP_DMA); 1518 buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL | __GFP_DMA);
1557 if (!buffer) { 1519 if (!buffer) {
1558 printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " 1520 sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory "
1559 "failure.\n"); 1521 "allocation failure.\n");
1560 goto out; 1522 goto out;
1561 } 1523 }
1562 1524
@@ -1568,16 +1530,16 @@ static int sd_revalidate_disk(struct gendisk *disk)
1568 sdkp->WCE = 0; 1530 sdkp->WCE = 0;
1569 sdkp->RCD = 0; 1531 sdkp->RCD = 0;
1570 1532
1571 sd_spinup_disk(sdkp, disk->disk_name); 1533 sd_spinup_disk(sdkp);
1572 1534
1573 /* 1535 /*
1574 * Without media there is no reason to ask; moreover, some devices 1536 * Without media there is no reason to ask; moreover, some devices
1575 * react badly if we do. 1537 * react badly if we do.
1576 */ 1538 */
1577 if (sdkp->media_present) { 1539 if (sdkp->media_present) {
1578 sd_read_capacity(sdkp, disk->disk_name, buffer); 1540 sd_read_capacity(sdkp, buffer);
1579 sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); 1541 sd_read_write_protect_flag(sdkp, buffer);
1580 sd_read_cache_type(sdkp, disk->disk_name, buffer); 1542 sd_read_cache_type(sdkp, buffer);
1581 } 1543 }
1582 1544
1583 /* 1545 /*
@@ -1709,8 +1671,8 @@ static int sd_probe(struct device *dev)
1709 dev_set_drvdata(dev, sdkp); 1671 dev_set_drvdata(dev, sdkp);
1710 add_disk(gd); 1672 add_disk(gd);
1711 1673
1712 sdev_printk(KERN_NOTICE, sdp, "Attached scsi %sdisk %s\n", 1674 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
1713 sdp->removable ? "removable " : "", gd->disk_name); 1675 sdp->removable ? "removable " : "");
1714 1676
1715 return 0; 1677 return 0;
1716 1678
@@ -1774,6 +1736,31 @@ static void scsi_disk_release(struct class_device *cdev)
1774 kfree(sdkp); 1736 kfree(sdkp);
1775} 1737}
1776 1738
1739static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
1740{
1741 unsigned char cmd[6] = { START_STOP }; /* START_VALID */
1742 struct scsi_sense_hdr sshdr;
1743 struct scsi_device *sdp = sdkp->device;
1744 int res;
1745
1746 if (start)
1747 cmd[4] |= 1; /* START */
1748
1749 if (!scsi_device_online(sdp))
1750 return -ENODEV;
1751
1752 res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr,
1753 SD_TIMEOUT, SD_MAX_RETRIES);
1754 if (res) {
1755 sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n");
1756 sd_print_result(sdkp, res);
1757 if (driver_byte(res) & DRIVER_SENSE)
1758 sd_print_sense_hdr(sdkp, &sshdr);
1759 }
1760
1761 return res;
1762}
1763
1777/* 1764/*
1778 * Send a SYNCHRONIZE CACHE instruction down to the device through 1765 * Send a SYNCHRONIZE CACHE instruction down to the device through
1779 * the normal SCSI command structure. Wait for the command to 1766 * the normal SCSI command structure. Wait for the command to
@@ -1781,20 +1768,62 @@ static void scsi_disk_release(struct class_device *cdev)
1781 */ 1768 */
1782static void sd_shutdown(struct device *dev) 1769static void sd_shutdown(struct device *dev)
1783{ 1770{
1784 struct scsi_device *sdp = to_scsi_device(dev);
1785 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1771 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
1786 1772
1787 if (!sdkp) 1773 if (!sdkp)
1788 return; /* this can happen */ 1774 return; /* this can happen */
1789 1775
1790 if (sdkp->WCE) { 1776 if (sdkp->WCE) {
1791 printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n", 1777 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
1792 sdkp->disk->disk_name); 1778 sd_sync_cache(sdkp);
1793 sd_sync_cache(sdp); 1779 }
1780
1781 if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) {
1782 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
1783 sd_start_stop_device(sdkp, 0);
1794 } 1784 }
1785
1795 scsi_disk_put(sdkp); 1786 scsi_disk_put(sdkp);
1796} 1787}
1797 1788
1789static int sd_suspend(struct device *dev, pm_message_t mesg)
1790{
1791 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
1792 int ret;
1793
1794 if (!sdkp)
1795 return 0; /* this can happen */
1796
1797 if (sdkp->WCE) {
1798 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
1799 ret = sd_sync_cache(sdkp);
1800 if (ret)
1801 return ret;
1802 }
1803
1804 if (mesg.event == PM_EVENT_SUSPEND &&
1805 sdkp->device->manage_start_stop) {
1806 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
1807 ret = sd_start_stop_device(sdkp, 0);
1808 if (ret)
1809 return ret;
1810 }
1811
1812 return 0;
1813}
1814
1815static int sd_resume(struct device *dev)
1816{
1817 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
1818
1819 if (!sdkp->device->manage_start_stop)
1820 return 0;
1821
1822 sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
1823
1824 return sd_start_stop_device(sdkp, 1);
1825}
1826
1798/** 1827/**
1799 * init_sd - entry point for this driver (both when built in or when 1828 * init_sd - entry point for this driver (both when built in or when
1800 * a module). 1829 * a module).
@@ -1852,3 +1881,19 @@ static void __exit exit_sd(void)
1852 1881
1853module_init(init_sd); 1882module_init(init_sd);
1854module_exit(exit_sd); 1883module_exit(exit_sd);
1884
1885static void sd_print_sense_hdr(struct scsi_disk *sdkp,
1886 struct scsi_sense_hdr *sshdr)
1887{
1888 sd_printk(KERN_INFO, sdkp, "");
1889 scsi_show_sense_hdr(sshdr);
1890 sd_printk(KERN_INFO, sdkp, "");
1891 scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
1892}
1893
1894static void sd_print_result(struct scsi_disk *sdkp, int result)
1895{
1896 sd_printk(KERN_INFO, sdkp, "");
1897 scsi_show_result(result);
1898}
1899
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 81e3bc7b02a1..570977cf9efb 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -917,6 +917,8 @@ sg_ioctl(struct inode *inode, struct file *filp,
917 return result; 917 return result;
918 if (val < 0) 918 if (val < 0)
919 return -EINVAL; 919 return -EINVAL;
920 val = min_t(int, val,
921 sdp->device->request_queue->max_sectors * 512);
920 if (val != sfp->reserve.bufflen) { 922 if (val != sfp->reserve.bufflen) {
921 if (sg_res_in_use(sfp) || sfp->mmap_called) 923 if (sg_res_in_use(sfp) || sfp->mmap_called)
922 return -EBUSY; 924 return -EBUSY;
@@ -925,7 +927,8 @@ sg_ioctl(struct inode *inode, struct file *filp,
925 } 927 }
926 return 0; 928 return 0;
927 case SG_GET_RESERVED_SIZE: 929 case SG_GET_RESERVED_SIZE:
928 val = (int) sfp->reserve.bufflen; 930 val = min_t(int, sfp->reserve.bufflen,
931 sdp->device->request_queue->max_sectors * 512);
929 return put_user(val, ip); 932 return put_user(val, ip);
930 case SG_SET_COMMAND_Q: 933 case SG_SET_COMMAND_Q:
931 result = get_user(val, ip); 934 result = get_user(val, ip);
@@ -1061,6 +1064,9 @@ sg_ioctl(struct inode *inode, struct file *filp,
1061 if (sdp->detached) 1064 if (sdp->detached)
1062 return -ENODEV; 1065 return -ENODEV;
1063 return scsi_ioctl(sdp->device, cmd_in, p); 1066 return scsi_ioctl(sdp->device, cmd_in, p);
1067 case BLKSECTGET:
1068 return put_user(sdp->device->request_queue->max_sectors * 512,
1069 ip);
1064 default: 1070 default:
1065 if (read_only) 1071 if (read_only)
1066 return -EPERM; /* don't know so take safe approach */ 1072 return -EPERM; /* don't know so take safe approach */
@@ -2339,6 +2345,7 @@ sg_add_sfp(Sg_device * sdp, int dev)
2339{ 2345{
2340 Sg_fd *sfp; 2346 Sg_fd *sfp;
2341 unsigned long iflags; 2347 unsigned long iflags;
2348 int bufflen;
2342 2349
2343 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); 2350 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN);
2344 if (!sfp) 2351 if (!sfp)
@@ -2369,7 +2376,9 @@ sg_add_sfp(Sg_device * sdp, int dev)
2369 if (unlikely(sg_big_buff != def_reserved_size)) 2376 if (unlikely(sg_big_buff != def_reserved_size))
2370 sg_big_buff = def_reserved_size; 2377 sg_big_buff = def_reserved_size;
2371 2378
2372 sg_build_reserve(sfp, sg_big_buff); 2379 bufflen = min_t(int, sg_big_buff,
2380 sdp->device->request_queue->max_sectors * 512);
2381 sg_build_reserve(sfp, bufflen);
2373 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n", 2382 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n",
2374 sfp->reserve.bufflen, sfp->reserve.k_use_sg)); 2383 sfp->reserve.bufflen, sfp->reserve.k_use_sg));
2375 return sfp; 2384 return sfp;
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 1857d68e7195..f9a52af7f5b4 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -62,6 +62,8 @@
62MODULE_DESCRIPTION("SCSI cdrom (sr) driver"); 62MODULE_DESCRIPTION("SCSI cdrom (sr) driver");
63MODULE_LICENSE("GPL"); 63MODULE_LICENSE("GPL");
64MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR); 64MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR);
65MODULE_ALIAS_SCSI_DEVICE(TYPE_ROM);
66MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);
65 67
66#define SR_DISKS 256 68#define SR_DISKS 256
67 69
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 98d8411bbccc..55bfeccf68a2 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -89,6 +89,7 @@ MODULE_AUTHOR("Kai Makisara");
89MODULE_DESCRIPTION("SCSI tape (st) driver"); 89MODULE_DESCRIPTION("SCSI tape (st) driver");
90MODULE_LICENSE("GPL"); 90MODULE_LICENSE("GPL");
91MODULE_ALIAS_CHARDEV_MAJOR(SCSI_TAPE_MAJOR); 91MODULE_ALIAS_CHARDEV_MAJOR(SCSI_TAPE_MAJOR);
92MODULE_ALIAS_SCSI_DEVICE(TYPE_TAPE);
92 93
93/* Set 'perm' (4th argument) to 0 to disable module_param's definition 94/* Set 'perm' (4th argument) to 0 to disable module_param's definition
94 * of sysfs parameters (which module_param doesn't yet support). 95 * of sysfs parameters (which module_param doesn't yet support).
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index a583e89238fc..3158949ffa62 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -2680,7 +2680,7 @@ static int __init dc390_module_init(void)
2680 printk (KERN_INFO "DC390: Using safe settings.\n"); 2680 printk (KERN_INFO "DC390: Using safe settings.\n");
2681 } 2681 }
2682 2682
2683 return pci_module_init(&dc390_driver); 2683 return pci_register_driver(&dc390_driver);
2684} 2684}
2685 2685
2686static void __exit dc390_module_exit(void) 2686static void __exit dc390_module_exit(void)
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 9bf420eef77f..284a0734e0cd 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -10,9 +10,6 @@ obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o
10obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o 10obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o
11obj-$(CONFIG_USB_KBTAB) += kbtab.o 11obj-$(CONFIG_USB_KBTAB) += kbtab.o
12obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o 12obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o
13obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o
14obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o
15obj-$(CONFIG_USB_EGALAX) += touchkitusb.o
16obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o 13obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o
17obj-$(CONFIG_USB_POWERMATE) += powermate.o 14obj-$(CONFIG_USB_POWERMATE) += powermate.o
18obj-$(CONFIG_USB_WACOM) += wacom.o 15obj-$(CONFIG_USB_WACOM) += wacom.o
@@ -20,7 +17,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o
20obj-$(CONFIG_USB_YEALINK) += yealink.o 17obj-$(CONFIG_USB_YEALINK) += yealink.o
21obj-$(CONFIG_USB_XPAD) += xpad.o 18obj-$(CONFIG_USB_XPAD) += xpad.o
22obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o 19obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o
23obj-$(CONFIG_USB_GTCO) += gtco.o 20obj-$(CONFIG_USB_GTCO) += gtco.o
24 21
25ifeq ($(CONFIG_USB_DEBUG),y) 22ifeq ($(CONFIG_USB_DEBUG),y)
26EXTRA_CFLAGS += -DDEBUG 23EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index 909138e5aa04..be8e9243c062 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -111,7 +111,7 @@ resubmit:
111 111
112static int usb_acecad_open(struct input_dev *dev) 112static int usb_acecad_open(struct input_dev *dev)
113{ 113{
114 struct usb_acecad *acecad = dev->private; 114 struct usb_acecad *acecad = input_get_drvdata(dev);
115 115
116 acecad->irq->dev = acecad->usbdev; 116 acecad->irq->dev = acecad->usbdev;
117 if (usb_submit_urb(acecad->irq, GFP_KERNEL)) 117 if (usb_submit_urb(acecad->irq, GFP_KERNEL))
@@ -122,7 +122,7 @@ static int usb_acecad_open(struct input_dev *dev)
122 122
123static void usb_acecad_close(struct input_dev *dev) 123static void usb_acecad_close(struct input_dev *dev)
124{ 124{
125 struct usb_acecad *acecad = dev->private; 125 struct usb_acecad *acecad = input_get_drvdata(dev);
126 126
127 usb_kill_urb(acecad->irq); 127 usb_kill_urb(acecad->irq);
128} 128}
@@ -135,6 +135,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
135 struct usb_acecad *acecad; 135 struct usb_acecad *acecad;
136 struct input_dev *input_dev; 136 struct input_dev *input_dev;
137 int pipe, maxp; 137 int pipe, maxp;
138 int err = -ENOMEM;
138 139
139 if (interface->desc.bNumEndpoints != 1) 140 if (interface->desc.bNumEndpoints != 1)
140 return -ENODEV; 141 return -ENODEV;
@@ -149,16 +150,22 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
149 150
150 acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); 151 acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL);
151 input_dev = input_allocate_device(); 152 input_dev = input_allocate_device();
152 if (!acecad || !input_dev) 153 if (!acecad || !input_dev) {
154 err = -ENOMEM;
153 goto fail1; 155 goto fail1;
156 }
154 157
155 acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma); 158 acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
156 if (!acecad->data) 159 if (!acecad->data) {
160 err= -ENOMEM;
157 goto fail1; 161 goto fail1;
162 }
158 163
159 acecad->irq = usb_alloc_urb(0, GFP_KERNEL); 164 acecad->irq = usb_alloc_urb(0, GFP_KERNEL);
160 if (!acecad->irq) 165 if (!acecad->irq) {
166 err = -ENOMEM;
161 goto fail2; 167 goto fail2;
168 }
162 169
163 acecad->usbdev = dev; 170 acecad->usbdev = dev;
164 acecad->input = input_dev; 171 acecad->input = input_dev;
@@ -178,8 +185,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
178 input_dev->name = acecad->name; 185 input_dev->name = acecad->name;
179 input_dev->phys = acecad->phys; 186 input_dev->phys = acecad->phys;
180 usb_to_input_id(dev, &input_dev->id); 187 usb_to_input_id(dev, &input_dev->id);
181 input_dev->cdev.dev = &intf->dev; 188 input_dev->dev.parent = &intf->dev;
182 input_dev->private = acecad; 189
190 input_set_drvdata(input_dev, acecad);
183 191
184 input_dev->open = usb_acecad_open; 192 input_dev->open = usb_acecad_open;
185 input_dev->close = usb_acecad_close; 193 input_dev->close = usb_acecad_close;
@@ -221,7 +229,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
221 acecad->irq->transfer_dma = acecad->data_dma; 229 acecad->irq->transfer_dma = acecad->data_dma;
222 acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 230 acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
223 231
224 input_register_device(acecad->input); 232 err = input_register_device(acecad->input);
233 if (err)
234 goto fail2;
225 235
226 usb_set_intfdata(intf, acecad); 236 usb_set_intfdata(intf, acecad);
227 237
@@ -230,7 +240,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
230 fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); 240 fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma);
231 fail1: input_free_device(input_dev); 241 fail1: input_free_device(input_dev);
232 kfree(acecad); 242 kfree(acecad);
233 return -ENOMEM; 243 return err;
234} 244}
235 245
236static void usb_acecad_disconnect(struct usb_interface *intf) 246static void usb_acecad_disconnect(struct usb_interface *intf)
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index f857935e615c..cc0a498763d8 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -798,7 +798,7 @@ MODULE_DEVICE_TABLE(usb, aiptek_ids);
798 */ 798 */
799static int aiptek_open(struct input_dev *inputdev) 799static int aiptek_open(struct input_dev *inputdev)
800{ 800{
801 struct aiptek *aiptek = inputdev->private; 801 struct aiptek *aiptek = input_get_drvdata(inputdev);
802 802
803 aiptek->urb->dev = aiptek->usbdev; 803 aiptek->urb->dev = aiptek->usbdev;
804 if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0) 804 if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0)
@@ -812,7 +812,7 @@ static int aiptek_open(struct input_dev *inputdev)
812 */ 812 */
813static void aiptek_close(struct input_dev *inputdev) 813static void aiptek_close(struct input_dev *inputdev)
814{ 814{
815 struct aiptek *aiptek = inputdev->private; 815 struct aiptek *aiptek = input_get_drvdata(inputdev);
816 816
817 usb_kill_urb(aiptek->urb); 817 usb_kill_urb(aiptek->urb);
818} 818}
@@ -1972,6 +1972,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1972 AIPTEK_PROGRAMMABLE_DELAY_200, 1972 AIPTEK_PROGRAMMABLE_DELAY_200,
1973 AIPTEK_PROGRAMMABLE_DELAY_300 1973 AIPTEK_PROGRAMMABLE_DELAY_300
1974 }; 1974 };
1975 int err = -ENOMEM;
1975 1976
1976 /* programmableDelay is where the command-line specified 1977 /* programmableDelay is where the command-line specified
1977 * delay is kept. We make it the first element of speeds[], 1978 * delay is kept. We make it the first element of speeds[],
@@ -2043,8 +2044,10 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2043 inputdev->name = "Aiptek"; 2044 inputdev->name = "Aiptek";
2044 inputdev->phys = aiptek->features.usbPath; 2045 inputdev->phys = aiptek->features.usbPath;
2045 usb_to_input_id(usbdev, &inputdev->id); 2046 usb_to_input_id(usbdev, &inputdev->id);
2046 inputdev->cdev.dev = &intf->dev; 2047 inputdev->dev.parent = &intf->dev;
2047 inputdev->private = aiptek; 2048
2049 input_set_drvdata(inputdev, aiptek);
2050
2048 inputdev->open = aiptek_open; 2051 inputdev->open = aiptek_open;
2049 inputdev->close = aiptek_close; 2052 inputdev->close = aiptek_close;
2050 2053
@@ -2133,7 +2136,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2133 2136
2134 /* Register the tablet as an Input Device 2137 /* Register the tablet as an Input Device
2135 */ 2138 */
2136 input_register_device(aiptek->inputdev); 2139 err = input_register_device(aiptek->inputdev);
2140 if (err)
2141 goto fail2;
2137 2142
2138 /* We now will look for the evdev device which is mapped to 2143 /* We now will look for the evdev device which is mapped to
2139 * the tablet. The partial name is kept in the link list of 2144 * the tablet. The partial name is kept in the link list of
@@ -2165,23 +2170,13 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2165 2170
2166 return 0; 2171 return 0;
2167 2172
2168fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, 2173 fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
2169 aiptek->data_dma); 2174 aiptek->data_dma);
2170fail1: input_free_device(inputdev); 2175 fail1: input_free_device(inputdev);
2171 kfree(aiptek); 2176 kfree(aiptek);
2172 return -ENOMEM; 2177 return err;
2173} 2178}
2174 2179
2175/* Forward declaration */
2176static void aiptek_disconnect(struct usb_interface *intf);
2177
2178static struct usb_driver aiptek_driver = {
2179 .name = "aiptek",
2180 .probe = aiptek_probe,
2181 .disconnect = aiptek_disconnect,
2182 .id_table = aiptek_ids,
2183};
2184
2185/*********************************************************************** 2180/***********************************************************************
2186 * Deal with tablet disconnecting from the system. 2181 * Deal with tablet disconnecting from the system.
2187 */ 2182 */
@@ -2206,6 +2201,13 @@ static void aiptek_disconnect(struct usb_interface *intf)
2206 } 2201 }
2207} 2202}
2208 2203
2204static struct usb_driver aiptek_driver = {
2205 .name = "aiptek",
2206 .probe = aiptek_probe,
2207 .disconnect = aiptek_disconnect,
2208 .id_table = aiptek_ids,
2209};
2210
2209static int __init aiptek_init(void) 2211static int __init aiptek_init(void)
2210{ 2212{
2211 int result = usb_register(&aiptek_driver); 2213 int result = usb_register(&aiptek_driver);
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c
index c77291d3d063..e3215267db11 100644
--- a/drivers/usb/input/appletouch.c
+++ b/drivers/usb/input/appletouch.c
@@ -466,7 +466,7 @@ exit:
466 466
467static int atp_open(struct input_dev *input) 467static int atp_open(struct input_dev *input)
468{ 468{
469 struct atp *dev = input->private; 469 struct atp *dev = input_get_drvdata(input);
470 470
471 if (usb_submit_urb(dev->urb, GFP_ATOMIC)) 471 if (usb_submit_urb(dev->urb, GFP_ATOMIC))
472 return -EIO; 472 return -EIO;
@@ -477,7 +477,7 @@ static int atp_open(struct input_dev *input)
477 477
478static void atp_close(struct input_dev *input) 478static void atp_close(struct input_dev *input)
479{ 479{
480 struct atp *dev = input->private; 480 struct atp *dev = input_get_drvdata(input);
481 481
482 usb_kill_urb(dev->urb); 482 usb_kill_urb(dev->urb);
483 dev->open = 0; 483 dev->open = 0;
@@ -491,8 +491,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
491 struct usb_host_interface *iface_desc; 491 struct usb_host_interface *iface_desc;
492 struct usb_endpoint_descriptor *endpoint; 492 struct usb_endpoint_descriptor *endpoint;
493 int int_in_endpointAddr = 0; 493 int int_in_endpointAddr = 0;
494 int i, retval = -ENOMEM; 494 int i, error = -ENOMEM;
495
496 495
497 /* set up the endpoint information */ 496 /* set up the endpoint information */
498 /* use only the first interrupt-in endpoint */ 497 /* use only the first interrupt-in endpoint */
@@ -567,17 +566,13 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
567 } 566 }
568 567
569 dev->urb = usb_alloc_urb(0, GFP_KERNEL); 568 dev->urb = usb_alloc_urb(0, GFP_KERNEL);
570 if (!dev->urb) { 569 if (!dev->urb)
571 retval = -ENOMEM;
572 goto err_free_devs; 570 goto err_free_devs;
573 }
574 571
575 dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL, 572 dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL,
576 &dev->urb->transfer_dma); 573 &dev->urb->transfer_dma);
577 if (!dev->data) { 574 if (!dev->data)
578 retval = -ENOMEM;
579 goto err_free_urb; 575 goto err_free_urb;
580 }
581 576
582 usb_fill_int_urb(dev->urb, udev, 577 usb_fill_int_urb(dev->urb, udev,
583 usb_rcvintpipe(udev, int_in_endpointAddr), 578 usb_rcvintpipe(udev, int_in_endpointAddr),
@@ -589,9 +584,10 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
589 input_dev->name = "appletouch"; 584 input_dev->name = "appletouch";
590 input_dev->phys = dev->phys; 585 input_dev->phys = dev->phys;
591 usb_to_input_id(dev->udev, &input_dev->id); 586 usb_to_input_id(dev->udev, &input_dev->id);
592 input_dev->cdev.dev = &iface->dev; 587 input_dev->dev.parent = &iface->dev;
588
589 input_set_drvdata(input_dev, dev);
593 590
594 input_dev->private = dev;
595 input_dev->open = atp_open; 591 input_dev->open = atp_open;
596 input_dev->close = atp_close; 592 input_dev->close = atp_close;
597 593
@@ -633,20 +629,25 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
633 set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 629 set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
634 set_bit(BTN_LEFT, input_dev->keybit); 630 set_bit(BTN_LEFT, input_dev->keybit);
635 631
636 input_register_device(dev->input); 632 error = input_register_device(dev->input);
633 if (error)
634 goto err_free_buffer;
637 635
638 /* save our data pointer in this interface device */ 636 /* save our data pointer in this interface device */
639 usb_set_intfdata(iface, dev); 637 usb_set_intfdata(iface, dev);
640 638
641 return 0; 639 return 0;
642 640
641 err_free_buffer:
642 usb_buffer_free(dev->udev, dev->datalen,
643 dev->data, dev->urb->transfer_dma);
643 err_free_urb: 644 err_free_urb:
644 usb_free_urb(dev->urb); 645 usb_free_urb(dev->urb);
645 err_free_devs: 646 err_free_devs:
646 usb_set_intfdata(iface, NULL); 647 usb_set_intfdata(iface, NULL);
647 kfree(dev); 648 kfree(dev);
648 input_free_device(input_dev); 649 input_free_device(input_dev);
649 return retval; 650 return error;
650} 651}
651 652
652static void atp_disconnect(struct usb_interface *iface) 653static void atp_disconnect(struct usb_interface *iface)
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index b724e36f7b92..471aab206443 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -120,6 +120,7 @@
120 * behaviour. 120 * behaviour.
121 */ 121 */
122#define FILTER_TIME 60 /* msec */ 122#define FILTER_TIME 60 /* msec */
123#define REPEAT_DELAY 500 /* msec */
123 124
124static unsigned long channel_mask; 125static unsigned long channel_mask;
125module_param(channel_mask, ulong, 0644); 126module_param(channel_mask, ulong, 0644);
@@ -133,6 +134,10 @@ static int repeat_filter = FILTER_TIME;
133module_param(repeat_filter, int, 0644); 134module_param(repeat_filter, int, 0644);
134MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec"); 135MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec");
135 136
137static int repeat_delay = REPEAT_DELAY;
138module_param(repeat_delay, int, 0644);
139MODULE_PARM_DESC(repeat_delay, "Delay before sending repeats, default = 500 msec");
140
136#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) 141#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
137#undef err 142#undef err
138#define err(format, arg...) printk(KERN_ERR format , ## arg) 143#define err(format, arg...) printk(KERN_ERR format , ## arg)
@@ -174,6 +179,8 @@ struct ati_remote {
174 unsigned char old_data[2]; /* Detect duplicate events */ 179 unsigned char old_data[2]; /* Detect duplicate events */
175 unsigned long old_jiffies; 180 unsigned long old_jiffies;
176 unsigned long acc_jiffies; /* handle acceleration */ 181 unsigned long acc_jiffies; /* handle acceleration */
182 unsigned long first_jiffies;
183
177 unsigned int repeat_count; 184 unsigned int repeat_count;
178 185
179 char name[NAME_BUFSIZE]; 186 char name[NAME_BUFSIZE];
@@ -318,7 +325,7 @@ static void ati_remote_dump(unsigned char *data, unsigned int len)
318 */ 325 */
319static int ati_remote_open(struct input_dev *inputdev) 326static int ati_remote_open(struct input_dev *inputdev)
320{ 327{
321 struct ati_remote *ati_remote = inputdev->private; 328 struct ati_remote *ati_remote = input_get_drvdata(inputdev);
322 329
323 /* On first open, submit the read urb which was set up previously. */ 330 /* On first open, submit the read urb which was set up previously. */
324 ati_remote->irq_urb->dev = ati_remote->udev; 331 ati_remote->irq_urb->dev = ati_remote->udev;
@@ -336,7 +343,7 @@ static int ati_remote_open(struct input_dev *inputdev)
336 */ 343 */
337static void ati_remote_close(struct input_dev *inputdev) 344static void ati_remote_close(struct input_dev *inputdev)
338{ 345{
339 struct ati_remote *ati_remote = inputdev->private; 346 struct ati_remote *ati_remote = input_get_drvdata(inputdev);
340 347
341 usb_kill_urb(ati_remote->irq_urb); 348 usb_kill_urb(ati_remote->irq_urb);
342} 349}
@@ -501,21 +508,31 @@ static void ati_remote_input_report(struct urb *urb)
501 } 508 }
502 509
503 if (ati_remote_tbl[index].kind == KIND_FILTERED) { 510 if (ati_remote_tbl[index].kind == KIND_FILTERED) {
511 unsigned long now = jiffies;
512
504 /* Filter duplicate events which happen "too close" together. */ 513 /* Filter duplicate events which happen "too close" together. */
505 if (ati_remote->old_data[0] == data[1] && 514 if (ati_remote->old_data[0] == data[1] &&
506 ati_remote->old_data[1] == data[2] && 515 ati_remote->old_data[1] == data[2] &&
507 time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(repeat_filter))) { 516 time_before(now, ati_remote->old_jiffies +
517 msecs_to_jiffies(repeat_filter))) {
508 ati_remote->repeat_count++; 518 ati_remote->repeat_count++;
509 } else { 519 } else {
510 ati_remote->repeat_count = 0; 520 ati_remote->repeat_count = 0;
521 ati_remote->first_jiffies = now;
511 } 522 }
512 523
513 ati_remote->old_data[0] = data[1]; 524 ati_remote->old_data[0] = data[1];
514 ati_remote->old_data[1] = data[2]; 525 ati_remote->old_data[1] = data[2];
515 ati_remote->old_jiffies = jiffies; 526 ati_remote->old_jiffies = now;
516 527
528 /* Ensure we skip at least the 4 first duplicate events (generated
529 * by a single keypress), and continue skipping until repeat_delay
530 * msecs have passed
531 */
517 if (ati_remote->repeat_count > 0 && 532 if (ati_remote->repeat_count > 0 &&
518 ati_remote->repeat_count < 5) 533 (ati_remote->repeat_count < 5 ||
534 time_before(now, ati_remote->first_jiffies +
535 msecs_to_jiffies(repeat_delay))))
519 return; 536 return;
520 537
521 538
@@ -653,7 +670,8 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
653 if (ati_remote_tbl[i].type == EV_KEY) 670 if (ati_remote_tbl[i].type == EV_KEY)
654 set_bit(ati_remote_tbl[i].code, idev->keybit); 671 set_bit(ati_remote_tbl[i].code, idev->keybit);
655 672
656 idev->private = ati_remote; 673 input_set_drvdata(idev, ati_remote);
674
657 idev->open = ati_remote_open; 675 idev->open = ati_remote_open;
658 idev->close = ati_remote_close; 676 idev->close = ati_remote_close;
659 677
@@ -661,7 +679,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
661 idev->phys = ati_remote->phys; 679 idev->phys = ati_remote->phys;
662 680
663 usb_to_input_id(ati_remote->udev, &idev->id); 681 usb_to_input_id(ati_remote->udev, &idev->id);
664 idev->cdev.dev = &ati_remote->udev->dev; 682 idev->dev.parent = &ati_remote->udev->dev;
665} 683}
666 684
667static int ati_remote_initialize(struct ati_remote *ati_remote) 685static int ati_remote_initialize(struct ati_remote *ati_remote)
@@ -772,15 +790,17 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de
772 goto fail3; 790 goto fail3;
773 791
774 /* Set up and register input device */ 792 /* Set up and register input device */
775 input_register_device(ati_remote->idev); 793 err = input_register_device(ati_remote->idev);
794 if (err)
795 goto fail3;
776 796
777 usb_set_intfdata(interface, ati_remote); 797 usb_set_intfdata(interface, ati_remote);
778 return 0; 798 return 0;
779 799
780fail3: usb_kill_urb(ati_remote->irq_urb); 800 fail3: usb_kill_urb(ati_remote->irq_urb);
781 usb_kill_urb(ati_remote->out_urb); 801 usb_kill_urb(ati_remote->out_urb);
782fail2: ati_remote_free_buffers(ati_remote); 802 fail2: ati_remote_free_buffers(ati_remote);
783fail1: input_free_device(input_dev); 803 fail1: input_free_device(input_dev);
784 kfree(ati_remote); 804 kfree(ati_remote);
785 return err; 805 return err;
786} 806}
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c
index 6459be90599c..a9032aa3465f 100644
--- a/drivers/usb/input/ati_remote2.c
+++ b/drivers/usb/input/ati_remote2.c
@@ -131,7 +131,7 @@ static struct usb_driver ati_remote2_driver = {
131 131
132static int ati_remote2_open(struct input_dev *idev) 132static int ati_remote2_open(struct input_dev *idev)
133{ 133{
134 struct ati_remote2 *ar2 = idev->private; 134 struct ati_remote2 *ar2 = input_get_drvdata(idev);
135 int r; 135 int r;
136 136
137 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); 137 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL);
@@ -153,7 +153,7 @@ static int ati_remote2_open(struct input_dev *idev)
153 153
154static void ati_remote2_close(struct input_dev *idev) 154static void ati_remote2_close(struct input_dev *idev)
155{ 155{
156 struct ati_remote2 *ar2 = idev->private; 156 struct ati_remote2 *ar2 = input_get_drvdata(idev);
157 157
158 usb_kill_urb(ar2->urb[0]); 158 usb_kill_urb(ar2->urb[0]);
159 usb_kill_urb(ar2->urb[1]); 159 usb_kill_urb(ar2->urb[1]);
@@ -337,14 +337,14 @@ static void ati_remote2_complete_key(struct urb *urb)
337static int ati_remote2_input_init(struct ati_remote2 *ar2) 337static int ati_remote2_input_init(struct ati_remote2 *ar2)
338{ 338{
339 struct input_dev *idev; 339 struct input_dev *idev;
340 int i; 340 int i, retval;
341 341
342 idev = input_allocate_device(); 342 idev = input_allocate_device();
343 if (!idev) 343 if (!idev)
344 return -ENOMEM; 344 return -ENOMEM;
345 345
346 ar2->idev = idev; 346 ar2->idev = idev;
347 idev->private = ar2; 347 input_set_drvdata(idev, ar2);
348 348
349 idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL); 349 idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL);
350 idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); 350 idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
@@ -362,13 +362,13 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
362 idev->phys = ar2->phys; 362 idev->phys = ar2->phys;
363 363
364 usb_to_input_id(ar2->udev, &idev->id); 364 usb_to_input_id(ar2->udev, &idev->id);
365 idev->cdev.dev = &ar2->udev->dev; 365 idev->dev.parent = &ar2->udev->dev;
366 366
367 i = input_register_device(idev); 367 retval = input_register_device(idev);
368 if (i) 368 if (retval)
369 input_free_device(idev); 369 input_free_device(idev);
370 370
371 return i; 371 return retval;
372} 372}
373 373
374static int ati_remote2_urb_init(struct ati_remote2 *ar2) 374static int ati_remote2_urb_init(struct ati_remote2 *ar2)
diff --git a/drivers/usb/input/gtco.c b/drivers/usb/input/gtco.c
index ae756e0afc99..b2ca10f2fe0e 100644
--- a/drivers/usb/input/gtco.c
+++ b/drivers/usb/input/gtco.c
@@ -187,7 +187,6 @@ struct hid_descriptor
187 187
188 188
189/* 189/*
190 *
191 * This is an abbreviated parser for the HID Report Descriptor. We 190 * This is an abbreviated parser for the HID Report Descriptor. We
192 * know what devices we are talking to, so this is by no means meant 191 * know what devices we are talking to, so this is by no means meant
193 * to be generic. We can make some safe assumptions: 192 * to be generic. We can make some safe assumptions:
@@ -204,7 +203,7 @@ struct hid_descriptor
204static void parse_hid_report_descriptor(struct gtco *device, char * report, 203static void parse_hid_report_descriptor(struct gtco *device, char * report,
205 int length) 204 int length)
206{ 205{
207 int x,i=0; 206 int x, i = 0;
208 207
209 /* Tag primitive vars */ 208 /* Tag primitive vars */
210 __u8 prefix; 209 __u8 prefix;
@@ -215,7 +214,6 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
215 __u16 data16 = 0; 214 __u16 data16 = 0;
216 __u32 data32 = 0; 215 __u32 data32 = 0;
217 216
218
219 /* For parsing logic */ 217 /* For parsing logic */
220 int inputnum = 0; 218 int inputnum = 0;
221 __u32 usage = 0; 219 __u32 usage = 0;
@@ -225,46 +223,46 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
225 __u32 oldval[TAG_GLOB_MAX]; 223 __u32 oldval[TAG_GLOB_MAX];
226 224
227 /* Debug stuff */ 225 /* Debug stuff */
228 char maintype='x'; 226 char maintype = 'x';
229 char globtype[12]; 227 char globtype[12];
230 int indent=0; 228 int indent = 0;
231 char indentstr[10]=""; 229 char indentstr[10] = "";
232
233 230
234 231
235 dbg("======>>>>>>PARSE<<<<<<======"); 232 dbg("======>>>>>>PARSE<<<<<<======");
236 233
237 /* Walk this report and pull out the info we need */ 234 /* Walk this report and pull out the info we need */
238 while (i<length){ 235 while (i < length) {
239 prefix=report[i]; 236 prefix = report[i];
240 237
241 /* Skip over prefix */ 238 /* Skip over prefix */
242 i++; 239 i++;
243 240
244 /* Determine data size and save the data in the proper variable */ 241 /* Determine data size and save the data in the proper variable */
245 size = PREF_SIZE(prefix); 242 size = PREF_SIZE(prefix);
246 switch(size){ 243 switch (size) {
247 case 1: 244 case 1:
248 data = report[i]; 245 data = report[i];
249 break; 246 break;
250 case 2: 247 case 2:
251 data16 = le16_to_cpu(get_unaligned((__le16*)(&(report[i])))); 248 data16 = le16_to_cpu(get_unaligned((__le16 *)&report[i]));
252 break; 249 break;
253 case 3: 250 case 3:
254 size = 4; 251 size = 4;
255 data32 = le32_to_cpu(get_unaligned((__le32*)(&(report[i])))); 252 data32 = le32_to_cpu(get_unaligned((__le32 *)&report[i]));
253 break;
256 } 254 }
257 255
258 /* Skip size of data */ 256 /* Skip size of data */
259 i+=size; 257 i += size;
260 258
261 /* What we do depends on the tag type */ 259 /* What we do depends on the tag type */
262 tag = PREF_TAG(prefix); 260 tag = PREF_TAG(prefix);
263 type = PREF_TYPE(prefix); 261 type = PREF_TYPE(prefix);
264 switch(type){ 262 switch (type) {
265 case TYPE_MAIN: 263 case TYPE_MAIN:
266 strcpy(globtype,""); 264 strcpy(globtype, "");
267 switch(tag){ 265 switch (tag) {
268 266
269 case TAG_MAIN_INPUT: 267 case TAG_MAIN_INPUT:
270 /* 268 /*
@@ -274,19 +272,17 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
274 * min/max values 272 * min/max values
275 */ 273 */
276 274
277 maintype='I'; 275 maintype = 'I';
278 if (data==2){ 276 if (data == 2)
279 strcpy(globtype,"Variable"); 277 strcpy(globtype, "Variable");
280 } 278 else if (data == 3)
281 if (data==3){ 279 strcpy(globtype, "Var|Const");
282 strcpy(globtype,"Var|Const");
283 }
284 280
285 dbg("::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits", 281 dbg("::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits",
286 globalval[TAG_GLOB_REPORT_ID],inputnum, 282 globalval[TAG_GLOB_REPORT_ID], inputnum,
287 globalval[TAG_GLOB_LOG_MAX],globalval[TAG_GLOB_LOG_MAX], 283 globalval[TAG_GLOB_LOG_MAX], globalval[TAG_GLOB_LOG_MAX],
288 globalval[TAG_GLOB_LOG_MIN],globalval[TAG_GLOB_LOG_MIN], 284 globalval[TAG_GLOB_LOG_MIN], globalval[TAG_GLOB_LOG_MIN],
289 (globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT])); 285 globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT]);
290 286
291 287
292 /* 288 /*
@@ -295,43 +291,43 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
295 that, we look for everything else by 291 that, we look for everything else by
296 local usage value 292 local usage value
297 */ 293 */
298 switch (inputnum){ 294 switch (inputnum) {
299 case 0: /* X coord */ 295 case 0: /* X coord */
300 dbg("GER: X Usage: 0x%x",usage); 296 dbg("GER: X Usage: 0x%x", usage);
301 if (device->max_X == 0){ 297 if (device->max_X == 0) {
302 device->max_X = globalval[TAG_GLOB_LOG_MAX]; 298 device->max_X = globalval[TAG_GLOB_LOG_MAX];
303 device->min_X = globalval[TAG_GLOB_LOG_MIN]; 299 device->min_X = globalval[TAG_GLOB_LOG_MIN];
304 } 300 }
305
306 break; 301 break;
302
307 case 1: /* Y coord */ 303 case 1: /* Y coord */
308 dbg("GER: Y Usage: 0x%x",usage); 304 dbg("GER: Y Usage: 0x%x", usage);
309 if (device->max_Y == 0){ 305 if (device->max_Y == 0) {
310 device->max_Y = globalval[TAG_GLOB_LOG_MAX]; 306 device->max_Y = globalval[TAG_GLOB_LOG_MAX];
311 device->min_Y = globalval[TAG_GLOB_LOG_MIN]; 307 device->min_Y = globalval[TAG_GLOB_LOG_MIN];
312 } 308 }
313 break; 309 break;
310
314 default: 311 default:
315 /* Tilt X */ 312 /* Tilt X */
316 if (usage == DIGITIZER_USAGE_TILT_X){ 313 if (usage == DIGITIZER_USAGE_TILT_X) {
317 if (device->maxtilt_X == 0){ 314 if (device->maxtilt_X == 0) {
318 device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX]; 315 device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX];
319 device->mintilt_X = globalval[TAG_GLOB_LOG_MIN]; 316 device->mintilt_X = globalval[TAG_GLOB_LOG_MIN];
320 } 317 }
321 } 318 }
322 319
323 /* Tilt Y */ 320 /* Tilt Y */
324 if (usage == DIGITIZER_USAGE_TILT_Y){ 321 if (usage == DIGITIZER_USAGE_TILT_Y) {
325 if (device->maxtilt_Y == 0){ 322 if (device->maxtilt_Y == 0) {
326 device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX]; 323 device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX];
327 device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN]; 324 device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN];
328 } 325 }
329 } 326 }
330 327
331
332 /* Pressure */ 328 /* Pressure */
333 if (usage == DIGITIZER_USAGE_TIP_PRESSURE){ 329 if (usage == DIGITIZER_USAGE_TIP_PRESSURE) {
334 if (device->maxpressure == 0){ 330 if (device->maxpressure == 0) {
335 device->maxpressure = globalval[TAG_GLOB_LOG_MAX]; 331 device->maxpressure = globalval[TAG_GLOB_LOG_MAX];
336 device->minpressure = globalval[TAG_GLOB_LOG_MIN]; 332 device->minpressure = globalval[TAG_GLOB_LOG_MIN];
337 } 333 }
@@ -341,214 +337,226 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
341 } 337 }
342 338
343 inputnum++; 339 inputnum++;
344
345
346 break; 340 break;
341
347 case TAG_MAIN_OUTPUT: 342 case TAG_MAIN_OUTPUT:
348 maintype='O'; 343 maintype = 'O';
349 break; 344 break;
345
350 case TAG_MAIN_FEATURE: 346 case TAG_MAIN_FEATURE:
351 maintype='F'; 347 maintype = 'F';
352 break; 348 break;
349
353 case TAG_MAIN_COL_START: 350 case TAG_MAIN_COL_START:
354 maintype='S'; 351 maintype = 'S';
355 352
356 if (data==0){ 353 if (data == 0) {
357 dbg("======>>>>>> Physical"); 354 dbg("======>>>>>> Physical");
358 strcpy(globtype,"Physical"); 355 strcpy(globtype, "Physical");
359 }else{ 356 } else
360 dbg("======>>>>>>"); 357 dbg("======>>>>>>");
361 }
362 358
363 /* Indent the debug output */ 359 /* Indent the debug output */
364 indent++; 360 indent++;
365 for (x=0;x<indent;x++){ 361 for (x = 0; x < indent; x++)
366 indentstr[x]='-'; 362 indentstr[x] = '-';
367 } 363 indentstr[x] = 0;
368 indentstr[x]=0;
369 364
370 /* Save global tags */ 365 /* Save global tags */
371 for (x=0;x<TAG_GLOB_MAX;x++){ 366 for (x = 0; x < TAG_GLOB_MAX; x++)
372 oldval[x] = globalval[x]; 367 oldval[x] = globalval[x];
373 }
374 368
375 break; 369 break;
370
376 case TAG_MAIN_COL_END: 371 case TAG_MAIN_COL_END:
377 dbg("<<<<<<======"); 372 dbg("<<<<<<======");
378 maintype='E'; 373 maintype = 'E';
379 indent--; 374 indent--;
380 for (x=0;x<indent;x++){ 375 for (x = 0; x < indent; x++)
381 indentstr[x]='-'; 376 indentstr[x] = '-';
382 } 377 indentstr[x] = 0;
383 indentstr[x]=0;
384 378
385 /* Copy global tags back */ 379 /* Copy global tags back */
386 for (x=0;x<TAG_GLOB_MAX;x++){ 380 for (x = 0; x < TAG_GLOB_MAX; x++)
387 globalval[x] = oldval[x]; 381 globalval[x] = oldval[x];
388 }
389 382
390 break; 383 break;
391 } 384 }
392 385
393 switch (size){ 386 switch (size) {
394 case 1: 387 case 1:
395 dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", 388 dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x",
396 indentstr,tag,maintype,size,globtype,data); 389 indentstr, tag, maintype, size, globtype, data);
397 break; 390 break;
391
398 case 2: 392 case 2:
399 dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", 393 dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x",
400 indentstr,tag,maintype,size,globtype, data16); 394 indentstr, tag, maintype, size, globtype, data16);
401 break; 395 break;
396
402 case 4: 397 case 4:
403 dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", 398 dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x",
404 indentstr,tag,maintype,size,globtype,data32); 399 indentstr, tag, maintype, size, globtype, data32);
405 break; 400 break;
406 } 401 }
407 break; 402 break;
403
408 case TYPE_GLOBAL: 404 case TYPE_GLOBAL:
409 switch(tag){ 405 switch (tag) {
410 case TAG_GLOB_USAGE: 406 case TAG_GLOB_USAGE:
411 /* 407 /*
412 * First time we hit the global usage tag, 408 * First time we hit the global usage tag,
413 * it should tell us the type of device 409 * it should tell us the type of device
414 */ 410 */
415 if (device->usage == 0){ 411 if (device->usage == 0)
416 device->usage = data; 412 device->usage = data;
417 } 413
418 strcpy(globtype,"USAGE"); 414 strcpy(globtype, "USAGE");
419 break; 415 break;
420 case TAG_GLOB_LOG_MIN : 416
421 strcpy(globtype,"LOG_MIN"); 417 case TAG_GLOB_LOG_MIN:
418 strcpy(globtype, "LOG_MIN");
422 break; 419 break;
423 case TAG_GLOB_LOG_MAX : 420
424 strcpy(globtype,"LOG_MAX"); 421 case TAG_GLOB_LOG_MAX:
422 strcpy(globtype, "LOG_MAX");
425 break; 423 break;
426 case TAG_GLOB_PHYS_MIN : 424
427 strcpy(globtype,"PHYS_MIN"); 425 case TAG_GLOB_PHYS_MIN:
426 strcpy(globtype, "PHYS_MIN");
428 break; 427 break;
429 case TAG_GLOB_PHYS_MAX : 428
430 strcpy(globtype,"PHYS_MAX"); 429 case TAG_GLOB_PHYS_MAX:
430 strcpy(globtype, "PHYS_MAX");
431 break; 431 break;
432 case TAG_GLOB_UNIT_EXP : 432
433 strcpy(globtype,"EXP"); 433 case TAG_GLOB_UNIT_EXP:
434 strcpy(globtype, "EXP");
434 break; 435 break;
435 case TAG_GLOB_UNIT : 436
436 strcpy(globtype,"UNIT"); 437 case TAG_GLOB_UNIT:
438 strcpy(globtype, "UNIT");
437 break; 439 break;
438 case TAG_GLOB_REPORT_SZ : 440
439 strcpy(globtype,"REPORT_SZ"); 441 case TAG_GLOB_REPORT_SZ:
442 strcpy(globtype, "REPORT_SZ");
440 break; 443 break;
441 case TAG_GLOB_REPORT_ID : 444
442 strcpy(globtype,"REPORT_ID"); 445 case TAG_GLOB_REPORT_ID:
446 strcpy(globtype, "REPORT_ID");
443 /* New report, restart numbering */ 447 /* New report, restart numbering */
444 inputnum=0; 448 inputnum = 0;
445 break; 449 break;
450
446 case TAG_GLOB_REPORT_CNT: 451 case TAG_GLOB_REPORT_CNT:
447 strcpy(globtype,"REPORT_CNT"); 452 strcpy(globtype, "REPORT_CNT");
448 break; 453 break;
449 case TAG_GLOB_PUSH : 454
450 strcpy(globtype,"PUSH"); 455 case TAG_GLOB_PUSH:
456 strcpy(globtype, "PUSH");
451 break; 457 break;
458
452 case TAG_GLOB_POP: 459 case TAG_GLOB_POP:
453 strcpy(globtype,"POP"); 460 strcpy(globtype, "POP");
454 break; 461 break;
455 } 462 }
456 463
457
458 /* Check to make sure we have a good tag number 464 /* Check to make sure we have a good tag number
459 so we don't overflow array */ 465 so we don't overflow array */
460 if (tag < TAG_GLOB_MAX){ 466 if (tag < TAG_GLOB_MAX) {
461 switch (size){ 467 switch (size) {
462 case 1: 468 case 1:
463 dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data); 469 dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",
464 globalval[tag]=data; 470 indentstr, globtype, tag, size, data);
471 globalval[tag] = data;
465 break; 472 break;
473
466 case 2: 474 case 2:
467 dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data16); 475 dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",
468 globalval[tag]=data16; 476 indentstr, globtype, tag, size, data16);
477 globalval[tag] = data16;
469 break; 478 break;
479
470 case 4: 480 case 4:
471 dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data32); 481 dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",
472 globalval[tag]=data32; 482 indentstr, globtype, tag, size, data32);
483 globalval[tag] = data32;
473 break; 484 break;
474 } 485 }
475 }else{ 486 } else {
476 dbg("%sGLOBALTAG: ILLEGAL TAG:%d SIZE: %d ", 487 dbg("%sGLOBALTAG: ILLEGAL TAG:%d SIZE: %d ",
477 indentstr,tag,size); 488 indentstr, tag, size);
478 } 489 }
479
480
481 break; 490 break;
482 491
483 case TYPE_LOCAL: 492 case TYPE_LOCAL:
484 switch(tag){ 493 switch (tag) {
485 case TAG_GLOB_USAGE: 494 case TAG_GLOB_USAGE:
486 strcpy(globtype,"USAGE"); 495 strcpy(globtype, "USAGE");
487 /* Always 1 byte */ 496 /* Always 1 byte */
488 usage = data; 497 usage = data;
489 break; 498 break;
490 case TAG_GLOB_LOG_MIN : 499
491 strcpy(globtype,"MIN"); 500 case TAG_GLOB_LOG_MIN:
501 strcpy(globtype, "MIN");
492 break; 502 break;
493 case TAG_GLOB_LOG_MAX : 503
494 strcpy(globtype,"MAX"); 504 case TAG_GLOB_LOG_MAX:
505 strcpy(globtype, "MAX");
495 break; 506 break;
507
496 default: 508 default:
497 strcpy(globtype,"UNKNOWN"); 509 strcpy(globtype, "UNKNOWN");
510 break;
498 } 511 }
499 512
500 switch (size){ 513 switch (size) {
501 case 1: 514 case 1:
502 dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", 515 dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x",
503 indentstr,tag,globtype,size,data); 516 indentstr, tag, globtype, size, data);
504 break; 517 break;
518
505 case 2: 519 case 2:
506 dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", 520 dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x",
507 indentstr,tag,globtype,size,data16); 521 indentstr, tag, globtype, size, data16);
508 break; 522 break;
523
509 case 4: 524 case 4:
510 dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", 525 dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x",
511 indentstr,tag,globtype,size,data32); 526 indentstr, tag, globtype, size, data32);
512 break; 527 break;
513 } 528 }
514 529
515 break; 530 break;
516 } 531 }
517
518 } 532 }
519
520} 533}
521 534
522
523
524/* INPUT DRIVER Routines */ 535/* INPUT DRIVER Routines */
525 536
526
527/* 537/*
528 * Called when opening the input device. This will submit the URB to 538 * Called when opening the input device. This will submit the URB to
529 * the usb system so we start getting reports 539 * the usb system so we start getting reports
530 */ 540 */
531static int gtco_input_open(struct input_dev *inputdev) 541static int gtco_input_open(struct input_dev *inputdev)
532{ 542{
533 struct gtco *device; 543 struct gtco *device = input_get_drvdata(inputdev);
534 device = inputdev->private;
535 544
536 device->urbinfo->dev = device->usbdev; 545 device->urbinfo->dev = device->usbdev;
537 if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) { 546 if (usb_submit_urb(device->urbinfo, GFP_KERNEL))
538 return -EIO; 547 return -EIO;
539 } 548
540 return 0; 549 return 0;
541} 550}
542 551
543/** 552/*
544 Called when closing the input device. This will unlink the URB 553 * Called when closing the input device. This will unlink the URB
545*/ 554 */
546static void gtco_input_close(struct input_dev *inputdev) 555static void gtco_input_close(struct input_dev *inputdev)
547{ 556{
548 struct gtco *device = inputdev->private; 557 struct gtco *device = input_get_drvdata(inputdev);
549 558
550 usb_kill_urb(device->urbinfo); 559 usb_kill_urb(device->urbinfo);
551
552} 560}
553 561
554 562
@@ -560,19 +568,16 @@ static void gtco_input_close(struct input_dev *inputdev)
560 * placed in the struct gtco structure 568 * placed in the struct gtco structure
561 * 569 *
562 */ 570 */
563static void gtco_setup_caps(struct input_dev *inputdev) 571static void gtco_setup_caps(struct input_dev *inputdev)
564{ 572{
565 struct gtco *device = inputdev->private; 573 struct gtco *device = input_get_drvdata(inputdev);
566
567 574
568 /* Which events */ 575 /* Which events */
569 inputdev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); 576 inputdev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC);
570 577
571
572 /* Misc event menu block */ 578 /* Misc event menu block */
573 inputdev->mscbit[0] = BIT(MSC_SCAN)|BIT(MSC_SERIAL)|BIT(MSC_RAW) ; 579 inputdev->mscbit[0] = BIT(MSC_SCAN)|BIT(MSC_SERIAL)|BIT(MSC_RAW) ;
574 580
575
576 /* Absolute values based on HID report info */ 581 /* Absolute values based on HID report info */
577 input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, 582 input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X,
578 0, 0); 583 0, 0);
@@ -590,17 +595,12 @@ static void gtco_setup_caps(struct input_dev *inputdev)
590 input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure, 595 input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure,
591 device->maxpressure, 0, 0); 596 device->maxpressure, 0, 0);
592 597
593
594 /* Transducer */ 598 /* Transducer */
595 input_set_abs_params(inputdev, ABS_MISC, 0,0xFF, 0, 0); 599 input_set_abs_params(inputdev, ABS_MISC, 0, 0xFF, 0, 0);
596
597} 600}
598 601
599
600
601/* USB Routines */ 602/* USB Routines */
602 603
603
604/* 604/*
605 * URB callback routine. Called when we get IRQ reports from the 605 * URB callback routine. Called when we get IRQ reports from the
606 * digitizer. 606 * digitizer.
@@ -610,9 +610,7 @@ static void gtco_setup_caps(struct input_dev *inputdev)
610 */ 610 */
611static void gtco_urb_callback(struct urb *urbinfo) 611static void gtco_urb_callback(struct urb *urbinfo)
612{ 612{
613 613 struct gtco *device = urbinfo->context;
614
615 struct gtco *device = urbinfo->context;
616 struct input_dev *inputdev; 614 struct input_dev *inputdev;
617 int rc; 615 int rc;
618 u32 val = 0; 616 u32 val = 0;
@@ -621,19 +619,20 @@ static void gtco_urb_callback(struct urb *urbinfo)
621 619
622 inputdev = device->inputdevice; 620 inputdev = device->inputdevice;
623 621
624
625 /* Was callback OK? */ 622 /* Was callback OK? */
626 if ((urbinfo->status == -ECONNRESET ) || 623 if (urbinfo->status == -ECONNRESET ||
627 (urbinfo->status == -ENOENT ) || 624 urbinfo->status == -ENOENT ||
628 (urbinfo->status == -ESHUTDOWN )){ 625 urbinfo->status == -ESHUTDOWN) {
629 626
630 /* Shutdown is occurring. Return and don't queue up any more */ 627 /* Shutdown is occurring. Return and don't queue up any more */
631 return; 628 return;
632 } 629 }
633 630
634 if (urbinfo->status != 0 ) { 631 if (urbinfo->status != 0) {
635 /* Some unknown error. Hopefully temporary. Just go and */ 632 /*
636 /* requeue an URB */ 633 * Some unknown error. Hopefully temporary. Just go and
634 * requeue an URB
635 */
637 goto resubmit; 636 goto resubmit;
638 } 637 }
639 638
@@ -642,10 +641,9 @@ static void gtco_urb_callback(struct urb *urbinfo)
642 */ 641 */
643 642
644 /* PID dependent when we interpret the report */ 643 /* PID dependent when we interpret the report */
645 if ((inputdev->id.product == PID_1000 )|| 644 if (inputdev->id.product == PID_1000 ||
646 (inputdev->id.product == PID_1001 )|| 645 inputdev->id.product == PID_1001 ||
647 (inputdev->id.product == PID_1002 )) 646 inputdev->id.product == PID_1002) {
648 {
649 647
650 /* 648 /*
651 * Switch on the report ID 649 * Switch on the report ID
@@ -653,10 +651,10 @@ static void gtco_urb_callback(struct urb *urbinfo)
653 * the report number. We can just fall through the case 651 * the report number. We can just fall through the case
654 * statements if we start with the highest number report 652 * statements if we start with the highest number report
655 */ 653 */
656 switch(device->buffer[0]){ 654 switch (device->buffer[0]) {
657 case 5: 655 case 5:
658 /* Pressure is 9 bits */ 656 /* Pressure is 9 bits */
659 val = ((u16)(device->buffer[8]) << 1); 657 val = ((u16)(device->buffer[8]) << 1);
660 val |= (u16)(device->buffer[7] >> 7); 658 val |= (u16)(device->buffer[7] >> 7);
661 input_report_abs(inputdev, ABS_PRESSURE, 659 input_report_abs(inputdev, ABS_PRESSURE,
662 device->buffer[8]); 660 device->buffer[8]);
@@ -664,7 +662,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
664 /* Mask out the Y tilt value used for pressure */ 662 /* Mask out the Y tilt value used for pressure */
665 device->buffer[7] = (u8)((device->buffer[7]) & 0x7F); 663 device->buffer[7] = (u8)((device->buffer[7]) & 0x7F);
666 664
667
668 /* Fall thru */ 665 /* Fall thru */
669 case 4: 666 case 4:
670 /* Tilt */ 667 /* Tilt */
@@ -684,11 +681,10 @@ static void gtco_urb_callback(struct urb *urbinfo)
684 input_report_abs(inputdev, ABS_TILT_Y, (s32)valsigned); 681 input_report_abs(inputdev, ABS_TILT_Y, (s32)valsigned);
685 682
686 /* Fall thru */ 683 /* Fall thru */
687
688 case 2: 684 case 2:
689 case 3: 685 case 3:
690 /* Convert buttons, only 5 bits possible */ 686 /* Convert buttons, only 5 bits possible */
691 val = (device->buffer[5])&MASK_BUTTON; 687 val = (device->buffer[5]) & MASK_BUTTON;
692 688
693 /* We don't apply any meaning to the bitmask, 689 /* We don't apply any meaning to the bitmask,
694 just report */ 690 just report */
@@ -696,132 +692,109 @@ static void gtco_urb_callback(struct urb *urbinfo)
696 692
697 /* Fall thru */ 693 /* Fall thru */
698 case 1: 694 case 1:
699
700 /* All reports have X and Y coords in the same place */ 695 /* All reports have X and Y coords in the same place */
701 val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[1]))); 696 val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1]));
702 input_report_abs(inputdev, ABS_X, val); 697 input_report_abs(inputdev, ABS_X, val);
703 698
704 val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[3]))); 699 val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3]));
705 input_report_abs(inputdev, ABS_Y, val); 700 input_report_abs(inputdev, ABS_Y, val);
706 701
707
708 /* Ditto for proximity bit */ 702 /* Ditto for proximity bit */
709 if (device->buffer[5]& MASK_INRANGE){ 703 val = device->buffer[5] & MASK_INRANGE ? 1 : 0;
710 val = 1;
711 }else{
712 val=0;
713 }
714 input_report_abs(inputdev, ABS_DISTANCE, val); 704 input_report_abs(inputdev, ABS_DISTANCE, val);
715 705
716
717 /* Report 1 is an exception to how we handle buttons */ 706 /* Report 1 is an exception to how we handle buttons */
718 /* Buttons are an index, not a bitmask */ 707 /* Buttons are an index, not a bitmask */
719 if (device->buffer[0] == 1){ 708 if (device->buffer[0] == 1) {
720 709
721 /* Convert buttons, 5 bit index */ 710 /*
722 /* Report value of index set as one, 711 * Convert buttons, 5 bit index
723 the rest as 0 */ 712 * Report value of index set as one,
724 val = device->buffer[5]& MASK_BUTTON; 713 * the rest as 0
714 */
715 val = device->buffer[5] & MASK_BUTTON;
725 dbg("======>>>>>>REPORT 1: val 0x%X(%d)", 716 dbg("======>>>>>>REPORT 1: val 0x%X(%d)",
726 val,val); 717 val, val);
727 718
728 /* 719 /*
729 * We don't apply any meaning to the button 720 * We don't apply any meaning to the button
730 * index, just report it 721 * index, just report it
731 */ 722 */
732 input_event(inputdev, EV_MSC, MSC_SERIAL, val); 723 input_event(inputdev, EV_MSC, MSC_SERIAL, val);
733
734
735 } 724 }
736
737 break; 725 break;
726
738 case 7: 727 case 7:
739 /* Menu blocks */ 728 /* Menu blocks */
740 input_event(inputdev, EV_MSC, MSC_SCAN, 729 input_event(inputdev, EV_MSC, MSC_SCAN,
741 device->buffer[1]); 730 device->buffer[1]);
742
743
744 break; 731 break;
745
746 } 732 }
747
748
749 } 733 }
734
750 /* Other pid class */ 735 /* Other pid class */
751 if ((inputdev->id.product == PID_400 )|| 736 if (inputdev->id.product == PID_400 ||
752 (inputdev->id.product == PID_401 )) 737 inputdev->id.product == PID_401) {
753 {
754 738
755 /* Report 2 */ 739 /* Report 2 */
756 if (device->buffer[0] == 2){ 740 if (device->buffer[0] == 2) {
757 /* Menu blocks */ 741 /* Menu blocks */
758 input_event(inputdev, EV_MSC, MSC_SCAN, 742 input_event(inputdev, EV_MSC, MSC_SCAN, device->buffer[1]);
759 device->buffer[1]);
760 } 743 }
761 744
762 /* Report 1 */ 745 /* Report 1 */
763 if (device->buffer[0] == 1){ 746 if (device->buffer[0] == 1) {
764 char buttonbyte; 747 char buttonbyte;
765 748
766
767 /* IF X max > 64K, we still a bit from the y report */ 749 /* IF X max > 64K, we still a bit from the y report */
768 if (device->max_X > 0x10000){ 750 if (device->max_X > 0x10000) {
769 751
770 val = (u16)(((u16)(device->buffer[2]<<8))|((u8)(device->buffer[1]))); 752 val = (u16)(((u16)(device->buffer[2] << 8)) | (u8)device->buffer[1]);
771 val |= (u32)(((u8)device->buffer[3]&0x1)<< 16); 753 val |= (u32)(((u8)device->buffer[3] & 0x1) << 16);
772 754
773 input_report_abs(inputdev, ABS_X, val); 755 input_report_abs(inputdev, ABS_X, val);
774 756
775 le_buffer[0] = (u8)((u8)(device->buffer[3])>>1); 757 le_buffer[0] = (u8)((u8)(device->buffer[3]) >> 1);
776 le_buffer[0] |= (u8)((device->buffer[3]&0x1)<<7); 758 le_buffer[0] |= (u8)((device->buffer[3] & 0x1) << 7);
777
778 le_buffer[1] = (u8)(device->buffer[4]>>1);
779 le_buffer[1] |= (u8)((device->buffer[5]&0x1)<<7);
780 759
781 val = le16_to_cpu(get_unaligned((__le16 *)(le_buffer))); 760 le_buffer[1] = (u8)(device->buffer[4] >> 1);
761 le_buffer[1] |= (u8)((device->buffer[5] & 0x1) << 7);
782 762
763 val = le16_to_cpu(get_unaligned((__le16 *)le_buffer));
783 input_report_abs(inputdev, ABS_Y, val); 764 input_report_abs(inputdev, ABS_Y, val);
784 765
785
786 /* 766 /*
787 * Shift the button byte right by one to 767 * Shift the button byte right by one to
788 * make it look like the standard report 768 * make it look like the standard report
789 */ 769 */
790 buttonbyte = (device->buffer[5])>>1; 770 buttonbyte = device->buffer[5] >> 1;
791 }else{ 771 } else {
792 772
793 val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[1])))); 773 val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1]));
794 input_report_abs(inputdev, ABS_X, val); 774 input_report_abs(inputdev, ABS_X, val);
795 775
796 val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[3])))); 776 val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3]));
797 input_report_abs(inputdev, ABS_Y, val); 777 input_report_abs(inputdev, ABS_Y, val);
798 778
799 buttonbyte = device->buffer[5]; 779 buttonbyte = device->buffer[5];
800
801 } 780 }
802 781
803
804 /* BUTTONS and PROXIMITY */ 782 /* BUTTONS and PROXIMITY */
805 if (buttonbyte& MASK_INRANGE){ 783 val = buttonbyte & MASK_INRANGE ? 1 : 0;
806 val = 1;
807 }else{
808 val=0;
809 }
810 input_report_abs(inputdev, ABS_DISTANCE, val); 784 input_report_abs(inputdev, ABS_DISTANCE, val);
811 785
812 /* Convert buttons, only 4 bits possible */ 786 /* Convert buttons, only 4 bits possible */
813 val = buttonbyte&0x0F; 787 val = buttonbyte & 0x0F;
814#ifdef USE_BUTTONS 788#ifdef USE_BUTTONS
815 for ( i=0;i<5;i++){ 789 for (i = 0; i < 5; i++)
816 input_report_key(inputdev, BTN_DIGI+i,val&(1<<i)); 790 input_report_key(inputdev, BTN_DIGI + i, val & (1 << i));
817 }
818#else 791#else
819 /* We don't apply any meaning to the bitmask, just report */ 792 /* We don't apply any meaning to the bitmask, just report */
820 input_event(inputdev, EV_MSC, MSC_SERIAL, val); 793 input_event(inputdev, EV_MSC, MSC_SERIAL, val);
821#endif 794#endif
795
822 /* TRANSDUCER */ 796 /* TRANSDUCER */
823 input_report_abs(inputdev, ABS_MISC, device->buffer[6]); 797 input_report_abs(inputdev, ABS_MISC, device->buffer[6]);
824
825 } 798 }
826 } 799 }
827 800
@@ -833,10 +806,8 @@ static void gtco_urb_callback(struct urb *urbinfo)
833 806
834 resubmit: 807 resubmit:
835 rc = usb_submit_urb(urbinfo, GFP_ATOMIC); 808 rc = usb_submit_urb(urbinfo, GFP_ATOMIC);
836 if (rc != 0) { 809 if (rc != 0)
837 err("usb_submit_urb failed rc=0x%x",rc); 810 err("usb_submit_urb failed rc=0x%x", rc);
838 }
839
840} 811}
841 812
842/* 813/*
@@ -854,58 +825,46 @@ static int gtco_probe(struct usb_interface *usbinterface,
854 const struct usb_device_id *id) 825 const struct usb_device_id *id)
855{ 826{
856 827
857 struct gtco *device = NULL; 828 struct gtco *gtco;
858 char path[PATHLENGTH]; 829 struct input_dev *input_dev;
859 struct input_dev *inputdev;
860 struct hid_descriptor *hid_desc; 830 struct hid_descriptor *hid_desc;
861 char *report; 831 char *report = NULL;
862 int result=0, retry; 832 int result = 0, retry;
833 int error;
863 struct usb_endpoint_descriptor *endpoint; 834 struct usb_endpoint_descriptor *endpoint;
864 835
865 /* Allocate memory for device structure */ 836 /* Allocate memory for device structure */
866 device = kzalloc(sizeof(struct gtco), GFP_KERNEL); 837 gtco = kzalloc(sizeof(struct gtco), GFP_KERNEL);
867 if (device == NULL) { 838 input_dev = input_allocate_device();
839 if (!gtco || !input_dev) {
868 err("No more memory"); 840 err("No more memory");
869 return -ENOMEM; 841 error = -ENOMEM;
842 goto err_free_devs;
870 } 843 }
871 844
872 845 /* Set pointer to the input device */
873 device->inputdevice = input_allocate_device(); 846 gtco->inputdevice = input_dev;
874 if (!device->inputdevice){
875 kfree(device);
876 err("No more memory");
877 return -ENOMEM;
878 }
879
880 /* Get pointer to the input device */
881 inputdev = device->inputdevice;
882 847
883 /* Save interface information */ 848 /* Save interface information */
884 device->usbdev = usb_get_dev(interface_to_usbdev(usbinterface)); 849 gtco->usbdev = usb_get_dev(interface_to_usbdev(usbinterface));
885
886 850
887 /* Allocate some data for incoming reports */ 851 /* Allocate some data for incoming reports */
888 device->buffer = usb_buffer_alloc(device->usbdev, REPORT_MAX_SIZE, 852 gtco->buffer = usb_buffer_alloc(gtco->usbdev, REPORT_MAX_SIZE,
889 GFP_KERNEL, &(device->buf_dma)); 853 GFP_KERNEL, &gtco->buf_dma);
890 if (!device->buffer){ 854 if (!gtco->buffer) {
891 input_free_device(device->inputdevice); 855 err("No more memory for us buffers");
892 kfree(device); 856 error = -ENOMEM;
893 err("No more memory"); 857 goto err_free_devs;
894 return -ENOMEM;
895 } 858 }
896 859
897 /* Allocate URB for reports */ 860 /* Allocate URB for reports */
898 device->urbinfo = usb_alloc_urb(0, GFP_KERNEL); 861 gtco->urbinfo = usb_alloc_urb(0, GFP_KERNEL);
899 if (!device->urbinfo) { 862 if (!gtco->urbinfo) {
900 usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, 863 err("Failed to allocate URB");
901 device->buffer, device->buf_dma);
902 input_free_device(device->inputdevice);
903 kfree(device);
904 err("No more memory");
905 return -ENOMEM; 864 return -ENOMEM;
865 goto err_free_buf;
906 } 866 }
907 867
908
909 /* 868 /*
910 * The endpoint is always altsetting 0, we know this since we know 869 * The endpoint is always altsetting 0, we know this since we know
911 * this device only has one interrupt endpoint 870 * this device only has one interrupt endpoint
@@ -913,51 +872,43 @@ static int gtco_probe(struct usb_interface *usbinterface,
913 endpoint = &usbinterface->altsetting[0].endpoint[0].desc; 872 endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
914 873
915 /* Some debug */ 874 /* Some debug */
916 dbg("gtco # interfaces: %d",usbinterface->num_altsetting); 875 dbg("gtco # interfaces: %d", usbinterface->num_altsetting);
917 dbg("num endpoints: %d",usbinterface->cur_altsetting->desc.bNumEndpoints); 876 dbg("num endpoints: %d", usbinterface->cur_altsetting->desc.bNumEndpoints);
918 dbg("interface class: %d",usbinterface->cur_altsetting->desc.bInterfaceClass); 877 dbg("interface class: %d", usbinterface->cur_altsetting->desc.bInterfaceClass);
919 dbg("endpoint: attribute:0x%x type:0x%x",endpoint->bmAttributes,endpoint->bDescriptorType); 878 dbg("endpoint: attribute:0x%x type:0x%x", endpoint->bmAttributes, endpoint->bDescriptorType);
920 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) 879 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)
921 dbg("endpoint: we have interrupt endpoint\n"); 880 dbg("endpoint: we have interrupt endpoint\n");
922 881
923 dbg("endpoint extra len:%d ",usbinterface->altsetting[0].extralen); 882 dbg("endpoint extra len:%d ", usbinterface->altsetting[0].extralen);
924
925
926 883
927 /* 884 /*
928 * Find the HID descriptor so we can find out the size of the 885 * Find the HID descriptor so we can find out the size of the
929 * HID report descriptor 886 * HID report descriptor
930 */ 887 */
931 if (usb_get_extra_descriptor(usbinterface->cur_altsetting, 888 if (usb_get_extra_descriptor(usbinterface->cur_altsetting,
932 HID_DEVICE_TYPE,&hid_desc) != 0){ 889 HID_DEVICE_TYPE, &hid_desc) != 0){
933 err("Can't retrieve exta USB descriptor to get hid report descriptor length"); 890 err("Can't retrieve exta USB descriptor to get hid report descriptor length");
934 usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, 891 error = -EIO;
935 device->buffer, device->buf_dma); 892 goto err_free_urb;
936 input_free_device(device->inputdevice);
937 kfree(device);
938 return -EIO;
939 } 893 }
940 894
941 dbg("Extra descriptor success: type:%d len:%d", 895 dbg("Extra descriptor success: type:%d len:%d",
942 hid_desc->bDescriptorType, hid_desc->wDescriptorLength); 896 hid_desc->bDescriptorType, hid_desc->wDescriptorLength);
943 897
944 if (!(report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL))) { 898 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
945 usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, 899 if (!report) {
946 device->buffer, device->buf_dma); 900 err("No more memory for report");
947 901 error = -ENOMEM;
948 input_free_device(device->inputdevice); 902 goto err_free_urb;
949 kfree(device);
950 err("No more memory");
951 return -ENOMEM;
952 } 903 }
953 904
954 /* Couple of tries to get reply */ 905 /* Couple of tries to get reply */
955 for (retry=0;retry<3;retry++) { 906 for (retry = 0; retry < 3; retry++) {
956 result = usb_control_msg(device->usbdev, 907 result = usb_control_msg(gtco->usbdev,
957 usb_rcvctrlpipe(device->usbdev, 0), 908 usb_rcvctrlpipe(gtco->usbdev, 0),
958 USB_REQ_GET_DESCRIPTOR, 909 USB_REQ_GET_DESCRIPTOR,
959 USB_RECIP_INTERFACE | USB_DIR_IN, 910 USB_RECIP_INTERFACE | USB_DIR_IN,
960 (REPORT_DEVICE_TYPE << 8), 911 REPORT_DEVICE_TYPE << 8,
961 0, /* interface */ 912 0, /* interface */
962 report, 913 report,
963 hid_desc->wDescriptorLength, 914 hid_desc->wDescriptorLength,
@@ -969,72 +920,76 @@ static int gtco_probe(struct usb_interface *usbinterface,
969 920
970 /* If we didn't get the report, fail */ 921 /* If we didn't get the report, fail */
971 dbg("usb_control_msg result: :%d", result); 922 dbg("usb_control_msg result: :%d", result);
972 if (result != hid_desc->wDescriptorLength){ 923 if (result != hid_desc->wDescriptorLength) {
973 kfree(report);
974 usb_buffer_free(device->usbdev, REPORT_MAX_SIZE,
975 device->buffer, device->buf_dma);
976 input_free_device(device->inputdevice);
977 kfree(device);
978 err("Failed to get HID Report Descriptor of size: %d", 924 err("Failed to get HID Report Descriptor of size: %d",
979 hid_desc->wDescriptorLength); 925 hid_desc->wDescriptorLength);
980 return -EIO; 926 error = -EIO;
927 goto err_free_urb;
981 } 928 }
982 929
983
984 /* Now we parse the report */ 930 /* Now we parse the report */
985 parse_hid_report_descriptor(device,report,result); 931 parse_hid_report_descriptor(gtco, report, result);
986 932
987 /* Now we delete it */ 933 /* Now we delete it */
988 kfree(report); 934 kfree(report);
989 935
990 /* Create a device file node */ 936 /* Create a device file node */
991 usb_make_path(device->usbdev, path, PATHLENGTH); 937 usb_make_path(gtco->usbdev, gtco->usbpath, sizeof(gtco->usbpath));
992 sprintf(device->usbpath, "%s/input0", path); 938 strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath));
993
994 939
995 /* Set Input device functions */ 940 /* Set Input device functions */
996 inputdev->open = gtco_input_open; 941 input_dev->open = gtco_input_open;
997 inputdev->close = gtco_input_close; 942 input_dev->close = gtco_input_close;
998 943
999 /* Set input device information */ 944 /* Set input device information */
1000 inputdev->name = "GTCO_CalComp"; 945 input_dev->name = "GTCO_CalComp";
1001 inputdev->phys = device->usbpath; 946 input_dev->phys = gtco->usbpath;
1002 inputdev->private = device;
1003 947
948 input_set_drvdata(input_dev, gtco);
1004 949
1005 /* Now set up all the input device capabilities */ 950 /* Now set up all the input device capabilities */
1006 gtco_setup_caps(inputdev); 951 gtco_setup_caps(input_dev);
1007 952
1008 /* Set input device required ID information */ 953 /* Set input device required ID information */
1009 usb_to_input_id(device->usbdev, &device->inputdevice->id); 954 usb_to_input_id(gtco->usbdev, &input_dev->id);
1010 inputdev->cdev.dev = &usbinterface->dev; 955 input_dev->dev.parent = &usbinterface->dev;
1011 956
1012 /* Setup the URB, it will be posted later on open of input device */ 957 /* Setup the URB, it will be posted later on open of input device */
1013 endpoint = &usbinterface->altsetting[0].endpoint[0].desc; 958 endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
1014 959
1015 usb_fill_int_urb(device->urbinfo, 960 usb_fill_int_urb(gtco->urbinfo,
1016 device->usbdev, 961 gtco->usbdev,
1017 usb_rcvintpipe(device->usbdev, 962 usb_rcvintpipe(gtco->usbdev,
1018 endpoint->bEndpointAddress), 963 endpoint->bEndpointAddress),
1019 device->buffer, 964 gtco->buffer,
1020 REPORT_MAX_SIZE, 965 REPORT_MAX_SIZE,
1021 gtco_urb_callback, 966 gtco_urb_callback,
1022 device, 967 gtco,
1023 endpoint->bInterval); 968 endpoint->bInterval);
1024 969
1025 device->urbinfo->transfer_dma = device->buf_dma; 970 gtco->urbinfo->transfer_dma = gtco->buf_dma;
1026 device->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 971 gtco->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1027
1028 972
1029 /* Save device pointer in USB interface device */ 973 /* Save gtco pointer in USB interface gtco */
1030 usb_set_intfdata(usbinterface, device); 974 usb_set_intfdata(usbinterface, gtco);
1031 975
1032 /* All done, now register the input device */ 976 /* All done, now register the input device */
1033 input_register_device(inputdev); 977 error = input_register_device(input_dev);
978 if (error)
979 goto err_free_urb;
1034 980
1035 info( "gtco driver created usb: %s\n", path);
1036 return 0; 981 return 0;
1037 982
983 err_free_urb:
984 usb_free_urb(gtco->urbinfo);
985 err_free_buf:
986 usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE,
987 gtco->buffer, gtco->buf_dma);
988 err_free_devs:
989 kfree(report);
990 input_free_device(input_dev);
991 kfree(gtco);
992 return error;
1038} 993}
1039 994
1040/* 995/*
@@ -1044,47 +999,46 @@ static int gtco_probe(struct usb_interface *usbinterface,
1044 */ 999 */
1045static void gtco_disconnect(struct usb_interface *interface) 1000static void gtco_disconnect(struct usb_interface *interface)
1046{ 1001{
1047
1048 /* Grab private device ptr */ 1002 /* Grab private device ptr */
1049 struct gtco *device = usb_get_intfdata (interface); 1003 struct gtco *gtco = usb_get_intfdata(interface);
1050 1004
1051 /* Now reverse all the registration stuff */ 1005 /* Now reverse all the registration stuff */
1052 if (device) { 1006 if (gtco) {
1053 input_unregister_device(device->inputdevice); 1007 input_unregister_device(gtco->inputdevice);
1054 usb_kill_urb(device->urbinfo); 1008 usb_kill_urb(gtco->urbinfo);
1055 usb_free_urb(device->urbinfo); 1009 usb_free_urb(gtco->urbinfo);
1056 usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, 1010 usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE,
1057 device->buffer, device->buf_dma); 1011 gtco->buffer, gtco->buf_dma);
1058 kfree(device); 1012 kfree(gtco);
1059 } 1013 }
1060 1014
1061 info("gtco driver disconnected"); 1015 info("gtco driver disconnected");
1062} 1016}
1063 1017
1064
1065/* STANDARD MODULE LOAD ROUTINES */ 1018/* STANDARD MODULE LOAD ROUTINES */
1066 1019
1067static struct usb_driver gtco_driverinfo_table = { 1020static struct usb_driver gtco_driverinfo_table = {
1068#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) 1021 .name = "gtco",
1069 .owner = THIS_MODULE, 1022 .id_table = gtco_usbid_table,
1070#endif 1023 .probe = gtco_probe,
1071 .name = "gtco", 1024 .disconnect = gtco_disconnect,
1072 .id_table = gtco_usbid_table,
1073 .probe = gtco_probe,
1074 .disconnect = gtco_disconnect,
1075}; 1025};
1026
1076/* 1027/*
1077 * Register this module with the USB subsystem 1028 * Register this module with the USB subsystem
1078 */ 1029 */
1079static int __init gtco_init(void) 1030static int __init gtco_init(void)
1080{ 1031{
1081 int rc; 1032 int error;
1082 rc = usb_register(&gtco_driverinfo_table); 1033
1083 if (rc) { 1034 error = usb_register(&gtco_driverinfo_table);
1084 err("usb_register() failed rc=0x%x", rc); 1035 if (error) {
1036 err("usb_register() failed rc=0x%x", error);
1037 return error;
1085 } 1038 }
1086 printk("GTCO usb driver version: %s",GTCO_VERSION); 1039
1087 return rc; 1040 printk("GTCO usb driver version: %s", GTCO_VERSION);
1041 return 0;
1088} 1042}
1089 1043
1090/* 1044/*
@@ -1095,7 +1049,7 @@ static void __exit gtco_exit(void)
1095 usb_deregister(&gtco_driverinfo_table); 1049 usb_deregister(&gtco_driverinfo_table);
1096} 1050}
1097 1051
1098module_init (gtco_init); 1052module_init(gtco_init);
1099module_exit (gtco_exit); 1053module_exit(gtco_exit);
1100 1054
1101MODULE_LICENSE("GPL"); 1055MODULE_LICENSE("GPL");
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
deleted file mode 100644
index aac968aab860..000000000000
--- a/drivers/usb/input/itmtouch.c
+++ /dev/null
@@ -1,271 +0,0 @@
1/******************************************************************************
2 * itmtouch.c -- Driver for ITM touchscreen panel
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
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
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * Based upon original work by Chris Collins <xfire-itmtouch@xware.cx>.
19 *
20 * Kudos to ITM for providing me with the datasheet for the panel,
21 * even though it was a day later than I had finished writing this
22 * driver.
23 *
24 * It has meant that I've been able to correct my interpretation of the
25 * protocol packets however.
26 *
27 * CC -- 2003/9/29
28 *
29 * History
30 * 1.0 & 1.1 2003 (CC) vojtech@suse.cz
31 * Original version for 2.4.x kernels
32 *
33 * 1.2 02/03/2005 (HCE) hc@mivu.no
34 * Complete rewrite to support Linux 2.6.10, thanks to mtouchusb.c for hints.
35 * Unfortunately no calibration support at this time.
36 *
37 * 1.2.1 09/03/2005 (HCE) hc@mivu.no
38 * Code cleanup and adjusting syntax to start matching kernel standards
39 *
40 * 1.2.2 10/05/2006 (MJA) massad@gmail.com
41 * Flag for detecting if the screen was being touch was incorrectly
42 * inverted, so no touch events were being detected.
43 *
44 *****************************************************************************/
45
46#include <linux/kernel.h>
47#include <linux/slab.h>
48#include <linux/module.h>
49#include <linux/init.h>
50#include <linux/usb/input.h>
51
52/* only an 8 byte buffer necessary for a single packet */
53#define ITM_BUFSIZE 8
54#define PATH_SIZE 64
55
56#define USB_VENDOR_ID_ITMINC 0x0403
57#define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9
58
59#define DRIVER_AUTHOR "Hans-Christian Egtvedt <hc@mivu.no>"
60#define DRIVER_VERSION "v1.2.2"
61#define DRIVER_DESC "USB ITM Inc Touch Panel Driver"
62#define DRIVER_LICENSE "GPL"
63
64MODULE_AUTHOR( DRIVER_AUTHOR );
65MODULE_DESCRIPTION( DRIVER_DESC );
66MODULE_LICENSE( DRIVER_LICENSE );
67
68struct itmtouch_dev {
69 struct usb_device *usbdev; /* usb device */
70 struct input_dev *inputdev; /* input device */
71 struct urb *readurb; /* urb */
72 char rbuf[ITM_BUFSIZE]; /* data */
73 int users;
74 char name[128];
75 char phys[64];
76};
77
78static struct usb_device_id itmtouch_ids [] = {
79 { USB_DEVICE(USB_VENDOR_ID_ITMINC, USB_PRODUCT_ID_TOUCHPANEL) },
80 { }
81};
82
83static void itmtouch_irq(struct urb *urb)
84{
85 struct itmtouch_dev *itmtouch = urb->context;
86 unsigned char *data = urb->transfer_buffer;
87 struct input_dev *dev = itmtouch->inputdev;
88 int retval;
89
90 switch (urb->status) {
91 case 0:
92 /* success */
93 break;
94 case -ETIME:
95 /* this urb is timing out */
96 dbg("%s - urb timed out - was the device unplugged?",
97 __FUNCTION__);
98 return;
99 case -ECONNRESET:
100 case -ENOENT:
101 case -ESHUTDOWN:
102 /* this urb is terminated, clean up */
103 dbg("%s - urb shutting down with status: %d",
104 __FUNCTION__, urb->status);
105 return;
106 default:
107 dbg("%s - nonzero urb status received: %d",
108 __FUNCTION__, urb->status);
109 goto exit;
110 }
111
112 /* if pressure has been released, then don't report X/Y */
113 if (!(data[7] & 0x20)) {
114 input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F));
115 input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F));
116 }
117
118 input_report_abs(dev, ABS_PRESSURE, (data[2] & 1) << 7 | (data[5] & 0x7F));
119 input_report_key(dev, BTN_TOUCH, ~data[7] & 0x20);
120 input_sync(dev);
121
122exit:
123 retval = usb_submit_urb (urb, GFP_ATOMIC);
124 if (retval)
125 printk(KERN_ERR "%s - usb_submit_urb failed with result: %d",
126 __FUNCTION__, retval);
127}
128
129static int itmtouch_open(struct input_dev *input)
130{
131 struct itmtouch_dev *itmtouch = input->private;
132
133 itmtouch->readurb->dev = itmtouch->usbdev;
134
135 if (usb_submit_urb(itmtouch->readurb, GFP_KERNEL))
136 return -EIO;
137
138 return 0;
139}
140
141static void itmtouch_close(struct input_dev *input)
142{
143 struct itmtouch_dev *itmtouch = input->private;
144
145 usb_kill_urb(itmtouch->readurb);
146}
147
148static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id)
149{
150 struct itmtouch_dev *itmtouch;
151 struct input_dev *input_dev;
152 struct usb_host_interface *interface;
153 struct usb_endpoint_descriptor *endpoint;
154 struct usb_device *udev = interface_to_usbdev(intf);
155 unsigned int pipe;
156 unsigned int maxp;
157
158 interface = intf->cur_altsetting;
159 endpoint = &interface->endpoint[0].desc;
160
161 itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL);
162 input_dev = input_allocate_device();
163 if (!itmtouch || !input_dev) {
164 err("%s - Out of memory.", __FUNCTION__);
165 goto fail;
166 }
167
168 itmtouch->usbdev = udev;
169 itmtouch->inputdev = input_dev;
170
171 if (udev->manufacturer)
172 strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name));
173
174 if (udev->product) {
175 if (udev->manufacturer)
176 strlcat(itmtouch->name, " ", sizeof(itmtouch->name));
177 strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name));
178 }
179
180 if (!strlen(itmtouch->name))
181 sprintf(itmtouch->name, "USB ITM touchscreen");
182
183 usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys));
184 strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys));
185
186 input_dev->name = itmtouch->name;
187 input_dev->phys = itmtouch->phys;
188 usb_to_input_id(udev, &input_dev->id);
189 input_dev->cdev.dev = &intf->dev;
190 input_dev->private = itmtouch;
191
192 input_dev->open = itmtouch_open;
193 input_dev->close = itmtouch_close;
194
195 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
196 input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
197 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
198
199 /* device limits */
200 /* as specified by the ITM datasheet, X and Y are 12bit,
201 * Z (pressure) is 8 bit. However, the fields are defined up
202 * to 14 bits for future possible expansion.
203 */
204 input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0);
205 input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0);
206 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0);
207
208 /* initialise the URB so we can read from the transport stream */
209 pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress);
210 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
211
212 if (maxp > ITM_BUFSIZE)
213 maxp = ITM_BUFSIZE;
214
215 itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL);
216 if (!itmtouch->readurb) {
217 dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__);
218 goto fail;
219 }
220
221 usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf,
222 maxp, itmtouch_irq, itmtouch, endpoint->bInterval);
223
224 input_register_device(itmtouch->inputdev);
225
226 usb_set_intfdata(intf, itmtouch);
227
228 return 0;
229
230 fail: input_free_device(input_dev);
231 kfree(itmtouch);
232 return -ENOMEM;
233}
234
235static void itmtouch_disconnect(struct usb_interface *intf)
236{
237 struct itmtouch_dev *itmtouch = usb_get_intfdata(intf);
238
239 usb_set_intfdata(intf, NULL);
240
241 if (itmtouch) {
242 input_unregister_device(itmtouch->inputdev);
243 usb_kill_urb(itmtouch->readurb);
244 usb_free_urb(itmtouch->readurb);
245 kfree(itmtouch);
246 }
247}
248
249MODULE_DEVICE_TABLE(usb, itmtouch_ids);
250
251static struct usb_driver itmtouch_driver = {
252 .name = "itmtouch",
253 .probe = itmtouch_probe,
254 .disconnect = itmtouch_disconnect,
255 .id_table = itmtouch_ids,
256};
257
258static int __init itmtouch_init(void)
259{
260 info(DRIVER_DESC " " DRIVER_VERSION);
261 info(DRIVER_AUTHOR);
262 return usb_register(&itmtouch_driver);
263}
264
265static void __exit itmtouch_exit(void)
266{
267 usb_deregister(&itmtouch_driver);
268}
269
270module_init(itmtouch_init);
271module_exit(itmtouch_exit);
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index fedbcb127c21..c4781b9d1297 100644
--- a/drivers/usb/input/kbtab.c
+++ b/drivers/usb/input/kbtab.c
@@ -100,7 +100,7 @@ MODULE_DEVICE_TABLE(usb, kbtab_ids);
100 100
101static int kbtab_open(struct input_dev *dev) 101static int kbtab_open(struct input_dev *dev)
102{ 102{
103 struct kbtab *kbtab = dev->private; 103 struct kbtab *kbtab = input_get_drvdata(dev);
104 104
105 kbtab->irq->dev = kbtab->usbdev; 105 kbtab->irq->dev = kbtab->usbdev;
106 if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) 106 if (usb_submit_urb(kbtab->irq, GFP_KERNEL))
@@ -111,7 +111,7 @@ static int kbtab_open(struct input_dev *dev)
111 111
112static void kbtab_close(struct input_dev *dev) 112static void kbtab_close(struct input_dev *dev)
113{ 113{
114 struct kbtab *kbtab = dev->private; 114 struct kbtab *kbtab = input_get_drvdata(dev);
115 115
116 usb_kill_urb(kbtab->irq); 116 usb_kill_urb(kbtab->irq);
117} 117}
@@ -122,6 +122,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
122 struct usb_endpoint_descriptor *endpoint; 122 struct usb_endpoint_descriptor *endpoint;
123 struct kbtab *kbtab; 123 struct kbtab *kbtab;
124 struct input_dev *input_dev; 124 struct input_dev *input_dev;
125 int error = -ENOMEM;
125 126
126 kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); 127 kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL);
127 input_dev = input_allocate_device(); 128 input_dev = input_allocate_device();
@@ -145,8 +146,9 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
145 input_dev->name = "KB Gear Tablet"; 146 input_dev->name = "KB Gear Tablet";
146 input_dev->phys = kbtab->phys; 147 input_dev->phys = kbtab->phys;
147 usb_to_input_id(dev, &input_dev->id); 148 usb_to_input_id(dev, &input_dev->id);
148 input_dev->cdev.dev = &intf->dev; 149 input_dev->dev.parent = &intf->dev;
149 input_dev->private = kbtab; 150
151 input_set_drvdata(input_dev, kbtab);
150 152
151 input_dev->open = kbtab_open; 153 input_dev->open = kbtab_open;
152 input_dev->close = kbtab_close; 154 input_dev->close = kbtab_close;
@@ -168,15 +170,19 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
168 kbtab->irq->transfer_dma = kbtab->data_dma; 170 kbtab->irq->transfer_dma = kbtab->data_dma;
169 kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 171 kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
170 172
171 input_register_device(kbtab->dev); 173 error = input_register_device(kbtab->dev);
174 if (error)
175 goto fail3;
172 176
173 usb_set_intfdata(intf, kbtab); 177 usb_set_intfdata(intf, kbtab);
178
174 return 0; 179 return 0;
175 180
176fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); 181 fail3: usb_free_urb(kbtab->irq);
177fail1: input_free_device(input_dev); 182 fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma);
183 fail1: input_free_device(input_dev);
178 kfree(kbtab); 184 kfree(kbtab);
179 return -ENOMEM; 185 return error;
180} 186}
181 187
182static void kbtab_disconnect(struct usb_interface *intf) 188static void kbtab_disconnect(struct usb_interface *intf)
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 98bd323369c7..1bffc9fa98c2 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -394,7 +394,7 @@ resubmit:
394 394
395static int keyspan_open(struct input_dev *dev) 395static int keyspan_open(struct input_dev *dev)
396{ 396{
397 struct usb_keyspan *remote = dev->private; 397 struct usb_keyspan *remote = input_get_drvdata(dev);
398 398
399 remote->irq_urb->dev = remote->udev; 399 remote->irq_urb->dev = remote->udev;
400 if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) 400 if (usb_submit_urb(remote->irq_urb, GFP_KERNEL))
@@ -405,7 +405,7 @@ static int keyspan_open(struct input_dev *dev)
405 405
406static void keyspan_close(struct input_dev *dev) 406static void keyspan_close(struct input_dev *dev)
407{ 407{
408 struct usb_keyspan *remote = dev->private; 408 struct usb_keyspan *remote = input_get_drvdata(dev);
409 409
410 usb_kill_urb(remote->irq_urb); 410 usb_kill_urb(remote->irq_urb);
411} 411}
@@ -437,7 +437,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
437 struct usb_endpoint_descriptor *endpoint; 437 struct usb_endpoint_descriptor *endpoint;
438 struct usb_keyspan *remote; 438 struct usb_keyspan *remote;
439 struct input_dev *input_dev; 439 struct input_dev *input_dev;
440 int i, retval; 440 int i, error;
441 441
442 endpoint = keyspan_get_in_endpoint(interface->cur_altsetting); 442 endpoint = keyspan_get_in_endpoint(interface->cur_altsetting);
443 if (!endpoint) 443 if (!endpoint)
@@ -446,7 +446,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
446 remote = kzalloc(sizeof(*remote), GFP_KERNEL); 446 remote = kzalloc(sizeof(*remote), GFP_KERNEL);
447 input_dev = input_allocate_device(); 447 input_dev = input_allocate_device();
448 if (!remote || !input_dev) { 448 if (!remote || !input_dev) {
449 retval = -ENOMEM; 449 error = -ENOMEM;
450 goto fail1; 450 goto fail1;
451 } 451 }
452 452
@@ -458,19 +458,19 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
458 458
459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma); 459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
460 if (!remote->in_buffer) { 460 if (!remote->in_buffer) {
461 retval = -ENOMEM; 461 error = -ENOMEM;
462 goto fail1; 462 goto fail1;
463 } 463 }
464 464
465 remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); 465 remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
466 if (!remote->irq_urb) { 466 if (!remote->irq_urb) {
467 retval = -ENOMEM; 467 error = -ENOMEM;
468 goto fail2; 468 goto fail2;
469 } 469 }
470 470
471 retval = keyspan_setup(udev); 471 error = keyspan_setup(udev);
472 if (retval) { 472 if (error) {
473 retval = -ENODEV; 473 error = -ENODEV;
474 goto fail3; 474 goto fail3;
475 } 475 }
476 476
@@ -495,14 +495,15 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
495 input_dev->name = remote->name; 495 input_dev->name = remote->name;
496 input_dev->phys = remote->phys; 496 input_dev->phys = remote->phys;
497 usb_to_input_id(udev, &input_dev->id); 497 usb_to_input_id(udev, &input_dev->id);
498 input_dev->cdev.dev = &interface->dev; 498 input_dev->dev.parent = &interface->dev;
499 499
500 input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ 500 input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */
501 for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) 501 for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++)
502 if (keyspan_key_table[i] != KEY_RESERVED) 502 if (keyspan_key_table[i] != KEY_RESERVED)
503 set_bit(keyspan_key_table[i], input_dev->keybit); 503 set_bit(keyspan_key_table[i], input_dev->keybit);
504 504
505 input_dev->private = remote; 505 input_set_drvdata(input_dev, remote);
506
506 input_dev->open = keyspan_open; 507 input_dev->open = keyspan_open;
507 input_dev->close = keyspan_close; 508 input_dev->close = keyspan_close;
508 509
@@ -517,7 +518,9 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
517 remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 518 remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
518 519
519 /* we can register the device now, as it is ready */ 520 /* we can register the device now, as it is ready */
520 input_register_device(remote->input); 521 error = input_register_device(remote->input);
522 if (error)
523 goto fail3;
521 524
522 /* save our data pointer in this interface device */ 525 /* save our data pointer in this interface device */
523 usb_set_intfdata(interface, remote); 526 usb_set_intfdata(interface, remote);
@@ -529,7 +532,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
529 fail1: kfree(remote); 532 fail1: kfree(remote);
530 input_free_device(input_dev); 533 input_free_device(input_dev);
531 534
532 return retval; 535 return error;
533} 536}
534 537
535/* 538/*
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
deleted file mode 100644
index 92c4e07da4c8..000000000000
--- a/drivers/usb/input/mtouchusb.c
+++ /dev/null
@@ -1,332 +0,0 @@
1/******************************************************************************
2 * mtouchusb.c -- Driver for Microtouch (Now 3M) USB Touchscreens
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
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
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * Based upon original work by Radoslaw Garbacz (usb-support@ite.pl)
19 * (http://freshmeat.net/projects/3mtouchscreendriver)
20 *
21 * History
22 *
23 * 0.3 & 0.4 2002 (TEJ) tejohnson@yahoo.com
24 * Updated to 2.4.18, then 2.4.19
25 * Old version still relied on stealing a minor
26 *
27 * 0.5 02/26/2004 (TEJ) tejohnson@yahoo.com
28 * Complete rewrite using Linux Input in 2.6.3
29 * Unfortunately no calibration support at this time
30 *
31 * 1.4 04/25/2004 (TEJ) tejohnson@yahoo.com
32 * Changed reset from standard USB dev reset to vendor reset
33 * Changed data sent to host from compensated to raw coordinates
34 * Eliminated vendor/product module params
35 * Performed multiple successful tests with an EXII-5010UC
36 *
37 * 1.5 02/27/2005 ddstreet@ieee.org
38 * Added module parameter to select raw or hw-calibrated coordinate reporting
39 *
40 *****************************************************************************/
41
42#include <linux/kernel.h>
43#include <linux/slab.h>
44#include <linux/module.h>
45#include <linux/init.h>
46#include <linux/usb/input.h>
47
48#define MTOUCHUSB_MIN_XC 0x0
49#define MTOUCHUSB_MAX_RAW_XC 0x4000
50#define MTOUCHUSB_MAX_CALIB_XC 0xffff
51#define MTOUCHUSB_XC_FUZZ 0x0
52#define MTOUCHUSB_XC_FLAT 0x0
53#define MTOUCHUSB_MIN_YC 0x0
54#define MTOUCHUSB_MAX_RAW_YC 0x4000
55#define MTOUCHUSB_MAX_CALIB_YC 0xffff
56#define MTOUCHUSB_YC_FUZZ 0x0
57#define MTOUCHUSB_YC_FLAT 0x0
58
59#define MTOUCHUSB_ASYNC_REPORT 1
60#define MTOUCHUSB_RESET 7
61#define MTOUCHUSB_REPORT_DATA_SIZE 11
62#define MTOUCHUSB_REQ_CTRLLR_ID 10
63
64#define MTOUCHUSB_GET_RAW_XC(data) (data[8]<<8 | data[7])
65#define MTOUCHUSB_GET_CALIB_XC(data) (data[4]<<8 | data[3])
66#define MTOUCHUSB_GET_RAW_YC(data) (data[10]<<8 | data[9])
67#define MTOUCHUSB_GET_CALIB_YC(data) (data[6]<<8 | data[5])
68#define MTOUCHUSB_GET_XC(data) (raw_coordinates ? \
69 MTOUCHUSB_GET_RAW_XC(data) : \
70 MTOUCHUSB_GET_CALIB_XC(data))
71#define MTOUCHUSB_GET_YC(data) (raw_coordinates ? \
72 MTOUCHUSB_GET_RAW_YC(data) : \
73 MTOUCHUSB_GET_CALIB_YC(data))
74#define MTOUCHUSB_GET_TOUCHED(data) ((data[2] & 0x40) ? 1:0)
75
76#define DRIVER_VERSION "v1.5"
77#define DRIVER_AUTHOR "Todd E. Johnson, tejohnson@yahoo.com"
78#define DRIVER_DESC "3M USB Touchscreen Driver"
79#define DRIVER_LICENSE "GPL"
80
81static int raw_coordinates = 1;
82
83module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR);
84MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)");
85
86struct mtouch_usb {
87 unsigned char *data;
88 dma_addr_t data_dma;
89 struct urb *irq;
90 struct usb_device *udev;
91 struct input_dev *input;
92 char name[128];
93 char phys[64];
94};
95
96static struct usb_device_id mtouchusb_devices[] = {
97 { USB_DEVICE(0x0596, 0x0001) },
98 { }
99};
100
101static void mtouchusb_irq(struct urb *urb)
102{
103 struct mtouch_usb *mtouch = urb->context;
104 int retval;
105
106 switch (urb->status) {
107 case 0:
108 /* success */
109 break;
110 case -ETIME:
111 /* this urb is timing out */
112 dbg("%s - urb timed out - was the device unplugged?",
113 __FUNCTION__);
114 return;
115 case -ECONNRESET:
116 case -ENOENT:
117 case -ESHUTDOWN:
118 /* this urb is terminated, clean up */
119 dbg("%s - urb shutting down with status: %d",
120 __FUNCTION__, urb->status);
121 return;
122 default:
123 dbg("%s - nonzero urb status received: %d",
124 __FUNCTION__, urb->status);
125 goto exit;
126 }
127
128 input_report_key(mtouch->input, BTN_TOUCH,
129 MTOUCHUSB_GET_TOUCHED(mtouch->data));
130 input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data));
131 input_report_abs(mtouch->input, ABS_Y,
132 (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC)
133 - MTOUCHUSB_GET_YC(mtouch->data));
134 input_sync(mtouch->input);
135
136exit:
137 retval = usb_submit_urb(urb, GFP_ATOMIC);
138 if (retval)
139 err("%s - usb_submit_urb failed with result: %d",
140 __FUNCTION__, retval);
141}
142
143static int mtouchusb_open(struct input_dev *input)
144{
145 struct mtouch_usb *mtouch = input->private;
146
147 mtouch->irq->dev = mtouch->udev;
148
149 if (usb_submit_urb(mtouch->irq, GFP_ATOMIC))
150 return -EIO;
151
152 return 0;
153}
154
155static void mtouchusb_close(struct input_dev *input)
156{
157 struct mtouch_usb *mtouch = input->private;
158
159 usb_kill_urb(mtouch->irq);
160}
161
162static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
163{
164 dbg("%s - called", __FUNCTION__);
165
166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
167 GFP_ATOMIC, &mtouch->data_dma);
168
169 if (!mtouch->data)
170 return -1;
171
172 return 0;
173}
174
175static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
176{
177 dbg("%s - called", __FUNCTION__);
178
179 if (mtouch->data)
180 usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE,
181 mtouch->data, mtouch->data_dma);
182}
183
184static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
185{
186 struct mtouch_usb *mtouch;
187 struct input_dev *input_dev;
188 struct usb_host_interface *interface;
189 struct usb_endpoint_descriptor *endpoint;
190 struct usb_device *udev = interface_to_usbdev(intf);
191 int nRet;
192
193 dbg("%s - called", __FUNCTION__);
194
195 dbg("%s - setting interface", __FUNCTION__);
196 interface = intf->cur_altsetting;
197
198 dbg("%s - setting endpoint", __FUNCTION__);
199 endpoint = &interface->endpoint[0].desc;
200
201 mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL);
202 input_dev = input_allocate_device();
203 if (!mtouch || !input_dev) {
204 err("%s - Out of memory.", __FUNCTION__);
205 goto fail1;
206 }
207
208 dbg("%s - allocating buffers", __FUNCTION__);
209 if (mtouchusb_alloc_buffers(udev, mtouch))
210 goto fail2;
211
212 mtouch->udev = udev;
213 mtouch->input = input_dev;
214
215 if (udev->manufacturer)
216 strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name));
217
218 if (udev->product) {
219 if (udev->manufacturer)
220 strlcat(mtouch->name, " ", sizeof(mtouch->name));
221 strlcat(mtouch->name, udev->product, sizeof(mtouch->name));
222 }
223
224 if (!strlen(mtouch->name))
225 snprintf(mtouch->name, sizeof(mtouch->name),
226 "USB Touchscreen %04x:%04x",
227 le16_to_cpu(udev->descriptor.idVendor),
228 le16_to_cpu(udev->descriptor.idProduct));
229
230 usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys));
231 strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys));
232
233 input_dev->name = mtouch->name;
234 input_dev->phys = mtouch->phys;
235 usb_to_input_id(udev, &input_dev->id);
236 input_dev->cdev.dev = &intf->dev;
237 input_dev->private = mtouch;
238
239 input_dev->open = mtouchusb_open;
240 input_dev->close = mtouchusb_close;
241
242 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
243 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
244 input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC,
245 raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC,
246 MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT);
247 input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC,
248 raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC,
249 MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT);
250
251 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
252 MTOUCHUSB_RESET,
253 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
254 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
255 dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
256 __FUNCTION__, nRet);
257
258 dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__);
259 mtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
260 if (!mtouch->irq) {
261 dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__);
262 goto fail2;
263 }
264
265 dbg("%s - usb_fill_int_urb", __FUNCTION__);
266 usb_fill_int_urb(mtouch->irq, mtouch->udev,
267 usb_rcvintpipe(mtouch->udev, 0x81),
268 mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE,
269 mtouchusb_irq, mtouch, endpoint->bInterval);
270
271 dbg("%s - input_register_device", __FUNCTION__);
272 input_register_device(mtouch->input);
273
274 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
275 MTOUCHUSB_ASYNC_REPORT,
276 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
277 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
278 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
279 __FUNCTION__, nRet);
280
281 usb_set_intfdata(intf, mtouch);
282 return 0;
283
284fail2: mtouchusb_free_buffers(udev, mtouch);
285fail1: input_free_device(input_dev);
286 kfree(mtouch);
287 return -ENOMEM;
288}
289
290static void mtouchusb_disconnect(struct usb_interface *intf)
291{
292 struct mtouch_usb *mtouch = usb_get_intfdata(intf);
293
294 dbg("%s - called", __FUNCTION__);
295 usb_set_intfdata(intf, NULL);
296 if (mtouch) {
297 dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__);
298 usb_kill_urb(mtouch->irq);
299 input_unregister_device(mtouch->input);
300 usb_free_urb(mtouch->irq);
301 mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch);
302 kfree(mtouch);
303 }
304}
305
306MODULE_DEVICE_TABLE(usb, mtouchusb_devices);
307
308static struct usb_driver mtouchusb_driver = {
309 .name = "mtouchusb",
310 .probe = mtouchusb_probe,
311 .disconnect = mtouchusb_disconnect,
312 .id_table = mtouchusb_devices,
313};
314
315static int __init mtouchusb_init(void)
316{
317 dbg("%s - called", __FUNCTION__);
318 return usb_register(&mtouchusb_driver);
319}
320
321static void __exit mtouchusb_cleanup(void)
322{
323 dbg("%s - called", __FUNCTION__);
324 usb_deregister(&mtouchusb_driver);
325}
326
327module_init(mtouchusb_init);
328module_exit(mtouchusb_cleanup);
329
330MODULE_AUTHOR(DRIVER_AUTHOR);
331MODULE_DESCRIPTION(DRIVER_DESC);
332MODULE_LICENSE("GPL");
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index fea97e5437f8..4f93a760faee 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -252,7 +252,7 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne
252static int powermate_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int _value) 252static int powermate_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int _value)
253{ 253{
254 unsigned int command = (unsigned int)_value; 254 unsigned int command = (unsigned int)_value;
255 struct powermate_device *pm = dev->private; 255 struct powermate_device *pm = input_get_drvdata(dev);
256 256
257 if (type == EV_MSC && code == MSC_PULSELED){ 257 if (type == EV_MSC && code == MSC_PULSELED){
258 /* 258 /*
@@ -308,7 +308,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
308 struct powermate_device *pm; 308 struct powermate_device *pm;
309 struct input_dev *input_dev; 309 struct input_dev *input_dev;
310 int pipe, maxp; 310 int pipe, maxp;
311 int err = -ENOMEM; 311 int error = -ENOMEM;
312 312
313 interface = intf->cur_altsetting; 313 interface = intf->cur_altsetting;
314 endpoint = &interface->endpoint[0].desc; 314 endpoint = &interface->endpoint[0].desc;
@@ -359,8 +359,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
359 359
360 input_dev->phys = pm->phys; 360 input_dev->phys = pm->phys;
361 usb_to_input_id(udev, &input_dev->id); 361 usb_to_input_id(udev, &input_dev->id);
362 input_dev->cdev.dev = &intf->dev; 362 input_dev->dev.parent = &intf->dev;
363 input_dev->private = pm; 363
364 input_set_drvdata(input_dev, pm);
364 365
365 input_dev->event = powermate_input_event; 366 input_dev->event = powermate_input_event;
366 367
@@ -387,11 +388,14 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
387 388
388 /* register our interrupt URB with the USB system */ 389 /* register our interrupt URB with the USB system */
389 if (usb_submit_urb(pm->irq, GFP_KERNEL)) { 390 if (usb_submit_urb(pm->irq, GFP_KERNEL)) {
390 err = -EIO; 391 error = -EIO;
391 goto fail4; 392 goto fail4;
392 } 393 }
393 394
394 input_register_device(pm->input); 395 error = input_register_device(pm->input);
396 if (error)
397 goto fail5;
398
395 399
396 /* force an update of everything */ 400 /* force an update of everything */
397 pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; 401 pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS;
@@ -400,12 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
400 usb_set_intfdata(intf, pm); 404 usb_set_intfdata(intf, pm);
401 return 0; 405 return 0;
402 406
403fail4: usb_free_urb(pm->config); 407 fail5: usb_kill_urb(pm->irq);
404fail3: usb_free_urb(pm->irq); 408 fail4: usb_free_urb(pm->config);
405fail2: powermate_free_buffers(udev, pm); 409 fail3: usb_free_urb(pm->irq);
406fail1: input_free_device(input_dev); 410 fail2: powermate_free_buffers(udev, pm);
411 fail1: input_free_device(input_dev);
407 kfree(pm); 412 kfree(pm);
408 return err; 413 return error;
409} 414}
410 415
411/* 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 */
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
deleted file mode 100644
index 2a314b065922..000000000000
--- a/drivers/usb/input/touchkitusb.c
+++ /dev/null
@@ -1,392 +0,0 @@
1/******************************************************************************
2 * touchkitusb.c -- Driver for eGalax TouchKit USB Touchscreens
3 *
4 * Copyright (C) 2004-2005 by Daniel Ritz <daniel.ritz@gmx.ch>
5 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * Based upon mtouchusb.c
22 *
23 *****************************************************************************/
24
25//#define DEBUG
26
27#include <linux/kernel.h>
28#include <linux/slab.h>
29#include <linux/module.h>
30#include <linux/init.h>
31#include <linux/usb/input.h>
32
33#define TOUCHKIT_MIN_XC 0x0
34#define TOUCHKIT_MAX_XC 0x07ff
35#define TOUCHKIT_XC_FUZZ 0x0
36#define TOUCHKIT_XC_FLAT 0x0
37#define TOUCHKIT_MIN_YC 0x0
38#define TOUCHKIT_MAX_YC 0x07ff
39#define TOUCHKIT_YC_FUZZ 0x0
40#define TOUCHKIT_YC_FLAT 0x0
41#define TOUCHKIT_REPORT_DATA_SIZE 16
42
43#define TOUCHKIT_DOWN 0x01
44
45#define TOUCHKIT_PKT_TYPE_MASK 0xFE
46#define TOUCHKIT_PKT_TYPE_REPT 0x80
47#define TOUCHKIT_PKT_TYPE_DIAG 0x0A
48
49#define DRIVER_VERSION "v0.1"
50#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
51#define DRIVER_DESC "eGalax TouchKit USB HID Touchscreen Driver"
52
53static int swap_xy;
54module_param(swap_xy, bool, 0644);
55MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
56
57struct touchkit_usb {
58 unsigned char *data;
59 dma_addr_t data_dma;
60 char buffer[TOUCHKIT_REPORT_DATA_SIZE];
61 int buf_len;
62 struct urb *irq;
63 struct usb_device *udev;
64 struct input_dev *input;
65 char name[128];
66 char phys[64];
67};
68
69static struct usb_device_id touchkit_devices[] = {
70 {USB_DEVICE(0x3823, 0x0001)},
71 {USB_DEVICE(0x0123, 0x0001)},
72 {USB_DEVICE(0x0eef, 0x0001)},
73 {USB_DEVICE(0x0eef, 0x0002)},
74 {}
75};
76
77/* helpers to read the data */
78static inline int touchkit_get_touched(char *data)
79{
80 return (data[0] & TOUCHKIT_DOWN) ? 1 : 0;
81}
82
83static inline int touchkit_get_x(char *data)
84{
85 return ((data[3] & 0x0F) << 7) | (data[4] & 0x7F);
86}
87
88static inline int touchkit_get_y(char *data)
89{
90 return ((data[1] & 0x0F) << 7) | (data[2] & 0x7F);
91}
92
93
94/* processes one input packet. */
95static void touchkit_process_pkt(struct touchkit_usb *touchkit, char *pkt)
96{
97 int x, y;
98
99 /* only process report packets */
100 if ((pkt[0] & TOUCHKIT_PKT_TYPE_MASK) != TOUCHKIT_PKT_TYPE_REPT)
101 return;
102
103 if (swap_xy) {
104 y = touchkit_get_x(pkt);
105 x = touchkit_get_y(pkt);
106 } else {
107 x = touchkit_get_x(pkt);
108 y = touchkit_get_y(pkt);
109 }
110
111 input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt));
112 input_report_abs(touchkit->input, ABS_X, x);
113 input_report_abs(touchkit->input, ABS_Y, y);
114 input_sync(touchkit->input);
115}
116
117
118static int touchkit_get_pkt_len(char *buf)
119{
120 switch (buf[0] & TOUCHKIT_PKT_TYPE_MASK) {
121 case TOUCHKIT_PKT_TYPE_REPT:
122 return 5;
123
124 case TOUCHKIT_PKT_TYPE_DIAG:
125 return buf[1] + 2;
126 }
127
128 return 0;
129}
130
131static void touchkit_process(struct touchkit_usb *touchkit, int len)
132{
133 char *buffer;
134 int pkt_len, buf_len, pos;
135
136 /* if the buffer contains data, append */
137 if (unlikely(touchkit->buf_len)) {
138 int tmp;
139
140 /* if only 1 byte in buffer, add another one to get length */
141 if (touchkit->buf_len == 1)
142 touchkit->buffer[1] = touchkit->data[0];
143
144 pkt_len = touchkit_get_pkt_len(touchkit->buffer);
145
146 /* unknown packet: drop everything */
147 if (!pkt_len)
148 return;
149
150 /* append, process */
151 tmp = pkt_len - touchkit->buf_len;
152 memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp);
153 touchkit_process_pkt(touchkit, touchkit->buffer);
154
155 buffer = touchkit->data + tmp;
156 buf_len = len - tmp;
157 } else {
158 buffer = touchkit->data;
159 buf_len = len;
160 }
161
162 /* only one byte left in buffer */
163 if (unlikely(buf_len == 1)) {
164 touchkit->buffer[0] = buffer[0];
165 touchkit->buf_len = 1;
166 return;
167 }
168
169 /* loop over the buffer */
170 pos = 0;
171 while (pos < buf_len) {
172 /* get packet len */
173 pkt_len = touchkit_get_pkt_len(buffer + pos);
174
175 /* unknown packet: drop everything */
176 if (unlikely(!pkt_len))
177 return;
178
179 /* full packet: process */
180 if (likely(pkt_len <= buf_len)) {
181 touchkit_process_pkt(touchkit, buffer + pos);
182 } else {
183 /* incomplete packet: save in buffer */
184 memcpy(touchkit->buffer, buffer + pos, buf_len - pos);
185 touchkit->buf_len = buf_len - pos;
186 }
187 pos += pkt_len;
188 }
189}
190
191
192static void touchkit_irq(struct urb *urb)
193{
194 struct touchkit_usb *touchkit = urb->context;
195 int retval;
196
197 switch (urb->status) {
198 case 0:
199 /* success */
200 break;
201 case -ETIME:
202 /* this urb is timing out */
203 dbg("%s - urb timed out - was the device unplugged?",
204 __FUNCTION__);
205 return;
206 case -ECONNRESET:
207 case -ENOENT:
208 case -ESHUTDOWN:
209 /* this urb is terminated, clean up */
210 dbg("%s - urb shutting down with status: %d",
211 __FUNCTION__, urb->status);
212 return;
213 default:
214 dbg("%s - nonzero urb status received: %d",
215 __FUNCTION__, urb->status);
216 goto exit;
217 }
218
219 touchkit_process(touchkit, urb->actual_length);
220
221exit:
222 retval = usb_submit_urb(urb, GFP_ATOMIC);
223 if (retval)
224 err("%s - usb_submit_urb failed with result: %d",
225 __FUNCTION__, retval);
226}
227
228static int touchkit_open(struct input_dev *input)
229{
230 struct touchkit_usb *touchkit = input->private;
231
232 touchkit->irq->dev = touchkit->udev;
233
234 if (usb_submit_urb(touchkit->irq, GFP_ATOMIC))
235 return -EIO;
236
237 return 0;
238}
239
240static void touchkit_close(struct input_dev *input)
241{
242 struct touchkit_usb *touchkit = input->private;
243
244 usb_kill_urb(touchkit->irq);
245}
246
247static int touchkit_alloc_buffers(struct usb_device *udev,
248 struct touchkit_usb *touchkit)
249{
250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
251 GFP_ATOMIC, &touchkit->data_dma);
252
253 if (!touchkit->data)
254 return -1;
255
256 return 0;
257}
258
259static void touchkit_free_buffers(struct usb_device *udev,
260 struct touchkit_usb *touchkit)
261{
262 if (touchkit->data)
263 usb_buffer_free(udev, TOUCHKIT_REPORT_DATA_SIZE,
264 touchkit->data, touchkit->data_dma);
265}
266
267static int touchkit_probe(struct usb_interface *intf,
268 const struct usb_device_id *id)
269{
270 struct touchkit_usb *touchkit;
271 struct input_dev *input_dev;
272 struct usb_host_interface *interface;
273 struct usb_endpoint_descriptor *endpoint;
274 struct usb_device *udev = interface_to_usbdev(intf);
275
276 interface = intf->cur_altsetting;
277 endpoint = &interface->endpoint[0].desc;
278
279 touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL);
280 input_dev = input_allocate_device();
281 if (!touchkit || !input_dev)
282 goto out_free;
283
284 if (touchkit_alloc_buffers(udev, touchkit))
285 goto out_free;
286
287 touchkit->irq = usb_alloc_urb(0, GFP_KERNEL);
288 if (!touchkit->irq) {
289 dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__);
290 goto out_free_buffers;
291 }
292
293 touchkit->udev = udev;
294 touchkit->input = input_dev;
295
296 if (udev->manufacturer)
297 strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name));
298
299 if (udev->product) {
300 if (udev->manufacturer)
301 strlcat(touchkit->name, " ", sizeof(touchkit->name));
302 strlcat(touchkit->name, udev->product, sizeof(touchkit->name));
303 }
304
305 if (!strlen(touchkit->name))
306 snprintf(touchkit->name, sizeof(touchkit->name),
307 "USB Touchscreen %04x:%04x",
308 le16_to_cpu(udev->descriptor.idVendor),
309 le16_to_cpu(udev->descriptor.idProduct));
310
311 usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys));
312 strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys));
313
314 input_dev->name = touchkit->name;
315 input_dev->phys = touchkit->phys;
316 usb_to_input_id(udev, &input_dev->id);
317 input_dev->cdev.dev = &intf->dev;
318 input_dev->private = touchkit;
319 input_dev->open = touchkit_open;
320 input_dev->close = touchkit_close;
321
322 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
323 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
324 input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC,
325 TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT);
326 input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC,
327 TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT);
328
329 usb_fill_int_urb(touchkit->irq, touchkit->udev,
330 usb_rcvintpipe(touchkit->udev, 0x81),
331 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE,
332 touchkit_irq, touchkit, endpoint->bInterval);
333
334 touchkit->irq->transfer_dma = touchkit->data_dma;
335 touchkit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
336
337 input_register_device(touchkit->input);
338
339 usb_set_intfdata(intf, touchkit);
340 return 0;
341
342out_free_buffers:
343 touchkit_free_buffers(udev, touchkit);
344out_free:
345 input_free_device(input_dev);
346 kfree(touchkit);
347 return -ENOMEM;
348}
349
350static void touchkit_disconnect(struct usb_interface *intf)
351{
352 struct touchkit_usb *touchkit = usb_get_intfdata(intf);
353
354 dbg("%s - called", __FUNCTION__);
355
356 if (!touchkit)
357 return;
358
359 dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__);
360 usb_set_intfdata(intf, NULL);
361 usb_kill_urb(touchkit->irq);
362 input_unregister_device(touchkit->input);
363 usb_free_urb(touchkit->irq);
364 touchkit_free_buffers(interface_to_usbdev(intf), touchkit);
365 kfree(touchkit);
366}
367
368MODULE_DEVICE_TABLE(usb, touchkit_devices);
369
370static struct usb_driver touchkit_driver = {
371 .name = "touchkitusb",
372 .probe = touchkit_probe,
373 .disconnect = touchkit_disconnect,
374 .id_table = touchkit_devices,
375};
376
377static int __init touchkit_init(void)
378{
379 return usb_register(&touchkit_driver);
380}
381
382static void __exit touchkit_cleanup(void)
383{
384 usb_deregister(&touchkit_driver);
385}
386
387module_init(touchkit_init);
388module_exit(touchkit_cleanup);
389
390MODULE_AUTHOR(DRIVER_AUTHOR);
391MODULE_DESCRIPTION(DRIVER_DESC);
392MODULE_LICENSE("GPL");
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 86e37a20f8e5..e0829413336b 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -647,7 +647,7 @@ exit:
647 647
648static int usbtouch_open(struct input_dev *input) 648static int usbtouch_open(struct input_dev *input)
649{ 649{
650 struct usbtouch_usb *usbtouch = input->private; 650 struct usbtouch_usb *usbtouch = input_get_drvdata(input);
651 651
652 usbtouch->irq->dev = usbtouch->udev; 652 usbtouch->irq->dev = usbtouch->udev;
653 653
@@ -659,7 +659,7 @@ static int usbtouch_open(struct input_dev *input)
659 659
660static void usbtouch_close(struct input_dev *input) 660static void usbtouch_close(struct input_dev *input)
661{ 661{
662 struct usbtouch_usb *usbtouch = input->private; 662 struct usbtouch_usb *usbtouch = input_get_drvdata(input);
663 663
664 usb_kill_urb(usbtouch->irq); 664 usb_kill_urb(usbtouch->irq);
665} 665}
@@ -740,8 +740,10 @@ static int usbtouch_probe(struct usb_interface *intf,
740 input_dev->name = usbtouch->name; 740 input_dev->name = usbtouch->name;
741 input_dev->phys = usbtouch->phys; 741 input_dev->phys = usbtouch->phys;
742 usb_to_input_id(udev, &input_dev->id); 742 usb_to_input_id(udev, &input_dev->id);
743 input_dev->cdev.dev = &intf->dev; 743 input_dev->dev.parent = &intf->dev;
744 input_dev->private = usbtouch; 744
745 input_set_drvdata(input_dev, usbtouch);
746
745 input_dev->open = usbtouch_open; 747 input_dev->open = usbtouch_open;
746 input_dev->close = usbtouch_close; 748 input_dev->close = usbtouch_close;
747 749
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index 12b42746ded8..1fe48208c2f4 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -122,7 +122,7 @@ void wacom_input_sync(void *wcombo)
122 122
123static int wacom_open(struct input_dev *dev) 123static int wacom_open(struct input_dev *dev)
124{ 124{
125 struct wacom *wacom = dev->private; 125 struct wacom *wacom = input_get_drvdata(dev);
126 126
127 wacom->irq->dev = wacom->usbdev; 127 wacom->irq->dev = wacom->usbdev;
128 if (usb_submit_urb(wacom->irq, GFP_KERNEL)) 128 if (usb_submit_urb(wacom->irq, GFP_KERNEL))
@@ -133,7 +133,7 @@ static int wacom_open(struct input_dev *dev)
133 133
134static void wacom_close(struct input_dev *dev) 134static void wacom_close(struct input_dev *dev)
135{ 135{
136 struct wacom *wacom = dev->private; 136 struct wacom *wacom = input_get_drvdata(dev);
137 137
138 usb_kill_urb(wacom->irq); 138 usb_kill_urb(wacom->irq);
139} 139}
@@ -201,6 +201,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
201 struct wacom *wacom; 201 struct wacom *wacom;
202 struct wacom_wac *wacom_wac; 202 struct wacom_wac *wacom_wac;
203 struct input_dev *input_dev; 203 struct input_dev *input_dev;
204 int error = -ENOMEM;
204 char rep_data[2], limit = 0; 205 char rep_data[2], limit = 0;
205 206
206 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 207 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
@@ -229,8 +230,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
229 wacom->wacom_wac = wacom_wac; 230 wacom->wacom_wac = wacom_wac;
230 usb_to_input_id(dev, &input_dev->id); 231 usb_to_input_id(dev, &input_dev->id);
231 232
232 input_dev->cdev.dev = &intf->dev; 233 input_dev->dev.parent = &intf->dev;
233 input_dev->private = wacom; 234
235 input_set_drvdata(input_dev, wacom);
236
234 input_dev->open = wacom_open; 237 input_dev->open = wacom_open;
235 input_dev->close = wacom_close; 238 input_dev->close = wacom_close;
236 239
@@ -252,7 +255,9 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
252 wacom->irq->transfer_dma = wacom->data_dma; 255 wacom->irq->transfer_dma = wacom->data_dma;
253 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 256 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
254 257
255 input_register_device(wacom->dev); 258 error = input_register_device(wacom->dev);
259 if (error)
260 goto fail3;
256 261
257 /* Ask the tablet to report tablet data. Repeat until it succeeds */ 262 /* Ask the tablet to report tablet data. Repeat until it succeeds */
258 do { 263 do {
@@ -265,11 +270,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
265 usb_set_intfdata(intf, wacom); 270 usb_set_intfdata(intf, wacom);
266 return 0; 271 return 0;
267 272
268fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma); 273 fail3: usb_free_urb(wacom->irq);
269fail1: input_free_device(input_dev); 274 fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma);
275 fail1: input_free_device(input_dev);
270 kfree(wacom); 276 kfree(wacom);
271 kfree(wacom_wac); 277 kfree(wacom_wac);
272 return -ENOMEM; 278 return error;
273} 279}
274 280
275static void wacom_disconnect(struct usb_interface *intf) 281static void wacom_disconnect(struct usb_interface *intf)
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index e4bc76ebc835..735723912950 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -267,7 +267,7 @@ exit:
267 267
268static int xpad_open (struct input_dev *dev) 268static int xpad_open (struct input_dev *dev)
269{ 269{
270 struct usb_xpad *xpad = dev->private; 270 struct usb_xpad *xpad = input_get_drvdata(dev);
271 271
272 xpad->irq_in->dev = xpad->udev; 272 xpad->irq_in->dev = xpad->udev;
273 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) 273 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
@@ -278,7 +278,7 @@ static int xpad_open (struct input_dev *dev)
278 278
279static void xpad_close (struct input_dev *dev) 279static void xpad_close (struct input_dev *dev)
280{ 280{
281 struct usb_xpad *xpad = dev->private; 281 struct usb_xpad *xpad = input_get_drvdata(dev);
282 282
283 usb_kill_urb(xpad->irq_in); 283 usb_kill_urb(xpad->irq_in);
284} 284}
@@ -312,6 +312,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
312 struct input_dev *input_dev; 312 struct input_dev *input_dev;
313 struct usb_endpoint_descriptor *ep_irq_in; 313 struct usb_endpoint_descriptor *ep_irq_in;
314 int i; 314 int i;
315 int error = -ENOMEM;
315 316
316 for (i = 0; xpad_device[i].idVendor; i++) { 317 for (i = 0; xpad_device[i].idVendor; i++) {
317 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && 318 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
@@ -344,8 +345,10 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
344 input_dev->name = xpad_device[i].name; 345 input_dev->name = xpad_device[i].name;
345 input_dev->phys = xpad->phys; 346 input_dev->phys = xpad->phys;
346 usb_to_input_id(udev, &input_dev->id); 347 usb_to_input_id(udev, &input_dev->id);
347 input_dev->cdev.dev = &intf->dev; 348 input_dev->dev.parent = &intf->dev;
348 input_dev->private = xpad; 349
350 input_set_drvdata(input_dev, xpad);
351
349 input_dev->open = xpad_open; 352 input_dev->open = xpad_open;
350 input_dev->close = xpad_close; 353 input_dev->close = xpad_close;
351 354
@@ -373,15 +376,18 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
373 xpad->irq_in->transfer_dma = xpad->idata_dma; 376 xpad->irq_in->transfer_dma = xpad->idata_dma;
374 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 377 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
375 378
376 input_register_device(xpad->dev); 379 error = input_register_device(xpad->dev);
380 if (error)
381 goto fail3;
377 382
378 usb_set_intfdata(intf, xpad); 383 usb_set_intfdata(intf, xpad);
379 return 0; 384 return 0;
380 385
381fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 386 fail3: usb_free_urb(xpad->irq_in);
382fail1: input_free_device(input_dev); 387 fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
388 fail1: input_free_device(input_dev);
383 kfree(xpad); 389 kfree(xpad);
384 return -ENOMEM; 390 return error;
385 391
386} 392}
387 393
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index caff8e6d7448..c54f1a5dcb4a 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -502,7 +502,7 @@ static int input_ev(struct input_dev *dev, unsigned int type,
502 502
503static int input_open(struct input_dev *dev) 503static int input_open(struct input_dev *dev)
504{ 504{
505 struct yealink_dev *yld = dev->private; 505 struct yealink_dev *yld = input_get_drvdata(dev);
506 int i, ret; 506 int i, ret;
507 507
508 dbg("%s", __FUNCTION__); 508 dbg("%s", __FUNCTION__);
@@ -529,7 +529,7 @@ static int input_open(struct input_dev *dev)
529 529
530static void input_close(struct input_dev *dev) 530static void input_close(struct input_dev *dev)
531{ 531{
532 struct yealink_dev *yld = dev->private; 532 struct yealink_dev *yld = input_get_drvdata(dev);
533 533
534 usb_kill_urb(yld->urb_ctl); 534 usb_kill_urb(yld->urb_ctl);
535 usb_kill_urb(yld->urb_irq); 535 usb_kill_urb(yld->urb_irq);
@@ -937,9 +937,10 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
937 input_dev->name = nfo->name; 937 input_dev->name = nfo->name;
938 input_dev->phys = yld->phys; 938 input_dev->phys = yld->phys;
939 usb_to_input_id(udev, &input_dev->id); 939 usb_to_input_id(udev, &input_dev->id);
940 input_dev->cdev.dev = &intf->dev; 940 input_dev->dev.parent = &intf->dev;
941
942 input_set_drvdata(input_dev, yld);
941 943
942 input_dev->private = yld;
943 input_dev->open = input_open; 944 input_dev->open = input_open;
944 input_dev->close = input_close; 945 input_dev->close = input_close;
945 /* input_dev->event = input_ev; TODO */ 946 /* input_dev->event = input_ev; TODO */
@@ -955,7 +956,9 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
955 } 956 }
956 } 957 }
957 958
958 input_register_device(yld->idev); 959 ret = input_register_device(yld->idev);
960 if (ret)
961 return usb_cleanup(yld, ret);
959 962
960 usb_set_intfdata(intf, yld); 963 usb_set_intfdata(intf, yld);
961 964
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index a0cc05d21a6a..60d29440f316 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -55,7 +55,6 @@
55#include <linux/usb.h> 55#include <linux/usb.h>
56#include <linux/types.h> 56#include <linux/types.h>
57#include <linux/ethtool.h> 57#include <linux/ethtool.h>
58#include <linux/pci.h>
59#include <linux/dma-mapping.h> 58#include <linux/dma-mapping.h>
60#include <linux/wait.h> 59#include <linux/wait.h>
61#include <asm/uaccess.h> 60#include <asm/uaccess.h>
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index b1cb72c3780f..d18b51f989c9 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -389,7 +389,10 @@ config FB_ARC
389 389
390config FB_ATARI 390config FB_ATARI
391 bool "Atari native chipset support" 391 bool "Atari native chipset support"
392 depends on (FB = y) && ATARI && BROKEN 392 depends on (FB = y) && ATARI
393 select FB_CFB_FILLRECT
394 select FB_CFB_COPYAREA
395 select FB_CFB_IMAGEBLIT
393 help 396 help
394 This is the frame buffer device driver for the builtin graphics 397 This is the frame buffer device driver for the builtin graphics
395 chipset found in Ataris. 398 chipset found in Ataris.
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 760305c8a841..869351785ee8 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -63,7 +63,8 @@ obj-$(CONFIG_FB_TCX) += tcx.o sbuslib.o
63obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o 63obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o
64obj-$(CONFIG_FB_SGIVW) += sgivwfb.o 64obj-$(CONFIG_FB_SGIVW) += sgivwfb.o
65obj-$(CONFIG_FB_ACORN) += acornfb.o 65obj-$(CONFIG_FB_ACORN) += acornfb.o
66obj-$(CONFIG_FB_ATARI) += atafb.o 66obj-$(CONFIG_FB_ATARI) += atafb.o c2p.o atafb_mfb.o \
67 atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o
67obj-$(CONFIG_FB_MAC) += macfb.o 68obj-$(CONFIG_FB_MAC) += macfb.o
68obj-$(CONFIG_FB_HGA) += hgafb.o 69obj-$(CONFIG_FB_HGA) += hgafb.o
69obj-$(CONFIG_FB_IGA) += igafb.o 70obj-$(CONFIG_FB_IGA) += igafb.o
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index bffe2b946344..0038a0541c7e 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -2,7 +2,7 @@
2 * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device 2 * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device
3 * 3 *
4 * Copyright (C) 1994 Martin Schaller & Roman Hodek 4 * Copyright (C) 1994 Martin Schaller & Roman Hodek
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive 7 * License. See the file COPYING in the main directory of this archive
8 * for more details. 8 * for more details.
@@ -70,14 +70,8 @@
70#include <linux/fb.h> 70#include <linux/fb.h>
71#include <asm/atarikb.h> 71#include <asm/atarikb.h>
72 72
73#include <video/fbcon.h> 73#include "c2p.h"
74#include <video/fbcon-cfb8.h> 74#include "atafb.h"
75#include <video/fbcon-cfb16.h>
76#include <video/fbcon-iplan2p2.h>
77#include <video/fbcon-iplan2p4.h>
78#include <video/fbcon-iplan2p8.h>
79#include <video/fbcon-mfb.h>
80
81 75
82#define SWITCH_ACIA 0x01 /* modes for switch on OverScan */ 76#define SWITCH_ACIA 0x01 /* modes for switch on OverScan */
83#define SWITCH_SND6 0x40 77#define SWITCH_SND6 0x40
@@ -87,22 +81,48 @@
87 81
88#define up(x, r) (((x) + (r) - 1) & ~((r)-1)) 82#define up(x, r) (((x) + (r) - 1) & ~((r)-1))
89 83
84 /*
85 * Interface to the world
86 */
87
88static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);
89static int atafb_set_par(struct fb_info *info);
90static int atafb_setcolreg(unsigned int regno, unsigned int red, unsigned int green,
91 unsigned int blue, unsigned int transp,
92 struct fb_info *info);
93static int atafb_blank(int blank, struct fb_info *info);
94static int atafb_pan_display(struct fb_var_screeninfo *var,
95 struct fb_info *info);
96static void atafb_fillrect(struct fb_info *info,
97 const struct fb_fillrect *rect);
98static void atafb_copyarea(struct fb_info *info,
99 const struct fb_copyarea *region);
100static void atafb_imageblit(struct fb_info *info, const struct fb_image *image);
101static int atafb_ioctl(struct fb_info *info, unsigned int cmd,
102 unsigned long arg);
103
90 104
91static int default_par=0; /* default resolution (0=none) */ 105static int default_par; /* default resolution (0=none) */
92 106
93static unsigned long default_mem_req=0; 107static unsigned long default_mem_req;
94 108
95static int hwscroll=-1; 109static int hwscroll = -1;
96 110
97static int use_hwscroll = 1; 111static int use_hwscroll = 1;
98 112
99static int sttt_xres=640,st_yres=400,tt_yres=480; 113static int sttt_xres = 640, st_yres = 400, tt_yres = 480;
100static int sttt_xres_virtual=640,sttt_yres_virtual=400; 114static int sttt_xres_virtual = 640, sttt_yres_virtual = 400;
101static int ovsc_offset=0, ovsc_addlen=0; 115static int ovsc_offset, ovsc_addlen;
116
117 /*
118 * Hardware parameters for current mode
119 */
102 120
103static struct atafb_par { 121static struct atafb_par {
104 void *screen_base; 122 void *screen_base;
105 int yres_virtual; 123 int yres_virtual;
124 u_long next_line;
125 u_long next_plane;
106#if defined ATAFB_TT || defined ATAFB_STE 126#if defined ATAFB_TT || defined ATAFB_STE
107 union { 127 union {
108 struct { 128 struct {
@@ -138,7 +158,7 @@ static struct atafb_par {
138/* Don't calculate an own resolution, and thus don't change the one found when 158/* Don't calculate an own resolution, and thus don't change the one found when
139 * booting (currently used for the Falcon to keep settings for internal video 159 * booting (currently used for the Falcon to keep settings for internal video
140 * hardware extensions (e.g. ScreenBlaster) */ 160 * hardware extensions (e.g. ScreenBlaster) */
141static int DontCalcRes = 0; 161static int DontCalcRes = 0;
142 162
143#ifdef ATAFB_FALCON 163#ifdef ATAFB_FALCON
144#define HHT hw.falcon.hht 164#define HHT hw.falcon.hht
@@ -163,83 +183,84 @@ static int DontCalcRes = 0;
163#define VMO_PREMASK 0x0c 183#define VMO_PREMASK 0x0c
164#endif 184#endif
165 185
166static struct fb_info fb_info; 186static struct fb_info fb_info = {
187 .fix = {
188 .id = "Atari ",
189 .visual = FB_VISUAL_PSEUDOCOLOR,
190 .accel = FB_ACCEL_NONE,
191 }
192};
167 193
168static void *screen_base; /* base address of screen */ 194static void *screen_base; /* base address of screen */
169static void *real_screen_base; /* (only for Overscan) */ 195static void *real_screen_base; /* (only for Overscan) */
170 196
171static int screen_len; 197static int screen_len;
172 198
173static int current_par_valid=0; 199static int current_par_valid;
174 200
175static int mono_moni=0; 201static int mono_moni;
176
177static struct display disp;
178 202
179 203
180#ifdef ATAFB_EXT 204#ifdef ATAFB_EXT
181/* external video handling */
182 205
183static unsigned external_xres; 206/* external video handling */
184static unsigned external_xres_virtual; 207static unsigned int external_xres;
185static unsigned external_yres; 208static unsigned int external_xres_virtual;
186/* not needed - atafb will never support panning/hardwarescroll with external 209static unsigned int external_yres;
187 * static unsigned external_yres_virtual;
188*/
189 210
190static unsigned external_depth; 211/*
191static int external_pmode; 212 * not needed - atafb will never support panning/hardwarescroll with external
192static void *external_addr = 0; 213 * static unsigned int external_yres_virtual;
193static unsigned long external_len; 214 */
194static unsigned long external_vgaiobase = 0; 215static unsigned int external_depth;
195static unsigned int external_bitspercol = 6; 216static int external_pmode;
196 217static void *external_addr;
197/* 218static unsigned long external_len;
198JOE <joe@amber.dinoco.de>: 219static unsigned long external_vgaiobase;
199added card type for external driver, is only needed for 220static unsigned int external_bitspercol = 6;
200colormap handling.
201*/
202 221
222/*
223 * JOE <joe@amber.dinoco.de>:
224 * added card type for external driver, is only needed for
225 * colormap handling.
226 */
203enum cardtype { IS_VGA, IS_MV300 }; 227enum cardtype { IS_VGA, IS_MV300 };
204static enum cardtype external_card_type = IS_VGA; 228static enum cardtype external_card_type = IS_VGA;
205 229
206/* 230/*
207The MV300 mixes the color registers. So we need an array of munged 231 * The MV300 mixes the color registers. So we need an array of munged
208indices in order to access the correct reg. 232 * indices in order to access the correct reg.
209*/ 233 */
210static int MV300_reg_1bit[2]={0,1}; 234static int MV300_reg_1bit[2] = {
211static int MV300_reg_4bit[16]={ 235 0, 1
2120, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; 236};
213static int MV300_reg_8bit[256]={ 237static int MV300_reg_4bit[16] = {
2140, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 238 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
2158, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 239};
2164, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 240static int MV300_reg_8bit[256] = {
21712, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 241 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240,
2182, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 242 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248,
21910, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 243 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244,
2206, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 244 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252,
22114, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 245 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242,
2221, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 246 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250,
2239, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 247 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246,
2245, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 248 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254,
22513, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 249 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241,
2263, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 250 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249,
22711, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 251 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245,
2287, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 252 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253,
22915, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 }; 253 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243,
254 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251,
255 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247,
256 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255
257};
230 258
231static int *MV300_reg = MV300_reg_8bit; 259static int *MV300_reg = MV300_reg_8bit;
232
233/*
234And on the MV300 it's difficult to read out the hardware palette. So we
235just keep track of the set colors in our own array here, and use that!
236*/
237
238static struct { unsigned char red,green,blue,pad; } ext_color[256];
239#endif /* ATAFB_EXT */ 260#endif /* ATAFB_EXT */
240 261
241 262
242static int inverse=0; 263static int inverse;
243 264
244extern int fontheight_8x8; 265extern int fontheight_8x8;
245extern int fontwidth_8x8; 266extern int fontwidth_8x8;
@@ -249,96 +270,154 @@ extern int fontheight_8x16;
249extern int fontwidth_8x16; 270extern int fontwidth_8x16;
250extern unsigned char fontdata_8x16[]; 271extern unsigned char fontdata_8x16[];
251 272
273/*
274 * struct fb_ops {
275 * * open/release and usage marking
276 * struct module *owner;
277 * int (*fb_open)(struct fb_info *info, int user);
278 * int (*fb_release)(struct fb_info *info, int user);
279 *
280 * * For framebuffers with strange non linear layouts or that do not
281 * * work with normal memory mapped access
282 * ssize_t (*fb_read)(struct file *file, char __user *buf, size_t count, loff_t *ppos);
283 * ssize_t (*fb_write)(struct file *file, const char __user *buf, size_t count, loff_t *ppos);
284 *
285 * * checks var and eventually tweaks it to something supported,
286 * * DOES NOT MODIFY PAR *
287 * int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);
288 *
289 * * set the video mode according to info->var *
290 * int (*fb_set_par)(struct fb_info *info);
291 *
292 * * set color register *
293 * int (*fb_setcolreg)(unsigned int regno, unsigned int red, unsigned int green,
294 * unsigned int blue, unsigned int transp, struct fb_info *info);
295 *
296 * * set color registers in batch *
297 * int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info);
298 *
299 * * blank display *
300 * int (*fb_blank)(int blank, struct fb_info *info);
301 *
302 * * pan display *
303 * int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info);
304 *
305 * *** The meat of the drawing engine ***
306 * * Draws a rectangle *
307 * void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
308 * * Copy data from area to another *
309 * void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
310 * * Draws a image to the display *
311 * void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
312 *
313 * * Draws cursor *
314 * int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);
315 *
316 * * Rotates the display *
317 * void (*fb_rotate)(struct fb_info *info, int angle);
318 *
319 * * wait for blit idle, optional *
320 * int (*fb_sync)(struct fb_info *info);
321 *
322 * * perform fb specific ioctl (optional) *
323 * int (*fb_ioctl)(struct fb_info *info, unsigned int cmd,
324 * unsigned long arg);
325 *
326 * * Handle 32bit compat ioctl (optional) *
327 * int (*fb_compat_ioctl)(struct fb_info *info, unsigned int cmd,
328 * unsigned long arg);
329 *
330 * * perform fb specific mmap *
331 * int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma);
332 *
333 * * save current hardware state *
334 * void (*fb_save_state)(struct fb_info *info);
335 *
336 * * restore saved state *
337 * void (*fb_restore_state)(struct fb_info *info);
338 * } ;
339 */
340
341
252/* ++roman: This structure abstracts from the underlying hardware (ST(e), 342/* ++roman: This structure abstracts from the underlying hardware (ST(e),
253 * TT, or Falcon. 343 * TT, or Falcon.
254 * 344 *
255 * int (*detect)( void ) 345 * int (*detect)(void)
256 * This function should detect the current video mode settings and 346 * This function should detect the current video mode settings and
257 * store them in atafb_predefined[0] for later reference by the 347 * store them in atafb_predefined[0] for later reference by the
258 * user. Return the index+1 of an equivalent predefined mode or 0 348 * user. Return the index+1 of an equivalent predefined mode or 0
259 * if there is no such. 349 * if there is no such.
260 * 350 *
261 * int (*encode_fix)( struct fb_fix_screeninfo *fix, 351 * int (*encode_fix)(struct fb_fix_screeninfo *fix,
262 * struct atafb_par *par ) 352 * struct atafb_par *par)
263 * This function should fill in the 'fix' structure based on the 353 * This function should fill in the 'fix' structure based on the
264 * values in the 'par' structure. 354 * values in the 'par' structure.
265 * 355 * !!! Obsolete, perhaps !!!
266 * int (*decode_var)( struct fb_var_screeninfo *var, 356 *
267 * struct atafb_par *par ) 357 * int (*decode_var)(struct fb_var_screeninfo *var,
358 * struct atafb_par *par)
268 * Get the video params out of 'var'. If a value doesn't fit, round 359 * Get the video params out of 'var'. If a value doesn't fit, round
269 * it up, if it's too big, return EINVAL. 360 * it up, if it's too big, return EINVAL.
270 * Round up in the following order: bits_per_pixel, xres, yres, 361 * Round up in the following order: bits_per_pixel, xres, yres,
271 * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, 362 * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields,
272 * horizontal timing, vertical timing. 363 * horizontal timing, vertical timing.
273 * 364 *
274 * int (*encode_var)( struct fb_var_screeninfo *var, 365 * int (*encode_var)(struct fb_var_screeninfo *var,
275 * struct atafb_par *par ); 366 * struct atafb_par *par);
276 * Fill the 'var' structure based on the values in 'par' and maybe 367 * Fill the 'var' structure based on the values in 'par' and maybe
277 * other values read out of the hardware. 368 * other values read out of the hardware.
278 * 369 *
279 * void (*get_par)( struct atafb_par *par ) 370 * void (*get_par)(struct atafb_par *par)
280 * Fill the hardware's 'par' structure. 371 * Fill the hardware's 'par' structure.
281 * 372 * !!! Used only by detect() !!!
282 * void (*set_par)( struct atafb_par *par ) 373 *
374 * void (*set_par)(struct atafb_par *par)
283 * Set the hardware according to 'par'. 375 * Set the hardware according to 'par'.
284 *
285 * int (*getcolreg)( unsigned regno, unsigned *red,
286 * unsigned *green, unsigned *blue,
287 * unsigned *transp, struct fb_info *info )
288 * Read a single color register and split it into
289 * colors/transparent. Return != 0 for invalid regno.
290 * 376 *
291 * void (*set_screen_base)(void *s_base) 377 * void (*set_screen_base)(void *s_base)
292 * Set the base address of the displayed frame buffer. Only called 378 * Set the base address of the displayed frame buffer. Only called
293 * if yres_virtual > yres or xres_virtual > xres. 379 * if yres_virtual > yres or xres_virtual > xres.
294 * 380 *
295 * int (*blank)( int blank_mode ) 381 * int (*blank)(int blank_mode)
296 * Blank the screen if blank_mode!=0, else unblank. If blank==NULL then 382 * Blank the screen if blank_mode != 0, else unblank. If blank == NULL then
297 * the caller blanks by setting the CLUT to all black. Return 0 if blanking 383 * the caller blanks by setting the CLUT to all black. Return 0 if blanking
298 * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which 384 * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which
299 * doesn't support it. Implements VESA suspend and powerdown modes on 385 * doesn't support it. Implements VESA suspend and powerdown modes on
300 * hardware that supports disabling hsync/vsync: 386 * hardware that supports disabling hsync/vsync:
301 * blank_mode==2: suspend vsync, 3:suspend hsync, 4: powerdown. 387 * blank_mode == 2: suspend vsync, 3:suspend hsync, 4: powerdown.
302 */ 388 */
303 389
304static struct fb_hwswitch { 390static struct fb_hwswitch {
305 int (*detect)( void ); 391 int (*detect)(void);
306 int (*encode_fix)( struct fb_fix_screeninfo *fix, 392 int (*encode_fix)(struct fb_fix_screeninfo *fix,
307 struct atafb_par *par ); 393 struct atafb_par *par);
308 int (*decode_var)( struct fb_var_screeninfo *var, 394 int (*decode_var)(struct fb_var_screeninfo *var,
309 struct atafb_par *par ); 395 struct atafb_par *par);
310 int (*encode_var)( struct fb_var_screeninfo *var, 396 int (*encode_var)(struct fb_var_screeninfo *var,
311 struct atafb_par *par ); 397 struct atafb_par *par);
312 void (*get_par)( struct atafb_par *par ); 398 void (*get_par)(struct atafb_par *par);
313 void (*set_par)( struct atafb_par *par ); 399 void (*set_par)(struct atafb_par *par);
314 int (*getcolreg)( unsigned regno, unsigned *red,
315 unsigned *green, unsigned *blue,
316 unsigned *transp, struct fb_info *info );
317 void (*set_screen_base)(void *s_base); 400 void (*set_screen_base)(void *s_base);
318 int (*blank)( int blank_mode ); 401 int (*blank)(int blank_mode);
319 int (*pan_display)( struct fb_var_screeninfo *var, 402 int (*pan_display)(struct fb_var_screeninfo *var,
320 struct atafb_par *par); 403 struct fb_info *info);
321} *fbhw; 404} *fbhw;
322 405
323static char *autodetect_names[] = {"autodetect", NULL}; 406static char *autodetect_names[] = { "autodetect", NULL };
324static char *stlow_names[] = {"stlow", NULL}; 407static char *stlow_names[] = { "stlow", NULL };
325static char *stmid_names[] = {"stmid", "default5", NULL}; 408static char *stmid_names[] = { "stmid", "default5", NULL };
326static char *sthigh_names[] = {"sthigh", "default4", NULL}; 409static char *sthigh_names[] = { "sthigh", "default4", NULL };
327static char *ttlow_names[] = {"ttlow", NULL}; 410static char *ttlow_names[] = { "ttlow", NULL };
328static char *ttmid_names[]= {"ttmid", "default1", NULL}; 411static char *ttmid_names[] = { "ttmid", "default1", NULL };
329static char *tthigh_names[]= {"tthigh", "default2", NULL}; 412static char *tthigh_names[] = { "tthigh", "default2", NULL };
330static char *vga2_names[] = {"vga2", NULL}; 413static char *vga2_names[] = { "vga2", NULL };
331static char *vga4_names[] = {"vga4", NULL}; 414static char *vga4_names[] = { "vga4", NULL };
332static char *vga16_names[] = {"vga16", "default3", NULL}; 415static char *vga16_names[] = { "vga16", "default3", NULL };
333static char *vga256_names[] = {"vga256", NULL}; 416static char *vga256_names[] = { "vga256", NULL };
334static char *falh2_names[] = {"falh2", NULL}; 417static char *falh2_names[] = { "falh2", NULL };
335static char *falh16_names[] = {"falh16", NULL}; 418static char *falh16_names[] = { "falh16", NULL };
336 419
337static char **fb_var_names[] = { 420static char **fb_var_names[] = {
338 /* Writing the name arrays directly in this array (via "(char *[]){...}")
339 * crashes gcc 2.5.8 (sigsegv) if the inner array
340 * contains more than two items. I've also seen that all elements
341 * were identical to the last (my cross-gcc) :-(*/
342 autodetect_names, 421 autodetect_names,
343 stlow_names, 422 stlow_names,
344 stmid_names, 423 stmid_names,
@@ -353,18 +432,17 @@ static char **fb_var_names[] = {
353 falh2_names, 432 falh2_names,
354 falh16_names, 433 falh16_names,
355 NULL 434 NULL
356 /* ,NULL */ /* this causes a sigsegv on my gcc-2.5.8 */
357}; 435};
358 436
359static struct fb_var_screeninfo atafb_predefined[] = { 437static struct fb_var_screeninfo atafb_predefined[] = {
360 /* 438 /*
361 * yres_virtual==0 means use hw-scrolling if possible, else yres 439 * yres_virtual == 0 means use hw-scrolling if possible, else yres
362 */ 440 */
363 { /* autodetect */ 441 { /* autodetect */
364 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */ 442 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */
365 {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/ 443 {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/
366 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, 444 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
367 { /* st low */ 445 { /* st low */
368 320, 200, 320, 0, 0, 0, 4, 0, 446 320, 200, 320, 0, 0, 0, 4, 0,
369 {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 447 {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0},
370 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, 448 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -414,27 +492,100 @@ static struct fb_var_screeninfo atafb_predefined[] = {
414 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, 492 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
415}; 493};
416 494
417static int num_atafb_predefined=ARRAY_SIZE(atafb_predefined); 495static int num_atafb_predefined = ARRAY_SIZE(atafb_predefined);
418 496
497static struct fb_videomode atafb_modedb[] __initdata = {
498 /*
499 * Atari Video Modes
500 *
501 * If you change these, make sure to update DEFMODE_* as well!
502 */
419 503
420static int 504 /*
421get_video_mode(char *vname) 505 * ST/TT Video Modes
506 */
507
508 {
509 /* 320x200, 15 kHz, 60 Hz (ST low) */
510 "st-low", 60, 320, 200, 32000, 32, 16, 31, 14, 96, 4,
511 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
512 }, {
513 /* 640x200, 15 kHz, 60 Hz (ST medium) */
514 "st-mid", 60, 640, 200, 32000, 32, 16, 31, 14, 96, 4,
515 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
516 }, {
517 /* 640x400, 30.25 kHz, 63.5 Hz (ST high) */
518 "st-high", 63, 640, 400, 32000, 128, 0, 40, 14, 128, 4,
519 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
520 }, {
521 /* 320x480, 15 kHz, 60 Hz (TT low) */
522 "tt-low", 60, 320, 480, 31041, 120, 100, 8, 16, 140, 30,
523 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
524 }, {
525 /* 640x480, 29 kHz, 57 Hz (TT medium) */
526 "tt-mid", 60, 640, 480, 31041, 120, 100, 8, 16, 140, 30,
527 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
528 }, {
529 /* 1280x960, 29 kHz, 60 Hz (TT high) */
530 "tt-high", 57, 640, 960, 31041, 120, 100, 8, 16, 140, 30,
531 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
532 },
533
534 /*
535 * VGA Video Modes
536 */
537
538 {
539 /* 640x480, 31 kHz, 60 Hz (VGA) */
540 "vga", 63.5, 640, 480, 32000, 18, 42, 31, 11, 96, 3,
541 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
542 }, {
543 /* 640x400, 31 kHz, 70 Hz (VGA) */
544 "vga70", 70, 640, 400, 32000, 18, 42, 31, 11, 96, 3,
545 FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
546 },
547
548 /*
549 * Falcon HiRes Video Modes
550 */
551
552 {
553 /* 896x608, 31 kHz, 60 Hz (Falcon High) */
554 "falh", 60, 896, 608, 32000, 18, 42, 31, 1, 96,3,
555 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
556 },
557};
558
559#define NUM_TOTAL_MODES ARRAY_SIZE(atafb_modedb)
560
561static char *mode_option __initdata = NULL;
562
563 /* default modes */
564
565#define DEFMODE_TT 5 /* "tt-high" for TT */
566#define DEFMODE_F30 7 /* "vga70" for Falcon */
567#define DEFMODE_STE 2 /* "st-high" for ST/E */
568#define DEFMODE_EXT 6 /* "vga" for external */
569
570
571static int get_video_mode(char *vname)
422{ 572{
423 char ***name_list; 573 char ***name_list;
424 char **name; 574 char **name;
425 int i; 575 int i;
426 name_list=fb_var_names; 576
427 for (i = 0 ; i < num_atafb_predefined ; i++) { 577 name_list = fb_var_names;
428 name=*(name_list++); 578 for (i = 0; i < num_atafb_predefined; i++) {
429 if (! name || ! *name) 579 name = *name_list++;
430 break; 580 if (!name || !*name)
431 while (*name) { 581 break;
432 if (! strcmp(vname, *name)) 582 while (*name) {
433 return i+1; 583 if (!strcmp(vname, *name))
434 name++; 584 return i + 1;
585 name++;
586 }
435 } 587 }
436 } 588 return 0;
437 return 0;
438} 589}
439 590
440 591
@@ -443,93 +594,84 @@ get_video_mode(char *vname)
443 594
444#ifdef ATAFB_TT 595#ifdef ATAFB_TT
445 596
446static int tt_encode_fix( struct fb_fix_screeninfo *fix, 597static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
447 struct atafb_par *par )
448
449{ 598{
450 int mode; 599 int mode;
451 600
452 strcpy(fix->id,"Atari Builtin"); 601 strcpy(fix->id, "Atari Builtin");
453 fix->smem_start = (unsigned long)real_screen_base; 602 fix->smem_start = (unsigned long)real_screen_base;
454 fix->smem_len = screen_len; 603 fix->smem_len = screen_len;
455 fix->type=FB_TYPE_INTERLEAVED_PLANES; 604 fix->type = FB_TYPE_INTERLEAVED_PLANES;
456 fix->type_aux=2; 605 fix->type_aux = 2;
457 fix->visual=FB_VISUAL_PSEUDOCOLOR; 606 fix->visual = FB_VISUAL_PSEUDOCOLOR;
458 mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK; 607 mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK;
459 if (mode == TT_SHIFTER_TTHIGH || mode == TT_SHIFTER_STHIGH) { 608 if (mode == TT_SHIFTER_TTHIGH || mode == TT_SHIFTER_STHIGH) {
460 fix->type=FB_TYPE_PACKED_PIXELS; 609 fix->type = FB_TYPE_PACKED_PIXELS;
461 fix->type_aux=0; 610 fix->type_aux = 0;
462 if (mode == TT_SHIFTER_TTHIGH) 611 if (mode == TT_SHIFTER_TTHIGH)
463 fix->visual=FB_VISUAL_MONO01; 612 fix->visual = FB_VISUAL_MONO01;
464 } 613 }
465 fix->xpanstep=0; 614 fix->xpanstep = 0;
466 fix->ypanstep=1; 615 fix->ypanstep = 1;
467 fix->ywrapstep=0; 616 fix->ywrapstep = 0;
468 fix->line_length = 0; 617 fix->line_length = 0;
469 fix->accel = FB_ACCEL_ATARIBLITT; 618 fix->accel = FB_ACCEL_ATARIBLITT;
470 return 0; 619 return 0;
471} 620}
472 621
473 622static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
474static int tt_decode_var( struct fb_var_screeninfo *var,
475 struct atafb_par *par )
476{ 623{
477 int xres=var->xres; 624 int xres = var->xres;
478 int yres=var->yres; 625 int yres = var->yres;
479 int bpp=var->bits_per_pixel; 626 int bpp = var->bits_per_pixel;
480 int linelen; 627 int linelen;
481 int yres_virtual = var->yres_virtual; 628 int yres_virtual = var->yres_virtual;
482 629
483 if (mono_moni) { 630 if (mono_moni) {
484 if (bpp > 1 || xres > sttt_xres*2 || yres >tt_yres*2) 631 if (bpp > 1 || xres > sttt_xres * 2 || yres > tt_yres * 2)
485 return -EINVAL; 632 return -EINVAL;
486 par->hw.tt.mode=TT_SHIFTER_TTHIGH; 633 par->hw.tt.mode = TT_SHIFTER_TTHIGH;
487 xres=sttt_xres*2; 634 xres = sttt_xres * 2;
488 yres=tt_yres*2; 635 yres = tt_yres * 2;
489 bpp=1; 636 bpp = 1;
490 } else { 637 } else {
491 if (bpp > 8 || xres > sttt_xres || yres > tt_yres) 638 if (bpp > 8 || xres > sttt_xres || yres > tt_yres)
492 return -EINVAL; 639 return -EINVAL;
493 if (bpp > 4) { 640 if (bpp > 4) {
494 if (xres > sttt_xres/2 || yres > tt_yres) 641 if (xres > sttt_xres / 2 || yres > tt_yres)
495 return -EINVAL; 642 return -EINVAL;
496 par->hw.tt.mode=TT_SHIFTER_TTLOW; 643 par->hw.tt.mode = TT_SHIFTER_TTLOW;
497 xres=sttt_xres/2; 644 xres = sttt_xres / 2;
498 yres=tt_yres; 645 yres = tt_yres;
499 bpp=8; 646 bpp = 8;
500 } 647 } else if (bpp > 2) {
501 else if (bpp > 2) {
502 if (xres > sttt_xres || yres > tt_yres) 648 if (xres > sttt_xres || yres > tt_yres)
503 return -EINVAL; 649 return -EINVAL;
504 if (xres > sttt_xres/2 || yres > st_yres/2) { 650 if (xres > sttt_xres / 2 || yres > st_yres / 2) {
505 par->hw.tt.mode=TT_SHIFTER_TTMID; 651 par->hw.tt.mode = TT_SHIFTER_TTMID;
506 xres=sttt_xres; 652 xres = sttt_xres;
507 yres=tt_yres; 653 yres = tt_yres;
508 bpp=4; 654 bpp = 4;
509 } 655 } else {
510 else { 656 par->hw.tt.mode = TT_SHIFTER_STLOW;
511 par->hw.tt.mode=TT_SHIFTER_STLOW; 657 xres = sttt_xres / 2;
512 xres=sttt_xres/2; 658 yres = st_yres / 2;
513 yres=st_yres/2; 659 bpp = 4;
514 bpp=4;
515 } 660 }
516 } 661 } else if (bpp > 1) {
517 else if (bpp > 1) { 662 if (xres > sttt_xres || yres > st_yres / 2)
518 if (xres > sttt_xres || yres > st_yres/2)
519 return -EINVAL; 663 return -EINVAL;
520 par->hw.tt.mode=TT_SHIFTER_STMID; 664 par->hw.tt.mode = TT_SHIFTER_STMID;
521 xres=sttt_xres; 665 xres = sttt_xres;
522 yres=st_yres/2; 666 yres = st_yres / 2;
523 bpp=2; 667 bpp = 2;
524 } 668 } else if (var->xres > sttt_xres || var->yres > st_yres) {
525 else if (var->xres > sttt_xres || var->yres > st_yres) {
526 return -EINVAL; 669 return -EINVAL;
527 } 670 } else {
528 else { 671 par->hw.tt.mode = TT_SHIFTER_STHIGH;
529 par->hw.tt.mode=TT_SHIFTER_STHIGH; 672 xres = sttt_xres;
530 xres=sttt_xres; 673 yres = st_yres;
531 yres=st_yres; 674 bpp = 1;
532 bpp=1;
533 } 675 }
534 } 676 }
535 if (yres_virtual <= 0) 677 if (yres_virtual <= 0)
@@ -537,10 +679,10 @@ static int tt_decode_var( struct fb_var_screeninfo *var,
537 else if (yres_virtual < yres) 679 else if (yres_virtual < yres)
538 yres_virtual = yres; 680 yres_virtual = yres;
539 if (var->sync & FB_SYNC_EXT) 681 if (var->sync & FB_SYNC_EXT)
540 par->hw.tt.sync=0; 682 par->hw.tt.sync = 0;
541 else 683 else
542 par->hw.tt.sync=1; 684 par->hw.tt.sync = 1;
543 linelen=xres*bpp/8; 685 linelen = xres * bpp / 8;
544 if (yres_virtual * linelen > screen_len && screen_len) 686 if (yres_virtual * linelen > screen_len && screen_len)
545 return -EINVAL; 687 return -EINVAL;
546 if (yres * linelen > screen_len && screen_len) 688 if (yres * linelen > screen_len && screen_len)
@@ -552,154 +694,123 @@ static int tt_decode_var( struct fb_var_screeninfo *var,
552 return 0; 694 return 0;
553} 695}
554 696
555static int tt_encode_var( struct fb_var_screeninfo *var, 697static int tt_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
556 struct atafb_par *par )
557{ 698{
558 int linelen; 699 int linelen;
559 memset(var, 0, sizeof(struct fb_var_screeninfo)); 700 memset(var, 0, sizeof(struct fb_var_screeninfo));
560 var->red.offset=0; 701 var->red.offset = 0;
561 var->red.length=4; 702 var->red.length = 4;
562 var->red.msb_right=0; 703 var->red.msb_right = 0;
563 var->grayscale=0; 704 var->grayscale = 0;
564 705
565 var->pixclock=31041; 706 var->pixclock = 31041;
566 var->left_margin=120; /* these may be incorrect */ 707 var->left_margin = 120; /* these may be incorrect */
567 var->right_margin=100; 708 var->right_margin = 100;
568 var->upper_margin=8; 709 var->upper_margin = 8;
569 var->lower_margin=16; 710 var->lower_margin = 16;
570 var->hsync_len=140; 711 var->hsync_len = 140;
571 var->vsync_len=30; 712 var->vsync_len = 30;
572 713
573 var->height=-1; 714 var->height = -1;
574 var->width=-1; 715 var->width = -1;
575 716
576 if (par->hw.tt.sync & 1) 717 if (par->hw.tt.sync & 1)
577 var->sync=0; 718 var->sync = 0;
578 else 719 else
579 var->sync=FB_SYNC_EXT; 720 var->sync = FB_SYNC_EXT;
580 721
581 switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) { 722 switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) {
582 case TT_SHIFTER_STLOW: 723 case TT_SHIFTER_STLOW:
583 var->xres=sttt_xres/2; 724 var->xres = sttt_xres / 2;
584 var->xres_virtual=sttt_xres_virtual/2; 725 var->xres_virtual = sttt_xres_virtual / 2;
585 var->yres=st_yres/2; 726 var->yres = st_yres / 2;
586 var->bits_per_pixel=4; 727 var->bits_per_pixel = 4;
587 break; 728 break;
588 case TT_SHIFTER_STMID: 729 case TT_SHIFTER_STMID:
589 var->xres=sttt_xres; 730 var->xres = sttt_xres;
590 var->xres_virtual=sttt_xres_virtual; 731 var->xres_virtual = sttt_xres_virtual;
591 var->yres=st_yres/2; 732 var->yres = st_yres / 2;
592 var->bits_per_pixel=2; 733 var->bits_per_pixel = 2;
593 break; 734 break;
594 case TT_SHIFTER_STHIGH: 735 case TT_SHIFTER_STHIGH:
595 var->xres=sttt_xres; 736 var->xres = sttt_xres;
596 var->xres_virtual=sttt_xres_virtual; 737 var->xres_virtual = sttt_xres_virtual;
597 var->yres=st_yres; 738 var->yres = st_yres;
598 var->bits_per_pixel=1; 739 var->bits_per_pixel = 1;
599 break; 740 break;
600 case TT_SHIFTER_TTLOW: 741 case TT_SHIFTER_TTLOW:
601 var->xres=sttt_xres/2; 742 var->xres = sttt_xres / 2;
602 var->xres_virtual=sttt_xres_virtual/2; 743 var->xres_virtual = sttt_xres_virtual / 2;
603 var->yres=tt_yres; 744 var->yres = tt_yres;
604 var->bits_per_pixel=8; 745 var->bits_per_pixel = 8;
605 break; 746 break;
606 case TT_SHIFTER_TTMID: 747 case TT_SHIFTER_TTMID:
607 var->xres=sttt_xres; 748 var->xres = sttt_xres;
608 var->xres_virtual=sttt_xres_virtual; 749 var->xres_virtual = sttt_xres_virtual;
609 var->yres=tt_yres; 750 var->yres = tt_yres;
610 var->bits_per_pixel=4; 751 var->bits_per_pixel = 4;
611 break; 752 break;
612 case TT_SHIFTER_TTHIGH: 753 case TT_SHIFTER_TTHIGH:
613 var->red.length=0; 754 var->red.length = 0;
614 var->xres=sttt_xres*2; 755 var->xres = sttt_xres * 2;
615 var->xres_virtual=sttt_xres_virtual*2; 756 var->xres_virtual = sttt_xres_virtual * 2;
616 var->yres=tt_yres*2; 757 var->yres = tt_yres * 2;
617 var->bits_per_pixel=1; 758 var->bits_per_pixel = 1;
618 break; 759 break;
619 } 760 }
620 var->blue=var->green=var->red; 761 var->blue = var->green = var->red;
621 var->transp.offset=0; 762 var->transp.offset = 0;
622 var->transp.length=0; 763 var->transp.length = 0;
623 var->transp.msb_right=0; 764 var->transp.msb_right = 0;
624 linelen=var->xres_virtual * var->bits_per_pixel / 8; 765 linelen = var->xres_virtual * var->bits_per_pixel / 8;
625 if (! use_hwscroll) 766 if (!use_hwscroll)
626 var->yres_virtual=var->yres; 767 var->yres_virtual = var->yres;
627 else if (screen_len) { 768 else if (screen_len) {
628 if (par->yres_virtual) 769 if (par->yres_virtual)
629 var->yres_virtual = par->yres_virtual; 770 var->yres_virtual = par->yres_virtual;
630 else 771 else
631 /* yres_virtual==0 means use maximum */ 772 /* yres_virtual == 0 means use maximum */
632 var->yres_virtual = screen_len / linelen; 773 var->yres_virtual = screen_len / linelen;
633 } else { 774 } else {
634 if (hwscroll < 0) 775 if (hwscroll < 0)
635 var->yres_virtual = 2 * var->yres; 776 var->yres_virtual = 2 * var->yres;
636 else 777 else
637 var->yres_virtual=var->yres+hwscroll * 16; 778 var->yres_virtual = var->yres + hwscroll * 16;
638 } 779 }
639 var->xoffset=0; 780 var->xoffset = 0;
640 if (screen_base) 781 if (screen_base)
641 var->yoffset=(par->screen_base - screen_base)/linelen; 782 var->yoffset = (par->screen_base - screen_base) / linelen;
642 else 783 else
643 var->yoffset=0; 784 var->yoffset = 0;
644 var->nonstd=0; 785 var->nonstd = 0;
645 var->activate=0; 786 var->activate = 0;
646 var->vmode=FB_VMODE_NONINTERLACED; 787 var->vmode = FB_VMODE_NONINTERLACED;
647 return 0; 788 return 0;
648} 789}
649 790
650 791static void tt_get_par(struct atafb_par *par)
651static void tt_get_par( struct atafb_par *par )
652{ 792{
653 unsigned long addr; 793 unsigned long addr;
654 par->hw.tt.mode=shifter_tt.tt_shiftmode; 794 par->hw.tt.mode = shifter_tt.tt_shiftmode;
655 par->hw.tt.sync=shifter.syncmode; 795 par->hw.tt.sync = shifter.syncmode;
656 addr = ((shifter.bas_hi & 0xff) << 16) | 796 addr = ((shifter.bas_hi & 0xff) << 16) |
657 ((shifter.bas_md & 0xff) << 8) | 797 ((shifter.bas_md & 0xff) << 8) |
658 ((shifter.bas_lo & 0xff)); 798 ((shifter.bas_lo & 0xff));
659 par->screen_base = phys_to_virt(addr); 799 par->screen_base = phys_to_virt(addr);
660} 800}
661 801
662static void tt_set_par( struct atafb_par *par ) 802static void tt_set_par(struct atafb_par *par)
663{ 803{
664 shifter_tt.tt_shiftmode=par->hw.tt.mode; 804 shifter_tt.tt_shiftmode = par->hw.tt.mode;
665 shifter.syncmode=par->hw.tt.sync; 805 shifter.syncmode = par->hw.tt.sync;
666 /* only set screen_base if really necessary */ 806 /* only set screen_base if really necessary */
667 if (current_par.screen_base != par->screen_base) 807 if (current_par.screen_base != par->screen_base)
668 fbhw->set_screen_base(par->screen_base); 808 fbhw->set_screen_base(par->screen_base);
669} 809}
670 810
671 811static int tt_setcolreg(unsigned int regno, unsigned int red,
672static int tt_getcolreg(unsigned regno, unsigned *red, 812 unsigned int green, unsigned int blue,
673 unsigned *green, unsigned *blue, 813 unsigned int transp, struct fb_info *info)
674 unsigned *transp, struct fb_info *info)
675{
676 int t, col;
677
678 if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH)
679 regno += 254;
680 if (regno > 255)
681 return 1;
682 t = tt_palette[regno];
683 col = t & 15;
684 col |= col << 4;
685 col |= col << 8;
686 *blue = col;
687 col = (t >> 4) & 15;
688 col |= col << 4;
689 col |= col << 8;
690 *green = col;
691 col = (t >> 8) & 15;
692 col |= col << 4;
693 col |= col << 8;
694 *red = col;
695 *transp = 0;
696 return 0;
697}
698
699
700static int tt_setcolreg(unsigned regno, unsigned red,
701 unsigned green, unsigned blue,
702 unsigned transp, struct fb_info *info)
703{ 814{
704 if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) 815 if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH)
705 regno += 254; 816 regno += 254;
@@ -708,15 +819,14 @@ static int tt_setcolreg(unsigned regno, unsigned red,
708 tt_palette[regno] = (((red >> 12) << 8) | ((green >> 12) << 4) | 819 tt_palette[regno] = (((red >> 12) << 8) | ((green >> 12) << 4) |
709 (blue >> 12)); 820 (blue >> 12));
710 if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == 821 if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) ==
711 TT_SHIFTER_STHIGH && regno == 254) 822 TT_SHIFTER_STHIGH && regno == 254)
712 tt_palette[0] = 0; 823 tt_palette[0] = 0;
713 return 0; 824 return 0;
714} 825}
715 826
716 827static int tt_detect(void)
717static int tt_detect( void ) 828{
718 829 struct atafb_par par;
719{ struct atafb_par par;
720 830
721 /* Determine the connected monitor: The DMA sound must be 831 /* Determine the connected monitor: The DMA sound must be
722 * disabled before reading the MFP GPIP, because the Sound 832 * disabled before reading the MFP GPIP, because the Sound
@@ -726,9 +836,9 @@ static int tt_detect( void )
726 * announced that the Eagle is TT compatible, but only the PCM is 836 * announced that the Eagle is TT compatible, but only the PCM is
727 * missing... 837 * missing...
728 */ 838 */
729 if (ATARIHW_PRESENT(PCM_8BIT)) { 839 if (ATARIHW_PRESENT(PCM_8BIT)) {
730 tt_dmasnd.ctrl = DMASND_CTRL_OFF; 840 tt_dmasnd.ctrl = DMASND_CTRL_OFF;
731 udelay(20); /* wait a while for things to settle down */ 841 udelay(20); /* wait a while for things to settle down */
732 } 842 }
733 mono_moni = (mfp.par_dt_reg & 0x80) == 0; 843 mono_moni = (mfp.par_dt_reg & 0x80) == 0;
734 844
@@ -755,19 +865,24 @@ static struct pixel_clock {
755 unsigned long f; /* f/[Hz] */ 865 unsigned long f; /* f/[Hz] */
756 unsigned long t; /* t/[ps] (=1/f) */ 866 unsigned long t; /* t/[ps] (=1/f) */
757 int right, hsync, left; /* standard timing in clock cycles, not pixel */ 867 int right, hsync, left; /* standard timing in clock cycles, not pixel */
758 /* hsync initialized in falcon_detect() */ 868 /* hsync initialized in falcon_detect() */
759 int sync_mask; /* or-mask for hw.falcon.sync to set this clock */ 869 int sync_mask; /* or-mask for hw.falcon.sync to set this clock */
760 int control_mask; /* ditto, for hw.falcon.vid_control */ 870 int control_mask; /* ditto, for hw.falcon.vid_control */
761} 871} f25 = {
762f25 = {25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25}, 872 25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25
763f32 = {32000000, 31250, 18, 0, 42, 0x0, 0}, 873}, f32 = {
764fext = { 0, 0, 18, 0, 42, 0x1, 0}; 874 32000000, 31250, 18, 0, 42, 0x0, 0
875}, fext = {
876 0, 0, 18, 0, 42, 0x1, 0
877};
765 878
766/* VIDEL-prescale values [mon_type][pixel_length from VCO] */ 879/* VIDEL-prescale values [mon_type][pixel_length from VCO] */
767static int vdl_prescale[4][3] = {{4,2,1}, {4,2,1}, {4,2,2}, {4,2,1}}; 880static int vdl_prescale[4][3] = {
881 { 4,2,1 }, { 4,2,1 }, { 4,2,2 }, { 4,2,1 }
882};
768 883
769/* Default hsync timing [mon_type] in picoseconds */ 884/* Default hsync timing [mon_type] in picoseconds */
770static long h_syncs[4] = {3000000, 4875000, 4000000, 4875000}; 885static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 };
771 886
772#ifdef FBCON_HAS_CFB16 887#ifdef FBCON_HAS_CFB16
773static u16 fbcon_cfb16_cmap[16]; 888static u16 fbcon_cfb16_cmap[16];
@@ -775,12 +890,12 @@ static u16 fbcon_cfb16_cmap[16];
775 890
776static inline int hxx_prescale(struct falcon_hw *hw) 891static inline int hxx_prescale(struct falcon_hw *hw)
777{ 892{
778 return hw->ste_mode ? 16 : 893 return hw->ste_mode ? 16
779 vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; 894 : vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3];
780} 895}
781 896
782static int falcon_encode_fix( struct fb_fix_screeninfo *fix, 897static int falcon_encode_fix(struct fb_fix_screeninfo *fix,
783 struct atafb_par *par ) 898 struct atafb_par *par)
784{ 899{
785 strcpy(fix->id, "Atari Builtin"); 900 strcpy(fix->id, "Atari Builtin");
786 fix->smem_start = (unsigned long)real_screen_base; 901 fix->smem_start = (unsigned long)real_screen_base;
@@ -796,8 +911,7 @@ static int falcon_encode_fix( struct fb_fix_screeninfo *fix,
796 fix->type_aux = 0; 911 fix->type_aux = 0;
797 /* no smooth scrolling with longword aligned video mem */ 912 /* no smooth scrolling with longword aligned video mem */
798 fix->xpanstep = 32; 913 fix->xpanstep = 32;
799 } 914 } else if (par->hw.falcon.f_shift & 0x100) {
800 else if (par->hw.falcon.f_shift & 0x100) {
801 fix->type = FB_TYPE_PACKED_PIXELS; 915 fix->type = FB_TYPE_PACKED_PIXELS;
802 fix->type_aux = 0; 916 fix->type_aux = 0;
803 /* Is this ok or should it be DIRECTCOLOR? */ 917 /* Is this ok or should it be DIRECTCOLOR? */
@@ -809,9 +923,8 @@ static int falcon_encode_fix( struct fb_fix_screeninfo *fix,
809 return 0; 923 return 0;
810} 924}
811 925
812 926static int falcon_decode_var(struct fb_var_screeninfo *var,
813static int falcon_decode_var( struct fb_var_screeninfo *var, 927 struct atafb_par *par)
814 struct atafb_par *par )
815{ 928{
816 int bpp = var->bits_per_pixel; 929 int bpp = var->bits_per_pixel;
817 int xres = var->xres; 930 int xres = var->xres;
@@ -823,17 +936,19 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
823 int linelen; 936 int linelen;
824 int interlace = 0, doubleline = 0; 937 int interlace = 0, doubleline = 0;
825 struct pixel_clock *pclock; 938 struct pixel_clock *pclock;
826 int plen; /* width of pixel in clock cycles */ 939 int plen; /* width of pixel in clock cycles */
827 int xstretch; 940 int xstretch;
828 int prescale; 941 int prescale;
829 int longoffset = 0; 942 int longoffset = 0;
830 int hfreq, vfreq; 943 int hfreq, vfreq;
944 int hdb_off, hde_off, base_off;
945 int gstart, gend1, gend2, align;
831 946
832/* 947/*
833 Get the video params out of 'var'. If a value doesn't fit, round 948 Get the video params out of 'var'. If a value doesn't fit, round
834 it up, if it's too big, return EINVAL. 949 it up, if it's too big, return EINVAL.
835 Round up in the following order: bits_per_pixel, xres, yres, 950 Round up in the following order: bits_per_pixel, xres, yres,
836 xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, 951 xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields,
837 horizontal timing, vertical timing. 952 horizontal timing, vertical timing.
838 953
839 There is a maximum of screen resolution determined by pixelclock 954 There is a maximum of screen resolution determined by pixelclock
@@ -843,11 +958,11 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
843 Frequency range for multisync monitors is given via command line. 958 Frequency range for multisync monitors is given via command line.
844 For TV and SM124 both frequencies are fixed. 959 For TV and SM124 both frequencies are fixed.
845 960
846 X % 16 == 0 to fit 8x?? font (except 1 bitplane modes must use X%32==0) 961 X % 16 == 0 to fit 8x?? font (except 1 bitplane modes must use X%32 == 0)
847 Y % 16 == 0 to fit 8x16 font 962 Y % 16 == 0 to fit 8x16 font
848 Y % 8 == 0 if Y<400 963 Y % 8 == 0 if Y<400
849 964
850 Currently interlace and doubleline mode in var are ignored. 965 Currently interlace and doubleline mode in var are ignored.
851 On SM124 and TV only the standard resolutions can be used. 966 On SM124 and TV only the standard resolutions can be used.
852*/ 967*/
853 968
@@ -855,43 +970,38 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
855 if (!xres || !yres || !bpp) 970 if (!xres || !yres || !bpp)
856 return -EINVAL; 971 return -EINVAL;
857 972
858 if (mon_type == F_MON_SM && bpp != 1) { 973 if (mon_type == F_MON_SM && bpp != 1)
859 return -EINVAL; 974 return -EINVAL;
860 } 975
861 else if (bpp <= 1) { 976 if (bpp <= 1) {
862 bpp = 1; 977 bpp = 1;
863 par->hw.falcon.f_shift = 0x400; 978 par->hw.falcon.f_shift = 0x400;
864 par->hw.falcon.st_shift = 0x200; 979 par->hw.falcon.st_shift = 0x200;
865 } 980 } else if (bpp <= 2) {
866 else if (bpp <= 2) {
867 bpp = 2; 981 bpp = 2;
868 par->hw.falcon.f_shift = 0x000; 982 par->hw.falcon.f_shift = 0x000;
869 par->hw.falcon.st_shift = 0x100; 983 par->hw.falcon.st_shift = 0x100;
870 } 984 } else if (bpp <= 4) {
871 else if (bpp <= 4) {
872 bpp = 4; 985 bpp = 4;
873 par->hw.falcon.f_shift = 0x000; 986 par->hw.falcon.f_shift = 0x000;
874 par->hw.falcon.st_shift = 0x000; 987 par->hw.falcon.st_shift = 0x000;
875 } 988 } else if (bpp <= 8) {
876 else if (bpp <= 8) {
877 bpp = 8; 989 bpp = 8;
878 par->hw.falcon.f_shift = 0x010; 990 par->hw.falcon.f_shift = 0x010;
879 } 991 } else if (bpp <= 16) {
880 else if (bpp <= 16) { 992 bpp = 16; /* packed pixel mode */
881 bpp = 16; /* packed pixel mode */ 993 par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */
882 par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */ 994 } else
883 }
884 else
885 return -EINVAL; 995 return -EINVAL;
886 par->hw.falcon.bpp = bpp; 996 par->hw.falcon.bpp = bpp;
887 997
888 if (mon_type == F_MON_SM || DontCalcRes) { 998 if (mon_type == F_MON_SM || DontCalcRes) {
889 /* Skip all calculations. VGA/TV/SC1224 only supported. */ 999 /* Skip all calculations. VGA/TV/SC1224 only supported. */
890 struct fb_var_screeninfo *myvar = &atafb_predefined[0]; 1000 struct fb_var_screeninfo *myvar = &atafb_predefined[0];
891 1001
892 if (bpp > myvar->bits_per_pixel || 1002 if (bpp > myvar->bits_per_pixel ||
893 var->xres > myvar->xres || 1003 var->xres > myvar->xres ||
894 var->yres > myvar->yres) 1004 var->yres > myvar->yres)
895 return -EINVAL; 1005 return -EINVAL;
896 fbhw->get_par(par); /* Current par will be new par */ 1006 fbhw->get_par(par); /* Current par will be new par */
897 goto set_screen_base; /* Don't forget this */ 1007 goto set_screen_base; /* Don't forget this */
@@ -910,8 +1020,8 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
910 yres = 400; 1020 yres = 400;
911 1021
912 /* 2 planes must use STE compatibility mode */ 1022 /* 2 planes must use STE compatibility mode */
913 par->hw.falcon.ste_mode = bpp==2; 1023 par->hw.falcon.ste_mode = bpp == 2;
914 par->hw.falcon.mono = bpp==1; 1024 par->hw.falcon.mono = bpp == 1;
915 1025
916 /* Total and visible scanline length must be a multiple of one longword, 1026 /* Total and visible scanline length must be a multiple of one longword,
917 * this and the console fontwidth yields the alignment for xres and 1027 * this and the console fontwidth yields the alignment for xres and
@@ -967,8 +1077,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
967 left_margin = hsync_len = 128 / plen; 1077 left_margin = hsync_len = 128 / plen;
968 right_margin = 0; 1078 right_margin = 0;
969 /* TODO set all margins */ 1079 /* TODO set all margins */
970 } 1080 } else
971 else
972#endif 1081#endif
973 if (mon_type == F_MON_SC || mon_type == F_MON_TV) { 1082 if (mon_type == F_MON_SC || mon_type == F_MON_TV) {
974 plen = 2 * xstretch; 1083 plen = 2 * xstretch;
@@ -1002,26 +1111,24 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1002 vsync_len *= 2; 1111 vsync_len *= 2;
1003 } 1112 }
1004 } 1113 }
1005 } 1114 } else { /* F_MON_VGA */
1006 else
1007 { /* F_MON_VGA */
1008 if (bpp == 16) 1115 if (bpp == 16)
1009 xstretch = 2; /* Double pixel width only for hicolor */ 1116 xstretch = 2; /* Double pixel width only for hicolor */
1010 /* Default values are used for vert./hor. timing if no pixelclock given. */ 1117 /* Default values are used for vert./hor. timing if no pixelclock given. */
1011 if (var->pixclock == 0) { 1118 if (var->pixclock == 0) {
1012 int linesize; 1119 int linesize;
1013 1120
1014 /* Choose master pixelclock depending on hor. timing */ 1121 /* Choose master pixelclock depending on hor. timing */
1015 plen = 1 * xstretch; 1122 plen = 1 * xstretch;
1016 if ((plen * xres + f25.right+f25.hsync+f25.left) * 1123 if ((plen * xres + f25.right + f25.hsync + f25.left) *
1017 fb_info.monspecs.hfmin < f25.f) 1124 fb_info.monspecs.hfmin < f25.f)
1018 pclock = &f25; 1125 pclock = &f25;
1019 else if ((plen * xres + f32.right+f32.hsync+f32.left) * 1126 else if ((plen * xres + f32.right + f32.hsync +
1020 fb_info.monspecs.hfmin < f32.f) 1127 f32.left) * fb_info.monspecs.hfmin < f32.f)
1021 pclock = &f32; 1128 pclock = &f32;
1022 else if ((plen * xres + fext.right+fext.hsync+fext.left) * 1129 else if ((plen * xres + fext.right + fext.hsync +
1023 fb_info.monspecs.hfmin < fext.f 1130 fext.left) * fb_info.monspecs.hfmin < fext.f &&
1024 && fext.f) 1131 fext.f)
1025 pclock = &fext; 1132 pclock = &fext;
1026 else 1133 else
1027 return -EINVAL; 1134 return -EINVAL;
@@ -1033,22 +1140,24 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1033 upper_margin = 31; 1140 upper_margin = 31;
1034 lower_margin = 11; 1141 lower_margin = 11;
1035 vsync_len = 3; 1142 vsync_len = 3;
1036 } 1143 } else {
1037 else {
1038 /* Choose largest pixelclock <= wanted clock */ 1144 /* Choose largest pixelclock <= wanted clock */
1039 int i; 1145 int i;
1040 unsigned long pcl = ULONG_MAX; 1146 unsigned long pcl = ULONG_MAX;
1041 pclock = 0; 1147 pclock = 0;
1042 for (i=1; i <= 4; i *= 2) { 1148 for (i = 1; i <= 4; i *= 2) {
1043 if (f25.t*i >= var->pixclock && f25.t*i < pcl) { 1149 if (f25.t * i >= var->pixclock &&
1150 f25.t * i < pcl) {
1044 pcl = f25.t * i; 1151 pcl = f25.t * i;
1045 pclock = &f25; 1152 pclock = &f25;
1046 } 1153 }
1047 if (f32.t*i >= var->pixclock && f32.t*i < pcl) { 1154 if (f32.t * i >= var->pixclock &&
1155 f32.t * i < pcl) {
1048 pcl = f32.t * i; 1156 pcl = f32.t * i;
1049 pclock = &f32; 1157 pclock = &f32;
1050 } 1158 }
1051 if (fext.t && fext.t*i >= var->pixclock && fext.t*i < pcl) { 1159 if (fext.t && fext.t * i >= var->pixclock &&
1160 fext.t * i < pcl) {
1052 pcl = fext.t * i; 1161 pcl = fext.t * i;
1053 pclock = &fext; 1162 pclock = &fext;
1054 } 1163 }
@@ -1070,8 +1179,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1070 upper_margin = (upper_margin + 1) / 2; 1179 upper_margin = (upper_margin + 1) / 2;
1071 lower_margin = (lower_margin + 1) / 2; 1180 lower_margin = (lower_margin + 1) / 2;
1072 vsync_len = (vsync_len + 1) / 2; 1181 vsync_len = (vsync_len + 1) / 2;
1073 } 1182 } else if (var->vmode & FB_VMODE_DOUBLE) {
1074 else if (var->vmode & FB_VMODE_DOUBLE) {
1075 /* External unit is [double lines per frame] */ 1183 /* External unit is [double lines per frame] */
1076 upper_margin *= 2; 1184 upper_margin *= 2;
1077 lower_margin *= 2; 1185 lower_margin *= 2;
@@ -1079,7 +1187,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1079 } 1187 }
1080 } 1188 }
1081 if (pclock == &fext) 1189 if (pclock == &fext)
1082 longoffset = 1; /* VIDEL doesn't synchronize on short offset */ 1190 longoffset = 1; /* VIDEL doesn't synchronize on short offset */
1083 } 1191 }
1084 /* Is video bus bandwidth (32MB/s) too low for this resolution? */ 1192 /* Is video bus bandwidth (32MB/s) too low for this resolution? */
1085 /* this is definitely wrong if bus clock != 32MHz */ 1193 /* this is definitely wrong if bus clock != 32MHz */
@@ -1098,7 +1206,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1098 * between interlace and non-interlace without messing around 1206 * between interlace and non-interlace without messing around
1099 * with these. 1207 * with these.
1100 */ 1208 */
1101 again: 1209again:
1102 /* Set base_offset 128 and video bus width */ 1210 /* Set base_offset 128 and video bus width */
1103 par->hw.falcon.vid_control = mon_type | f030_bus_width; 1211 par->hw.falcon.vid_control = mon_type | f030_bus_width;
1104 if (!longoffset) 1212 if (!longoffset)
@@ -1112,37 +1220,34 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1112 /* External or internal clock */ 1220 /* External or internal clock */
1113 par->hw.falcon.sync = pclock->sync_mask | 0x2; 1221 par->hw.falcon.sync = pclock->sync_mask | 0x2;
1114 /* Pixellength and prescale */ 1222 /* Pixellength and prescale */
1115 par->hw.falcon.vid_mode = (2/plen) << 2; 1223 par->hw.falcon.vid_mode = (2 / plen) << 2;
1116 if (doubleline) 1224 if (doubleline)
1117 par->hw.falcon.vid_mode |= VMO_DOUBLE; 1225 par->hw.falcon.vid_mode |= VMO_DOUBLE;
1118 if (interlace) 1226 if (interlace)
1119 par->hw.falcon.vid_mode |= VMO_INTER; 1227 par->hw.falcon.vid_mode |= VMO_INTER;
1120 1228
1121 /********************* 1229 /*********************
1122 Horizontal timing: unit = [master clock cycles] 1230 * Horizontal timing: unit = [master clock cycles]
1123 unit of hxx-registers: [master clock cycles * prescale] 1231 * unit of hxx-registers: [master clock cycles * prescale]
1124 Hxx-registers are 9 bit wide 1232 * Hxx-registers are 9 bit wide
1125 1233 *
1126 1 line = ((hht + 2) * 2 * prescale) clock cycles 1234 * 1 line = ((hht + 2) * 2 * prescale) clock cycles
1127 1235 *
1128 graphic output = hdb & 0x200 ? 1236 * graphic output = hdb & 0x200 ?
1129 ((hht+2)*2 - hdb + hde) * prescale - hdboff + hdeoff: 1237 * ((hht + 2) * 2 - hdb + hde) * prescale - hdboff + hdeoff:
1130 ( hht + 2 - hdb + hde) * prescale - hdboff + hdeoff 1238 * (hht + 2 - hdb + hde) * prescale - hdboff + hdeoff
1131 (this must be a multiple of plen*128/bpp, on VGA pixels 1239 * (this must be a multiple of plen*128/bpp, on VGA pixels
1132 to the right may be cut off with a bigger right margin) 1240 * to the right may be cut off with a bigger right margin)
1133 1241 *
1134 start of graphics relative to start of 1st halfline = hdb & 0x200 ? 1242 * start of graphics relative to start of 1st halfline = hdb & 0x200 ?
1135 (hdb - hht - 2) * prescale + hdboff : 1243 * (hdb - hht - 2) * prescale + hdboff :
1136 hdb * prescale + hdboff 1244 * hdb * prescale + hdboff
1137 1245 *
1138 end of graphics relative to start of 1st halfline = 1246 * end of graphics relative to start of 1st halfline =
1139 (hde + hht + 2) * prescale + hdeoff 1247 * (hde + hht + 2) * prescale + hdeoff
1140 *********************/ 1248 *********************/
1141 /* Calculate VIDEL registers */ 1249 /* Calculate VIDEL registers */
1142 { 1250{
1143 int hdb_off, hde_off, base_off;
1144 int gstart, gend1, gend2, align;
1145
1146 prescale = hxx_prescale(&par->hw.falcon); 1251 prescale = hxx_prescale(&par->hw.falcon);
1147 base_off = par->hw.falcon.vid_control & VCO_SHORTOFFS ? 64 : 128; 1252 base_off = par->hw.falcon.vid_control & VCO_SHORTOFFS ? 64 : 128;
1148 1253
@@ -1154,8 +1259,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1154 align = 1; 1259 align = 1;
1155 hde_off = 0; 1260 hde_off = 0;
1156 hdb_off = (base_off + 16 * plen) + prescale; 1261 hdb_off = (base_off + 16 * plen) + prescale;
1157 } 1262 } else {
1158 else {
1159 align = 128 / bpp; 1263 align = 128 / bpp;
1160 hde_off = ((128 / bpp + 2) * plen); 1264 hde_off = ((128 / bpp + 2) * plen);
1161 if (par->hw.falcon.ste_mode) 1265 if (par->hw.falcon.ste_mode)
@@ -1164,23 +1268,24 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1164 hdb_off = (base_off + (128 / bpp + 18) * plen) + prescale; 1268 hdb_off = (base_off + (128 / bpp + 18) * plen) + prescale;
1165 } 1269 }
1166 1270
1167 gstart = (prescale/2 + plen * left_margin) / prescale; 1271 gstart = (prescale / 2 + plen * left_margin) / prescale;
1168 /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ 1272 /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */
1169 gend1 = gstart + ((xres + align-1) / align)*align * plen / prescale; 1273 gend1 = gstart + ((xres + align - 1) / align) * align * plen / prescale;
1170 /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */ 1274 /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */
1171 gend2 = gstart + xres * plen / prescale; 1275 gend2 = gstart + xres * plen / prescale;
1172 par->HHT = plen * (left_margin + xres + right_margin) / 1276 par->HHT = plen * (left_margin + xres + right_margin) /
1173 (2 * prescale) - 2; 1277 (2 * prescale) - 2;
1174/* par->HHT = (gend2 + plen * right_margin / prescale) / 2 - 2;*/ 1278/* par->HHT = (gend2 + plen * right_margin / prescale) / 2 - 2;*/
1175 1279
1176 par->HDB = gstart - hdb_off/prescale; 1280 par->HDB = gstart - hdb_off / prescale;
1177 par->HBE = gstart; 1281 par->HBE = gstart;
1178 if (par->HDB < 0) par->HDB += par->HHT + 2 + 0x200; 1282 if (par->HDB < 0)
1179 par->HDE = gend1 - par->HHT - 2 - hde_off/prescale; 1283 par->HDB += par->HHT + 2 + 0x200;
1284 par->HDE = gend1 - par->HHT - 2 - hde_off / prescale;
1180 par->HBB = gend2 - par->HHT - 2; 1285 par->HBB = gend2 - par->HHT - 2;
1181#if 0 1286#if 0
1182 /* One more Videl constraint: data fetch of two lines must not overlap */ 1287 /* One more Videl constraint: data fetch of two lines must not overlap */
1183 if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) { 1288 if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) {
1184 /* if this happens increase margins, decrease hfreq. */ 1289 /* if this happens increase margins, decrease hfreq. */
1185 } 1290 }
1186#endif 1291#endif
@@ -1189,11 +1294,11 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1189 par->HSS = par->HHT + 2 - plen * hsync_len / prescale; 1294 par->HSS = par->HHT + 2 - plen * hsync_len / prescale;
1190 if (par->HSS < par->HBB) 1295 if (par->HSS < par->HBB)
1191 par->HSS = par->HBB; 1296 par->HSS = par->HBB;
1192 } 1297}
1193 1298
1194 /* check hor. frequency */ 1299 /* check hor. frequency */
1195 hfreq = pclock->f / ((par->HHT+2)*prescale*2); 1300 hfreq = pclock->f / ((par->HHT + 2) * prescale * 2);
1196 if (hfreq > fb_info.monspecs.hfmax && mon_type!=F_MON_VGA) { 1301 if (hfreq > fb_info.monspecs.hfmax && mon_type != F_MON_VGA) {
1197 /* ++guenther: ^^^^^^^^^^^^^^^^^^^ can't remember why I did this */ 1302 /* ++guenther: ^^^^^^^^^^^^^^^^^^^ can't remember why I did this */
1198 /* Too high -> enlarge margin */ 1303 /* Too high -> enlarge margin */
1199 left_margin += 1; 1304 left_margin += 1;
@@ -1213,12 +1318,14 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1213 par->VBE = (upper_margin * 2 + 1); /* must begin on odd halfline */ 1318 par->VBE = (upper_margin * 2 + 1); /* must begin on odd halfline */
1214 par->VDB = par->VBE; 1319 par->VDB = par->VBE;
1215 par->VDE = yres; 1320 par->VDE = yres;
1216 if (!interlace) par->VDE <<= 1; 1321 if (!interlace)
1217 if (doubleline) par->VDE <<= 1; /* VDE now half lines per (half-)frame */ 1322 par->VDE <<= 1;
1323 if (doubleline)
1324 par->VDE <<= 1; /* VDE now half lines per (half-)frame */
1218 par->VDE += par->VDB; 1325 par->VDE += par->VDB;
1219 par->VBB = par->VDE; 1326 par->VBB = par->VDE;
1220 par->VFT = par->VBB + (lower_margin * 2 - 1) - 1; 1327 par->VFT = par->VBB + (lower_margin * 2 - 1) - 1;
1221 par->VSS = par->VFT+1 - (vsync_len * 2 - 1); 1328 par->VSS = par->VFT + 1 - (vsync_len * 2 - 1);
1222 /* vbb,vss,vft must be even in interlace mode */ 1329 /* vbb,vss,vft must be even in interlace mode */
1223 if (interlace) { 1330 if (interlace) {
1224 par->VBB++; 1331 par->VBB++;
@@ -1229,55 +1336,53 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1229 /* V-frequency check, hope I didn't create any loop here. */ 1336 /* V-frequency check, hope I didn't create any loop here. */
1230 /* Interlace and doubleline are mutually exclusive. */ 1337 /* Interlace and doubleline are mutually exclusive. */
1231 vfreq = (hfreq * 2) / (par->VFT + 1); 1338 vfreq = (hfreq * 2) / (par->VFT + 1);
1232 if (vfreq > fb_info.monspecs.vfmax && !doubleline && !interlace) { 1339 if (vfreq > fb_info.monspecs.vfmax && !doubleline && !interlace) {
1233 /* Too high -> try again with doubleline */ 1340 /* Too high -> try again with doubleline */
1234 doubleline = 1; 1341 doubleline = 1;
1235 goto again; 1342 goto again;
1236 } 1343 } else if (vfreq < fb_info.monspecs.vfmin && !interlace && !doubleline) {
1237 else if (vfreq < fb_info.monspecs.vfmin && !interlace && !doubleline) {
1238 /* Too low -> try again with interlace */ 1344 /* Too low -> try again with interlace */
1239 interlace = 1; 1345 interlace = 1;
1240 goto again; 1346 goto again;
1241 } 1347 } else if (vfreq < fb_info.monspecs.vfmin && doubleline) {
1242 else if (vfreq < fb_info.monspecs.vfmin && doubleline) {
1243 /* Doubleline too low -> clear doubleline and enlarge margins */ 1348 /* Doubleline too low -> clear doubleline and enlarge margins */
1244 int lines; 1349 int lines;
1245 doubleline = 0; 1350 doubleline = 0;
1246 for (lines=0; 1351 for (lines = 0;
1247 (hfreq*2)/(par->VFT+1+4*lines-2*yres)>fb_info.monspecs.vfmax; 1352 (hfreq * 2) / (par->VFT + 1 + 4 * lines - 2 * yres) >
1353 fb_info.monspecs.vfmax;
1248 lines++) 1354 lines++)
1249 ; 1355 ;
1250 upper_margin += lines; 1356 upper_margin += lines;
1251 lower_margin += lines; 1357 lower_margin += lines;
1252 goto again; 1358 goto again;
1253 } 1359 } else if (vfreq > fb_info.monspecs.vfmax && doubleline) {
1254 else if (vfreq > fb_info.monspecs.vfmax && doubleline) {
1255 /* Doubleline too high -> enlarge margins */ 1360 /* Doubleline too high -> enlarge margins */
1256 int lines; 1361 int lines;
1257 for (lines=0; 1362 for (lines = 0;
1258 (hfreq*2)/(par->VFT+1+4*lines)>fb_info.monspecs.vfmax; 1363 (hfreq * 2) / (par->VFT + 1 + 4 * lines) >
1259 lines+=2) 1364 fb_info.monspecs.vfmax;
1365 lines += 2)
1260 ; 1366 ;
1261 upper_margin += lines; 1367 upper_margin += lines;
1262 lower_margin += lines; 1368 lower_margin += lines;
1263 goto again; 1369 goto again;
1264 } 1370 } else if (vfreq > fb_info.monspecs.vfmax && interlace) {
1265 else if (vfreq > fb_info.monspecs.vfmax && interlace) {
1266 /* Interlace, too high -> enlarge margins */ 1371 /* Interlace, too high -> enlarge margins */
1267 int lines; 1372 int lines;
1268 for (lines=0; 1373 for (lines = 0;
1269 (hfreq*2)/(par->VFT+1+4*lines)>fb_info.monspecs.vfmax; 1374 (hfreq * 2) / (par->VFT + 1 + 4 * lines) >
1375 fb_info.monspecs.vfmax;
1270 lines++) 1376 lines++)
1271 ; 1377 ;
1272 upper_margin += lines; 1378 upper_margin += lines;
1273 lower_margin += lines; 1379 lower_margin += lines;
1274 goto again; 1380 goto again;
1275 } 1381 } else if (vfreq < fb_info.monspecs.vfmin ||
1276 else if (vfreq < fb_info.monspecs.vfmin || 1382 vfreq > fb_info.monspecs.vfmax)
1277 vfreq > fb_info.monspecs.vfmax)
1278 return -EINVAL; 1383 return -EINVAL;
1279 1384
1280 set_screen_base: 1385set_screen_base:
1281 linelen = xres_virtual * bpp / 8; 1386 linelen = xres_virtual * bpp / 8;
1282 if (yres_virtual * linelen > screen_len && screen_len) 1387 if (yres_virtual * linelen > screen_len && screen_len)
1283 return -EINVAL; 1388 return -EINVAL;
@@ -1289,11 +1394,20 @@ static int falcon_decode_var( struct fb_var_screeninfo *var,
1289 par->screen_base = screen_base + var->yoffset * linelen; 1394 par->screen_base = screen_base + var->yoffset * linelen;
1290 par->hw.falcon.xoffset = 0; 1395 par->hw.falcon.xoffset = 0;
1291 1396
1397 // FIXME!!! sort of works, no crash
1398 //par->next_line = linelen;
1399 //par->next_plane = yres_virtual * linelen;
1400 par->next_line = linelen;
1401 par->next_plane = 2;
1402 // crashes
1403 //par->next_plane = linelen;
1404 //par->next_line = yres_virtual * linelen;
1405
1292 return 0; 1406 return 0;
1293} 1407}
1294 1408
1295static int falcon_encode_var( struct fb_var_screeninfo *var, 1409static int falcon_encode_var(struct fb_var_screeninfo *var,
1296 struct atafb_par *par ) 1410 struct atafb_par *par)
1297{ 1411{
1298/* !!! only for VGA !!! */ 1412/* !!! only for VGA !!! */
1299 int linelen; 1413 int linelen;
@@ -1306,10 +1420,10 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1306 var->pixclock = hw->sync & 0x1 ? fext.t : 1420 var->pixclock = hw->sync & 0x1 ? fext.t :
1307 hw->vid_control & VCO_CLOCK25 ? f25.t : f32.t; 1421 hw->vid_control & VCO_CLOCK25 ? f25.t : f32.t;
1308 1422
1309 var->height=-1; 1423 var->height = -1;
1310 var->width=-1; 1424 var->width = -1;
1311 1425
1312 var->sync=0; 1426 var->sync = 0;
1313 if (hw->vid_control & VCO_HSYPOS) 1427 if (hw->vid_control & VCO_HSYPOS)
1314 var->sync |= FB_SYNC_HOR_HIGH_ACT; 1428 var->sync |= FB_SYNC_HOR_HIGH_ACT;
1315 if (hw->vid_control & VCO_VSYPOS) 1429 if (hw->vid_control & VCO_VSYPOS)
@@ -1320,7 +1434,7 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1320 var->vmode |= FB_VMODE_INTERLACED; 1434 var->vmode |= FB_VMODE_INTERLACED;
1321 if (hw->vid_mode & VMO_DOUBLE) 1435 if (hw->vid_mode & VMO_DOUBLE)
1322 var->vmode |= FB_VMODE_DOUBLE; 1436 var->vmode |= FB_VMODE_DOUBLE;
1323 1437
1324 /* visible y resolution: 1438 /* visible y resolution:
1325 * Graphics display starts at line VDB and ends at line 1439 * Graphics display starts at line VDB and ends at line
1326 * VDE. If interlace mode off unit of VC-registers is 1440 * VDE. If interlace mode off unit of VC-registers is
@@ -1332,14 +1446,15 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1332 if (var->vmode & FB_VMODE_DOUBLE) 1446 if (var->vmode & FB_VMODE_DOUBLE)
1333 var->yres >>= 1; 1447 var->yres >>= 1;
1334 1448
1335 /* to get bpp, we must examine f_shift and st_shift. 1449 /*
1450 * to get bpp, we must examine f_shift and st_shift.
1336 * f_shift is valid if any of bits no. 10, 8 or 4 1451 * f_shift is valid if any of bits no. 10, 8 or 4
1337 * is set. Priority in f_shift is: 10 ">" 8 ">" 4, i.e. 1452 * is set. Priority in f_shift is: 10 ">" 8 ">" 4, i.e.
1338 * if bit 10 set then bit 8 and bit 4 don't care... 1453 * if bit 10 set then bit 8 and bit 4 don't care...
1339 * If all these bits are 0 get display depth from st_shift 1454 * If all these bits are 0 get display depth from st_shift
1340 * (as for ST and STE) 1455 * (as for ST and STE)
1341 */ 1456 */
1342 if (hw->f_shift & 0x400) /* 2 colors */ 1457 if (hw->f_shift & 0x400) /* 2 colors */
1343 var->bits_per_pixel = 1; 1458 var->bits_per_pixel = 1;
1344 else if (hw->f_shift & 0x100) /* hicolor */ 1459 else if (hw->f_shift & 0x100) /* hicolor */
1345 var->bits_per_pixel = 16; 1460 var->bits_per_pixel = 16;
@@ -1349,7 +1464,7 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1349 var->bits_per_pixel = 4; 1464 var->bits_per_pixel = 4;
1350 else if (hw->st_shift == 0x100) 1465 else if (hw->st_shift == 0x100)
1351 var->bits_per_pixel = 2; 1466 var->bits_per_pixel = 2;
1352 else /* if (hw->st_shift == 0x200) */ 1467 else /* if (hw->st_shift == 0x200) */
1353 var->bits_per_pixel = 1; 1468 var->bits_per_pixel = 1;
1354 1469
1355 var->xres = hw->line_width * 16 / var->bits_per_pixel; 1470 var->xres = hw->line_width * 16 / var->bits_per_pixel;
@@ -1358,42 +1473,42 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1358 var->xres_virtual += 16; 1473 var->xres_virtual += 16;
1359 1474
1360 if (var->bits_per_pixel == 16) { 1475 if (var->bits_per_pixel == 16) {
1361 var->red.offset=11; 1476 var->red.offset = 11;
1362 var->red.length=5; 1477 var->red.length = 5;
1363 var->red.msb_right=0; 1478 var->red.msb_right = 0;
1364 var->green.offset=5; 1479 var->green.offset = 5;
1365 var->green.length=6; 1480 var->green.length = 6;
1366 var->green.msb_right=0; 1481 var->green.msb_right = 0;
1367 var->blue.offset=0; 1482 var->blue.offset = 0;
1368 var->blue.length=5; 1483 var->blue.length = 5;
1369 var->blue.msb_right=0; 1484 var->blue.msb_right = 0;
1370 } 1485 } else {
1371 else { 1486 var->red.offset = 0;
1372 var->red.offset=0;
1373 var->red.length = hw->ste_mode ? 4 : 6; 1487 var->red.length = hw->ste_mode ? 4 : 6;
1374 var->red.msb_right=0; 1488 if (var->red.length > var->bits_per_pixel)
1375 var->grayscale=0; 1489 var->red.length = var->bits_per_pixel;
1376 var->blue=var->green=var->red; 1490 var->red.msb_right = 0;
1491 var->grayscale = 0;
1492 var->blue = var->green = var->red;
1377 } 1493 }
1378 var->transp.offset=0; 1494 var->transp.offset = 0;
1379 var->transp.length=0; 1495 var->transp.length = 0;
1380 var->transp.msb_right=0; 1496 var->transp.msb_right = 0;
1381 1497
1382 linelen = var->xres_virtual * var->bits_per_pixel / 8; 1498 linelen = var->xres_virtual * var->bits_per_pixel / 8;
1383 if (screen_len) { 1499 if (screen_len) {
1384 if (par->yres_virtual) 1500 if (par->yres_virtual)
1385 var->yres_virtual = par->yres_virtual; 1501 var->yres_virtual = par->yres_virtual;
1386 else 1502 else
1387 /* yres_virtual==0 means use maximum */ 1503 /* yres_virtual == 0 means use maximum */
1388 var->yres_virtual = screen_len / linelen; 1504 var->yres_virtual = screen_len / linelen;
1389 } 1505 } else {
1390 else {
1391 if (hwscroll < 0) 1506 if (hwscroll < 0)
1392 var->yres_virtual = 2 * var->yres; 1507 var->yres_virtual = 2 * var->yres;
1393 else 1508 else
1394 var->yres_virtual=var->yres+hwscroll * 16; 1509 var->yres_virtual = var->yres + hwscroll * 16;
1395 } 1510 }
1396 var->xoffset=0; /* TODO change this */ 1511 var->xoffset = 0; /* TODO change this */
1397 1512
1398 /* hdX-offsets */ 1513 /* hdX-offsets */
1399 prescale = hxx_prescale(hw); 1514 prescale = hxx_prescale(hw);
@@ -1402,8 +1517,7 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1402 if (hw->f_shift & 0x100) { 1517 if (hw->f_shift & 0x100) {
1403 hde_off = 0; 1518 hde_off = 0;
1404 hdb_off = (base_off + 16 * plen) + prescale; 1519 hdb_off = (base_off + 16 * plen) + prescale;
1405 } 1520 } else {
1406 else {
1407 hde_off = ((128 / var->bits_per_pixel + 2) * plen); 1521 hde_off = ((128 / var->bits_per_pixel + 2) * plen);
1408 if (hw->ste_mode) 1522 if (hw->ste_mode)
1409 hdb_off = (64 + base_off + (128 / var->bits_per_pixel + 2) * plen) 1523 hdb_off = (64 + base_off + (128 / var->bits_per_pixel + 2) * plen)
@@ -1415,8 +1529,8 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1415 1529
1416 /* Right margin includes hsync */ 1530 /* Right margin includes hsync */
1417 var->left_margin = hdb_off + prescale * ((hw->hdb & 0x1ff) - 1531 var->left_margin = hdb_off + prescale * ((hw->hdb & 0x1ff) -
1418 (hw->hdb & 0x200 ? 2+hw->hht : 0)); 1532 (hw->hdb & 0x200 ? 2 + hw->hht : 0));
1419 if (hw->ste_mode || mon_type!=F_MON_VGA) 1533 if (hw->ste_mode || mon_type != F_MON_VGA)
1420 var->right_margin = prescale * (hw->hht + 2 - hw->hde) - hde_off; 1534 var->right_margin = prescale * (hw->hht + 2 - hw->hde) - hde_off;
1421 else 1535 else
1422 /* can't use this in ste_mode, because hbb is +1 off */ 1536 /* can't use this in ste_mode, because hbb is +1 off */
@@ -1424,15 +1538,14 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1424 var->hsync_len = prescale * (hw->hht + 2 - hw->hss); 1538 var->hsync_len = prescale * (hw->hht + 2 - hw->hss);
1425 1539
1426 /* Lower margin includes vsync */ 1540 /* Lower margin includes vsync */
1427 var->upper_margin = hw->vdb / 2 ; /* round down to full lines */ 1541 var->upper_margin = hw->vdb / 2; /* round down to full lines */
1428 var->lower_margin = (hw->vft+1 - hw->vde + 1) / 2; /* round up */ 1542 var->lower_margin = (hw->vft + 1 - hw->vde + 1) / 2; /* round up */
1429 var->vsync_len = (hw->vft+1 - hw->vss + 1) / 2; /* round up */ 1543 var->vsync_len = (hw->vft + 1 - hw->vss + 1) / 2; /* round up */
1430 if (var->vmode & FB_VMODE_INTERLACED) { 1544 if (var->vmode & FB_VMODE_INTERLACED) {
1431 var->upper_margin *= 2; 1545 var->upper_margin *= 2;
1432 var->lower_margin *= 2; 1546 var->lower_margin *= 2;
1433 var->vsync_len *= 2; 1547 var->vsync_len *= 2;
1434 } 1548 } else if (var->vmode & FB_VMODE_DOUBLE) {
1435 else if (var->vmode & FB_VMODE_DOUBLE) {
1436 var->upper_margin = (var->upper_margin + 1) / 2; 1549 var->upper_margin = (var->upper_margin + 1) / 2;
1437 var->lower_margin = (var->lower_margin + 1) / 2; 1550 var->lower_margin = (var->lower_margin + 1) / 2;
1438 var->vsync_len = (var->vsync_len + 1) / 2; 1551 var->vsync_len = (var->vsync_len + 1) / 2;
@@ -1447,20 +1560,19 @@ static int falcon_encode_var( struct fb_var_screeninfo *var,
1447 var->lower_margin -= var->vsync_len; 1560 var->lower_margin -= var->vsync_len;
1448 1561
1449 if (screen_base) 1562 if (screen_base)
1450 var->yoffset=(par->screen_base - screen_base)/linelen; 1563 var->yoffset = (par->screen_base - screen_base) / linelen;
1451 else 1564 else
1452 var->yoffset=0; 1565 var->yoffset = 0;
1453 var->nonstd=0; /* what is this for? */ 1566 var->nonstd = 0; /* what is this for? */
1454 var->activate=0; 1567 var->activate = 0;
1455 return 0; 1568 return 0;
1456} 1569}
1457 1570
1458 1571static int f_change_mode;
1459static int f_change_mode = 0;
1460static struct falcon_hw f_new_mode; 1572static struct falcon_hw f_new_mode;
1461static int f_pan_display = 0; 1573static int f_pan_display;
1462 1574
1463static void falcon_get_par( struct atafb_par *par ) 1575static void falcon_get_par(struct atafb_par *par)
1464{ 1576{
1465 unsigned long addr; 1577 unsigned long addr;
1466 struct falcon_hw *hw = &par->hw.falcon; 1578 struct falcon_hw *hw = &par->hw.falcon;
@@ -1492,12 +1604,12 @@ static void falcon_get_par( struct atafb_par *par )
1492 par->screen_base = phys_to_virt(addr); 1604 par->screen_base = phys_to_virt(addr);
1493 1605
1494 /* derived parameters */ 1606 /* derived parameters */
1495 hw->ste_mode = (hw->f_shift & 0x510)==0 && hw->st_shift==0x100; 1607 hw->ste_mode = (hw->f_shift & 0x510) == 0 && hw->st_shift == 0x100;
1496 hw->mono = (hw->f_shift & 0x400) || 1608 hw->mono = (hw->f_shift & 0x400) ||
1497 ((hw->f_shift & 0x510)==0 && hw->st_shift==0x200); 1609 ((hw->f_shift & 0x510) == 0 && hw->st_shift == 0x200);
1498} 1610}
1499 1611
1500static void falcon_set_par( struct atafb_par *par ) 1612static void falcon_set_par(struct atafb_par *par)
1501{ 1613{
1502 f_change_mode = 0; 1614 f_change_mode = 0;
1503 1615
@@ -1519,8 +1631,7 @@ static void falcon_set_par( struct atafb_par *par )
1519 f_change_mode = 1; 1631 f_change_mode = 1;
1520} 1632}
1521 1633
1522 1634static irqreturn_t falcon_vbl_switcher(int irq, void *dummy)
1523static irqreturn_t falcon_vbl_switcher( int irq, void *dummy )
1524{ 1635{
1525 struct falcon_hw *hw = &f_new_mode; 1636 struct falcon_hw *hw = &f_new_mode;
1526 1637
@@ -1529,11 +1640,10 @@ static irqreturn_t falcon_vbl_switcher( int irq, void *dummy )
1529 1640
1530 if (hw->sync & 0x1) { 1641 if (hw->sync & 0x1) {
1531 /* Enable external pixelclock. This code only for ScreenWonder */ 1642 /* Enable external pixelclock. This code only for ScreenWonder */
1532 *(volatile unsigned short*)0xffff9202 = 0xffbf; 1643 *(volatile unsigned short *)0xffff9202 = 0xffbf;
1533 } 1644 } else {
1534 else {
1535 /* Turn off external clocks. Read sets all output bits to 1. */ 1645 /* Turn off external clocks. Read sets all output bits to 1. */
1536 *(volatile unsigned short*)0xffff9202; 1646 *(volatile unsigned short *)0xffff9202;
1537 } 1647 }
1538 shifter.syncmode = hw->sync; 1648 shifter.syncmode = hw->sync;
1539 1649
@@ -1550,15 +1660,14 @@ static irqreturn_t falcon_vbl_switcher( int irq, void *dummy )
1550 videl.vde = hw->vde; 1660 videl.vde = hw->vde;
1551 videl.vss = hw->vss; 1661 videl.vss = hw->vss;
1552 1662
1553 videl.f_shift = 0; /* write enables Falcon palette, 0: 4 planes */ 1663 videl.f_shift = 0; /* write enables Falcon palette, 0: 4 planes */
1554 if (hw->ste_mode) { 1664 if (hw->ste_mode) {
1555 videl.st_shift = hw->st_shift; /* write enables STE palette */ 1665 videl.st_shift = hw->st_shift; /* write enables STE palette */
1556 } 1666 } else {
1557 else {
1558 /* IMPORTANT: 1667 /* IMPORTANT:
1559 * set st_shift 0, so we can tell the screen-depth if f_shift==0. 1668 * set st_shift 0, so we can tell the screen-depth if f_shift == 0.
1560 * Writing 0 to f_shift enables 4 plane Falcon mode but 1669 * Writing 0 to f_shift enables 4 plane Falcon mode but
1561 * doesn't set st_shift. st_shift!=0 (!=4planes) is impossible 1670 * doesn't set st_shift. st_shift != 0 (!= 4planes) is impossible
1562 * with Falcon palette. 1671 * with Falcon palette.
1563 */ 1672 */
1564 videl.st_shift = 0; 1673 videl.st_shift = 0;
@@ -1580,12 +1689,13 @@ static irqreturn_t falcon_vbl_switcher( int irq, void *dummy )
1580 return IRQ_HANDLED; 1689 return IRQ_HANDLED;
1581} 1690}
1582 1691
1583 1692static int falcon_pan_display(struct fb_var_screeninfo *var,
1584static int falcon_pan_display( struct fb_var_screeninfo *var, 1693 struct fb_info *info)
1585 struct atafb_par *par )
1586{ 1694{
1695 struct atafb_par *par = (struct atafb_par *)info->par;
1696
1587 int xoffset; 1697 int xoffset;
1588 int bpp = fb_display[fb_info.currcon].var.bits_per_pixel; 1698 int bpp = info->var.bits_per_pixel;
1589 1699
1590 if (bpp == 1) 1700 if (bpp == 1)
1591 var->xoffset = up(var->xoffset, 32); 1701 var->xoffset = up(var->xoffset, 32);
@@ -1596,45 +1706,24 @@ static int falcon_pan_display( struct fb_var_screeninfo *var,
1596 var->xoffset = up(var->xoffset, 2); 1706 var->xoffset = up(var->xoffset, 2);
1597 } 1707 }
1598 par->hw.falcon.line_offset = bpp * 1708 par->hw.falcon.line_offset = bpp *
1599 (fb_display[fb_info.currcon].var.xres_virtual - fb_display[fb_info.currcon].var.xres) / 16; 1709 (info->var.xres_virtual - info->var.xres) / 16;
1600 if (par->hw.falcon.xoffset) 1710 if (par->hw.falcon.xoffset)
1601 par->hw.falcon.line_offset -= bpp; 1711 par->hw.falcon.line_offset -= bpp;
1602 xoffset = var->xoffset - par->hw.falcon.xoffset; 1712 xoffset = var->xoffset - par->hw.falcon.xoffset;
1603 1713
1604 par->screen_base = screen_base + 1714 par->screen_base = screen_base +
1605 (var->yoffset * fb_display[fb_info.currcon].var.xres_virtual + xoffset) * bpp / 8; 1715 (var->yoffset * info->var.xres_virtual + xoffset) * bpp / 8;
1606 if (fbhw->set_screen_base) 1716 if (fbhw->set_screen_base)
1607 fbhw->set_screen_base (par->screen_base); 1717 fbhw->set_screen_base(par->screen_base);
1608 else 1718 else
1609 return -EINVAL; /* shouldn't happen */ 1719 return -EINVAL; /* shouldn't happen */
1610 f_pan_display = 1; 1720 f_pan_display = 1;
1611 return 0; 1721 return 0;
1612} 1722}
1613 1723
1614 1724static int falcon_setcolreg(unsigned int regno, unsigned int red,
1615static int falcon_getcolreg( unsigned regno, unsigned *red, 1725 unsigned int green, unsigned int blue,
1616 unsigned *green, unsigned *blue, 1726 unsigned int transp, struct fb_info *info)
1617 unsigned *transp, struct fb_info *info )
1618{ unsigned long col;
1619
1620 if (regno > 255)
1621 return 1;
1622 /* This works in STE-mode (with 4bit/color) since f030_col-registers
1623 * hold up to 6bit/color.
1624 * Even with hicolor r/g/b=5/6/5 bit!
1625 */
1626 col = f030_col[regno];
1627 *red = (col >> 16) & 0xff00;
1628 *green = (col >> 8) & 0xff00;
1629 *blue = (col << 8) & 0xff00;
1630 *transp = 0;
1631 return 0;
1632}
1633
1634
1635static int falcon_setcolreg( unsigned regno, unsigned red,
1636 unsigned green, unsigned blue,
1637 unsigned transp, struct fb_info *info )
1638{ 1727{
1639 if (regno > 255) 1728 if (regno > 255)
1640 return 1; 1729 return 1;
@@ -1655,13 +1744,12 @@ static int falcon_setcolreg( unsigned regno, unsigned red,
1655 return 0; 1744 return 0;
1656} 1745}
1657 1746
1658 1747static int falcon_blank(int blank_mode)
1659static int falcon_blank( int blank_mode )
1660{ 1748{
1661/* ++guenther: we can switch off graphics by changing VDB and VDE, 1749 /* ++guenther: we can switch off graphics by changing VDB and VDE,
1662 * so VIDEL doesn't hog the bus while saving. 1750 * so VIDEL doesn't hog the bus while saving.
1663 * (this may affect usleep()). 1751 * (this may affect usleep()).
1664 */ 1752 */
1665 int vdb, vss, hbe, hss; 1753 int vdb, vss, hbe, hss;
1666 1754
1667 if (mon_type == F_MON_SM) /* this doesn't work on SM124 */ 1755 if (mon_type == F_MON_SM) /* this doesn't work on SM124 */
@@ -1694,14 +1782,13 @@ static int falcon_blank( int blank_mode )
1694 return 0; 1782 return 0;
1695} 1783}
1696 1784
1697 1785static int falcon_detect(void)
1698static int falcon_detect( void )
1699{ 1786{
1700 struct atafb_par par; 1787 struct atafb_par par;
1701 unsigned char fhw; 1788 unsigned char fhw;
1702 1789
1703 /* Determine connected monitor and set monitor parameters */ 1790 /* Determine connected monitor and set monitor parameters */
1704 fhw = *(unsigned char*)0xffff8006; 1791 fhw = *(unsigned char *)0xffff8006;
1705 mon_type = fhw >> 6 & 0x3; 1792 mon_type = fhw >> 6 & 0x3;
1706 /* bit 1 of fhw: 1=32 bit ram bus, 0=16 bit */ 1793 /* bit 1 of fhw: 1=32 bit ram bus, 0=16 bit */
1707 f030_bus_width = fhw << 6 & 0x80; 1794 f030_bus_width = fhw << 6 & 0x80;
@@ -1715,7 +1802,7 @@ static int falcon_detect( void )
1715 case F_MON_SC: 1802 case F_MON_SC:
1716 case F_MON_TV: 1803 case F_MON_TV:
1717 /* PAL...NTSC */ 1804 /* PAL...NTSC */
1718 fb_info.monspecs.vfmin = 49; /* not 50, since TOS defaults to 49.9x Hz */ 1805 fb_info.monspecs.vfmin = 49; /* not 50, since TOS defaults to 49.9x Hz */
1719 fb_info.monspecs.vfmax = 60; 1806 fb_info.monspecs.vfmax = 60;
1720 fb_info.monspecs.hfmin = 15620; 1807 fb_info.monspecs.hfmin = 15620;
1721 fb_info.monspecs.hfmax = 15755; 1808 fb_info.monspecs.hfmax = 15755;
@@ -1740,13 +1827,12 @@ static int falcon_detect( void )
1740 1827
1741#ifdef ATAFB_STE 1828#ifdef ATAFB_STE
1742 1829
1743static int stste_encode_fix( struct fb_fix_screeninfo *fix, 1830static int stste_encode_fix(struct fb_fix_screeninfo *fix,
1744 struct atafb_par *par ) 1831 struct atafb_par *par)
1745
1746{ 1832{
1747 int mode; 1833 int mode;
1748 1834
1749 strcpy(fix->id,"Atari Builtin"); 1835 strcpy(fix->id, "Atari Builtin");
1750 fix->smem_start = (unsigned long)real_screen_base; 1836 fix->smem_start = (unsigned long)real_screen_base;
1751 fix->smem_len = screen_len; 1837 fix->smem_len = screen_len;
1752 fix->type = FB_TYPE_INTERLEAVED_PLANES; 1838 fix->type = FB_TYPE_INTERLEAVED_PLANES;
@@ -1771,43 +1857,40 @@ static int stste_encode_fix( struct fb_fix_screeninfo *fix,
1771 return 0; 1857 return 0;
1772} 1858}
1773 1859
1774 1860static int stste_decode_var(struct fb_var_screeninfo *var,
1775static int stste_decode_var( struct fb_var_screeninfo *var, 1861 struct atafb_par *par)
1776 struct atafb_par *par )
1777{ 1862{
1778 int xres=var->xres; 1863 int xres = var->xres;
1779 int yres=var->yres; 1864 int yres = var->yres;
1780 int bpp=var->bits_per_pixel; 1865 int bpp = var->bits_per_pixel;
1781 int linelen; 1866 int linelen;
1782 int yres_virtual = var->yres_virtual; 1867 int yres_virtual = var->yres_virtual;
1783 1868
1784 if (mono_moni) { 1869 if (mono_moni) {
1785 if (bpp > 1 || xres > sttt_xres || yres > st_yres) 1870 if (bpp > 1 || xres > sttt_xres || yres > st_yres)
1786 return -EINVAL; 1871 return -EINVAL;
1787 par->hw.st.mode=ST_HIGH; 1872 par->hw.st.mode = ST_HIGH;
1788 xres=sttt_xres; 1873 xres = sttt_xres;
1789 yres=st_yres; 1874 yres = st_yres;
1790 bpp=1; 1875 bpp = 1;
1791 } else { 1876 } else {
1792 if (bpp > 4 || xres > sttt_xres || yres > st_yres) 1877 if (bpp > 4 || xres > sttt_xres || yres > st_yres)
1793 return -EINVAL; 1878 return -EINVAL;
1794 if (bpp > 2) { 1879 if (bpp > 2) {
1795 if (xres > sttt_xres/2 || yres > st_yres/2) 1880 if (xres > sttt_xres / 2 || yres > st_yres / 2)
1796 return -EINVAL; 1881 return -EINVAL;
1797 par->hw.st.mode=ST_LOW; 1882 par->hw.st.mode = ST_LOW;
1798 xres=sttt_xres/2; 1883 xres = sttt_xres / 2;
1799 yres=st_yres/2; 1884 yres = st_yres / 2;
1800 bpp=4; 1885 bpp = 4;
1801 } 1886 } else if (bpp > 1) {
1802 else if (bpp > 1) { 1887 if (xres > sttt_xres || yres > st_yres / 2)
1803 if (xres > sttt_xres || yres > st_yres/2)
1804 return -EINVAL; 1888 return -EINVAL;
1805 par->hw.st.mode=ST_MID; 1889 par->hw.st.mode = ST_MID;
1806 xres=sttt_xres; 1890 xres = sttt_xres;
1807 yres=st_yres/2; 1891 yres = st_yres / 2;
1808 bpp=2; 1892 bpp = 2;
1809 } 1893 } else
1810 else
1811 return -EINVAL; 1894 return -EINVAL;
1812 } 1895 }
1813 if (yres_virtual <= 0) 1896 if (yres_virtual <= 0)
@@ -1815,10 +1898,10 @@ static int stste_decode_var( struct fb_var_screeninfo *var,
1815 else if (yres_virtual < yres) 1898 else if (yres_virtual < yres)
1816 yres_virtual = yres; 1899 yres_virtual = yres;
1817 if (var->sync & FB_SYNC_EXT) 1900 if (var->sync & FB_SYNC_EXT)
1818 par->hw.st.sync=(par->hw.st.sync & ~1) | 1; 1901 par->hw.st.sync = (par->hw.st.sync & ~1) | 1;
1819 else 1902 else
1820 par->hw.st.sync=(par->hw.st.sync & ~1); 1903 par->hw.st.sync = (par->hw.st.sync & ~1);
1821 linelen=xres*bpp/8; 1904 linelen = xres * bpp / 8;
1822 if (yres_virtual * linelen > screen_len && screen_len) 1905 if (yres_virtual * linelen > screen_len && screen_len)
1823 return -EINVAL; 1906 return -EINVAL;
1824 if (yres * linelen > screen_len && screen_len) 1907 if (yres * linelen > screen_len && screen_len)
@@ -1826,93 +1909,91 @@ static int stste_decode_var( struct fb_var_screeninfo *var,
1826 if (var->yoffset + yres > yres_virtual && yres_virtual) 1909 if (var->yoffset + yres > yres_virtual && yres_virtual)
1827 return -EINVAL; 1910 return -EINVAL;
1828 par->yres_virtual = yres_virtual; 1911 par->yres_virtual = yres_virtual;
1829 par->screen_base=screen_base+ var->yoffset*linelen; 1912 par->screen_base = screen_base + var->yoffset * linelen;
1830 return 0; 1913 return 0;
1831} 1914}
1832 1915
1833static int stste_encode_var( struct fb_var_screeninfo *var, 1916static int stste_encode_var(struct fb_var_screeninfo *var,
1834 struct atafb_par *par ) 1917 struct atafb_par *par)
1835{ 1918{
1836 int linelen; 1919 int linelen;
1837 memset(var, 0, sizeof(struct fb_var_screeninfo)); 1920 memset(var, 0, sizeof(struct fb_var_screeninfo));
1838 var->red.offset=0; 1921 var->red.offset = 0;
1839 var->red.length = ATARIHW_PRESENT(EXTD_SHIFTER) ? 4 : 3; 1922 var->red.length = ATARIHW_PRESENT(EXTD_SHIFTER) ? 4 : 3;
1840 var->red.msb_right=0; 1923 var->red.msb_right = 0;
1841 var->grayscale=0; 1924 var->grayscale = 0;
1842 1925
1843 var->pixclock=31041; 1926 var->pixclock = 31041;
1844 var->left_margin=120; /* these are incorrect */ 1927 var->left_margin = 120; /* these are incorrect */
1845 var->right_margin=100; 1928 var->right_margin = 100;
1846 var->upper_margin=8; 1929 var->upper_margin = 8;
1847 var->lower_margin=16; 1930 var->lower_margin = 16;
1848 var->hsync_len=140; 1931 var->hsync_len = 140;
1849 var->vsync_len=30; 1932 var->vsync_len = 30;
1850 1933
1851 var->height=-1; 1934 var->height = -1;
1852 var->width=-1; 1935 var->width = -1;
1853 1936
1854 if (!(par->hw.st.sync & 1)) 1937 if (!(par->hw.st.sync & 1))
1855 var->sync=0; 1938 var->sync = 0;
1856 else 1939 else
1857 var->sync=FB_SYNC_EXT; 1940 var->sync = FB_SYNC_EXT;
1858 1941
1859 switch (par->hw.st.mode & 3) { 1942 switch (par->hw.st.mode & 3) {
1860 case ST_LOW: 1943 case ST_LOW:
1861 var->xres=sttt_xres/2; 1944 var->xres = sttt_xres / 2;
1862 var->yres=st_yres/2; 1945 var->yres = st_yres / 2;
1863 var->bits_per_pixel=4; 1946 var->bits_per_pixel = 4;
1864 break; 1947 break;
1865 case ST_MID: 1948 case ST_MID:
1866 var->xres=sttt_xres; 1949 var->xres = sttt_xres;
1867 var->yres=st_yres/2; 1950 var->yres = st_yres / 2;
1868 var->bits_per_pixel=2; 1951 var->bits_per_pixel = 2;
1869 break; 1952 break;
1870 case ST_HIGH: 1953 case ST_HIGH:
1871 var->xres=sttt_xres; 1954 var->xres = sttt_xres;
1872 var->yres=st_yres; 1955 var->yres = st_yres;
1873 var->bits_per_pixel=1; 1956 var->bits_per_pixel = 1;
1874 break; 1957 break;
1875 } 1958 }
1876 var->blue=var->green=var->red; 1959 var->blue = var->green = var->red;
1877 var->transp.offset=0; 1960 var->transp.offset = 0;
1878 var->transp.length=0; 1961 var->transp.length = 0;
1879 var->transp.msb_right=0; 1962 var->transp.msb_right = 0;
1880 var->xres_virtual=sttt_xres_virtual; 1963 var->xres_virtual = sttt_xres_virtual;
1881 linelen=var->xres_virtual * var->bits_per_pixel / 8; 1964 linelen = var->xres_virtual * var->bits_per_pixel / 8;
1882 ovsc_addlen=linelen*(sttt_yres_virtual - st_yres); 1965 ovsc_addlen = linelen * (sttt_yres_virtual - st_yres);
1883 1966
1884 if (! use_hwscroll) 1967 if (!use_hwscroll)
1885 var->yres_virtual=var->yres; 1968 var->yres_virtual = var->yres;
1886 else if (screen_len) { 1969 else if (screen_len) {
1887 if (par->yres_virtual) 1970 if (par->yres_virtual)
1888 var->yres_virtual = par->yres_virtual; 1971 var->yres_virtual = par->yres_virtual;
1889 else 1972 else
1890 /* yres_virtual==0 means use maximum */ 1973 /* yres_virtual == 0 means use maximum */
1891 var->yres_virtual = screen_len / linelen; 1974 var->yres_virtual = screen_len / linelen;
1892 } 1975 } else {
1893 else {
1894 if (hwscroll < 0) 1976 if (hwscroll < 0)
1895 var->yres_virtual = 2 * var->yres; 1977 var->yres_virtual = 2 * var->yres;
1896 else 1978 else
1897 var->yres_virtual=var->yres+hwscroll * 16; 1979 var->yres_virtual = var->yres + hwscroll * 16;
1898 } 1980 }
1899 var->xoffset=0; 1981 var->xoffset = 0;
1900 if (screen_base) 1982 if (screen_base)
1901 var->yoffset=(par->screen_base - screen_base)/linelen; 1983 var->yoffset = (par->screen_base - screen_base) / linelen;
1902 else 1984 else
1903 var->yoffset=0; 1985 var->yoffset = 0;
1904 var->nonstd=0; 1986 var->nonstd = 0;
1905 var->activate=0; 1987 var->activate = 0;
1906 var->vmode=FB_VMODE_NONINTERLACED; 1988 var->vmode = FB_VMODE_NONINTERLACED;
1907 return 0; 1989 return 0;
1908} 1990}
1909 1991
1910 1992static void stste_get_par(struct atafb_par *par)
1911static void stste_get_par( struct atafb_par *par )
1912{ 1993{
1913 unsigned long addr; 1994 unsigned long addr;
1914 par->hw.st.mode=shifter_tt.st_shiftmode; 1995 par->hw.st.mode = shifter_tt.st_shiftmode;
1915 par->hw.st.sync=shifter.syncmode; 1996 par->hw.st.sync = shifter.syncmode;
1916 addr = ((shifter.bas_hi & 0xff) << 16) | 1997 addr = ((shifter.bas_hi & 0xff) << 16) |
1917 ((shifter.bas_md & 0xff) << 8); 1998 ((shifter.bas_md & 0xff) << 8);
1918 if (ATARIHW_PRESENT(EXTD_SHIFTER)) 1999 if (ATARIHW_PRESENT(EXTD_SHIFTER))
@@ -1920,55 +2001,18 @@ static void stste_get_par( struct atafb_par *par )
1920 par->screen_base = phys_to_virt(addr); 2001 par->screen_base = phys_to_virt(addr);
1921} 2002}
1922 2003
1923static void stste_set_par( struct atafb_par *par ) 2004static void stste_set_par(struct atafb_par *par)
1924{ 2005{
1925 shifter_tt.st_shiftmode=par->hw.st.mode; 2006 shifter_tt.st_shiftmode = par->hw.st.mode;
1926 shifter.syncmode=par->hw.st.sync; 2007 shifter.syncmode = par->hw.st.sync;
1927 /* only set screen_base if really necessary */ 2008 /* only set screen_base if really necessary */
1928 if (current_par.screen_base != par->screen_base) 2009 if (current_par.screen_base != par->screen_base)
1929 fbhw->set_screen_base(par->screen_base); 2010 fbhw->set_screen_base(par->screen_base);
1930} 2011}
1931 2012
1932 2013static int stste_setcolreg(unsigned int regno, unsigned int red,
1933static int stste_getcolreg(unsigned regno, unsigned *red, 2014 unsigned int green, unsigned int blue,
1934 unsigned *green, unsigned *blue, 2015 unsigned int transp, struct fb_info *info)
1935 unsigned *transp, struct fb_info *info)
1936{
1937 unsigned col, t;
1938
1939 if (regno > 15)
1940 return 1;
1941 col = shifter_tt.color_reg[regno];
1942 if (ATARIHW_PRESENT(EXTD_SHIFTER)) {
1943 t = ((col >> 7) & 0xe) | ((col >> 11) & 1);
1944 t |= t << 4;
1945 *red = t | (t << 8);
1946 t = ((col >> 3) & 0xe) | ((col >> 7) & 1);
1947 t |= t << 4;
1948 *green = t | (t << 8);
1949 t = ((col << 1) & 0xe) | ((col >> 3) & 1);
1950 t |= t << 4;
1951 *blue = t | (t << 8);
1952 }
1953 else {
1954 t = (col >> 7) & 0xe;
1955 t |= t << 4;
1956 *red = t | (t << 8);
1957 t = (col >> 3) & 0xe;
1958 t |= t << 4;
1959 *green = t | (t << 8);
1960 t = (col << 1) & 0xe;
1961 t |= t << 4;
1962 *blue = t | (t << 8);
1963 }
1964 *transp = 0;
1965 return 0;
1966}
1967
1968
1969static int stste_setcolreg(unsigned regno, unsigned red,
1970 unsigned green, unsigned blue,
1971 unsigned transp, struct fb_info *info)
1972{ 2016{
1973 if (regno > 15) 2017 if (regno > 15)
1974 return 1; 2018 return 1;
@@ -1988,10 +2032,9 @@ static int stste_setcolreg(unsigned regno, unsigned red,
1988 return 0; 2032 return 0;
1989} 2033}
1990 2034
1991 2035static int stste_detect(void)
1992static int stste_detect( void ) 2036{
1993 2037 struct atafb_par par;
1994{ struct atafb_par par;
1995 2038
1996 /* Determine the connected monitor: The DMA sound must be 2039 /* Determine the connected monitor: The DMA sound must be
1997 * disabled before reading the MFP GPIP, because the Sound 2040 * disabled before reading the MFP GPIP, because the Sound
@@ -1999,7 +2042,7 @@ static int stste_detect( void )
1999 */ 2042 */
2000 if (ATARIHW_PRESENT(PCM_8BIT)) { 2043 if (ATARIHW_PRESENT(PCM_8BIT)) {
2001 tt_dmasnd.ctrl = DMASND_CTRL_OFF; 2044 tt_dmasnd.ctrl = DMASND_CTRL_OFF;
2002 udelay(20); /* wait a while for things to settle down */ 2045 udelay(20); /* wait a while for things to settle down */
2003 } 2046 }
2004 mono_moni = (mfp.par_dt_reg & 0x80) == 0; 2047 mono_moni = (mfp.par_dt_reg & 0x80) == 0;
2005 2048
@@ -2014,12 +2057,12 @@ static int stste_detect( void )
2014static void stste_set_screen_base(void *s_base) 2057static void stste_set_screen_base(void *s_base)
2015{ 2058{
2016 unsigned long addr; 2059 unsigned long addr;
2017 addr= virt_to_phys(s_base); 2060 addr = virt_to_phys(s_base);
2018 /* Setup Screen Memory */ 2061 /* Setup Screen Memory */
2019 shifter.bas_hi=(unsigned char) ((addr & 0xff0000) >> 16); 2062 shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16);
2020 shifter.bas_md=(unsigned char) ((addr & 0x00ff00) >> 8); 2063 shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8);
2021 if (ATARIHW_PRESENT(EXTD_SHIFTER)) 2064 if (ATARIHW_PRESENT(EXTD_SHIFTER))
2022 shifter.bas_lo=(unsigned char) (addr & 0x0000ff); 2065 shifter.bas_lo = (unsigned char)(addr & 0x0000ff);
2023} 2066}
2024 2067
2025#endif /* ATAFB_STE */ 2068#endif /* ATAFB_STE */
@@ -2045,51 +2088,49 @@ static void stste_set_screen_base(void *s_base)
2045/* SWITCH_ACIA may be used for Falcon (ScreenBlaster III internal!) */ 2088/* SWITCH_ACIA may be used for Falcon (ScreenBlaster III internal!) */
2046static void st_ovsc_switch(void) 2089static void st_ovsc_switch(void)
2047{ 2090{
2048 unsigned long flags; 2091 unsigned long flags;
2049 register unsigned char old, new; 2092 register unsigned char old, new;
2050 2093
2051 if (!(atari_switches & ATARI_SWITCH_OVSC_MASK)) 2094 if (!(atari_switches & ATARI_SWITCH_OVSC_MASK))
2052 return; 2095 return;
2053 local_irq_save(flags); 2096 local_irq_save(flags);
2054 2097
2055 mfp.tim_ct_b = 0x10; 2098 mfp.tim_ct_b = 0x10;
2056 mfp.active_edge |= 8; 2099 mfp.active_edge |= 8;
2057 mfp.tim_ct_b = 0; 2100 mfp.tim_ct_b = 0;
2058 mfp.tim_dt_b = 0xf0; 2101 mfp.tim_dt_b = 0xf0;
2059 mfp.tim_ct_b = 8; 2102 mfp.tim_ct_b = 8;
2060 while (mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */ 2103 while (mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */
2061 ; 2104 ;
2062 new = mfp.tim_dt_b;
2063 do {
2064 udelay(LINE_DELAY);
2065 old = new;
2066 new = mfp.tim_dt_b; 2105 new = mfp.tim_dt_b;
2067 } while (old != new); 2106 do {
2068 mfp.tim_ct_b = 0x10; 2107 udelay(LINE_DELAY);
2069 udelay(SYNC_DELAY); 2108 old = new;
2070 2109 new = mfp.tim_dt_b;
2071 if (atari_switches & ATARI_SWITCH_OVSC_IKBD) 2110 } while (old != new);
2072 acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID | ACIA_RIE; 2111 mfp.tim_ct_b = 0x10;
2073 if (atari_switches & ATARI_SWITCH_OVSC_MIDI) 2112 udelay(SYNC_DELAY);
2074 acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; 2113
2075 if (atari_switches & (ATARI_SWITCH_OVSC_SND6|ATARI_SWITCH_OVSC_SND7)) { 2114 if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
2076 sound_ym.rd_data_reg_sel = 14; 2115 acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID | ACIA_RIE;
2077 sound_ym.wd_data = sound_ym.rd_data_reg_sel | 2116 if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
2078 ((atari_switches&ATARI_SWITCH_OVSC_SND6) ? 0x40:0) | 2117 acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
2079 ((atari_switches&ATARI_SWITCH_OVSC_SND7) ? 0x80:0); 2118 if (atari_switches & (ATARI_SWITCH_OVSC_SND6|ATARI_SWITCH_OVSC_SND7)) {
2080 } 2119 sound_ym.rd_data_reg_sel = 14;
2081 local_irq_restore(flags); 2120 sound_ym.wd_data = sound_ym.rd_data_reg_sel |
2121 ((atari_switches & ATARI_SWITCH_OVSC_SND6) ? 0x40:0) |
2122 ((atari_switches & ATARI_SWITCH_OVSC_SND7) ? 0x80:0);
2123 }
2124 local_irq_restore(flags);
2082} 2125}
2083 2126
2084/* ------------------- External Video ---------------------- */ 2127/* ------------------- External Video ---------------------- */
2085 2128
2086#ifdef ATAFB_EXT 2129#ifdef ATAFB_EXT
2087 2130
2088static int ext_encode_fix( struct fb_fix_screeninfo *fix, 2131static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
2089 struct atafb_par *par )
2090
2091{ 2132{
2092 strcpy(fix->id,"Unknown Extern"); 2133 strcpy(fix->id, "Unknown Extern");
2093 fix->smem_start = (unsigned long)external_addr; 2134 fix->smem_start = (unsigned long)external_addr;
2094 fix->smem_len = PAGE_ALIGN(external_len); 2135 fix->smem_len = PAGE_ALIGN(external_len);
2095 if (external_depth == 1) { 2136 if (external_depth == 1) {
@@ -2099,31 +2140,29 @@ static int ext_encode_fix( struct fb_fix_screeninfo *fix,
2099 fix->visual = 2140 fix->visual =
2100 (external_pmode == FB_TYPE_INTERLEAVED_PLANES || 2141 (external_pmode == FB_TYPE_INTERLEAVED_PLANES ||
2101 external_pmode == FB_TYPE_PACKED_PIXELS) ? 2142 external_pmode == FB_TYPE_PACKED_PIXELS) ?
2102 FB_VISUAL_MONO10 : 2143 FB_VISUAL_MONO10 : FB_VISUAL_MONO01;
2103 FB_VISUAL_MONO01; 2144 } else {
2104 }
2105 else {
2106 /* Use STATIC if we don't know how to access color registers */ 2145 /* Use STATIC if we don't know how to access color registers */
2107 int visual = external_vgaiobase ? 2146 int visual = external_vgaiobase ?
2108 FB_VISUAL_PSEUDOCOLOR : 2147 FB_VISUAL_PSEUDOCOLOR :
2109 FB_VISUAL_STATIC_PSEUDOCOLOR; 2148 FB_VISUAL_STATIC_PSEUDOCOLOR;
2110 switch (external_pmode) { 2149 switch (external_pmode) {
2111 case -1: /* truecolor */ 2150 case -1: /* truecolor */
2112 fix->type=FB_TYPE_PACKED_PIXELS; 2151 fix->type = FB_TYPE_PACKED_PIXELS;
2113 fix->visual=FB_VISUAL_TRUECOLOR; 2152 fix->visual = FB_VISUAL_TRUECOLOR;
2114 break; 2153 break;
2115 case FB_TYPE_PACKED_PIXELS: 2154 case FB_TYPE_PACKED_PIXELS:
2116 fix->type=FB_TYPE_PACKED_PIXELS; 2155 fix->type = FB_TYPE_PACKED_PIXELS;
2117 fix->visual=visual; 2156 fix->visual = visual;
2118 break; 2157 break;
2119 case FB_TYPE_PLANES: 2158 case FB_TYPE_PLANES:
2120 fix->type=FB_TYPE_PLANES; 2159 fix->type = FB_TYPE_PLANES;
2121 fix->visual=visual; 2160 fix->visual = visual;
2122 break; 2161 break;
2123 case FB_TYPE_INTERLEAVED_PLANES: 2162 case FB_TYPE_INTERLEAVED_PLANES:
2124 fix->type=FB_TYPE_INTERLEAVED_PLANES; 2163 fix->type = FB_TYPE_INTERLEAVED_PLANES;
2125 fix->type_aux=2; 2164 fix->type_aux = 2;
2126 fix->visual=visual; 2165 fix->visual = visual;
2127 break; 2166 break;
2128 } 2167 }
2129 } 2168 }
@@ -2134,137 +2173,112 @@ static int ext_encode_fix( struct fb_fix_screeninfo *fix,
2134 return 0; 2173 return 0;
2135} 2174}
2136 2175
2137 2176static int ext_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
2138static int ext_decode_var( struct fb_var_screeninfo *var,
2139 struct atafb_par *par )
2140{ 2177{
2141 struct fb_var_screeninfo *myvar = &atafb_predefined[0]; 2178 struct fb_var_screeninfo *myvar = &atafb_predefined[0];
2142 2179
2143 if (var->bits_per_pixel > myvar->bits_per_pixel || 2180 if (var->bits_per_pixel > myvar->bits_per_pixel ||
2144 var->xres > myvar->xres || 2181 var->xres > myvar->xres ||
2145 var->xres_virtual > myvar->xres_virtual || 2182 var->xres_virtual > myvar->xres_virtual ||
2146 var->yres > myvar->yres || 2183 var->yres > myvar->yres ||
2147 var->xoffset > 0 || 2184 var->xoffset > 0 ||
2148 var->yoffset > 0) 2185 var->yoffset > 0)
2149 return -EINVAL; 2186 return -EINVAL;
2150 return 0; 2187 return 0;
2151} 2188}
2152 2189
2153 2190static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
2154static int ext_encode_var( struct fb_var_screeninfo *var,
2155 struct atafb_par *par )
2156{ 2191{
2157 memset(var, 0, sizeof(struct fb_var_screeninfo)); 2192 memset(var, 0, sizeof(struct fb_var_screeninfo));
2158 var->red.offset=0; 2193 var->red.offset = 0;
2159 var->red.length=(external_pmode == -1) ? external_depth/3 : 2194 var->red.length = (external_pmode == -1) ? external_depth / 3 :
2160 (external_vgaiobase ? external_bitspercol : 0); 2195 (external_vgaiobase ? external_bitspercol : 0);
2161 var->red.msb_right=0; 2196 var->red.msb_right = 0;
2162 var->grayscale=0; 2197 var->grayscale = 0;
2163 2198
2164 var->pixclock=31041; 2199 var->pixclock = 31041;
2165 var->left_margin=120; /* these are surely incorrect */ 2200 var->left_margin = 120; /* these are surely incorrect */
2166 var->right_margin=100; 2201 var->right_margin = 100;
2167 var->upper_margin=8; 2202 var->upper_margin = 8;
2168 var->lower_margin=16; 2203 var->lower_margin = 16;
2169 var->hsync_len=140; 2204 var->hsync_len = 140;
2170 var->vsync_len=30; 2205 var->vsync_len = 30;
2171 2206
2172 var->height=-1; 2207 var->height = -1;
2173 var->width=-1; 2208 var->width = -1;
2174 2209
2175 var->sync=0; 2210 var->sync = 0;
2176 2211
2177 var->xres = external_xres; 2212 var->xres = external_xres;
2178 var->yres = external_yres; 2213 var->yres = external_yres;
2179 var->xres_virtual = external_xres_virtual; 2214 var->xres_virtual = external_xres_virtual;
2180 var->bits_per_pixel = external_depth; 2215 var->bits_per_pixel = external_depth;
2181 2216
2182 var->blue=var->green=var->red; 2217 var->blue = var->green = var->red;
2183 var->transp.offset=0; 2218 var->transp.offset = 0;
2184 var->transp.length=0; 2219 var->transp.length = 0;
2185 var->transp.msb_right=0; 2220 var->transp.msb_right = 0;
2186 var->yres_virtual=var->yres; 2221 var->yres_virtual = var->yres;
2187 var->xoffset=0; 2222 var->xoffset = 0;
2188 var->yoffset=0; 2223 var->yoffset = 0;
2189 var->nonstd=0; 2224 var->nonstd = 0;
2190 var->activate=0; 2225 var->activate = 0;
2191 var->vmode=FB_VMODE_NONINTERLACED; 2226 var->vmode = FB_VMODE_NONINTERLACED;
2192 return 0; 2227 return 0;
2193} 2228}
2194 2229
2195 2230static void ext_get_par(struct atafb_par *par)
2196static void ext_get_par( struct atafb_par *par )
2197{ 2231{
2198 par->screen_base = external_addr; 2232 par->screen_base = external_addr;
2199} 2233}
2200 2234
2201static void ext_set_par( struct atafb_par *par ) 2235static void ext_set_par(struct atafb_par *par)
2202{ 2236{
2203} 2237}
2204 2238
2205#define OUTB(port,val) \ 2239#define OUTB(port,val) \
2206 *((unsigned volatile char *) ((port)+external_vgaiobase))=(val) 2240 *((unsigned volatile char *) ((port)+external_vgaiobase)) = (val)
2207#define INB(port) \ 2241#define INB(port) \
2208 (*((unsigned volatile char *) ((port)+external_vgaiobase))) 2242 (*((unsigned volatile char *) ((port)+external_vgaiobase)))
2209#define DACDelay \ 2243#define DACDelay \
2210 do { \ 2244 do { \
2211 unsigned char tmp=INB(0x3da); \ 2245 unsigned char tmp = INB(0x3da); \
2212 tmp=INB(0x3da); \ 2246 tmp = INB(0x3da); \
2213 } while (0) 2247 } while (0)
2214 2248
2215static int ext_getcolreg( unsigned regno, unsigned *red, 2249static int ext_setcolreg(unsigned int regno, unsigned int red,
2216 unsigned *green, unsigned *blue, 2250 unsigned int green, unsigned int blue,
2217 unsigned *transp, struct fb_info *info ) 2251 unsigned int transp, struct fb_info *info)
2218{ 2252{
2219 if (! external_vgaiobase) 2253 unsigned char colmask = (1 << external_bitspercol) - 1;
2254
2255 if (!external_vgaiobase)
2220 return 1; 2256 return 1;
2221 2257
2222 *red = ext_color[regno].red; 2258 switch (external_card_type) {
2223 *green = ext_color[regno].green; 2259 case IS_VGA:
2224 *blue = ext_color[regno].blue; 2260 OUTB(0x3c8, regno);
2225 *transp=0; 2261 DACDelay;
2226 return 0; 2262 OUTB(0x3c9, red & colmask);
2227} 2263 DACDelay;
2228 2264 OUTB(0x3c9, green & colmask);
2229static int ext_setcolreg( unsigned regno, unsigned red, 2265 DACDelay;
2230 unsigned green, unsigned blue, 2266 OUTB(0x3c9, blue & colmask);
2231 unsigned transp, struct fb_info *info ) 2267 DACDelay;
2268 return 0;
2232 2269
2233{ unsigned char colmask = (1 << external_bitspercol) - 1; 2270 case IS_MV300:
2271 OUTB((MV300_reg[regno] << 2) + 1, red);
2272 OUTB((MV300_reg[regno] << 2) + 1, green);
2273 OUTB((MV300_reg[regno] << 2) + 1, blue);
2274 return 0;
2234 2275
2235 if (! external_vgaiobase) 2276 default:
2236 return 1; 2277 return 1;
2237 2278 }
2238 ext_color[regno].red = red;
2239 ext_color[regno].green = green;
2240 ext_color[regno].blue = blue;
2241
2242 switch (external_card_type) {
2243 case IS_VGA:
2244 OUTB(0x3c8, regno);
2245 DACDelay;
2246 OUTB(0x3c9, red & colmask);
2247 DACDelay;
2248 OUTB(0x3c9, green & colmask);
2249 DACDelay;
2250 OUTB(0x3c9, blue & colmask);
2251 DACDelay;
2252 return 0;
2253
2254 case IS_MV300:
2255 OUTB((MV300_reg[regno] << 2)+1, red);
2256 OUTB((MV300_reg[regno] << 2)+1, green);
2257 OUTB((MV300_reg[regno] << 2)+1, blue);
2258 return 0;
2259
2260 default:
2261 return 1;
2262 }
2263} 2279}
2264
2265
2266static int ext_detect( void )
2267 2280
2281static int ext_detect(void)
2268{ 2282{
2269 struct fb_var_screeninfo *myvar = &atafb_predefined[0]; 2283 struct fb_var_screeninfo *myvar = &atafb_predefined[0];
2270 struct atafb_par dummy_par; 2284 struct atafb_par dummy_par;
@@ -2284,213 +2298,182 @@ static int ext_detect( void )
2284static void set_screen_base(void *s_base) 2298static void set_screen_base(void *s_base)
2285{ 2299{
2286 unsigned long addr; 2300 unsigned long addr;
2287 addr= virt_to_phys(s_base); 2301
2302 addr = virt_to_phys(s_base);
2288 /* Setup Screen Memory */ 2303 /* Setup Screen Memory */
2289 shifter.bas_hi=(unsigned char) ((addr & 0xff0000) >> 16); 2304 shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16);
2290 shifter.bas_md=(unsigned char) ((addr & 0x00ff00) >> 8); 2305 shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8);
2291 shifter.bas_lo=(unsigned char) (addr & 0x0000ff); 2306 shifter.bas_lo = (unsigned char)(addr & 0x0000ff);
2292} 2307}
2293 2308
2294 2309static int pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
2295static int pan_display( struct fb_var_screeninfo *var,
2296 struct atafb_par *par )
2297{ 2310{
2311 struct atafb_par *par = (struct atafb_par *)info->par;
2312
2298 if (!fbhw->set_screen_base || 2313 if (!fbhw->set_screen_base ||
2299 (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) 2314 (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset))
2300 return -EINVAL; 2315 return -EINVAL;
2301 var->xoffset = up(var->xoffset, 16); 2316 var->xoffset = up(var->xoffset, 16);
2302 par->screen_base = screen_base + 2317 par->screen_base = screen_base +
2303 (var->yoffset * fb_display[fb_info.currcon].var.xres_virtual + var->xoffset) 2318 (var->yoffset * info->var.xres_virtual + var->xoffset)
2304 * fb_display[fb_info.currcon].var.bits_per_pixel / 8; 2319 * info->var.bits_per_pixel / 8;
2305 fbhw->set_screen_base (par->screen_base); 2320 fbhw->set_screen_base(par->screen_base);
2306 return 0; 2321 return 0;
2307} 2322}
2308 2323
2309
2310/* ------------ Interfaces to hardware functions ------------ */ 2324/* ------------ Interfaces to hardware functions ------------ */
2311 2325
2312
2313#ifdef ATAFB_TT 2326#ifdef ATAFB_TT
2314static struct fb_hwswitch tt_switch = { 2327static struct fb_hwswitch tt_switch = {
2315 tt_detect, tt_encode_fix, tt_decode_var, tt_encode_var, 2328 .detect = tt_detect,
2316 tt_get_par, tt_set_par, tt_getcolreg, 2329 .encode_fix = tt_encode_fix,
2317 set_screen_base, NULL, pan_display 2330 .decode_var = tt_decode_var,
2331 .encode_var = tt_encode_var,
2332 .get_par = tt_get_par,
2333 .set_par = tt_set_par,
2334 .set_screen_base = set_screen_base,
2335 .pan_display = pan_display,
2318}; 2336};
2319#endif 2337#endif
2320 2338
2321#ifdef ATAFB_FALCON 2339#ifdef ATAFB_FALCON
2322static struct fb_hwswitch falcon_switch = { 2340static struct fb_hwswitch falcon_switch = {
2323 falcon_detect, falcon_encode_fix, falcon_decode_var, falcon_encode_var, 2341 .detect = falcon_detect,
2324 falcon_get_par, falcon_set_par, falcon_getcolreg, 2342 .encode_fix = falcon_encode_fix,
2325 set_screen_base, falcon_blank, falcon_pan_display 2343 .decode_var = falcon_decode_var,
2344 .encode_var = falcon_encode_var,
2345 .get_par = falcon_get_par,
2346 .set_par = falcon_set_par,
2347 .set_screen_base = set_screen_base,
2348 .blank = falcon_blank,
2349 .pan_display = falcon_pan_display,
2326}; 2350};
2327#endif 2351#endif
2328 2352
2329#ifdef ATAFB_STE 2353#ifdef ATAFB_STE
2330static struct fb_hwswitch st_switch = { 2354static struct fb_hwswitch st_switch = {
2331 stste_detect, stste_encode_fix, stste_decode_var, stste_encode_var, 2355 .detect = stste_detect,
2332 stste_get_par, stste_set_par, stste_getcolreg, 2356 .encode_fix = stste_encode_fix,
2333 stste_set_screen_base, NULL, pan_display 2357 .decode_var = stste_decode_var,
2358 .encode_var = stste_encode_var,
2359 .get_par = stste_get_par,
2360 .set_par = stste_set_par,
2361 .set_screen_base = stste_set_screen_base,
2362 .pan_display = pan_display
2334}; 2363};
2335#endif 2364#endif
2336 2365
2337#ifdef ATAFB_EXT 2366#ifdef ATAFB_EXT
2338static struct fb_hwswitch ext_switch = { 2367static struct fb_hwswitch ext_switch = {
2339 ext_detect, ext_encode_fix, ext_decode_var, ext_encode_var, 2368 .detect = ext_detect,
2340 ext_get_par, ext_set_par, ext_getcolreg, NULL, NULL, NULL 2369 .encode_fix = ext_encode_fix,
2370 .decode_var = ext_decode_var,
2371 .encode_var = ext_encode_var,
2372 .get_par = ext_get_par,
2373 .set_par = ext_set_par,
2341}; 2374};
2342#endif 2375#endif
2343 2376
2344 2377static void ata_get_par(struct atafb_par *par)
2345
2346static void atafb_get_par( struct atafb_par *par )
2347{ 2378{
2348 if (current_par_valid) { 2379 if (current_par_valid)
2349 *par=current_par; 2380 *par = current_par;
2350 }
2351 else 2381 else
2352 fbhw->get_par(par); 2382 fbhw->get_par(par);
2353} 2383}
2354 2384
2355 2385static void ata_set_par(struct atafb_par *par)
2356static void atafb_set_par( struct atafb_par *par )
2357{ 2386{
2358 fbhw->set_par(par); 2387 fbhw->set_par(par);
2359 current_par=*par; 2388 current_par = *par;
2360 current_par_valid=1; 2389 current_par_valid = 1;
2361} 2390}
2362 2391
2363 2392
2364
2365/* =========================================================== */ 2393/* =========================================================== */
2366/* ============== Hardware Independent Functions ============= */ 2394/* ============== Hardware Independent Functions ============= */
2367/* =========================================================== */ 2395/* =========================================================== */
2368 2396
2369
2370/* used for hardware scrolling */ 2397/* used for hardware scrolling */
2371 2398
2372static int 2399static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive)
2373fb_update_var(int con, struct fb_info *info)
2374{
2375 int off=fb_display[con].var.yoffset*fb_display[con].var.xres_virtual*
2376 fb_display[con].var.bits_per_pixel>>3;
2377
2378 current_par.screen_base=screen_base + off;
2379
2380 if (fbhw->set_screen_base)
2381 fbhw->set_screen_base(current_par.screen_base);
2382 return 0;
2383}
2384
2385static int
2386do_fb_set_var(struct fb_var_screeninfo *var, int isactive)
2387{ 2400{
2388 int err,activate; 2401 int err, activate;
2389 struct atafb_par par; 2402 struct atafb_par par;
2390 if ((err=fbhw->decode_var(var, &par))) 2403
2404 err = fbhw->decode_var(var, &par);
2405 if (err)
2391 return err; 2406 return err;
2392 activate=var->activate; 2407 activate = var->activate;
2393 if (((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) 2408 if (((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive)
2394 atafb_set_par(&par); 2409 ata_set_par(&par);
2395 fbhw->encode_var(var, &par); 2410 fbhw->encode_var(var, &par);
2396 var->activate=activate; 2411 var->activate = activate;
2397 return 0; 2412 return 0;
2398} 2413}
2399 2414
2400static int 2415static int atafb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
2401atafb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
2402{ 2416{
2403 struct atafb_par par; 2417 struct atafb_par par;
2404 if (con == -1) 2418 int err;
2405 atafb_get_par(&par); 2419 // Get fix directly (case con == -1 before)??
2406 else { 2420 err = fbhw->decode_var(&info->var, &par);
2407 int err; 2421 if (err)
2408 if ((err=fbhw->decode_var(&fb_display[con].var,&par))) 2422 return err;
2409 return err;
2410 }
2411 memset(fix, 0, sizeof(struct fb_fix_screeninfo)); 2423 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
2412 return fbhw->encode_fix(fix, &par); 2424 return fbhw->encode_fix(fix, &par);
2413} 2425}
2414 2426
2415static int 2427static int atafb_get_var(struct fb_var_screeninfo *var, struct fb_info *info)
2416atafb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
2417{ 2428{
2418 struct atafb_par par; 2429 struct atafb_par par;
2419 if (con == -1) { 2430
2420 atafb_get_par(&par); 2431 ata_get_par(&par);
2421 fbhw->encode_var(var, &par); 2432 fbhw->encode_var(var, &par);
2422 } 2433
2423 else
2424 *var=fb_display[con].var;
2425 return 0; 2434 return 0;
2426} 2435}
2427 2436
2428static void 2437// No longer called by fbcon!
2429atafb_set_disp(int con, struct fb_info *info) 2438// Still called by set_var internally
2439
2440static void atafb_set_disp(struct fb_info *info)
2430{ 2441{
2431 struct fb_fix_screeninfo fix; 2442 atafb_get_var(&info->var, info);
2432 struct fb_var_screeninfo var; 2443 atafb_get_fix(&info->fix, info);
2433 struct display *display;
2434 2444
2435 if (con >= 0) 2445 info->screen_base = (void *)info->fix.smem_start;
2436 display = &fb_display[con]; 2446
2437 else 2447 switch (info->fix.type) {
2438 display = &disp; /* used during initialization */ 2448 case FB_TYPE_INTERLEAVED_PLANES:
2439 2449 switch (info->var.bits_per_pixel) {
2440 atafb_get_fix(&fix, con, info); 2450 case 2:
2441 atafb_get_var(&var, con, info); 2451 // display->dispsw = &fbcon_iplan2p2;
2442 if (con == -1)
2443 con=0;
2444 info->screen_base = (void *)fix.smem_start;
2445 display->visual = fix.visual;
2446 display->type = fix.type;
2447 display->type_aux = fix.type_aux;
2448 display->ypanstep = fix.ypanstep;
2449 display->ywrapstep = fix.ywrapstep;
2450 display->line_length = fix.line_length;
2451 if (fix.visual != FB_VISUAL_PSEUDOCOLOR &&
2452 fix.visual != FB_VISUAL_DIRECTCOLOR)
2453 display->can_soft_blank = 0;
2454 else
2455 display->can_soft_blank = 1;
2456 display->inverse =
2457 (fix.visual == FB_VISUAL_MONO01 ? !inverse : inverse);
2458 switch (fix.type) {
2459 case FB_TYPE_INTERLEAVED_PLANES:
2460 switch (var.bits_per_pixel) {
2461#ifdef FBCON_HAS_IPLAN2P2
2462 case 2:
2463 display->dispsw = &fbcon_iplan2p2;
2464 break; 2452 break;
2465#endif 2453 case 4:
2466#ifdef FBCON_HAS_IPLAN2P4 2454 // display->dispsw = &fbcon_iplan2p4;
2467 case 4:
2468 display->dispsw = &fbcon_iplan2p4;
2469 break; 2455 break;
2470#endif 2456 case 8:
2471#ifdef FBCON_HAS_IPLAN2P8 2457 // display->dispsw = &fbcon_iplan2p8;
2472 case 8:
2473 display->dispsw = &fbcon_iplan2p8;
2474 break; 2458 break;
2475#endif
2476 } 2459 }
2477 break; 2460 break;
2478 case FB_TYPE_PACKED_PIXELS: 2461 case FB_TYPE_PACKED_PIXELS:
2479 switch (var.bits_per_pixel) { 2462 switch (info->var.bits_per_pixel) {
2480#ifdef FBCON_HAS_MFB 2463#ifdef FBCON_HAS_MFB
2481 case 1: 2464 case 1:
2482 display->dispsw = &fbcon_mfb; 2465 // display->dispsw = &fbcon_mfb;
2483 break; 2466 break;
2484#endif 2467#endif
2485#ifdef FBCON_HAS_CFB8 2468#ifdef FBCON_HAS_CFB8
2486 case 8: 2469 case 8:
2487 display->dispsw = &fbcon_cfb8; 2470 // display->dispsw = &fbcon_cfb8;
2488 break; 2471 break;
2489#endif 2472#endif
2490#ifdef FBCON_HAS_CFB16 2473#ifdef FBCON_HAS_CFB16
2491 case 16: 2474 case 16:
2492 display->dispsw = &fbcon_cfb16; 2475 // display->dispsw = &fbcon_cfb16;
2493 display->dispsw_data = fbcon_cfb16_cmap; 2476 // display->dispsw_data = fbcon_cfb16_cmap;
2494 break; 2477 break;
2495#endif 2478#endif
2496 } 2479 }
@@ -2498,74 +2481,203 @@ atafb_set_disp(int con, struct fb_info *info)
2498 } 2481 }
2499} 2482}
2500 2483
2484static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
2485 u_int transp, struct fb_info *info)
2486{
2487 red >>= 8;
2488 green >>= 8;
2489 blue >>= 8;
2490
2491 return info->fbops->fb_setcolreg(regno, red, green, blue, transp, info);
2492}
2493
2501static int 2494static int
2502atafb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) 2495atafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
2503{ 2496{
2504 int err,oldxres,oldyres,oldbpp,oldxres_virtual, 2497 int xoffset = var->xoffset;
2505 oldyres_virtual,oldyoffset; 2498 int yoffset = var->yoffset;
2506 if ((err=do_fb_set_var(var, con==info->currcon))) 2499 int err;
2507 return err; 2500
2508 if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { 2501 if (var->vmode & FB_VMODE_YWRAP) {
2509 oldxres=fb_display[con].var.xres; 2502 if (yoffset < 0 || yoffset >= info->var.yres_virtual || xoffset)
2510 oldyres=fb_display[con].var.yres; 2503 return -EINVAL;
2511 oldxres_virtual=fb_display[con].var.xres_virtual; 2504 } else {
2512 oldyres_virtual=fb_display[con].var.yres_virtual; 2505 if (xoffset + info->var.xres > info->var.xres_virtual ||
2513 oldbpp=fb_display[con].var.bits_per_pixel; 2506 yoffset + info->var.yres > info->var.yres_virtual)
2514 oldyoffset=fb_display[con].var.yoffset; 2507 return -EINVAL;
2515 fb_display[con].var=*var;
2516 if (oldxres != var->xres || oldyres != var->yres
2517 || oldxres_virtual != var->xres_virtual
2518 || oldyres_virtual != var->yres_virtual
2519 || oldbpp != var->bits_per_pixel
2520 || oldyoffset != var->yoffset) {
2521 atafb_set_disp(con, info);
2522 (*fb_info.changevar)(con);
2523 fb_alloc_cmap(&fb_display[con].cmap, 0, 0);
2524 do_install_cmap(con, info);
2525 }
2526 } 2508 }
2527 var->activate=0; 2509
2510 if (fbhw->pan_display) {
2511 err = fbhw->pan_display(var, info);
2512 if (err)
2513 return err;
2514 } else
2515 return -EINVAL;
2516
2517 info->var.xoffset = xoffset;
2518 info->var.yoffset = yoffset;
2519
2520 if (var->vmode & FB_VMODE_YWRAP)
2521 info->var.vmode |= FB_VMODE_YWRAP;
2522 else
2523 info->var.vmode &= ~FB_VMODE_YWRAP;
2524
2528 return 0; 2525 return 0;
2529} 2526}
2530 2527
2528/*
2529 * generic drawing routines; imageblit needs updating for image depth > 1
2530 */
2531 2531
2532#if BITS_PER_LONG == 32
2533#define BYTES_PER_LONG 4
2534#define SHIFT_PER_LONG 5
2535#elif BITS_PER_LONG == 64
2536#define BYTES_PER_LONG 8
2537#define SHIFT_PER_LONG 6
2538#else
2539#define Please update me
2540#endif
2532 2541
2533static int 2542
2534atafb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) 2543static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
2535{ 2544{
2536 if (con == info->currcon) /* current console ? */ 2545 struct atafb_par *par = (struct atafb_par *)info->par;
2537 return fb_get_cmap(cmap, kspc, fbhw->getcolreg, info); 2546 int x2, y2;
2547 u32 width, height;
2548
2549 if (!rect->width || !rect->height)
2550 return;
2551
2552 /*
2553 * We could use hardware clipping but on many cards you get around
2554 * hardware clipping by writing to framebuffer directly.
2555 * */
2556 x2 = rect->dx + rect->width;
2557 y2 = rect->dy + rect->height;
2558 x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual;
2559 y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual;
2560 width = x2 - rect->dx;
2561 height = y2 - rect->dy;
2562
2563 if (info->var.bits_per_pixel == 1)
2564 atafb_mfb_fillrect(info, par->next_line, rect->color,
2565 rect->dy, rect->dx, height, width);
2566 else if (info->var.bits_per_pixel == 2)
2567 atafb_iplan2p2_fillrect(info, par->next_line, rect->color,
2568 rect->dy, rect->dx, height, width);
2569 else if (info->var.bits_per_pixel == 4)
2570 atafb_iplan2p4_fillrect(info, par->next_line, rect->color,
2571 rect->dy, rect->dx, height, width);
2538 else 2572 else
2539 if (fb_display[con].cmap.len) /* non default colormap ? */ 2573 atafb_iplan2p8_fillrect(info, par->next_line, rect->color,
2540 fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2); 2574 rect->dy, rect->dx, height, width);
2541 else 2575
2542 fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), 2576 return;
2543 cmap, kspc ? 0 : 2);
2544 return 0;
2545} 2577}
2546 2578
2547static int 2579static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
2548atafb_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info *info)
2549{ 2580{
2550 int xoffset = var->xoffset; 2581 struct atafb_par *par = (struct atafb_par *)info->par;
2551 int yoffset = var->yoffset; 2582 int x2, y2;
2552 int err; 2583 u32 dx, dy, sx, sy, width, height;
2584 int rev_copy = 0;
2585
2586 /* clip the destination */
2587 x2 = area->dx + area->width;
2588 y2 = area->dy + area->height;
2589 dx = area->dx > 0 ? area->dx : 0;
2590 dy = area->dy > 0 ? area->dy : 0;
2591 x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual;
2592 y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual;
2593 width = x2 - dx;
2594 height = y2 - dy;
2595
2596 /* update sx,sy */
2597 sx = area->sx + (dx - area->dx);
2598 sy = area->sy + (dy - area->dy);
2599
2600 /* the source must be completely inside the virtual screen */
2601 if (sx < 0 || sy < 0 || (sx + width) > info->var.xres_virtual ||
2602 (sy + height) > info->var.yres_virtual)
2603 return;
2553 2604
2554 if ( xoffset < 0 || xoffset + fb_display[con].var.xres > fb_display[con].var.xres_virtual 2605 if (dy > sy || (dy == sy && dx > sx)) {
2555 || yoffset < 0 || yoffset + fb_display[con].var.yres > fb_display[con].var.yres_virtual) 2606 dy += height;
2556 return -EINVAL; 2607 sy += height;
2608 rev_copy = 1;
2609 }
2610
2611 if (info->var.bits_per_pixel == 1)
2612 atafb_mfb_copyarea(info, par->next_line, sy, sx, dy, dx, height, width);
2613 else if (info->var.bits_per_pixel == 2)
2614 atafb_iplan2p2_copyarea(info, par->next_line, sy, sx, dy, dx, height, width);
2615 else if (info->var.bits_per_pixel == 4)
2616 atafb_iplan2p4_copyarea(info, par->next_line, sy, sx, dy, dx, height, width);
2617 else
2618 atafb_iplan2p8_copyarea(info, par->next_line, sy, sx, dy, dx, height, width);
2557 2619
2558 if (con == info->currcon) { 2620 return;
2559 if (fbhw->pan_display) { 2621}
2560 if ((err = fbhw->pan_display(var, &current_par))) 2622
2561 return err; 2623static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
2624{
2625 struct atafb_par *par = (struct atafb_par *)info->par;
2626 int x2, y2;
2627 unsigned long *dst;
2628 int dst_idx;
2629 const char *src;
2630 u32 dx, dy, width, height, pitch;
2631
2632 /*
2633 * We could use hardware clipping but on many cards you get around
2634 * hardware clipping by writing to framebuffer directly like we are
2635 * doing here.
2636 */
2637 x2 = image->dx + image->width;
2638 y2 = image->dy + image->height;
2639 dx = image->dx;
2640 dy = image->dy;
2641 x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual;
2642 y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual;
2643 width = x2 - dx;
2644 height = y2 - dy;
2645
2646 if (image->depth == 1) {
2647 // used for font data
2648 dst = (unsigned long *)
2649 ((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1));
2650 dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8;
2651 dst_idx += dy * par->next_line * 8 + dx;
2652 src = image->data;
2653 pitch = (image->width + 7) / 8;
2654 while (height--) {
2655
2656 if (info->var.bits_per_pixel == 1)
2657 atafb_mfb_linefill(info, par->next_line,
2658 dy, dx, width, src,
2659 image->bg_color, image->fg_color);
2660 else if (info->var.bits_per_pixel == 2)
2661 atafb_iplan2p2_linefill(info, par->next_line,
2662 dy, dx, width, src,
2663 image->bg_color, image->fg_color);
2664 else if (info->var.bits_per_pixel == 4)
2665 atafb_iplan2p4_linefill(info, par->next_line,
2666 dy, dx, width, src,
2667 image->bg_color, image->fg_color);
2668 else
2669 atafb_iplan2p8_linefill(info, par->next_line,
2670 dy, dx, width, src,
2671 image->bg_color, image->fg_color);
2672 dy++;
2673 src += pitch;
2562 } 2674 }
2563 else 2675 } else {
2564 return -EINVAL; 2676 // only used for logo; broken
2677 c2p(info->screen_base, image->data, dx, dy, width, height,
2678 par->next_line, par->next_plane, image->width,
2679 info->var.bits_per_pixel);
2565 } 2680 }
2566 fb_display[con].var.xoffset = var->xoffset;
2567 fb_display[con].var.yoffset = var->yoffset;
2568 return 0;
2569} 2681}
2570 2682
2571static int 2683static int
@@ -2584,7 +2696,7 @@ atafb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
2584 if (copy_from_user((void *)&current_par, (void *)arg, 2696 if (copy_from_user((void *)&current_par, (void *)arg,
2585 sizeof(struct atafb_par))) 2697 sizeof(struct atafb_par)))
2586 return -EFAULT; 2698 return -EFAULT;
2587 atafb_set_par(&current_par); 2699 ata_set_par(&current_par);
2588 return 0; 2700 return 0;
2589#endif 2701#endif
2590 } 2702 }
@@ -2598,42 +2710,82 @@ atafb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
2598 * 3 = suspend hsync 2710 * 3 = suspend hsync
2599 * 4 = off 2711 * 4 = off
2600 */ 2712 */
2601static int 2713static int atafb_blank(int blank, struct fb_info *info)
2602atafb_blank(int blank, struct fb_info *info)
2603{ 2714{
2604 unsigned short black[16]; 2715 unsigned short black[16];
2605 struct fb_cmap cmap; 2716 struct fb_cmap cmap;
2606 if (fbhw->blank && !fbhw->blank(blank)) 2717 if (fbhw->blank && !fbhw->blank(blank))
2607 return 1; 2718 return 1;
2608 if (blank) { 2719 if (blank) {
2609 memset(black, 0, 16*sizeof(unsigned short)); 2720 memset(black, 0, 16 * sizeof(unsigned short));
2610 cmap.red=black; 2721 cmap.red = black;
2611 cmap.green=black; 2722 cmap.green = black;
2612 cmap.blue=black; 2723 cmap.blue = black;
2613 cmap.transp=NULL; 2724 cmap.transp = NULL;
2614 cmap.start=0; 2725 cmap.start = 0;
2615 cmap.len=16; 2726 cmap.len = 16;
2616 fb_set_cmap(&cmap, 1, info); 2727 fb_set_cmap(&cmap, info);
2617 } 2728 }
2729#if 0
2618 else 2730 else
2619 do_install_cmap(info->currcon, info); 2731 do_install_cmap(info);
2732#endif
2733 return 0;
2734}
2735
2736 /*
2737 * New fbcon interface ...
2738 */
2739
2740 /* check var by decoding var into hw par, rounding if necessary,
2741 * then encoding hw par back into new, validated var */
2742static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
2743{
2744 int err;
2745 struct atafb_par par;
2746
2747 /* Validate wanted screen parameters */
2748 // if ((err = ata_decode_var(var, &par)))
2749 err = fbhw->decode_var(var, &par);
2750 if (err)
2751 return err;
2752
2753 /* Encode (possibly rounded) screen parameters */
2754 fbhw->encode_var(var, &par);
2755 return 0;
2756}
2757
2758 /* actually set hw par by decoding var, then setting hardware from
2759 * hw par just decoded */
2760static int atafb_set_par(struct fb_info *info)
2761{
2762 struct atafb_par *par = (struct atafb_par *)info->par;
2763
2764 /* Decode wanted screen parameters */
2765 fbhw->decode_var(&info->var, par);
2766 fbhw->encode_fix(&info->fix, par);
2767
2768 /* Set new videomode */
2769 ata_set_par(par);
2770
2620 return 0; 2771 return 0;
2621} 2772}
2622 2773
2774
2623static struct fb_ops atafb_ops = { 2775static struct fb_ops atafb_ops = {
2624 .owner = THIS_MODULE, 2776 .owner = THIS_MODULE,
2625 .fb_get_fix = atafb_get_fix, 2777 .fb_check_var = atafb_check_var,
2626 .fb_get_var = atafb_get_var, 2778 .fb_set_par = atafb_set_par,
2627 .fb_set_var = atafb_set_var, 2779 .fb_setcolreg = atafb_setcolreg,
2628 .fb_get_cmap = atafb_get_cmap,
2629 .fb_set_cmap = gen_set_cmap,
2630 .fb_pan_display =atafb_pan_display,
2631 .fb_blank = atafb_blank, 2780 .fb_blank = atafb_blank,
2781 .fb_pan_display = atafb_pan_display,
2782 .fb_fillrect = atafb_fillrect,
2783 .fb_copyarea = atafb_copyarea,
2784 .fb_imageblit = atafb_imageblit,
2632 .fb_ioctl = atafb_ioctl, 2785 .fb_ioctl = atafb_ioctl,
2633}; 2786};
2634 2787
2635static void 2788static void check_default_par(int detected_mode)
2636check_default_par( int detected_mode )
2637{ 2789{
2638 char default_name[10]; 2790 char default_name[10];
2639 int i; 2791 int i;
@@ -2642,199 +2794,41 @@ check_default_par( int detected_mode )
2642 2794
2643 /* First try the user supplied mode */ 2795 /* First try the user supplied mode */
2644 if (default_par) { 2796 if (default_par) {
2645 var=atafb_predefined[default_par-1]; 2797 var = atafb_predefined[default_par - 1];
2646 var.activate = FB_ACTIVATE_TEST; 2798 var.activate = FB_ACTIVATE_TEST;
2647 if (do_fb_set_var(&var,1)) 2799 if (do_fb_set_var(&var, 1))
2648 default_par=0; /* failed */ 2800 default_par = 0; /* failed */
2649 } 2801 }
2650 /* Next is the autodetected one */ 2802 /* Next is the autodetected one */
2651 if (! default_par) { 2803 if (!default_par) {
2652 var=atafb_predefined[detected_mode-1]; /* autodetect */ 2804 var = atafb_predefined[detected_mode - 1]; /* autodetect */
2653 var.activate = FB_ACTIVATE_TEST; 2805 var.activate = FB_ACTIVATE_TEST;
2654 if (!do_fb_set_var(&var,1)) 2806 if (!do_fb_set_var(&var, 1))
2655 default_par=detected_mode; 2807 default_par = detected_mode;
2656 } 2808 }
2657 /* If that also failed, try some default modes... */ 2809 /* If that also failed, try some default modes... */
2658 if (! default_par) { 2810 if (!default_par) {
2659 /* try default1, default2... */ 2811 /* try default1, default2... */
2660 for (i=1 ; i < 10 ; i++) { 2812 for (i = 1; i < 10; i++) {
2661 sprintf(default_name,"default%d",i); 2813 sprintf(default_name,"default%d", i);
2662 default_par=get_video_mode(default_name); 2814 default_par = get_video_mode(default_name);
2663 if (! default_par) 2815 if (!default_par)
2664 panic("can't set default video mode"); 2816 panic("can't set default video mode");
2665 var=atafb_predefined[default_par-1]; 2817 var = atafb_predefined[default_par - 1];
2666 var.activate = FB_ACTIVATE_TEST; 2818 var.activate = FB_ACTIVATE_TEST;
2667 if (! do_fb_set_var(&var,1)) 2819 if (!do_fb_set_var(&var,1))
2668 break; /* ok */ 2820 break; /* ok */
2669 } 2821 }
2670 } 2822 }
2671 min_mem=var.xres_virtual * var.yres_virtual * var.bits_per_pixel/8; 2823 min_mem = var.xres_virtual * var.yres_virtual * var.bits_per_pixel / 8;
2672 if (default_mem_req < min_mem) 2824 if (default_mem_req < min_mem)
2673 default_mem_req=min_mem; 2825 default_mem_req = min_mem;
2674}
2675
2676static int
2677atafb_switch(int con, struct fb_info *info)
2678{
2679 /* Do we have to save the colormap ? */
2680 if (fb_display[info->currcon].cmap.len)
2681 fb_get_cmap(&fb_display[info->currcon].cmap, 1, fbhw->getcolreg,
2682 info);
2683 do_fb_set_var(&fb_display[con].var,1);
2684 info->currcon=con;
2685 /* Install new colormap */
2686 do_install_cmap(con, info);
2687 return 0;
2688}
2689
2690int __init atafb_init(void)
2691{
2692 int pad;
2693 int detected_mode;
2694 unsigned long mem_req;
2695
2696 if (!MACH_IS_ATARI)
2697 return -ENXIO;
2698
2699 do {
2700#ifdef ATAFB_EXT
2701 if (external_addr) {
2702 fbhw = &ext_switch;
2703 atafb_ops.fb_setcolreg = &ext_setcolreg;
2704 break;
2705 }
2706#endif
2707#ifdef ATAFB_TT
2708 if (ATARIHW_PRESENT(TT_SHIFTER)) {
2709 fbhw = &tt_switch;
2710 atafb_ops.fb_setcolreg = &tt_setcolreg;
2711 break;
2712 }
2713#endif
2714#ifdef ATAFB_FALCON
2715 if (ATARIHW_PRESENT(VIDEL_SHIFTER)) {
2716 fbhw = &falcon_switch;
2717 atafb_ops.fb_setcolreg = &falcon_setcolreg;
2718 request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO,
2719 "framebuffer/modeswitch", falcon_vbl_switcher);
2720 break;
2721 }
2722#endif
2723#ifdef ATAFB_STE
2724 if (ATARIHW_PRESENT(STND_SHIFTER) ||
2725 ATARIHW_PRESENT(EXTD_SHIFTER)) {
2726 fbhw = &st_switch;
2727 atafb_ops.fb_setcolreg = &stste_setcolreg;
2728 break;
2729 }
2730 fbhw = &st_switch;
2731 atafb_ops.fb_setcolreg = &stste_setcolreg;
2732 printk("Cannot determine video hardware; defaulting to ST(e)\n");
2733#else /* ATAFB_STE */
2734 /* no default driver included */
2735 /* Nobody will ever see this message :-) */
2736 panic("Cannot initialize video hardware");
2737#endif
2738 } while (0);
2739
2740 /* Multisync monitor capabilities */
2741 /* Atari-TOS defaults if no boot option present */
2742 if (fb_info.monspecs.hfmin == 0) {
2743 fb_info.monspecs.hfmin = 31000;
2744 fb_info.monspecs.hfmax = 32000;
2745 fb_info.monspecs.vfmin = 58;
2746 fb_info.monspecs.vfmax = 62;
2747 }
2748
2749 detected_mode = fbhw->detect();
2750 check_default_par(detected_mode);
2751#ifdef ATAFB_EXT
2752 if (!external_addr) {
2753#endif /* ATAFB_EXT */
2754 mem_req = default_mem_req + ovsc_offset + ovsc_addlen;
2755 mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE;
2756 screen_base = atari_stram_alloc(mem_req, "atafb");
2757 if (!screen_base)
2758 panic("Cannot allocate screen memory");
2759 memset(screen_base, 0, mem_req);
2760 pad = -(unsigned long)screen_base & (PAGE_SIZE-1);
2761 screen_base+=pad;
2762 real_screen_base=screen_base+ovsc_offset;
2763 screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK;
2764 st_ovsc_switch();
2765 if (CPU_IS_040_OR_060) {
2766 /* On a '040+, the cache mode of video RAM must be set to
2767 * write-through also for internal video hardware! */
2768 cache_push(virt_to_phys(screen_base), screen_len);
2769 kernel_set_cachemode(screen_base, screen_len,
2770 IOMAP_WRITETHROUGH);
2771 }
2772#ifdef ATAFB_EXT
2773 }
2774 else {
2775 /* Map the video memory (physical address given) to somewhere
2776 * in the kernel address space.
2777 */
2778 external_addr =
2779 ioremap_writethrough((unsigned long)external_addr,
2780 external_len);
2781 if (external_vgaiobase)
2782 external_vgaiobase =
2783 (unsigned long)ioremap(external_vgaiobase, 0x10000);
2784 screen_base =
2785 real_screen_base = external_addr;
2786 screen_len = external_len & PAGE_MASK;
2787 memset (screen_base, 0, external_len);
2788 }
2789#endif /* ATAFB_EXT */
2790
2791 strcpy(fb_info.modename, "Atari Builtin ");
2792 fb_info.changevar = NULL;
2793 fb_info.fbops = &atafb_ops;
2794 fb_info.disp = &disp;
2795 fb_info.currcon = -1;
2796 fb_info.switch_con = &atafb_switch;
2797 fb_info.updatevar = &fb_update_var;
2798 fb_info.flags = FBINFO_FLAG_DEFAULT;
2799 do_fb_set_var(&atafb_predefined[default_par-1], 1);
2800 strcat(fb_info.modename, fb_var_names[default_par-1][0]);
2801
2802 atafb_get_var(&disp.var, -1, &fb_info);
2803 atafb_set_disp(-1, &fb_info);
2804 do_install_cmap(0, &fb_info);
2805
2806 if (register_framebuffer(&fb_info) < 0) {
2807#ifdef ATAFB_EXT
2808 if (external_addr) {
2809 iounmap(external_addr);
2810 external_addr = NULL;
2811 }
2812 if (external_vgaiobase) {
2813 iounmap((void*)external_vgaiobase);
2814 external_vgaiobase = 0;
2815 }
2816#endif
2817 return -EINVAL;
2818 }
2819
2820 printk("Determined %dx%d, depth %d\n",
2821 disp.var.xres, disp.var.yres, disp.var.bits_per_pixel);
2822 if ((disp.var.xres != disp.var.xres_virtual) ||
2823 (disp.var.yres != disp.var.yres_virtual))
2824 printk(" virtual %dx%d\n",
2825 disp.var.xres_virtual, disp.var.yres_virtual);
2826 printk("fb%d: %s frame buffer device, using %dK of video memory\n",
2827 fb_info.node, fb_info.modename, screen_len>>10);
2828
2829 /* TODO: This driver cannot be unloaded yet */
2830 return 0;
2831} 2826}
2832 2827
2833
2834#ifdef ATAFB_EXT 2828#ifdef ATAFB_EXT
2835static void __init atafb_setup_ext(char *spec) 2829static void __init atafb_setup_ext(char *spec)
2836{ 2830{
2837 int xres, xres_virtual, yres, depth, planes; 2831 int xres, xres_virtual, yres, depth, planes;
2838 unsigned long addr, len; 2832 unsigned long addr, len;
2839 char *p; 2833 char *p;
2840 2834
@@ -2848,27 +2842,31 @@ static void __init atafb_setup_ext(char *spec)
2848 * 2842 *
2849 * Even xres_virtual is available, we neither support panning nor hw-scrolling! 2843 * Even xres_virtual is available, we neither support panning nor hw-scrolling!
2850 */ 2844 */
2851 if (!(p = strsep(&spec, ";")) || !*p) 2845 p = strsep(&spec, ";");
2852 return; 2846 if (!p || !*p)
2847 return;
2853 xres_virtual = xres = simple_strtoul(p, NULL, 10); 2848 xres_virtual = xres = simple_strtoul(p, NULL, 10);
2854 if (xres <= 0) 2849 if (xres <= 0)
2855 return; 2850 return;
2856 2851
2857 if (!(p = strsep(&spec, ";")) || !*p) 2852 p = strsep(&spec, ";");
2858 return; 2853 if (!p || !*p)
2854 return;
2859 yres = simple_strtoul(p, NULL, 10); 2855 yres = simple_strtoul(p, NULL, 10);
2860 if (yres <= 0) 2856 if (yres <= 0)
2861 return; 2857 return;
2862 2858
2863 if (!(p = strsep(&spec, ";")) || !*p) 2859 p = strsep(&spec, ";");
2864 return; 2860 if (!p || !*p)
2861 return;
2865 depth = simple_strtoul(p, NULL, 10); 2862 depth = simple_strtoul(p, NULL, 10);
2866 if (depth != 1 && depth != 2 && depth != 4 && depth != 8 && 2863 if (depth != 1 && depth != 2 && depth != 4 && depth != 8 &&
2867 depth != 16 && depth != 24) 2864 depth != 16 && depth != 24)
2868 return; 2865 return;
2869 2866
2870 if (!(p = strsep(&spec, ";")) || !*p) 2867 p = strsep(&spec, ";");
2871 return; 2868 if (!p || !*p)
2869 return;
2872 if (*p == 'i') 2870 if (*p == 'i')
2873 planes = FB_TYPE_INTERLEAVED_PLANES; 2871 planes = FB_TYPE_INTERLEAVED_PLANES;
2874 else if (*p == 'p') 2872 else if (*p == 'p')
@@ -2876,25 +2874,27 @@ static void __init atafb_setup_ext(char *spec)
2876 else if (*p == 'n') 2874 else if (*p == 'n')
2877 planes = FB_TYPE_PLANES; 2875 planes = FB_TYPE_PLANES;
2878 else if (*p == 't') 2876 else if (*p == 't')
2879 planes = -1; /* true color */ 2877 planes = -1; /* true color */
2880 else 2878 else
2881 return; 2879 return;
2882 2880
2883 2881 p = strsep(&spec, ";");
2884 if (!(p = strsep(&spec, ";")) || !*p) 2882 if (!p || !*p)
2885 return; 2883 return;
2886 addr = simple_strtoul(p, NULL, 0); 2884 addr = simple_strtoul(p, NULL, 0);
2887 2885
2888 if (!(p = strsep(&spec, ";")) || !*p) 2886 p = strsep(&spec, ";");
2889 len = xres*yres*depth/8; 2887 if (!p || !*p)
2888 len = xres * yres * depth / 8;
2890 else 2889 else
2891 len = simple_strtoul(p, NULL, 0); 2890 len = simple_strtoul(p, NULL, 0);
2892 2891
2893 if ((p = strsep(&spec, ";")) && *p) { 2892 p = strsep(&spec, ";");
2894 external_vgaiobase=simple_strtoul(p, NULL, 0); 2893 if (p && *p)
2895 } 2894 external_vgaiobase = simple_strtoul(p, NULL, 0);
2896 2895
2897 if ((p = strsep(&spec, ";")) && *p) { 2896 p = strsep(&spec, ";");
2897 if (p && *p) {
2898 external_bitspercol = simple_strtoul(p, NULL, 0); 2898 external_bitspercol = simple_strtoul(p, NULL, 0);
2899 if (external_bitspercol > 8) 2899 if (external_bitspercol > 8)
2900 external_bitspercol = 8; 2900 external_bitspercol = 8;
@@ -2902,59 +2902,61 @@ static void __init atafb_setup_ext(char *spec)
2902 external_bitspercol = 1; 2902 external_bitspercol = 1;
2903 } 2903 }
2904 2904
2905 if ((p = strsep(&spec, ";")) && *p) { 2905 p = strsep(&spec, ";");
2906 if (p && *p) {
2906 if (!strcmp(p, "vga")) 2907 if (!strcmp(p, "vga"))
2907 external_card_type = IS_VGA; 2908 external_card_type = IS_VGA;
2908 if (!strcmp(p, "mv300")) 2909 if (!strcmp(p, "mv300"))
2909 external_card_type = IS_MV300; 2910 external_card_type = IS_MV300;
2910 } 2911 }
2911 2912
2912 if ((p = strsep(&spec, ";")) && *p) { 2913 p = strsep(&spec, ";");
2914 if (p && *p) {
2913 xres_virtual = simple_strtoul(p, NULL, 10); 2915 xres_virtual = simple_strtoul(p, NULL, 10);
2914 if (xres_virtual < xres) 2916 if (xres_virtual < xres)
2915 xres_virtual = xres; 2917 xres_virtual = xres;
2916 if (xres_virtual*yres*depth/8 > len) 2918 if (xres_virtual * yres * depth / 8 > len)
2917 len=xres_virtual*yres*depth/8; 2919 len = xres_virtual * yres * depth / 8;
2918 } 2920 }
2919 2921
2920 external_xres = xres; 2922 external_xres = xres;
2921 external_xres_virtual = xres_virtual; 2923 external_xres_virtual = xres_virtual;
2922 external_yres = yres; 2924 external_yres = yres;
2923 external_depth = depth; 2925 external_depth = depth;
2924 external_pmode = planes; 2926 external_pmode = planes;
2925 external_addr = (void *)addr; 2927 external_addr = (void *)addr;
2926 external_len = len; 2928 external_len = len;
2927 2929
2928 if (external_card_type == IS_MV300) 2930 if (external_card_type == IS_MV300) {
2929 switch (external_depth) { 2931 switch (external_depth) {
2930 case 1: 2932 case 1:
2931 MV300_reg = MV300_reg_1bit; 2933 MV300_reg = MV300_reg_1bit;
2932 break; 2934 break;
2933 case 4: 2935 case 4:
2934 MV300_reg = MV300_reg_4bit; 2936 MV300_reg = MV300_reg_4bit;
2935 break; 2937 break;
2936 case 8: 2938 case 8:
2937 MV300_reg = MV300_reg_8bit; 2939 MV300_reg = MV300_reg_8bit;
2938 break; 2940 break;
2939 } 2941 }
2942 }
2940} 2943}
2941#endif /* ATAFB_EXT */ 2944#endif /* ATAFB_EXT */
2942 2945
2943
2944static void __init atafb_setup_int(char *spec) 2946static void __init atafb_setup_int(char *spec)
2945{ 2947{
2946 /* Format to config extended internal video hardware like OverScan: 2948 /* Format to config extended internal video hardware like OverScan:
2947 "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>" 2949 * "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>"
2948 Explanation: 2950 * Explanation:
2949 <xres>: x-resolution 2951 * <xres>: x-resolution
2950 <yres>: y-resolution 2952 * <yres>: y-resolution
2951 The following are only needed if you have an overscan which 2953 * The following are only needed if you have an overscan which
2952 needs a black border: 2954 * needs a black border:
2953 <xres_max>: max. length of a line in pixels your OverScan hardware would allow 2955 * <xres_max>: max. length of a line in pixels your OverScan hardware would allow
2954 <yres_max>: max. number of lines your OverScan hardware would allow 2956 * <yres_max>: max. number of lines your OverScan hardware would allow
2955 <offset>: Offset from physical beginning to visible beginning 2957 * <offset>: Offset from physical beginning to visible beginning
2956 of screen in bytes 2958 * of screen in bytes
2957 */ 2959 */
2958 int xres; 2960 int xres;
2959 char *p; 2961 char *p;
2960 2962
@@ -2963,23 +2965,19 @@ static void __init atafb_setup_int(char *spec)
2963 xres = simple_strtoul(p, NULL, 10); 2965 xres = simple_strtoul(p, NULL, 10);
2964 if (!(p = strsep(&spec, ";")) || !*p) 2966 if (!(p = strsep(&spec, ";")) || !*p)
2965 return; 2967 return;
2966 sttt_xres=xres; 2968 sttt_xres = xres;
2967 tt_yres=st_yres=simple_strtoul(p, NULL, 10); 2969 tt_yres = st_yres = simple_strtoul(p, NULL, 10);
2968 if ((p=strsep(&spec, ";")) && *p) { 2970 if ((p = strsep(&spec, ";")) && *p)
2969 sttt_xres_virtual=simple_strtoul(p, NULL, 10); 2971 sttt_xres_virtual = simple_strtoul(p, NULL, 10);
2970 } 2972 if ((p = strsep(&spec, ";")) && *p)
2971 if ((p=strsep(&spec, ";")) && *p) { 2973 sttt_yres_virtual = simple_strtoul(p, NULL, 0);
2972 sttt_yres_virtual=simple_strtoul(p, NULL, 0); 2974 if ((p = strsep(&spec, ";")) && *p)
2973 } 2975 ovsc_offset = simple_strtoul(p, NULL, 0);
2974 if ((p=strsep(&spec, ";")) && *p) {
2975 ovsc_offset=simple_strtoul(p, NULL, 0);
2976 }
2977 2976
2978 if (ovsc_offset || (sttt_yres_virtual != st_yres)) 2977 if (ovsc_offset || (sttt_yres_virtual != st_yres))
2979 use_hwscroll=0; 2978 use_hwscroll = 0;
2980} 2979}
2981 2980
2982
2983#ifdef ATAFB_FALCON 2981#ifdef ATAFB_FALCON
2984static void __init atafb_setup_mcap(char *spec) 2982static void __init atafb_setup_mcap(char *spec)
2985{ 2983{
@@ -3018,7 +3016,6 @@ static void __init atafb_setup_mcap(char *spec)
3018} 3016}
3019#endif /* ATAFB_FALCON */ 3017#endif /* ATAFB_FALCON */
3020 3018
3021
3022static void __init atafb_setup_user(char *spec) 3019static void __init atafb_setup_user(char *spec)
3023{ 3020{
3024 /* Format of user defined video mode is: <xres>;<yres>;<depth> 3021 /* Format of user defined video mode is: <xres>;<yres>;<depth>
@@ -3026,81 +3023,257 @@ static void __init atafb_setup_user(char *spec)
3026 char *p; 3023 char *p;
3027 int xres, yres, depth, temp; 3024 int xres, yres, depth, temp;
3028 3025
3029 if (!(p = strsep(&spec, ";")) || !*p) 3026 p = strsep(&spec, ";");
3027 if (!p || !*p)
3030 return; 3028 return;
3031 xres = simple_strtoul(p, NULL, 10); 3029 xres = simple_strtoul(p, NULL, 10);
3032 if (!(p = strsep(&spec, ";")) || !*p) 3030 p = strsep(&spec, ";");
3031 if (!p || !*p)
3033 return; 3032 return;
3034 yres = simple_strtoul(p, NULL, 10); 3033 yres = simple_strtoul(p, NULL, 10);
3035 if (!(p = strsep(&spec, "")) || !*p) 3034 p = strsep(&spec, "");
3035 if (!p || !*p)
3036 return; 3036 return;
3037 depth = simple_strtoul(p, NULL, 10); 3037 depth = simple_strtoul(p, NULL, 10);
3038 if ((temp=get_video_mode("user0"))) { 3038 temp = get_video_mode("user0");
3039 default_par=temp; 3039 if (temp) {
3040 atafb_predefined[default_par-1].xres = xres; 3040 default_par = temp;
3041 atafb_predefined[default_par-1].yres = yres; 3041 atafb_predefined[default_par - 1].xres = xres;
3042 atafb_predefined[default_par-1].bits_per_pixel = depth; 3042 atafb_predefined[default_par - 1].yres = yres;
3043 atafb_predefined[default_par - 1].bits_per_pixel = depth;
3043 } 3044 }
3044} 3045}
3045 3046
3046int __init atafb_setup( char *options ) 3047int __init atafb_setup(char *options)
3047{ 3048{
3048 char *this_opt; 3049 char *this_opt;
3049 int temp; 3050 int temp;
3050
3051 fb_info.fontname[0] = '\0';
3052 3051
3053 if (!options || !*options) 3052 if (!options || !*options)
3054 return 0; 3053 return 0;
3055 3054
3056 while ((this_opt = strsep(&options, ",")) != NULL) { 3055 while ((this_opt = strsep(&options, ",")) != NULL) {
3057 if (!*this_opt) continue; 3056 if (!*this_opt)
3058 if ((temp=get_video_mode(this_opt))) 3057 continue;
3059 default_par=temp; 3058 if ((temp = get_video_mode(this_opt))) {
3060 else if (! strcmp(this_opt, "inverse")) 3059 default_par = temp;
3061 inverse=1; 3060 mode_option = this_opt;
3062 else if (!strncmp(this_opt, "font:", 5)) 3061 } else if (!strcmp(this_opt, "inverse"))
3063 strcpy(fb_info.fontname, this_opt+5); 3062 inverse = 1;
3064 else if (! strncmp(this_opt, "hwscroll_",9)) { 3063 else if (!strncmp(this_opt, "hwscroll_", 9)) {
3065 hwscroll=simple_strtoul(this_opt+9, NULL, 10); 3064 hwscroll = simple_strtoul(this_opt + 9, NULL, 10);
3066 if (hwscroll < 0) 3065 if (hwscroll < 0)
3067 hwscroll = 0; 3066 hwscroll = 0;
3068 if (hwscroll > 200) 3067 if (hwscroll > 200)
3069 hwscroll = 200; 3068 hwscroll = 200;
3070 } 3069 }
3071#ifdef ATAFB_EXT 3070#ifdef ATAFB_EXT
3072 else if (!strcmp(this_opt,"mv300")) { 3071 else if (!strcmp(this_opt, "mv300")) {
3073 external_bitspercol = 8; 3072 external_bitspercol = 8;
3074 external_card_type = IS_MV300; 3073 external_card_type = IS_MV300;
3074 } else if (!strncmp(this_opt, "external:", 9))
3075 atafb_setup_ext(this_opt + 9);
3076#endif
3077 else if (!strncmp(this_opt, "internal:", 9))
3078 atafb_setup_int(this_opt + 9);
3079#ifdef ATAFB_FALCON
3080 else if (!strncmp(this_opt, "eclock:", 7)) {
3081 fext.f = simple_strtoul(this_opt + 7, NULL, 10);
3082 /* external pixelclock in kHz --> ps */
3083 fext.t = 1000000000 / fext.f;
3084 fext.f *= 1000;
3085 } else if (!strncmp(this_opt, "monitorcap:", 11))
3086 atafb_setup_mcap(this_opt + 11);
3087#endif
3088 else if (!strcmp(this_opt, "keep"))
3089 DontCalcRes = 1;
3090 else if (!strncmp(this_opt, "R", 1))
3091 atafb_setup_user(this_opt + 1);
3075 } 3092 }
3076 else if (!strncmp(this_opt,"external:",9)) 3093 return 0;
3077 atafb_setup_ext(this_opt+9); 3094}
3095
3096int __init atafb_init(void)
3097{
3098 int pad;
3099 int detected_mode;
3100 unsigned int defmode = 0;
3101 unsigned long mem_req;
3102
3103#ifndef MODULE
3104 char *option = NULL;
3105
3106 if (fb_get_options("atafb", &option))
3107 return -ENODEV;
3108 atafb_setup(option);
3109#endif
3110 printk("atafb_init: start\n");
3111
3112 if (!MACH_IS_ATARI)
3113 return -ENXIO;
3114
3115 do {
3116#ifdef ATAFB_EXT
3117 if (external_addr) {
3118 printk("atafb_init: initializing external hw\n");
3119 fbhw = &ext_switch;
3120 atafb_ops.fb_setcolreg = &ext_setcolreg;
3121 defmode = DEFMODE_EXT;
3122 break;
3123 }
3124#endif
3125#ifdef ATAFB_TT
3126 if (ATARIHW_PRESENT(TT_SHIFTER)) {
3127 printk("atafb_init: initializing TT hw\n");
3128 fbhw = &tt_switch;
3129 atafb_ops.fb_setcolreg = &tt_setcolreg;
3130 defmode = DEFMODE_TT;
3131 break;
3132 }
3078#endif 3133#endif
3079 else if (!strncmp(this_opt,"internal:",9))
3080 atafb_setup_int(this_opt+9);
3081#ifdef ATAFB_FALCON 3134#ifdef ATAFB_FALCON
3082 else if (!strncmp(this_opt, "eclock:", 7)) { 3135 if (ATARIHW_PRESENT(VIDEL_SHIFTER)) {
3083 fext.f = simple_strtoul(this_opt+7, NULL, 10); 3136 printk("atafb_init: initializing Falcon hw\n");
3084 /* external pixelclock in kHz --> ps */ 3137 fbhw = &falcon_switch;
3085 fext.t = 1000000000/fext.f; 3138 atafb_ops.fb_setcolreg = &falcon_setcolreg;
3086 fext.f *= 1000; 3139 request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO,
3140 "framebuffer/modeswitch", falcon_vbl_switcher);
3141 defmode = DEFMODE_F30;
3142 break;
3143 }
3144#endif
3145#ifdef ATAFB_STE
3146 if (ATARIHW_PRESENT(STND_SHIFTER) ||
3147 ATARIHW_PRESENT(EXTD_SHIFTER)) {
3148 printk("atafb_init: initializing ST/E hw\n");
3149 fbhw = &st_switch;
3150 atafb_ops.fb_setcolreg = &stste_setcolreg;
3151 defmode = DEFMODE_STE;
3152 break;
3153 }
3154 fbhw = &st_switch;
3155 atafb_ops.fb_setcolreg = &stste_setcolreg;
3156 printk("Cannot determine video hardware; defaulting to ST(e)\n");
3157#else /* ATAFB_STE */
3158 /* no default driver included */
3159 /* Nobody will ever see this message :-) */
3160 panic("Cannot initialize video hardware");
3161#endif
3162 } while (0);
3163
3164 /* Multisync monitor capabilities */
3165 /* Atari-TOS defaults if no boot option present */
3166 if (fb_info.monspecs.hfmin == 0) {
3167 fb_info.monspecs.hfmin = 31000;
3168 fb_info.monspecs.hfmax = 32000;
3169 fb_info.monspecs.vfmin = 58;
3170 fb_info.monspecs.vfmax = 62;
3087 } 3171 }
3088 else if (!strncmp(this_opt, "monitorcap:", 11)) 3172
3089 atafb_setup_mcap(this_opt+11); 3173 detected_mode = fbhw->detect();
3174 check_default_par(detected_mode);
3175#ifdef ATAFB_EXT
3176 if (!external_addr) {
3177#endif /* ATAFB_EXT */
3178 mem_req = default_mem_req + ovsc_offset + ovsc_addlen;
3179 mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE;
3180 screen_base = atari_stram_alloc(mem_req, "atafb");
3181 if (!screen_base)
3182 panic("Cannot allocate screen memory");
3183 memset(screen_base, 0, mem_req);
3184 pad = -(unsigned long)screen_base & (PAGE_SIZE - 1);
3185 screen_base += pad;
3186 real_screen_base = screen_base + ovsc_offset;
3187 screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK;
3188 st_ovsc_switch();
3189 if (CPU_IS_040_OR_060) {
3190 /* On a '040+, the cache mode of video RAM must be set to
3191 * write-through also for internal video hardware! */
3192 cache_push(virt_to_phys(screen_base), screen_len);
3193 kernel_set_cachemode(screen_base, screen_len,
3194 IOMAP_WRITETHROUGH);
3195 }
3196 printk("atafb: screen_base %p real_screen_base %p screen_len %d\n",
3197 screen_base, real_screen_base, screen_len);
3198#ifdef ATAFB_EXT
3199 } else {
3200 /* Map the video memory (physical address given) to somewhere
3201 * in the kernel address space.
3202 */
3203 external_addr = ioremap_writethrough((unsigned long)external_addr,
3204 external_len);
3205 if (external_vgaiobase)
3206 external_vgaiobase =
3207 (unsigned long)ioremap(external_vgaiobase, 0x10000);
3208 screen_base =
3209 real_screen_base = external_addr;
3210 screen_len = external_len & PAGE_MASK;
3211 memset (screen_base, 0, external_len);
3212 }
3213#endif /* ATAFB_EXT */
3214
3215// strcpy(fb_info.mode->name, "Atari Builtin ");
3216 fb_info.fbops = &atafb_ops;
3217 // try to set default (detected; requested) var
3218 do_fb_set_var(&atafb_predefined[default_par - 1], 1);
3219 // reads hw state into current par, which may not be sane yet
3220 ata_get_par(&current_par);
3221 fb_info.par = &current_par;
3222 // tries to read from HW which may not be initialized yet
3223 // so set sane var first, then call atafb_set_par
3224 atafb_get_var(&fb_info.var, &fb_info);
3225 fb_info.flags = FBINFO_FLAG_DEFAULT;
3226
3227 if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb,
3228 NUM_TOTAL_MODES, &atafb_modedb[defmode],
3229 fb_info.var.bits_per_pixel)) {
3230 return -EINVAL;
3231 }
3232
3233 atafb_set_disp(&fb_info);
3234
3235 fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0);
3236
3237
3238 printk("Determined %dx%d, depth %d\n",
3239 fb_info.var.xres, fb_info.var.yres, fb_info.var.bits_per_pixel);
3240 if ((fb_info.var.xres != fb_info.var.xres_virtual) ||
3241 (fb_info.var.yres != fb_info.var.yres_virtual))
3242 printk(" virtual %dx%d\n", fb_info.var.xres_virtual,
3243 fb_info.var.yres_virtual);
3244
3245 if (register_framebuffer(&fb_info) < 0) {
3246#ifdef ATAFB_EXT
3247 if (external_addr) {
3248 iounmap(external_addr);
3249 external_addr = NULL;
3250 }
3251 if (external_vgaiobase) {
3252 iounmap((void*)external_vgaiobase);
3253 external_vgaiobase = 0;
3254 }
3090#endif 3255#endif
3091 else if (!strcmp(this_opt, "keep")) 3256 return -EINVAL;
3092 DontCalcRes = 1; 3257 }
3093 else if (!strncmp(this_opt, "R", 1)) 3258
3094 atafb_setup_user(this_opt+1); 3259 // FIXME: mode needs setting!
3095 } 3260 //printk("fb%d: %s frame buffer device, using %dK of video memory\n",
3096 return 0; 3261 // fb_info.node, fb_info.mode->name, screen_len>>10);
3262 printk("fb%d: frame buffer device, using %dK of video memory\n",
3263 fb_info.node, screen_len >> 10);
3264
3265 /* TODO: This driver cannot be unloaded yet */
3266 return 0;
3097} 3267}
3098 3268
3269module_init(atafb_init);
3270
3099#ifdef MODULE 3271#ifdef MODULE
3100MODULE_LICENSE("GPL"); 3272MODULE_LICENSE("GPL");
3101 3273
3102int init_module(void) 3274int cleanup_module(void)
3103{ 3275{
3104 return atafb_init(); 3276 unregister_framebuffer(&fb_info);
3277 return atafb_deinit();
3105} 3278}
3106#endif /* MODULE */ 3279#endif /* MODULE */
diff --git a/drivers/video/atafb.h b/drivers/video/atafb.h
new file mode 100644
index 000000000000..014e05906cb1
--- /dev/null
+++ b/drivers/video/atafb.h
@@ -0,0 +1,36 @@
1#ifndef _VIDEO_ATAFB_H
2#define _VIDEO_ATAFB_H
3
4void atafb_mfb_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy,
5 int dx, int height, int width);
6void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color,
7 int sy, int sx, int height, int width);
8void atafb_mfb_linefill(struct fb_info *info, u_long next_line,
9 int dy, int dx, u32 width,
10 const u8 *data, u32 bgcolor, u32 fgcolor);
11
12void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy,
13 int dx, int height, int width);
14void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color,
15 int sy, int sx, int height, int width);
16void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line,
17 int dy, int dx, u32 width,
18 const u8 *data, u32 bgcolor, u32 fgcolor);
19
20void atafb_iplan2p4_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy,
21 int dx, int height, int width);
22void atafb_iplan2p4_fillrect(struct fb_info *info, u_long next_line, u32 color,
23 int sy, int sx, int height, int width);
24void atafb_iplan2p4_linefill(struct fb_info *info, u_long next_line,
25 int dy, int dx, u32 width,
26 const u8 *data, u32 bgcolor, u32 fgcolor);
27
28void atafb_iplan2p8_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy,
29 int dx, int height, int width);
30void atafb_iplan2p8_fillrect(struct fb_info *info, u_long next_line, u32 color,
31 int sy, int sx, int height, int width);
32void atafb_iplan2p8_linefill(struct fb_info *info, u_long next_line,
33 int dy, int dx, u32 width,
34 const u8 *data, u32 bgcolor, u32 fgcolor);
35
36#endif /* _VIDEO_ATAFB_H */
diff --git a/drivers/video/atafb_iplan2p2.c b/drivers/video/atafb_iplan2p2.c
new file mode 100644
index 000000000000..8cc9c50379d0
--- /dev/null
+++ b/drivers/video/atafb_iplan2p2.c
@@ -0,0 +1,293 @@
1/*
2 * linux/drivers/video/iplan2p2.c -- Low level frame buffer operations for
3 * interleaved bitplanes à la Atari (2
4 * planes, 2 bytes interleave)
5 *
6 * Created 5 Apr 1997 by Geert Uytterhoeven
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/module.h>
14#include <linux/string.h>
15#include <linux/fb.h>
16
17#include <asm/setup.h>
18
19#include "atafb.h"
20
21#define BPL 2
22#include "atafb_utils.h"
23
24void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line,
25 int sy, int sx, int dy, int dx,
26 int height, int width)
27{
28 /* bmove() has to distinguish two major cases: If both, source and
29 * destination, start at even addresses or both are at odd
30 * addresses, just the first odd and last even column (if present)
31 * require special treatment (memmove_col()). The rest between
32 * then can be copied by normal operations, because all adjacent
33 * bytes are affected and are to be stored in the same order.
34 * The pathological case is when the move should go from an odd
35 * address to an even or vice versa. Since the bytes in the plane
36 * words must be assembled in new order, it seems wisest to make
37 * all movements by memmove_col().
38 */
39
40 u8 *src, *dst;
41 u32 *s, *d;
42 int w, l , i, j;
43 u_int colsize;
44 u_int upwards = (dy < sy) || (dy == sy && dx < sx);
45
46 colsize = height;
47 if (!((sx ^ dx) & 15)) {
48 /* odd->odd or even->even */
49
50 if (upwards) {
51 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
52 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
53 if (sx & 15) {
54 memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2);
55 src += BPL * 2;
56 dst += BPL * 2;
57 width -= 8;
58 }
59 w = width >> 4;
60 if (w) {
61 s = (u32 *)src;
62 d = (u32 *)dst;
63 w *= BPL / 2;
64 l = next_line - w * 4;
65 for (j = height; j > 0; j--) {
66 for (i = w; i > 0; i--)
67 *d++ = *s++;
68 s = (u32 *)((u8 *)s + l);
69 d = (u32 *)((u8 *)d + l);
70 }
71 }
72 if (width & 15)
73 memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL),
74 0xff00ff00, height, next_line - BPL * 2);
75 } else {
76 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
77 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
78
79 if ((sx + width) & 15) {
80 src -= BPL * 2;
81 dst -= BPL * 2;
82 memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2);
83 width -= 8;
84 }
85 w = width >> 4;
86 if (w) {
87 s = (u32 *)src;
88 d = (u32 *)dst;
89 w *= BPL / 2;
90 l = next_line - w * 4;
91 for (j = height; j > 0; j--) {
92 for (i = w; i > 0; i--)
93 *--d = *--s;
94 s = (u32 *)((u8 *)s - l);
95 d = (u32 *)((u8 *)d - l);
96 }
97 }
98 if (sx & 15)
99 memmove32_col(dst - (width - 16) / (8 / BPL),
100 src - (width - 16) / (8 / BPL),
101 0xff00ff, colsize, -next_line - BPL * 2);
102 }
103 } else {
104 /* odd->even or even->odd */
105 if (upwards) {
106 u32 *src32, *dst32;
107 u32 pval[4], v, v1, mask;
108 int i, j, w, f;
109
110 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
111 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
112
113 mask = 0xff00ff00;
114 f = 0;
115 w = width;
116 if (sx & 15) {
117 f = 1;
118 w += 8;
119 }
120 if ((sx + width) & 15)
121 f |= 2;
122 w >>= 4;
123 for (i = height; i; i--) {
124 src32 = (u32 *)src;
125 dst32 = (u32 *)dst;
126
127 if (f & 1) {
128 pval[0] = (*src32++ << 8) & mask;
129 } else {
130 pval[0] = dst32[0] & mask;
131 }
132
133 for (j = w; j > 0; j--) {
134 v = *src32++;
135 v1 = v & mask;
136 *dst32++ = pval[0] | (v1 >> 8);
137 pval[0] = (v ^ v1) << 8;
138 }
139
140 if (f & 2) {
141 dst32[0] = (dst32[0] & mask) | pval[0];
142 }
143
144 src += next_line;
145 dst += next_line;
146 }
147 } else {
148 u32 *src32, *dst32;
149 u32 pval[4], v, v1, mask;
150 int i, j, w, f;
151
152 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
153 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
154
155 mask = 0xff00ff;
156 f = 0;
157 w = width;
158 if ((dx + width) & 15)
159 f = 1;
160 if (sx & 15) {
161 f |= 2;
162 w += 8;
163 }
164 w >>= 4;
165 for (i = height; i; i--) {
166 src32 = (u32 *)src;
167 dst32 = (u32 *)dst;
168
169 if (f & 1) {
170 pval[0] = dst32[-1] & mask;
171 } else {
172 pval[0] = (*--src32 >> 8) & mask;
173 }
174
175 for (j = w; j > 0; j--) {
176 v = *--src32;
177 v1 = v & mask;
178 *--dst32 = pval[0] | (v1 << 8);
179 pval[0] = (v ^ v1) >> 8;
180 }
181
182 if (!(f & 2)) {
183 dst32[-1] = (dst32[-1] & mask) | pval[0];
184 }
185
186 src -= next_line;
187 dst -= next_line;
188 }
189 }
190 }
191}
192
193void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color,
194 int sy, int sx, int height, int width)
195{
196 u32 *dest;
197 int rows, i;
198 u32 cval[4];
199
200 dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL));
201 if (sx & 15) {
202 u8 *dest8 = (u8 *)dest + 1;
203
204 expand8_col2mask(color, cval);
205
206 for (i = height; i; i--) {
207 fill8_col(dest8, cval);
208 dest8 += next_line;
209 }
210 dest += BPL / 2;
211 width -= 8;
212 }
213
214 expand16_col2mask(color, cval);
215 rows = width >> 4;
216 if (rows) {
217 u32 *d = dest;
218 u32 off = next_line - rows * BPL * 2;
219 for (i = height; i; i--) {
220 d = fill16_col(d, rows, cval);
221 d = (u32 *)((long)d + off);
222 }
223 dest += rows * BPL / 2;
224 width &= 15;
225 }
226
227 if (width) {
228 u8 *dest8 = (u8 *)dest;
229
230 expand8_col2mask(color, cval);
231
232 for (i = height; i; i--) {
233 fill8_col(dest8, cval);
234 dest8 += next_line;
235 }
236 }
237}
238
239void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line,
240 int dy, int dx, u32 width,
241 const u8 *data, u32 bgcolor, u32 fgcolor)
242{
243 u32 *dest;
244 const u16 *data16;
245 int rows;
246 u32 fgm[4], bgm[4], m;
247
248 dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL));
249 if (dx & 15) {
250 fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++);
251 dest += BPL / 2;
252 width -= 8;
253 }
254
255 if (width >= 16) {
256 data16 = (const u16 *)data;
257 expand16_2col2mask(fgcolor, bgcolor, fgm, bgm);
258
259 for (rows = width / 16; rows; rows--) {
260 u16 d = *data16++;
261 m = d | ((u32)d << 16);
262 *dest++ = (m & fgm[0]) ^ bgm[0];
263 }
264
265 data = (const u8 *)data16;
266 width &= 15;
267 }
268
269 if (width)
270 fill8_2col((u8 *)dest, fgcolor, bgcolor, *data);
271}
272
273#ifdef MODULE
274MODULE_LICENSE("GPL");
275
276int init_module(void)
277{
278 return 0;
279}
280
281void cleanup_module(void)
282{
283}
284#endif /* MODULE */
285
286
287 /*
288 * Visible symbols for modules
289 */
290
291EXPORT_SYMBOL(atafb_iplan2p2_copyarea);
292EXPORT_SYMBOL(atafb_iplan2p2_fillrect);
293EXPORT_SYMBOL(atafb_iplan2p2_linefill);
diff --git a/drivers/video/atafb_iplan2p4.c b/drivers/video/atafb_iplan2p4.c
new file mode 100644
index 000000000000..bee0d89463f7
--- /dev/null
+++ b/drivers/video/atafb_iplan2p4.c
@@ -0,0 +1,308 @@
1/*
2 * linux/drivers/video/iplan2p4.c -- Low level frame buffer operations for
3 * interleaved bitplanes à la Atari (4
4 * planes, 2 bytes interleave)
5 *
6 * Created 5 Apr 1997 by Geert Uytterhoeven
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/module.h>
14#include <linux/string.h>
15#include <linux/fb.h>
16
17#include <asm/setup.h>
18
19#include "atafb.h"
20
21#define BPL 4
22#include "atafb_utils.h"
23
24void atafb_iplan2p4_copyarea(struct fb_info *info, u_long next_line,
25 int sy, int sx, int dy, int dx,
26 int height, int width)
27{
28 /* bmove() has to distinguish two major cases: If both, source and
29 * destination, start at even addresses or both are at odd
30 * addresses, just the first odd and last even column (if present)
31 * require special treatment (memmove_col()). The rest between
32 * then can be copied by normal operations, because all adjacent
33 * bytes are affected and are to be stored in the same order.
34 * The pathological case is when the move should go from an odd
35 * address to an even or vice versa. Since the bytes in the plane
36 * words must be assembled in new order, it seems wisest to make
37 * all movements by memmove_col().
38 */
39
40 u8 *src, *dst;
41 u32 *s, *d;
42 int w, l , i, j;
43 u_int colsize;
44 u_int upwards = (dy < sy) || (dy == sy && dx < sx);
45
46 colsize = height;
47 if (!((sx ^ dx) & 15)) {
48 /* odd->odd or even->even */
49
50 if (upwards) {
51 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
52 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
53 if (sx & 15) {
54 memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2);
55 src += BPL * 2;
56 dst += BPL * 2;
57 width -= 8;
58 }
59 w = width >> 4;
60 if (w) {
61 s = (u32 *)src;
62 d = (u32 *)dst;
63 w *= BPL / 2;
64 l = next_line - w * 4;
65 for (j = height; j > 0; j--) {
66 for (i = w; i > 0; i--)
67 *d++ = *s++;
68 s = (u32 *)((u8 *)s + l);
69 d = (u32 *)((u8 *)d + l);
70 }
71 }
72 if (width & 15)
73 memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL),
74 0xff00ff00, height, next_line - BPL * 2);
75 } else {
76 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
77 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
78
79 if ((sx + width) & 15) {
80 src -= BPL * 2;
81 dst -= BPL * 2;
82 memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2);
83 width -= 8;
84 }
85 w = width >> 4;
86 if (w) {
87 s = (u32 *)src;
88 d = (u32 *)dst;
89 w *= BPL / 2;
90 l = next_line - w * 4;
91 for (j = height; j > 0; j--) {
92 for (i = w; i > 0; i--)
93 *--d = *--s;
94 s = (u32 *)((u8 *)s - l);
95 d = (u32 *)((u8 *)d - l);
96 }
97 }
98 if (sx & 15)
99 memmove32_col(dst - (width - 16) / (8 / BPL),
100 src - (width - 16) / (8 / BPL),
101 0xff00ff, colsize, -next_line - BPL * 2);
102 }
103 } else {
104 /* odd->even or even->odd */
105 if (upwards) {
106 u32 *src32, *dst32;
107 u32 pval[4], v, v1, mask;
108 int i, j, w, f;
109
110 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
111 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
112
113 mask = 0xff00ff00;
114 f = 0;
115 w = width;
116 if (sx & 15) {
117 f = 1;
118 w += 8;
119 }
120 if ((sx + width) & 15)
121 f |= 2;
122 w >>= 4;
123 for (i = height; i; i--) {
124 src32 = (u32 *)src;
125 dst32 = (u32 *)dst;
126
127 if (f & 1) {
128 pval[0] = (*src32++ << 8) & mask;
129 pval[1] = (*src32++ << 8) & mask;
130 } else {
131 pval[0] = dst32[0] & mask;
132 pval[1] = dst32[1] & mask;
133 }
134
135 for (j = w; j > 0; j--) {
136 v = *src32++;
137 v1 = v & mask;
138 *dst32++ = pval[0] | (v1 >> 8);
139 pval[0] = (v ^ v1) << 8;
140 v = *src32++;
141 v1 = v & mask;
142 *dst32++ = pval[1] | (v1 >> 8);
143 pval[1] = (v ^ v1) << 8;
144 }
145
146 if (f & 2) {
147 dst32[0] = (dst32[0] & mask) | pval[0];
148 dst32[1] = (dst32[1] & mask) | pval[1];
149 }
150
151 src += next_line;
152 dst += next_line;
153 }
154 } else {
155 u32 *src32, *dst32;
156 u32 pval[4], v, v1, mask;
157 int i, j, w, f;
158
159 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
160 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
161
162 mask = 0xff00ff;
163 f = 0;
164 w = width;
165 if ((dx + width) & 15)
166 f = 1;
167 if (sx & 15) {
168 f |= 2;
169 w += 8;
170 }
171 w >>= 4;
172 for (i = height; i; i--) {
173 src32 = (u32 *)src;
174 dst32 = (u32 *)dst;
175
176 if (f & 1) {
177 pval[0] = dst32[-1] & mask;
178 pval[1] = dst32[-2] & mask;
179 } else {
180 pval[0] = (*--src32 >> 8) & mask;
181 pval[1] = (*--src32 >> 8) & mask;
182 }
183
184 for (j = w; j > 0; j--) {
185 v = *--src32;
186 v1 = v & mask;
187 *--dst32 = pval[0] | (v1 << 8);
188 pval[0] = (v ^ v1) >> 8;
189 v = *--src32;
190 v1 = v & mask;
191 *--dst32 = pval[1] | (v1 << 8);
192 pval[1] = (v ^ v1) >> 8;
193 }
194
195 if (!(f & 2)) {
196 dst32[-1] = (dst32[-1] & mask) | pval[0];
197 dst32[-2] = (dst32[-2] & mask) | pval[1];
198 }
199
200 src -= next_line;
201 dst -= next_line;
202 }
203 }
204 }
205}
206
207void atafb_iplan2p4_fillrect(struct fb_info *info, u_long next_line, u32 color,
208 int sy, int sx, int height, int width)
209{
210 u32 *dest;
211 int rows, i;
212 u32 cval[4];
213
214 dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL));
215 if (sx & 15) {
216 u8 *dest8 = (u8 *)dest + 1;
217
218 expand8_col2mask(color, cval);
219
220 for (i = height; i; i--) {
221 fill8_col(dest8, cval);
222 dest8 += next_line;
223 }
224 dest += BPL / 2;
225 width -= 8;
226 }
227
228 expand16_col2mask(color, cval);
229 rows = width >> 4;
230 if (rows) {
231 u32 *d = dest;
232 u32 off = next_line - rows * BPL * 2;
233 for (i = height; i; i--) {
234 d = fill16_col(d, rows, cval);
235 d = (u32 *)((long)d + off);
236 }
237 dest += rows * BPL / 2;
238 width &= 15;
239 }
240
241 if (width) {
242 u8 *dest8 = (u8 *)dest;
243
244 expand8_col2mask(color, cval);
245
246 for (i = height; i; i--) {
247 fill8_col(dest8, cval);
248 dest8 += next_line;
249 }
250 }
251}
252
253void atafb_iplan2p4_linefill(struct fb_info *info, u_long next_line,
254 int dy, int dx, u32 width,
255 const u8 *data, u32 bgcolor, u32 fgcolor)
256{
257 u32 *dest;
258 const u16 *data16;
259 int rows;
260 u32 fgm[4], bgm[4], m;
261
262 dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL));
263 if (dx & 15) {
264 fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++);
265 dest += BPL / 2;
266 width -= 8;
267 }
268
269 if (width >= 16) {
270 data16 = (const u16 *)data;
271 expand16_2col2mask(fgcolor, bgcolor, fgm, bgm);
272
273 for (rows = width / 16; rows; rows--) {
274 u16 d = *data16++;
275 m = d | ((u32)d << 16);
276 *dest++ = (m & fgm[0]) ^ bgm[0];
277 *dest++ = (m & fgm[1]) ^ bgm[1];
278 }
279
280 data = (const u8 *)data16;
281 width &= 15;
282 }
283
284 if (width)
285 fill8_2col((u8 *)dest, fgcolor, bgcolor, *data);
286}
287
288#ifdef MODULE
289MODULE_LICENSE("GPL");
290
291int init_module(void)
292{
293 return 0;
294}
295
296void cleanup_module(void)
297{
298}
299#endif /* MODULE */
300
301
302 /*
303 * Visible symbols for modules
304 */
305
306EXPORT_SYMBOL(atafb_iplan2p4_copyarea);
307EXPORT_SYMBOL(atafb_iplan2p4_fillrect);
308EXPORT_SYMBOL(atafb_iplan2p4_linefill);
diff --git a/drivers/video/atafb_iplan2p8.c b/drivers/video/atafb_iplan2p8.c
new file mode 100644
index 000000000000..356fb52ce443
--- /dev/null
+++ b/drivers/video/atafb_iplan2p8.c
@@ -0,0 +1,345 @@
1/*
2 * linux/drivers/video/iplan2p8.c -- Low level frame buffer operations for
3 * interleaved bitplanes à la Atari (8
4 * planes, 2 bytes interleave)
5 *
6 * Created 5 Apr 1997 by Geert Uytterhoeven
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/module.h>
14#include <linux/string.h>
15#include <linux/fb.h>
16
17#include <asm/setup.h>
18
19#include "atafb.h"
20
21#define BPL 8
22#include "atafb_utils.h"
23
24
25/* Copies a 8 plane column from 's', height 'h', to 'd'. */
26
27/* This expands a 8 bit color into two longs for two movepl (8 plane)
28 * operations.
29 */
30
31void atafb_iplan2p8_copyarea(struct fb_info *info, u_long next_line,
32 int sy, int sx, int dy, int dx,
33 int height, int width)
34{
35 /* bmove() has to distinguish two major cases: If both, source and
36 * destination, start at even addresses or both are at odd
37 * addresses, just the first odd and last even column (if present)
38 * require special treatment (memmove_col()). The rest between
39 * then can be copied by normal operations, because all adjacent
40 * bytes are affected and are to be stored in the same order.
41 * The pathological case is when the move should go from an odd
42 * address to an even or vice versa. Since the bytes in the plane
43 * words must be assembled in new order, it seems wisest to make
44 * all movements by memmove_col().
45 */
46
47 u8 *src, *dst;
48 u32 *s, *d;
49 int w, l , i, j;
50 u_int colsize;
51 u_int upwards = (dy < sy) || (dy == sy && dx < sx);
52
53 colsize = height;
54 if (!((sx ^ dx) & 15)) {
55 /* odd->odd or even->even */
56
57 if (upwards) {
58 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
59 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
60 if (sx & 15) {
61 memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2);
62 src += BPL * 2;
63 dst += BPL * 2;
64 width -= 8;
65 }
66 w = width >> 4;
67 if (w) {
68 s = (u32 *)src;
69 d = (u32 *)dst;
70 w *= BPL / 2;
71 l = next_line - w * 4;
72 for (j = height; j > 0; j--) {
73 for (i = w; i > 0; i--)
74 *d++ = *s++;
75 s = (u32 *)((u8 *)s + l);
76 d = (u32 *)((u8 *)d + l);
77 }
78 }
79 if (width & 15)
80 memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL),
81 0xff00ff00, height, next_line - BPL * 2);
82 } else {
83 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
84 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
85
86 if ((sx + width) & 15) {
87 src -= BPL * 2;
88 dst -= BPL * 2;
89 memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2);
90 width -= 8;
91 }
92 w = width >> 4;
93 if (w) {
94 s = (u32 *)src;
95 d = (u32 *)dst;
96 w *= BPL / 2;
97 l = next_line - w * 4;
98 for (j = height; j > 0; j--) {
99 for (i = w; i > 0; i--)
100 *--d = *--s;
101 s = (u32 *)((u8 *)s - l);
102 d = (u32 *)((u8 *)d - l);
103 }
104 }
105 if (sx & 15)
106 memmove32_col(dst - (width - 16) / (8 / BPL),
107 src - (width - 16) / (8 / BPL),
108 0xff00ff, colsize, -next_line - BPL * 2);
109 }
110 } else {
111 /* odd->even or even->odd */
112 if (upwards) {
113 u32 *src32, *dst32;
114 u32 pval[4], v, v1, mask;
115 int i, j, w, f;
116
117 src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL);
118 dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL);
119
120 mask = 0xff00ff00;
121 f = 0;
122 w = width;
123 if (sx & 15) {
124 f = 1;
125 w += 8;
126 }
127 if ((sx + width) & 15)
128 f |= 2;
129 w >>= 4;
130 for (i = height; i; i--) {
131 src32 = (u32 *)src;
132 dst32 = (u32 *)dst;
133
134 if (f & 1) {
135 pval[0] = (*src32++ << 8) & mask;
136 pval[1] = (*src32++ << 8) & mask;
137 pval[2] = (*src32++ << 8) & mask;
138 pval[3] = (*src32++ << 8) & mask;
139 } else {
140 pval[0] = dst32[0] & mask;
141 pval[1] = dst32[1] & mask;
142 pval[2] = dst32[2] & mask;
143 pval[3] = dst32[3] & mask;
144 }
145
146 for (j = w; j > 0; j--) {
147 v = *src32++;
148 v1 = v & mask;
149 *dst32++ = pval[0] | (v1 >> 8);
150 pval[0] = (v ^ v1) << 8;
151 v = *src32++;
152 v1 = v & mask;
153 *dst32++ = pval[1] | (v1 >> 8);
154 pval[1] = (v ^ v1) << 8;
155 v = *src32++;
156 v1 = v & mask;
157 *dst32++ = pval[2] | (v1 >> 8);
158 pval[2] = (v ^ v1) << 8;
159 v = *src32++;
160 v1 = v & mask;
161 *dst32++ = pval[3] | (v1 >> 8);
162 pval[3] = (v ^ v1) << 8;
163 }
164
165 if (f & 2) {
166 dst32[0] = (dst32[0] & mask) | pval[0];
167 dst32[1] = (dst32[1] & mask) | pval[1];
168 dst32[2] = (dst32[2] & mask) | pval[2];
169 dst32[3] = (dst32[3] & mask) | pval[3];
170 }
171
172 src += next_line;
173 dst += next_line;
174 }
175 } else {
176 u32 *src32, *dst32;
177 u32 pval[4], v, v1, mask;
178 int i, j, w, f;
179
180 src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL);
181 dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL);
182
183 mask = 0xff00ff;
184 f = 0;
185 w = width;
186 if ((dx + width) & 15)
187 f = 1;
188 if (sx & 15) {
189 f |= 2;
190 w += 8;
191 }
192 w >>= 4;
193 for (i = height; i; i--) {
194 src32 = (u32 *)src;
195 dst32 = (u32 *)dst;
196
197 if (f & 1) {
198 pval[0] = dst32[-1] & mask;
199 pval[1] = dst32[-2] & mask;
200 pval[2] = dst32[-3] & mask;
201 pval[3] = dst32[-4] & mask;
202 } else {
203 pval[0] = (*--src32 >> 8) & mask;
204 pval[1] = (*--src32 >> 8) & mask;
205 pval[2] = (*--src32 >> 8) & mask;
206 pval[3] = (*--src32 >> 8) & mask;
207 }
208
209 for (j = w; j > 0; j--) {
210 v = *--src32;
211 v1 = v & mask;
212 *--dst32 = pval[0] | (v1 << 8);
213 pval[0] = (v ^ v1) >> 8;
214 v = *--src32;
215 v1 = v & mask;
216 *--dst32 = pval[1] | (v1 << 8);
217 pval[1] = (v ^ v1) >> 8;
218 v = *--src32;
219 v1 = v & mask;
220 *--dst32 = pval[2] | (v1 << 8);
221 pval[2] = (v ^ v1) >> 8;
222 v = *--src32;
223 v1 = v & mask;
224 *--dst32 = pval[3] | (v1 << 8);
225 pval[3] = (v ^ v1) >> 8;
226 }
227
228 if (!(f & 2)) {
229 dst32[-1] = (dst32[-1] & mask) | pval[0];
230 dst32[-2] = (dst32[-2] & mask) | pval[1];
231 dst32[-3] = (dst32[-3] & mask) | pval[2];
232 dst32[-4] = (dst32[-4] & mask) | pval[3];
233 }
234
235 src -= next_line;
236 dst -= next_line;
237 }
238 }
239 }
240}
241
242void atafb_iplan2p8_fillrect(struct fb_info *info, u_long next_line, u32 color,
243 int sy, int sx, int height, int width)
244{
245 u32 *dest;
246 int rows, i;
247 u32 cval[4];
248
249 dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL));
250 if (sx & 15) {
251 u8 *dest8 = (u8 *)dest + 1;
252
253 expand8_col2mask(color, cval);
254
255 for (i = height; i; i--) {
256 fill8_col(dest8, cval);
257 dest8 += next_line;
258 }
259 dest += BPL / 2;
260 width -= 8;
261 }
262
263 expand16_col2mask(color, cval);
264 rows = width >> 4;
265 if (rows) {
266 u32 *d = dest;
267 u32 off = next_line - rows * BPL * 2;
268 for (i = height; i; i--) {
269 d = fill16_col(d, rows, cval);
270 d = (u32 *)((long)d + off);
271 }
272 dest += rows * BPL / 2;
273 width &= 15;
274 }
275
276 if (width) {
277 u8 *dest8 = (u8 *)dest;
278
279 expand8_col2mask(color, cval);
280
281 for (i = height; i; i--) {
282 fill8_col(dest8, cval);
283 dest8 += next_line;
284 }
285 }
286}
287
288void atafb_iplan2p8_linefill(struct fb_info *info, u_long next_line,
289 int dy, int dx, u32 width,
290 const u8 *data, u32 bgcolor, u32 fgcolor)
291{
292 u32 *dest;
293 const u16 *data16;
294 int rows;
295 u32 fgm[4], bgm[4], m;
296
297 dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL));
298 if (dx & 15) {
299 fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++);
300 dest += BPL / 2;
301 width -= 8;
302 }
303
304 if (width >= 16) {
305 data16 = (const u16 *)data;
306 expand16_2col2mask(fgcolor, bgcolor, fgm, bgm);
307
308 for (rows = width / 16; rows; rows--) {
309 u16 d = *data16++;
310 m = d | ((u32)d << 16);
311 *dest++ = (m & fgm[0]) ^ bgm[0];
312 *dest++ = (m & fgm[1]) ^ bgm[1];
313 *dest++ = (m & fgm[2]) ^ bgm[2];
314 *dest++ = (m & fgm[3]) ^ bgm[3];
315 }
316
317 data = (const u8 *)data16;
318 width &= 15;
319 }
320
321 if (width)
322 fill8_2col((u8 *)dest, fgcolor, bgcolor, *data);
323}
324
325#ifdef MODULE
326MODULE_LICENSE("GPL");
327
328int init_module(void)
329{
330 return 0;
331}
332
333void cleanup_module(void)
334{
335}
336#endif /* MODULE */
337
338
339 /*
340 * Visible symbols for modules
341 */
342
343EXPORT_SYMBOL(atafb_iplan2p8_copyarea);
344EXPORT_SYMBOL(atafb_iplan2p8_fillrect);
345EXPORT_SYMBOL(atafb_iplan2p8_linefill);
diff --git a/drivers/video/atafb_mfb.c b/drivers/video/atafb_mfb.c
new file mode 100644
index 000000000000..6a352d62eecf
--- /dev/null
+++ b/drivers/video/atafb_mfb.c
@@ -0,0 +1,112 @@
1/*
2 * linux/drivers/video/mfb.c -- Low level frame buffer operations for
3 * monochrome
4 *
5 * Created 5 Apr 1997 by Geert Uytterhoeven
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for
9 * more details.
10 */
11
12#include <linux/module.h>
13#include <linux/string.h>
14#include <linux/fb.h>
15
16#include "atafb.h"
17#include "atafb_utils.h"
18
19
20 /*
21 * Monochrome
22 */
23
24void atafb_mfb_copyarea(struct fb_info *info, u_long next_line,
25 int sy, int sx, int dy, int dx,
26 int height, int width)
27{
28 u8 *src, *dest;
29 u_int rows;
30
31 if (sx == 0 && dx == 0 && width == next_line) {
32 src = (u8 *)info->screen_base + sy * (width >> 3);
33 dest = (u8 *)info->screen_base + dy * (width >> 3);
34 fb_memmove(dest, src, height * (width >> 3));
35 } else if (dy <= sy) {
36 src = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
37 dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
38 for (rows = height; rows--;) {
39 fb_memmove(dest, src, width >> 3);
40 src += next_line;
41 dest += next_line;
42 }
43 } else {
44 src = (u8 *)info->screen_base + (sy + height - 1) * next_line + (sx >> 3);
45 dest = (u8 *)info->screen_base + (dy + height - 1) * next_line + (dx >> 3);
46 for (rows = height; rows--;) {
47 fb_memmove(dest, src, width >> 3);
48 src -= next_line;
49 dest -= next_line;
50 }
51 }
52}
53
54void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color,
55 int sy, int sx, int height, int width)
56{
57 u8 *dest;
58 u_int rows;
59
60 dest = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
61
62 if (sx == 0 && width == next_line) {
63 if (color)
64 fb_memset255(dest, height * (width >> 3));
65 else
66 fb_memclear(dest, height * (width >> 3));
67 } else {
68 for (rows = height; rows--; dest += next_line) {
69 if (color)
70 fb_memset255(dest, width >> 3);
71 else
72 fb_memclear_small(dest, width >> 3);
73 }
74 }
75}
76
77void atafb_mfb_linefill(struct fb_info *info, u_long next_line,
78 int dy, int dx, u32 width,
79 const u8 *data, u32 bgcolor, u32 fgcolor)
80{
81 u8 *dest;
82 u_int rows;
83
84 dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
85
86 for (rows = width / 8; rows--; /* check margins */ ) {
87 // use fast_memmove or fb_memmove
88 *dest++ = *data++;
89 }
90}
91
92#ifdef MODULE
93MODULE_LICENSE("GPL");
94
95int init_module(void)
96{
97 return 0;
98}
99
100void cleanup_module(void)
101{
102}
103#endif /* MODULE */
104
105
106 /*
107 * Visible symbols for modules
108 */
109
110EXPORT_SYMBOL(atafb_mfb_copyarea);
111EXPORT_SYMBOL(atafb_mfb_fillrect);
112EXPORT_SYMBOL(atafb_mfb_linefill);
diff --git a/drivers/video/atafb_utils.h b/drivers/video/atafb_utils.h
new file mode 100644
index 000000000000..ac9e19dc5057
--- /dev/null
+++ b/drivers/video/atafb_utils.h
@@ -0,0 +1,400 @@
1#ifndef _VIDEO_ATAFB_UTILS_H
2#define _VIDEO_ATAFB_UTILS_H
3
4/* ================================================================= */
5/* Utility Assembler Functions */
6/* ================================================================= */
7
8/* ====================================================================== */
9
10/* Those of a delicate disposition might like to skip the next couple of
11 * pages.
12 *
13 * These functions are drop in replacements for memmove and
14 * memset(_, 0, _). However their five instances add at least a kilobyte
15 * to the object file. You have been warned.
16 *
17 * Not a great fan of assembler for the sake of it, but I think
18 * that these routines are at least 10 times faster than their C
19 * equivalents for large blits, and that's important to the lowest level of
20 * a graphics driver. Question is whether some scheme with the blitter
21 * would be faster. I suspect not for simple text system - not much
22 * asynchrony.
23 *
24 * Code is very simple, just gruesome expansion. Basic strategy is to
25 * increase data moved/cleared at each step to 16 bytes to reduce
26 * instruction per data move overhead. movem might be faster still
27 * For more than 15 bytes, we try to align the write direction on a
28 * longword boundary to get maximum speed. This is even more gruesome.
29 * Unaligned read/write used requires 68020+ - think this is a problem?
30 *
31 * Sorry!
32 */
33
34
35/* ++roman: I've optimized Robert's original versions in some minor
36 * aspects, e.g. moveq instead of movel, let gcc choose the registers,
37 * use movem in some places...
38 * For other modes than 1 plane, lots of more such assembler functions
39 * were needed (e.g. the ones using movep or expanding color values).
40 */
41
42/* ++andreas: more optimizations:
43 subl #65536,d0 replaced by clrw d0; subql #1,d0 for dbcc
44 addal is faster than addaw
45 movep is rather expensive compared to ordinary move's
46 some functions rewritten in C for clarity, no speed loss */
47
48static inline void *fb_memclear_small(void *s, size_t count)
49{
50 if (!count)
51 return 0;
52
53 asm volatile ("\n"
54 " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n"
55 "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n"
56 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n"
57 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n"
58 "1:"
59 : "=a" (s), "=d" (count)
60 : "d" (0), "0" ((char *)s + count), "1" (count));
61 asm volatile ("\n"
62 " subq.l #1,%1\n"
63 " jcs 3f\n"
64 " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n"
65 "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n"
66 " dbra %1,2b\n"
67 "3:"
68 : "=a" (s), "=d" (count)
69 : "d" (0), "0" (s), "1" (count)
70 : "d4", "d5", "d6"
71 );
72
73 return 0;
74}
75
76
77static inline void *fb_memclear(void *s, size_t count)
78{
79 if (!count)
80 return 0;
81
82 if (count < 16) {
83 asm volatile ("\n"
84 " lsr.l #1,%1 ; jcc 1f ; clr.b (%0)+\n"
85 "1: lsr.l #1,%1 ; jcc 1f ; clr.w (%0)+\n"
86 "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+\n"
87 "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+ ; clr.l (%0)+\n"
88 "1:"
89 : "=a" (s), "=d" (count)
90 : "0" (s), "1" (count));
91 } else {
92 long tmp;
93 asm volatile ("\n"
94 " move.l %1,%2\n"
95 " lsr.l #1,%2 ; jcc 1f ; clr.b (%0)+ ; subq.w #1,%1\n"
96 " lsr.l #1,%2 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/
97 " clr.w (%0)+ ; subq.w #2,%1 ; jra 2f\n"
98 "1: lsr.l #1,%2 ; jcc 2f\n"
99 " clr.w (%0)+ ; subq.w #2,%1\n"
100 "2: move.w %1,%2; lsr.l #2,%1 ; jeq 6f\n"
101 " lsr.l #1,%1 ; jcc 3f ; clr.l (%0)+\n"
102 "3: lsr.l #1,%1 ; jcc 4f ; clr.l (%0)+ ; clr.l (%0)+\n"
103 "4: subq.l #1,%1 ; jcs 6f\n"
104 "5: clr.l (%0)+; clr.l (%0)+ ; clr.l (%0)+ ; clr.l (%0)+\n"
105 " dbra %1,5b ; clr.w %1; subq.l #1,%1; jcc 5b\n"
106 "6: move.w %2,%1; btst #1,%1 ; jeq 7f ; clr.w (%0)+\n"
107 "7: btst #0,%1 ; jeq 8f ; clr.b (%0)+\n"
108 "8:"
109 : "=a" (s), "=d" (count), "=d" (tmp)
110 : "0" (s), "1" (count));
111 }
112
113 return 0;
114}
115
116
117static inline void *fb_memset255(void *s, size_t count)
118{
119 if (!count)
120 return 0;
121
122 asm volatile ("\n"
123 " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n"
124 "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n"
125 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n"
126 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n"
127 "1:"
128 : "=a" (s), "=d" (count)
129 : "d" (-1), "0" ((char *)s+count), "1" (count));
130 asm volatile ("\n"
131 " subq.l #1,%1 ; jcs 3f\n"
132 " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n"
133 "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n"
134 " dbra %1,2b\n"
135 "3:"
136 : "=a" (s), "=d" (count)
137 : "d" (-1), "0" (s), "1" (count)
138 : "d4", "d5", "d6");
139
140 return 0;
141}
142
143
144static inline void *fb_memmove(void *d, const void *s, size_t count)
145{
146 if (d < s) {
147 if (count < 16) {
148 asm volatile ("\n"
149 " lsr.l #1,%2 ; jcc 1f ; move.b (%1)+,(%0)+\n"
150 "1: lsr.l #1,%2 ; jcc 1f ; move.w (%1)+,(%0)+\n"
151 "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+\n"
152 "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n"
153 "1:"
154 : "=a" (d), "=a" (s), "=d" (count)
155 : "0" (d), "1" (s), "2" (count));
156 } else {
157 long tmp;
158 asm volatile ("\n"
159 " move.l %0,%3\n"
160 " lsr.l #1,%3 ; jcc 1f ; move.b (%1)+,(%0)+ ; subqw #1,%2\n"
161 " lsr.l #1,%3 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/
162 " move.w (%1)+,(%0)+ ; subqw #2,%2 ; jra 2f\n"
163 "1: lsr.l #1,%3 ; jcc 2f\n"
164 " move.w (%1)+,(%0)+ ; subqw #2,%2\n"
165 "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n"
166 " lsr.l #1,%2 ; jcc 3f ; move.l (%1)+,(%0)+\n"
167 "3: lsr.l #1,%2 ; jcc 4f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n"
168 "4: subq.l #1,%2 ; jcs 6f\n"
169 "5: move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n"
170 " move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n"
171 " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n"
172 "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w (%1)+,(%0)+\n"
173 "7: btst #0,%2 ; jeq 8f ; move.b (%1)+,(%0)+\n"
174 "8:"
175 : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp)
176 : "0" (d), "1" (s), "2" (count));
177 }
178 } else {
179 if (count < 16) {
180 asm volatile ("\n"
181 " lsr.l #1,%2 ; jcc 1f ; move.b -(%1),-(%0)\n"
182 "1: lsr.l #1,%2 ; jcc 1f ; move.w -(%1),-(%0)\n"
183 "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0)\n"
184 "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n"
185 "1:"
186 : "=a" (d), "=a" (s), "=d" (count)
187 : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count));
188 } else {
189 long tmp;
190
191 asm volatile ("\n"
192 " move.l %0,%3\n"
193 " lsr.l #1,%3 ; jcc 1f ; move.b -(%1),-(%0) ; subqw #1,%2\n"
194 " lsr.l #1,%3 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/
195 " move.w -(%1),-(%0) ; subqw #2,%2 ; jra 2f\n"
196 "1: lsr.l #1,%3 ; jcc 2f\n"
197 " move.w -(%1),-(%0) ; subqw #2,%2\n"
198 "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n"
199 " lsr.l #1,%2 ; jcc 3f ; move.l -(%1),-(%0)\n"
200 "3: lsr.l #1,%2 ; jcc 4f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n"
201 "4: subq.l #1,%2 ; jcs 6f\n"
202 "5: move.l -(%1),-(%0); move.l -(%1),-(%0)\n"
203 " move.l -(%1),-(%0); move.l -(%1),-(%0)\n"
204 " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n"
205 "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w -(%1),-(%0)\n"
206 "7: btst #0,%2 ; jeq 8f ; move.b -(%1),-(%0)\n"
207 "8:"
208 : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp)
209 : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count));
210 }
211 }
212
213 return 0;
214}
215
216
217/* ++andreas: Simple and fast version of memmove, assumes size is
218 divisible by 16, suitable for moving the whole screen bitplane */
219static inline void fast_memmove(char *dst, const char *src, size_t size)
220{
221 if (!size)
222 return;
223 if (dst < src)
224 asm volatile ("\n"
225 "1: movem.l (%0)+,%%d0/%%d1/%%a0/%%a1\n"
226 " movem.l %%d0/%%d1/%%a0/%%a1,%1@\n"
227 " addq.l #8,%1; addq.l #8,%1\n"
228 " dbra %2,1b\n"
229 " clr.w %2; subq.l #1,%2\n"
230 " jcc 1b"
231 : "=a" (src), "=a" (dst), "=d" (size)
232 : "0" (src), "1" (dst), "2" (size / 16 - 1)
233 : "d0", "d1", "a0", "a1", "memory");
234 else
235 asm volatile ("\n"
236 "1: subq.l #8,%0; subq.l #8,%0\n"
237 " movem.l %0@,%%d0/%%d1/%%a0/%%a1\n"
238 " movem.l %%d0/%%d1/%%a0/%%a1,-(%1)\n"
239 " dbra %2,1b\n"
240 " clr.w %2; subq.l #1,%2\n"
241 " jcc 1b"
242 : "=a" (src), "=a" (dst), "=d" (size)
243 : "0" (src + size), "1" (dst + size), "2" (size / 16 - 1)
244 : "d0", "d1", "a0", "a1", "memory");
245}
246
247#ifdef BPL
248
249/*
250 * This expands a up to 8 bit color into two longs
251 * for movel operations.
252 */
253static const u32 four2long[] = {
254 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
255 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
256 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
257 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff,
258};
259
260static inline void expand8_col2mask(u8 c, u32 m[])
261{
262 m[0] = four2long[c & 15];
263#if BPL > 4
264 m[1] = four2long[c >> 4];
265#endif
266}
267
268static inline void expand8_2col2mask(u8 fg, u8 bg, u32 fgm[], u32 bgm[])
269{
270 fgm[0] = four2long[fg & 15] ^ (bgm[0] = four2long[bg & 15]);
271#if BPL > 4
272 fgm[1] = four2long[fg >> 4] ^ (bgm[1] = four2long[bg >> 4]);
273#endif
274}
275
276/*
277 * set an 8bit value to a color
278 */
279static inline void fill8_col(u8 *dst, u32 m[])
280{
281 u32 tmp = m[0];
282 dst[0] = tmp;
283 dst[2] = (tmp >>= 8);
284#if BPL > 2
285 dst[4] = (tmp >>= 8);
286 dst[6] = tmp >> 8;
287#endif
288#if BPL > 4
289 tmp = m[1];
290 dst[8] = tmp;
291 dst[10] = (tmp >>= 8);
292 dst[12] = (tmp >>= 8);
293 dst[14] = tmp >> 8;
294#endif
295}
296
297/*
298 * set an 8bit value according to foreground/background color
299 */
300static inline void fill8_2col(u8 *dst, u8 fg, u8 bg, u32 mask)
301{
302 u32 fgm[2], bgm[2], tmp;
303
304 expand8_2col2mask(fg, bg, fgm, bgm);
305
306 mask |= mask << 8;
307#if BPL > 2
308 mask |= mask << 16;
309#endif
310 tmp = (mask & fgm[0]) ^ bgm[0];
311 dst[0] = tmp;
312 dst[2] = (tmp >>= 8);
313#if BPL > 2
314 dst[4] = (tmp >>= 8);
315 dst[6] = tmp >> 8;
316#endif
317#if BPL > 4
318 tmp = (mask & fgm[1]) ^ bgm[1];
319 dst[8] = tmp;
320 dst[10] = (tmp >>= 8);
321 dst[12] = (tmp >>= 8);
322 dst[14] = tmp >> 8;
323#endif
324}
325
326static const u32 two2word[] = {
327 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
328};
329
330static inline void expand16_col2mask(u8 c, u32 m[])
331{
332 m[0] = two2word[c & 3];
333#if BPL > 2
334 m[1] = two2word[(c >> 2) & 3];
335#endif
336#if BPL > 4
337 m[2] = two2word[(c >> 4) & 3];
338 m[3] = two2word[c >> 6];
339#endif
340}
341
342static inline void expand16_2col2mask(u8 fg, u8 bg, u32 fgm[], u32 bgm[])
343{
344 bgm[0] = two2word[bg & 3];
345 fgm[0] = two2word[fg & 3] ^ bgm[0];
346#if BPL > 2
347 bgm[1] = two2word[(bg >> 2) & 3];
348 fgm[1] = two2word[(fg >> 2) & 3] ^ bgm[1];
349#endif
350#if BPL > 4
351 bgm[2] = two2word[(bg >> 4) & 3];
352 fgm[2] = two2word[(fg >> 4) & 3] ^ bgm[2];
353 bgm[3] = two2word[bg >> 6];
354 fgm[3] = two2word[fg >> 6] ^ bgm[3];
355#endif
356}
357
358static inline u32 *fill16_col(u32 *dst, int rows, u32 m[])
359{
360 while (rows) {
361 *dst++ = m[0];
362#if BPL > 2
363 *dst++ = m[1];
364#endif
365#if BPL > 4
366 *dst++ = m[2];
367 *dst++ = m[3];
368#endif
369 rows--;
370 }
371 return dst;
372}
373
374static inline void memmove32_col(void *dst, void *src, u32 mask, u32 h, u32 bytes)
375{
376 u32 *s, *d, v;
377
378 s = src;
379 d = dst;
380 do {
381 v = (*s++ & mask) | (*d & ~mask);
382 *d++ = v;
383#if BPL > 2
384 v = (*s++ & mask) | (*d & ~mask);
385 *d++ = v;
386#endif
387#if BPL > 4
388 v = (*s++ & mask) | (*d & ~mask);
389 *d++ = v;
390 v = (*s++ & mask) | (*d & ~mask);
391 *d++ = v;
392#endif
393 d = (u32 *)((u8 *)d + bytes);
394 s = (u32 *)((u8 *)s + bytes);
395 } while (--h);
396}
397
398#endif
399
400#endif /* _VIDEO_ATAFB_UTILS_H */
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 508479920705..7db9de681716 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -1,7 +1,6 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/delay.h> 3#include <linux/delay.h>
4#include <linux/pci.h>
5#include <linux/fb.h> 4#include <linux/fb.h>
6 5
7 6
diff --git a/drivers/video/g364fb.c b/drivers/video/g364fb.c
index ca93a75f2997..b7655c05da53 100644
--- a/drivers/video/g364fb.c
+++ b/drivers/video/g364fb.c
@@ -26,7 +26,6 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/fb.h> 27#include <linux/fb.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/pci.h>
30#include <asm/io.h> 29#include <asm/io.h>
31#include <asm/jazz.h> 30#include <asm/jazz.h>
32 31
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c
index f4ede5f6b588..61e4c8759b23 100644
--- a/drivers/video/intelfb/intelfb_i2c.c
+++ b/drivers/video/intelfb/intelfb_i2c.c
@@ -104,7 +104,8 @@ static int intelfb_setup_i2c_bus(struct intelfb_info *dinfo,
104 104
105 chan->dinfo = dinfo; 105 chan->dinfo = dinfo;
106 chan->reg = reg; 106 chan->reg = reg;
107 snprintf(chan->adapter.name, I2C_NAME_SIZE, "intelfb %s", name); 107 snprintf(chan->adapter.name, sizeof(chan->adapter.name),
108 "intelfb %s", name);
108 chan->adapter.owner = THIS_MODULE; 109 chan->adapter.owner = THIS_MODULE;
109 chan->adapter.id = I2C_HW_B_INTELFB; 110 chan->adapter.id = I2C_HW_B_INTELFB;
110 chan->adapter.algo_data = &chan->algo; 111 chan->adapter.algo_data = &chan->algo;
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c
index 5ec718a5fe22..4baab7be58de 100644
--- a/drivers/video/matrox/i2c-matroxfb.c
+++ b/drivers/video/matrox/i2c-matroxfb.c
@@ -111,7 +111,7 @@ static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo,
111 b->mask.data = data; 111 b->mask.data = data;
112 b->mask.clock = clock; 112 b->mask.clock = clock;
113 b->adapter = matrox_i2c_adapter_template; 113 b->adapter = matrox_i2c_adapter_template;
114 snprintf(b->adapter.name, I2C_NAME_SIZE, name, 114 snprintf(b->adapter.name, sizeof(b->adapter.name), name,
115 minfo->fbcon.node); 115 minfo->fbcon.node);
116 i2c_set_adapdata(&b->adapter, b); 116 i2c_set_adapdata(&b->adapter, b);
117 b->adapter.algo_data = &b->bac; 117 b->adapter.algo_data = &b->bac;
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 233871655824..e64f8b5d0056 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -28,7 +28,6 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/fb.h> 29#include <linux/fb.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/pci.h>
32#include <linux/nvram.h> 31#include <linux/nvram.h>
33#include <asm/io.h> 32#include <asm/io.h>
34#include <asm/prom.h> 33#include <asm/prom.h>
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 81e43cda7d8b..07d1979bc23e 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -32,6 +32,8 @@
32#include <linux/ioctl.h> 32#include <linux/ioctl.h>
33#include <linux/notifier.h> 33#include <linux/notifier.h>
34#include <linux/reboot.h> 34#include <linux/reboot.h>
35#include <linux/kthread.h>
36#include <linux/freezer.h>
35 37
36#include <asm/uaccess.h> 38#include <asm/uaccess.h>
37#include <linux/fb.h> 39#include <linux/fb.h>
@@ -45,7 +47,7 @@
45#include <asm/ps3.h> 47#include <asm/ps3.h>
46 48
47#ifdef PS3FB_DEBUG 49#ifdef PS3FB_DEBUG
48#define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ##args) 50#define DPRINTK(fmt, args...) printk("%s: " fmt, __func__ , ##args)
49#else 51#else
50#define DPRINTK(fmt, args...) 52#define DPRINTK(fmt, args...)
51#endif 53#endif
@@ -129,7 +131,6 @@ struct ps3fb_priv {
129 u64 context_handle, memory_handle; 131 u64 context_handle, memory_handle;
130 void *xdr_ea; 132 void *xdr_ea;
131 struct gpu_driver_info *dinfo; 133 struct gpu_driver_info *dinfo;
132 struct semaphore sem;
133 u32 res_index; 134 u32 res_index;
134 135
135 u64 vblank_count; /* frame count */ 136 u64 vblank_count; /* frame count */
@@ -139,6 +140,8 @@ struct ps3fb_priv {
139 atomic_t ext_flip; /* on/off flip with vsync */ 140 atomic_t ext_flip; /* on/off flip with vsync */
140 atomic_t f_count; /* fb_open count */ 141 atomic_t f_count; /* fb_open count */
141 int is_blanked; 142 int is_blanked;
143 int is_kicked;
144 struct task_struct *task;
142}; 145};
143static struct ps3fb_priv ps3fb; 146static struct ps3fb_priv ps3fb;
144 147
@@ -294,10 +297,10 @@ static const struct fb_videomode ps3fb_modedb[] = {
294#define VP_OFF(i) (WIDTH(i) * Y_OFF(i) * BPP + X_OFF(i) * BPP) 297#define VP_OFF(i) (WIDTH(i) * Y_OFF(i) * BPP + X_OFF(i) * BPP)
295#define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET) 298#define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET)
296 299
297static int ps3fb_mode = 0; 300static int ps3fb_mode;
298module_param(ps3fb_mode, bool, 0); 301module_param(ps3fb_mode, bool, 0);
299 302
300static char *mode_option __initdata = NULL; 303static char *mode_option __initdata;
301 304
302 305
303static int ps3fb_get_res_table(u32 xres, u32 yres) 306static int ps3fb_get_res_table(u32 xres, u32 yres)
@@ -393,7 +396,7 @@ static int ps3fb_sync(u32 frame)
393 396
394 if (frame > ps3fb.num_frames - 1) { 397 if (frame > ps3fb.num_frames - 1) {
395 printk(KERN_WARNING "%s: invalid frame number (%u)\n", 398 printk(KERN_WARNING "%s: invalid frame number (%u)\n",
396 __FUNCTION__, frame); 399 __func__, frame);
397 return -EINVAL; 400 return -EINVAL;
398 } 401 }
399 offset = xres * yres * BPP * frame; 402 offset = xres * yres * BPP * frame;
@@ -406,23 +409,26 @@ static int ps3fb_sync(u32 frame)
406 (xres << 16) | yres, 409 (xres << 16) | yres,
407 xres * BPP); /* line_length */ 410 xres * BPP); /* line_length */
408 if (status) 411 if (status)
409 printk(KERN_ERR "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n", 412 printk(KERN_ERR
410 __FUNCTION__, status); 413 "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n",
414 __func__, status);
411#ifdef HEAD_A 415#ifdef HEAD_A
412 status = lv1_gpu_context_attribute(ps3fb.context_handle, 416 status = lv1_gpu_context_attribute(ps3fb.context_handle,
413 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 417 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
414 0, offset, 0, 0); 418 0, offset, 0, 0);
415 if (status) 419 if (status)
416 printk(KERN_ERR "%s: lv1_gpu_context_attribute FLIP failed: %d\n", 420 printk(KERN_ERR
417 __FUNCTION__, status); 421 "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
422 __func__, status);
418#endif 423#endif
419#ifdef HEAD_B 424#ifdef HEAD_B
420 status = lv1_gpu_context_attribute(ps3fb.context_handle, 425 status = lv1_gpu_context_attribute(ps3fb.context_handle,
421 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 426 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
422 1, offset, 0, 0); 427 1, offset, 0, 0);
423 if (status) 428 if (status)
424 printk(KERN_ERR "%s: lv1_gpu_context_attribute FLIP failed: %d\n", 429 printk(KERN_ERR
425 __FUNCTION__, status); 430 "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
431 __func__, status);
426#endif 432#endif
427 return 0; 433 return 0;
428} 434}
@@ -631,7 +637,7 @@ static int ps3fb_blank(int blank, struct fb_info *info)
631{ 637{
632 int retval; 638 int retval;
633 639
634 DPRINTK("%s: blank:%d\n", __FUNCTION__, blank); 640 DPRINTK("%s: blank:%d\n", __func__, blank);
635 switch (blank) { 641 switch (blank) {
636 case FB_BLANK_POWERDOWN: 642 case FB_BLANK_POWERDOWN:
637 case FB_BLANK_HSYNC_SUSPEND: 643 case FB_BLANK_HSYNC_SUSPEND:
@@ -677,13 +683,10 @@ EXPORT_SYMBOL_GPL(ps3fb_wait_for_vsync);
677 683
678void ps3fb_flip_ctl(int on) 684void ps3fb_flip_ctl(int on)
679{ 685{
680 if (on) { 686 if (on)
681 if (atomic_read(&ps3fb.ext_flip) > 0) { 687 atomic_dec_if_positive(&ps3fb.ext_flip);
682 atomic_dec(&ps3fb.ext_flip); 688 else
683 }
684 } else {
685 atomic_inc(&ps3fb.ext_flip); 689 atomic_inc(&ps3fb.ext_flip);
686 }
687} 690}
688 691
689EXPORT_SYMBOL_GPL(ps3fb_flip_ctl); 692EXPORT_SYMBOL_GPL(ps3fb_flip_ctl);
@@ -732,6 +735,11 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
732 if (copy_from_user(&val, argp, sizeof(val))) 735 if (copy_from_user(&val, argp, sizeof(val)))
733 break; 736 break;
734 737
738 if (!(val & PS3AV_MODE_MASK)) {
739 u32 id = ps3av_get_auto_mode(0);
740 if (id > 0)
741 val = (val & ~PS3AV_MODE_MASK) | id;
742 }
735 DPRINTK("PS3FB_IOCTL_SETMODE:%x\n", val); 743 DPRINTK("PS3FB_IOCTL_SETMODE:%x\n", val);
736 retval = -EINVAL; 744 retval = -EINVAL;
737 old_mode = ps3fb_mode; 745 old_mode = ps3fb_mode;
@@ -783,8 +791,7 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
783 791
784 case PS3FB_IOCTL_OFF: 792 case PS3FB_IOCTL_OFF:
785 DPRINTK("PS3FB_IOCTL_OFF:\n"); 793 DPRINTK("PS3FB_IOCTL_OFF:\n");
786 if (atomic_read(&ps3fb.ext_flip) > 0) 794 atomic_dec_if_positive(&ps3fb.ext_flip);
787 atomic_dec(&ps3fb.ext_flip);
788 retval = 0; 795 retval = 0;
789 break; 796 break;
790 797
@@ -805,11 +812,14 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
805 812
806static int ps3fbd(void *arg) 813static int ps3fbd(void *arg)
807{ 814{
808 daemonize("ps3fbd"); 815 while (!kthread_should_stop()) {
809 for (;;) { 816 try_to_freeze();
810 down(&ps3fb.sem); 817 set_current_state(TASK_INTERRUPTIBLE);
811 if (atomic_read(&ps3fb.ext_flip) == 0) 818 if (ps3fb.is_kicked) {
819 ps3fb.is_kicked = 0;
812 ps3fb_sync(0); /* single buffer */ 820 ps3fb_sync(0); /* single buffer */
821 }
822 schedule();
813 } 823 }
814 return 0; 824 return 0;
815} 825}
@@ -823,15 +833,18 @@ static irqreturn_t ps3fb_vsync_interrupt(int irq, void *ptr)
823 status = lv1_gpu_context_intr(ps3fb.context_handle, &v1); 833 status = lv1_gpu_context_intr(ps3fb.context_handle, &v1);
824 if (status) { 834 if (status) {
825 printk(KERN_ERR "%s: lv1_gpu_context_intr failed: %d\n", 835 printk(KERN_ERR "%s: lv1_gpu_context_intr failed: %d\n",
826 __FUNCTION__, status); 836 __func__, status);
827 return IRQ_NONE; 837 return IRQ_NONE;
828 } 838 }
829 839
830 if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) { 840 if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) {
831 /* VSYNC */ 841 /* VSYNC */
832 ps3fb.vblank_count = head->vblank_count; 842 ps3fb.vblank_count = head->vblank_count;
833 if (!ps3fb.is_blanked) 843 if (ps3fb.task && !ps3fb.is_blanked &&
834 up(&ps3fb.sem); 844 !atomic_read(&ps3fb.ext_flip)) {
845 ps3fb.is_kicked = 1;
846 wake_up_process(ps3fb.task);
847 }
835 wake_up_interruptible(&ps3fb.wait_vsync); 848 wake_up_interruptible(&ps3fb.wait_vsync);
836 } 849 }
837 850
@@ -879,7 +892,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev)
879 dinfo->nvcore_frequency/1000000, dinfo->memory_frequency/1000000); 892 dinfo->nvcore_frequency/1000000, dinfo->memory_frequency/1000000);
880 893
881 if (dinfo->version_driver != GPU_DRIVER_INFO_VERSION) { 894 if (dinfo->version_driver != GPU_DRIVER_INFO_VERSION) {
882 printk(KERN_ERR "%s: version_driver err:%x\n", __FUNCTION__, 895 printk(KERN_ERR "%s: version_driver err:%x\n", __func__,
883 dinfo->version_driver); 896 dinfo->version_driver);
884 return -EINVAL; 897 return -EINVAL;
885 } 898 }
@@ -888,7 +901,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev)
888 error = ps3_alloc_irq(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet, 901 error = ps3_alloc_irq(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet,
889 &ps3fb.irq_no); 902 &ps3fb.irq_no);
890 if (error) { 903 if (error) {
891 printk(KERN_ERR "%s: ps3_alloc_irq failed %d\n", __FUNCTION__, 904 printk(KERN_ERR "%s: ps3_alloc_irq failed %d\n", __func__,
892 error); 905 error);
893 return error; 906 return error;
894 } 907 }
@@ -896,7 +909,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev)
896 error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED, 909 error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED,
897 "ps3fb vsync", ps3fb.dev); 910 "ps3fb vsync", ps3fb.dev);
898 if (error) { 911 if (error) {
899 printk(KERN_ERR "%s: request_irq failed %d\n", __FUNCTION__, 912 printk(KERN_ERR "%s: request_irq failed %d\n", __func__,
900 error); 913 error);
901 ps3_free_irq(ps3fb.irq_no); 914 ps3_free_irq(ps3fb.irq_no);
902 return error; 915 return error;
@@ -915,7 +928,7 @@ static int ps3fb_xdr_settings(u64 xdr_lpar)
915 xdr_lpar, ps3fb_videomemory.size, 0); 928 xdr_lpar, ps3fb_videomemory.size, 0);
916 if (status) { 929 if (status) {
917 printk(KERN_ERR "%s: lv1_gpu_context_iomap failed: %d\n", 930 printk(KERN_ERR "%s: lv1_gpu_context_iomap failed: %d\n",
918 __FUNCTION__, status); 931 __func__, status);
919 return -ENXIO; 932 return -ENXIO;
920 } 933 }
921 DPRINTK("video:%p xdr_ea:%p ioif:%lx lpar:%lx phys:%lx size:%lx\n", 934 DPRINTK("video:%p xdr_ea:%p ioif:%lx lpar:%lx phys:%lx size:%lx\n",
@@ -927,8 +940,9 @@ static int ps3fb_xdr_settings(u64 xdr_lpar)
927 xdr_lpar, ps3fb_videomemory.size, 940 xdr_lpar, ps3fb_videomemory.size,
928 GPU_IOIF, 0); 941 GPU_IOIF, 0);
929 if (status) { 942 if (status) {
930 printk(KERN_ERR "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n", 943 printk(KERN_ERR
931 __FUNCTION__, status); 944 "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n",
945 __func__, status);
932 return -ENXIO; 946 return -ENXIO;
933 } 947 }
934 return 0; 948 return 0;
@@ -968,13 +982,14 @@ static int __init ps3fb_probe(struct platform_device *dev)
968 u64 xdr_lpar; 982 u64 xdr_lpar;
969 int status; 983 int status;
970 unsigned long offset; 984 unsigned long offset;
985 struct task_struct *task;
971 986
972 /* get gpu context handle */ 987 /* get gpu context handle */
973 status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, 988 status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0,
974 &ps3fb.memory_handle, &ddr_lpar); 989 &ps3fb.memory_handle, &ddr_lpar);
975 if (status) { 990 if (status) {
976 printk(KERN_ERR "%s: lv1_gpu_memory_allocate failed: %d\n", 991 printk(KERN_ERR "%s: lv1_gpu_memory_allocate failed: %d\n",
977 __FUNCTION__, status); 992 __func__, status);
978 goto err; 993 goto err;
979 } 994 }
980 DPRINTK("ddr:lpar:0x%lx\n", ddr_lpar); 995 DPRINTK("ddr:lpar:0x%lx\n", ddr_lpar);
@@ -985,14 +1000,14 @@ static int __init ps3fb_probe(struct platform_device *dev)
985 &lpar_reports, &lpar_reports_size); 1000 &lpar_reports, &lpar_reports_size);
986 if (status) { 1001 if (status) {
987 printk(KERN_ERR "%s: lv1_gpu_context_attribute failed: %d\n", 1002 printk(KERN_ERR "%s: lv1_gpu_context_attribute failed: %d\n",
988 __FUNCTION__, status); 1003 __func__, status);
989 goto err_gpu_memory_free; 1004 goto err_gpu_memory_free;
990 } 1005 }
991 1006
992 /* vsync interrupt */ 1007 /* vsync interrupt */
993 ps3fb.dinfo = ioremap(lpar_driver_info, 128 * 1024); 1008 ps3fb.dinfo = ioremap(lpar_driver_info, 128 * 1024);
994 if (!ps3fb.dinfo) { 1009 if (!ps3fb.dinfo) {
995 printk(KERN_ERR "%s: ioremap failed\n", __FUNCTION__); 1010 printk(KERN_ERR "%s: ioremap failed\n", __func__);
996 goto err_gpu_context_free; 1011 goto err_gpu_context_free;
997 } 1012 }
998 1013
@@ -1050,9 +1065,18 @@ static int __init ps3fb_probe(struct platform_device *dev)
1050 "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n", 1065 "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n",
1051 info->node, ps3fb_videomemory.size >> 10); 1066 info->node, ps3fb_videomemory.size >> 10);
1052 1067
1053 kernel_thread(ps3fbd, info, CLONE_KERNEL); 1068 task = kthread_run(ps3fbd, info, "ps3fbd");
1069 if (IS_ERR(task)) {
1070 retval = PTR_ERR(task);
1071 goto err_unregister_framebuffer;
1072 }
1073
1074 ps3fb.task = task;
1075
1054 return 0; 1076 return 0;
1055 1077
1078err_unregister_framebuffer:
1079 unregister_framebuffer(info);
1056err_fb_dealloc: 1080err_fb_dealloc:
1057 fb_dealloc_cmap(&info->cmap); 1081 fb_dealloc_cmap(&info->cmap);
1058err_framebuffer_release: 1082err_framebuffer_release:
@@ -1083,6 +1107,11 @@ void ps3fb_cleanup(void)
1083{ 1107{
1084 int status; 1108 int status;
1085 1109
1110 if (ps3fb.task) {
1111 struct task_struct *task = ps3fb.task;
1112 ps3fb.task = NULL;
1113 kthread_stop(task);
1114 }
1086 if (ps3fb.irq_no) { 1115 if (ps3fb.irq_no) {
1087 free_irq(ps3fb.irq_no, ps3fb.dev); 1116 free_irq(ps3fb.irq_no, ps3fb.dev);
1088 ps3_free_irq(ps3fb.irq_no); 1117 ps3_free_irq(ps3fb.irq_no);
@@ -1137,8 +1166,9 @@ int ps3fb_set_sync(void)
1137 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 1166 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
1138 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); 1167 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
1139 if (status) { 1168 if (status) {
1140 printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: %d\n", 1169 printk(KERN_ERR
1141 __FUNCTION__, status); 1170 "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: %d\n",
1171 __func__, status);
1142 return -1; 1172 return -1;
1143 } 1173 }
1144#endif 1174#endif
@@ -1148,8 +1178,9 @@ int ps3fb_set_sync(void)
1148 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); 1178 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
1149 1179
1150 if (status) { 1180 if (status) {
1151 printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_MODE failed: %d\n", 1181 printk(KERN_ERR
1152 __FUNCTION__, status); 1182 "%s: lv1_gpu_context_attribute DISPLAY_MODE failed: %d\n",
1183 __func__, status);
1153 return -1; 1184 return -1;
1154 } 1185 }
1155#endif 1186#endif
@@ -1174,7 +1205,7 @@ static int __init ps3fb_init(void)
1174 1205
1175 error = ps3av_dev_open(); 1206 error = ps3av_dev_open();
1176 if (error) { 1207 if (error) {
1177 printk(KERN_ERR "%s: ps3av_dev_open failed\n", __FUNCTION__); 1208 printk(KERN_ERR "%s: ps3av_dev_open failed\n", __func__);
1178 goto err; 1209 goto err;
1179 } 1210 }
1180 1211
@@ -1195,7 +1226,6 @@ static int __init ps3fb_init(void)
1195 1226
1196 atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */ 1227 atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */
1197 atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */ 1228 atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */
1198 init_MUTEX(&ps3fb.sem);
1199 init_waitqueue_head(&ps3fb.wait_vsync); 1229 init_waitqueue_head(&ps3fb.wait_vsync);
1200 ps3fb.num_frames = 1; 1230 ps3fb.num_frames = 1;
1201 1231
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
index 69f3b264a22e..c97709ecbad0 100644
--- a/drivers/video/stifb.c
+++ b/drivers/video/stifb.c
@@ -64,7 +64,6 @@
64#include <linux/fb.h> 64#include <linux/fb.h>
65#include <linux/init.h> 65#include <linux/init.h>
66#include <linux/ioport.h> 66#include <linux/ioport.h>
67#include <linux/pci.h>
68 67
69#include <asm/grfioctl.h> /* for HP-UX compatibility */ 68#include <asm/grfioctl.h> /* for HP-UX compatibility */
70#include <asm/uaccess.h> 69#include <asm/uaccess.h>
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
index 06fc19a61192..ad66f070acb8 100644
--- a/drivers/video/valkyriefb.c
+++ b/drivers/video/valkyriefb.c
@@ -51,7 +51,6 @@
51#include <linux/fb.h> 51#include <linux/fb.h>
52#include <linux/selection.h> 52#include <linux/selection.h>
53#include <linux/init.h> 53#include <linux/init.h>
54#include <linux/pci.h>
55#include <linux/nvram.h> 54#include <linux/nvram.h>
56#include <linux/adb.h> 55#include <linux/adb.h>
57#include <linux/cuda.h> 56#include <linux/cuda.h>
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c
index b3ce8859a586..2ce4cebc31d9 100644
--- a/drivers/zorro/proc.c
+++ b/drivers/zorro/proc.c
@@ -90,8 +90,9 @@ get_zorro_dev_info(char *buf, char **start, off_t pos, int count)
90 for (slot = cnt = 0; slot < zorro_num_autocon && count > cnt; slot++) { 90 for (slot = cnt = 0; slot < zorro_num_autocon && count > cnt; slot++) {
91 struct zorro_dev *z = &zorro_autocon[slot]; 91 struct zorro_dev *z = &zorro_autocon[slot];
92 len = sprintf(buf, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot, 92 len = sprintf(buf, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot,
93 z->id, zorro_resource_start(z), 93 z->id, (unsigned long)zorro_resource_start(z),
94 zorro_resource_len(z), z->rom.er_Type); 94 (unsigned long)zorro_resource_len(z),
95 z->rom.er_Type);
95 at += len; 96 at += len;
96 if (at >= pos) { 97 if (at >= pos) {
97 if (!*start) { 98 if (!*start) {
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index 87c29d7b6c17..c3ba0ec334c4 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -42,7 +42,8 @@ static ssize_t zorro_show_resource(struct device *dev, struct device_attribute *
42 struct zorro_dev *z = to_zorro_dev(dev); 42 struct zorro_dev *z = to_zorro_dev(dev);
43 43
44 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n", 44 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
45 zorro_resource_start(z), zorro_resource_end(z), 45 (unsigned long)zorro_resource_start(z),
46 (unsigned long)zorro_resource_end(z),
46 zorro_resource_flags(z)); 47 zorro_resource_flags(z));
47} 48}
48 49
diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
index 0f2b40605b06..4cc42b64820c 100644
--- a/drivers/zorro/zorro.c
+++ b/drivers/zorro/zorro.c
@@ -164,7 +164,8 @@ static int __init zorro_init(void)
164 if (request_resource(zorro_find_parent_resource(z), &z->resource)) 164 if (request_resource(zorro_find_parent_resource(z), &z->resource))
165 printk(KERN_ERR "Zorro: Address space collision on device %s " 165 printk(KERN_ERR "Zorro: Address space collision on device %s "
166 "[%lx:%lx]\n", 166 "[%lx:%lx]\n",
167 z->name, zorro_resource_start(z), zorro_resource_end(z)); 167 z->name, (unsigned long)zorro_resource_start(z),
168 (unsigned long)zorro_resource_end(z));
168 sprintf(z->dev.bus_id, "%02x", i); 169 sprintf(z->dev.bus_id, "%02x", i);
169 z->dev.parent = &zorro_bus.dev; 170 z->dev.parent = &zorro_bus.dev;
170 z->dev.bus = &zorro_bus_type; 171 z->dev.bus = &zorro_bus_type;
diff --git a/fs/Kconfig b/fs/Kconfig
index a42f767dcdd5..8ea7b04c661f 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1734,6 +1734,18 @@ config SUNRPC
1734config SUNRPC_GSS 1734config SUNRPC_GSS
1735 tristate 1735 tristate
1736 1736
1737config SUNRPC_BIND34
1738 bool "Support for rpcbind versions 3 & 4 (EXPERIMENTAL)"
1739 depends on SUNRPC && EXPERIMENTAL
1740 help
1741 Provides kernel support for querying rpcbind servers via versions 3
1742 and 4 of the rpcbind protocol. The kernel automatically falls back
1743 to version 2 if a remote rpcbind service does not support versions
1744 3 or 4.
1745
1746 If unsure, say N to get traditional behavior (version 2 rpcbind
1747 requests only).
1748
1737config RPCSEC_GSS_KRB5 1749config RPCSEC_GSS_KRB5
1738 tristate "Secure RPC: Kerberos V mechanism (EXPERIMENTAL)" 1750 tristate "Secure RPC: Kerberos V mechanism (EXPERIMENTAL)"
1739 depends on SUNRPC && EXPERIMENTAL 1751 depends on SUNRPC && EXPERIMENTAL
@@ -2020,7 +2032,6 @@ config AFS_FS
2020 tristate "Andrew File System support (AFS) (EXPERIMENTAL)" 2032 tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
2021 depends on INET && EXPERIMENTAL 2033 depends on INET && EXPERIMENTAL
2022 select AF_RXRPC 2034 select AF_RXRPC
2023 select KEYS
2024 help 2035 help
2025 If you say Y here, you will get an experimental Andrew File System 2036 If you say Y here, you will get an experimental Andrew File System
2026 driver. It currently only supports unsecured read-only AFS access. 2037 driver. It currently only supports unsecured read-only AFS access.
diff --git a/fs/afs/Makefile b/fs/afs/Makefile
index 01545eb1d872..cf83e5d63512 100644
--- a/fs/afs/Makefile
+++ b/fs/afs/Makefile
@@ -18,7 +18,7 @@ kafs-objs := \
18 security.o \ 18 security.o \
19 server.o \ 19 server.o \
20 super.o \ 20 super.o \
21 use-rtnetlink.o \ 21 netdevices.o \
22 vlclient.o \ 22 vlclient.o \
23 vlocation.o \ 23 vlocation.o \
24 vnode.o \ 24 vnode.o \
diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index 639399f0ab6f..9bdbf36a9aa9 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -468,7 +468,7 @@ int __init afs_callback_update_init(void)
468/* 468/*
469 * shut down the callback update process 469 * shut down the callback update process
470 */ 470 */
471void __exit afs_callback_update_kill(void) 471void afs_callback_update_kill(void)
472{ 472{
473 destroy_workqueue(afs_callback_update_worker); 473 destroy_workqueue(afs_callback_update_worker);
474} 474}
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 6685f4cbccb3..d5b2ad6575bc 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -443,6 +443,7 @@ static void SRXAFSCB_GetCapabilities(struct work_struct *work)
443 reply.ia.netmask[loop] = ifs[loop].netmask.s_addr; 443 reply.ia.netmask[loop] = ifs[loop].netmask.s_addr;
444 reply.ia.mtu[loop] = htonl(ifs[loop].mtu); 444 reply.ia.mtu[loop] = htonl(ifs[loop].mtu);
445 } 445 }
446 kfree(ifs);
446 } 447 }
447 448
448 reply.cap.capcount = htonl(1); 449 reply.cap.capcount = htonl(1);
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 2393d2a08d79..e54e6c2ad343 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -266,7 +266,8 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call,
266 call->unmarshall++; 266 call->unmarshall++;
267 267
268 if (call->count < PAGE_SIZE) { 268 if (call->count < PAGE_SIZE) {
269 buffer = kmap_atomic(call->reply3, KM_USER0); 269 page = call->reply3;
270 buffer = kmap_atomic(page, KM_USER0);
270 memset(buffer + PAGE_SIZE - call->count, 0, 271 memset(buffer + PAGE_SIZE - call->count, 0,
271 call->count); 272 call->count);
272 kunmap_atomic(buffer, KM_USER0); 273 kunmap_atomic(buffer, KM_USER0);
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 34665f7d7a19..d90c158cd934 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -349,7 +349,6 @@ struct afs_permits {
349 * record of one of a system's set of network interfaces 349 * record of one of a system's set of network interfaces
350 */ 350 */
351struct afs_interface { 351struct afs_interface {
352 unsigned index; /* interface index */
353 struct in_addr address; /* IPv4 address bound to interface */ 352 struct in_addr address; /* IPv4 address bound to interface */
354 struct in_addr netmask; /* netmask applied to address */ 353 struct in_addr netmask; /* netmask applied to address */
355 unsigned mtu; /* MTU of interface */ 354 unsigned mtu; /* MTU of interface */
@@ -392,7 +391,7 @@ extern void afs_give_up_callback(struct afs_vnode *);
392extern void afs_dispatch_give_up_callbacks(struct work_struct *); 391extern void afs_dispatch_give_up_callbacks(struct work_struct *);
393extern void afs_flush_callback_breaks(struct afs_server *); 392extern void afs_flush_callback_breaks(struct afs_server *);
394extern int __init afs_callback_update_init(void); 393extern int __init afs_callback_update_init(void);
395extern void __exit afs_callback_update_kill(void); 394extern void afs_callback_update_kill(void);
396 395
397/* 396/*
398 * cell.c 397 * cell.c
@@ -564,7 +563,7 @@ extern void afs_fs_exit(void);
564 * use-rtnetlink.c 563 * use-rtnetlink.c
565 */ 564 */
566extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); 565extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool);
567extern int afs_get_MAC_address(u8 [6]); 566extern int afs_get_MAC_address(u8 *, size_t);
568 567
569/* 568/*
570 * vlclient.c 569 * vlclient.c
@@ -591,7 +590,7 @@ extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *,
591 struct key *, 590 struct key *,
592 const char *, size_t); 591 const char *, size_t);
593extern void afs_put_vlocation(struct afs_vlocation *); 592extern void afs_put_vlocation(struct afs_vlocation *);
594extern void __exit afs_vlocation_purge(void); 593extern void afs_vlocation_purge(void);
595 594
596/* 595/*
597 * vnode.c 596 * vnode.c
diff --git a/fs/afs/main.c b/fs/afs/main.c
index 40c2704e7557..80ec6fd19a73 100644
--- a/fs/afs/main.c
+++ b/fs/afs/main.c
@@ -54,7 +54,7 @@ static int __init afs_get_client_UUID(void)
54 54
55 /* read the MAC address of one of the external interfaces and construct 55 /* read the MAC address of one of the external interfaces and construct
56 * a UUID from it */ 56 * a UUID from it */
57 ret = afs_get_MAC_address(afs_uuid.node); 57 ret = afs_get_MAC_address(afs_uuid.node, sizeof(afs_uuid.node));
58 if (ret < 0) 58 if (ret < 0)
59 return ret; 59 return ret;
60 60
diff --git a/fs/afs/netdevices.c b/fs/afs/netdevices.c
new file mode 100644
index 000000000000..fc27d4b52e5f
--- /dev/null
+++ b/fs/afs/netdevices.c
@@ -0,0 +1,68 @@
1/* AFS network device helpers
2 *
3 * Copyright (c) 2007 Patrick McHardy <kaber@trash.net>
4 */
5
6#include <linux/string.h>
7#include <linux/rtnetlink.h>
8#include <linux/inetdevice.h>
9#include <linux/netdevice.h>
10#include <linux/if_arp.h>
11#include "internal.h"
12
13/*
14 * get a MAC address from a random ethernet interface that has a real one
15 * - the buffer will normally be 6 bytes in size
16 */
17int afs_get_MAC_address(u8 *mac, size_t maclen)
18{
19 struct net_device *dev;
20 int ret = -ENODEV;
21
22 if (maclen != ETH_ALEN)
23 BUG();
24
25 rtnl_lock();
26 dev = __dev_getfirstbyhwtype(ARPHRD_ETHER);
27 if (dev) {
28 memcpy(mac, dev->dev_addr, maclen);
29 ret = 0;
30 }
31 rtnl_unlock();
32 return ret;
33}
34
35/*
36 * get a list of this system's interface IPv4 addresses, netmasks and MTUs
37 * - maxbufs must be at least 1
38 * - returns the number of interface records in the buffer
39 */
40int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs,
41 bool wantloopback)
42{
43 struct net_device *dev;
44 struct in_device *idev;
45 int n = 0;
46
47 ASSERT(maxbufs > 0);
48
49 rtnl_lock();
50 for_each_netdev(dev) {
51 if (dev->type == ARPHRD_LOOPBACK && !wantloopback)
52 continue;
53 idev = __in_dev_get_rtnl(dev);
54 if (!idev)
55 continue;
56 for_primary_ifa(idev) {
57 bufs[n].address.s_addr = ifa->ifa_address;
58 bufs[n].netmask.s_addr = ifa->ifa_mask;
59 bufs[n].mtu = dev->mtu;
60 n++;
61 if (n >= maxbufs)
62 goto out;
63 } endfor_ifa(idev);
64 }
65out:
66 rtnl_unlock();
67 return n;
68}
diff --git a/fs/afs/super.c b/fs/afs/super.c
index cebd03c91f57..41173f81ac47 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -20,6 +20,7 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/parser.h>
23#include "internal.h" 24#include "internal.h"
24 25
25#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ 26#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */
@@ -42,7 +43,7 @@ struct file_system_type afs_fs_type = {
42 .name = "afs", 43 .name = "afs",
43 .get_sb = afs_get_sb, 44 .get_sb = afs_get_sb,
44 .kill_sb = kill_anon_super, 45 .kill_sb = kill_anon_super,
45 .fs_flags = FS_BINARY_MOUNTDATA, 46 .fs_flags = 0,
46}; 47};
47 48
48static const struct super_operations afs_super_ops = { 49static const struct super_operations afs_super_ops = {
@@ -58,6 +59,20 @@ static const struct super_operations afs_super_ops = {
58static struct kmem_cache *afs_inode_cachep; 59static struct kmem_cache *afs_inode_cachep;
59static atomic_t afs_count_active_inodes; 60static atomic_t afs_count_active_inodes;
60 61
62enum {
63 afs_no_opt,
64 afs_opt_cell,
65 afs_opt_rwpath,
66 afs_opt_vol,
67};
68
69static const match_table_t afs_options_list = {
70 { afs_opt_cell, "cell=%s" },
71 { afs_opt_rwpath, "rwpath" },
72 { afs_opt_vol, "vol=%s" },
73 { afs_no_opt, NULL },
74};
75
61/* 76/*
62 * initialise the filesystem 77 * initialise the filesystem
63 */ 78 */
@@ -115,31 +130,6 @@ void __exit afs_fs_exit(void)
115} 130}
116 131
117/* 132/*
118 * check that an argument has a value
119 */
120static int want_arg(char **_value, const char *option)
121{
122 if (!_value || !*_value || !**_value) {
123 printk(KERN_NOTICE "kAFS: %s: argument missing\n", option);
124 return 0;
125 }
126 return 1;
127}
128
129/*
130 * check that there's no subsequent value
131 */
132static int want_no_value(char *const *_value, const char *option)
133{
134 if (*_value && **_value) {
135 printk(KERN_NOTICE "kAFS: %s: Invalid argument: %s\n",
136 option, *_value);
137 return 0;
138 }
139 return 1;
140}
141
142/*
143 * parse the mount options 133 * parse the mount options
144 * - this function has been shamelessly adapted from the ext3 fs which 134 * - this function has been shamelessly adapted from the ext3 fs which
145 * shamelessly adapted it from the msdos fs 135 * shamelessly adapted it from the msdos fs
@@ -148,48 +138,46 @@ static int afs_parse_options(struct afs_mount_params *params,
148 char *options, const char **devname) 138 char *options, const char **devname)
149{ 139{
150 struct afs_cell *cell; 140 struct afs_cell *cell;
151 char *key, *value; 141 substring_t args[MAX_OPT_ARGS];
152 int ret; 142 char *p;
143 int token;
153 144
154 _enter("%s", options); 145 _enter("%s", options);
155 146
156 options[PAGE_SIZE - 1] = 0; 147 options[PAGE_SIZE - 1] = 0;
157 148
158 ret = 0; 149 while ((p = strsep(&options, ","))) {
159 while ((key = strsep(&options, ","))) { 150 if (!*p)
160 value = strchr(key, '='); 151 continue;
161 if (value)
162 *value++ = 0;
163
164 _debug("kAFS: KEY: %s, VAL:%s", key, value ?: "-");
165 152
166 if (strcmp(key, "rwpath") == 0) { 153 token = match_token(p, afs_options_list, args);
167 if (!want_no_value(&value, "rwpath")) 154 switch (token) {
168 return -EINVAL; 155 case afs_opt_cell:
169 params->rwpath = 1; 156 cell = afs_cell_lookup(args[0].from,
170 } else if (strcmp(key, "vol") == 0) { 157 args[0].to - args[0].from);
171 if (!want_arg(&value, "vol"))
172 return -EINVAL;
173 *devname = value;
174 } else if (strcmp(key, "cell") == 0) {
175 if (!want_arg(&value, "cell"))
176 return -EINVAL;
177 cell = afs_cell_lookup(value, strlen(value));
178 if (IS_ERR(cell)) 158 if (IS_ERR(cell))
179 return PTR_ERR(cell); 159 return PTR_ERR(cell);
180 afs_put_cell(params->cell); 160 afs_put_cell(params->cell);
181 params->cell = cell; 161 params->cell = cell;
182 } else { 162 break;
183 printk("kAFS: Unknown mount option: '%s'\n", key); 163
184 ret = -EINVAL; 164 case afs_opt_rwpath:
185 goto error; 165 params->rwpath = 1;
166 break;
167
168 case afs_opt_vol:
169 *devname = args[0].from;
170 break;
171
172 default:
173 printk(KERN_ERR "kAFS:"
174 " Unknown or invalid mount option: '%s'\n", p);
175 return -EINVAL;
186 } 176 }
187 } 177 }
188 178
189 ret = 0; 179 _leave(" = 0");
190error: 180 return 0;
191 _leave(" = %d", ret);
192 return ret;
193} 181}
194 182
195/* 183/*
@@ -361,7 +349,6 @@ error:
361 349
362/* 350/*
363 * get an AFS superblock 351 * get an AFS superblock
364 * - TODO: don't use get_sb_nodev(), but rather call sget() directly
365 */ 352 */
366static int afs_get_sb(struct file_system_type *fs_type, 353static int afs_get_sb(struct file_system_type *fs_type,
367 int flags, 354 int flags,
@@ -386,7 +373,6 @@ static int afs_get_sb(struct file_system_type *fs_type,
386 goto error; 373 goto error;
387 } 374 }
388 375
389
390 ret = afs_parse_device_name(&params, dev_name); 376 ret = afs_parse_device_name(&params, dev_name);
391 if (ret < 0) 377 if (ret < 0)
392 goto error; 378 goto error;
diff --git a/fs/afs/use-rtnetlink.c b/fs/afs/use-rtnetlink.c
deleted file mode 100644
index f8991c700e02..000000000000
--- a/fs/afs/use-rtnetlink.c
+++ /dev/null
@@ -1,473 +0,0 @@
1/* RTNETLINK client
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#include <linux/netlink.h>
12#include <linux/rtnetlink.h>
13#include <linux/if_addr.h>
14#include <linux/if_arp.h>
15#include <linux/inetdevice.h>
16#include <net/netlink.h>
17#include "internal.h"
18
19struct afs_rtm_desc {
20 struct socket *nlsock;
21 struct afs_interface *bufs;
22 u8 *mac;
23 size_t nbufs;
24 size_t maxbufs;
25 void *data;
26 ssize_t datalen;
27 size_t datamax;
28 int msg_seq;
29 unsigned mac_index;
30 bool wantloopback;
31 int (*parse)(struct afs_rtm_desc *, struct nlmsghdr *);
32};
33
34/*
35 * parse an RTM_GETADDR response
36 */
37static int afs_rtm_getaddr_parse(struct afs_rtm_desc *desc,
38 struct nlmsghdr *nlhdr)
39{
40 struct afs_interface *this;
41 struct ifaddrmsg *ifa;
42 struct rtattr *rtattr;
43 const char *name;
44 size_t len;
45
46 ifa = (struct ifaddrmsg *) NLMSG_DATA(nlhdr);
47
48 _enter("{ix=%d,af=%d}", ifa->ifa_index, ifa->ifa_family);
49
50 if (ifa->ifa_family != AF_INET) {
51 _leave(" = 0 [family %d]", ifa->ifa_family);
52 return 0;
53 }
54 if (desc->nbufs >= desc->maxbufs) {
55 _leave(" = 0 [max %zu/%zu]", desc->nbufs, desc->maxbufs);
56 return 0;
57 }
58
59 this = &desc->bufs[desc->nbufs];
60
61 this->index = ifa->ifa_index;
62 this->netmask.s_addr = inet_make_mask(ifa->ifa_prefixlen);
63 this->mtu = 0;
64
65 rtattr = NLMSG_DATA(nlhdr) + NLMSG_ALIGN(sizeof(struct ifaddrmsg));
66 len = NLMSG_PAYLOAD(nlhdr, sizeof(struct ifaddrmsg));
67
68 name = "unknown";
69 for (; RTA_OK(rtattr, len); rtattr = RTA_NEXT(rtattr, len)) {
70 switch (rtattr->rta_type) {
71 case IFA_ADDRESS:
72 memcpy(&this->address, RTA_DATA(rtattr), 4);
73 break;
74 case IFA_LABEL:
75 name = RTA_DATA(rtattr);
76 break;
77 }
78 }
79
80 _debug("%s: "NIPQUAD_FMT"/"NIPQUAD_FMT,
81 name, NIPQUAD(this->address), NIPQUAD(this->netmask));
82
83 desc->nbufs++;
84 _leave(" = 0");
85 return 0;
86}
87
88/*
89 * parse an RTM_GETLINK response for MTUs
90 */
91static int afs_rtm_getlink_if_parse(struct afs_rtm_desc *desc,
92 struct nlmsghdr *nlhdr)
93{
94 struct afs_interface *this;
95 struct ifinfomsg *ifi;
96 struct rtattr *rtattr;
97 const char *name;
98 size_t len, loop;
99
100 ifi = (struct ifinfomsg *) NLMSG_DATA(nlhdr);
101
102 _enter("{ix=%d}", ifi->ifi_index);
103
104 for (loop = 0; loop < desc->nbufs; loop++) {
105 this = &desc->bufs[loop];
106 if (this->index == ifi->ifi_index)
107 goto found;
108 }
109
110 _leave(" = 0 [no match]");
111 return 0;
112
113found:
114 if (ifi->ifi_type == ARPHRD_LOOPBACK && !desc->wantloopback) {
115 _leave(" = 0 [loopback]");
116 return 0;
117 }
118
119 rtattr = NLMSG_DATA(nlhdr) + NLMSG_ALIGN(sizeof(struct ifinfomsg));
120 len = NLMSG_PAYLOAD(nlhdr, sizeof(struct ifinfomsg));
121
122 name = "unknown";
123 for (; RTA_OK(rtattr, len); rtattr = RTA_NEXT(rtattr, len)) {
124 switch (rtattr->rta_type) {
125 case IFLA_MTU:
126 memcpy(&this->mtu, RTA_DATA(rtattr), 4);
127 break;
128 case IFLA_IFNAME:
129 name = RTA_DATA(rtattr);
130 break;
131 }
132 }
133
134 _debug("%s: "NIPQUAD_FMT"/"NIPQUAD_FMT" mtu %u",
135 name, NIPQUAD(this->address), NIPQUAD(this->netmask),
136 this->mtu);
137
138 _leave(" = 0");
139 return 0;
140}
141
142/*
143 * parse an RTM_GETLINK response for the MAC address belonging to the lowest
144 * non-internal interface
145 */
146static int afs_rtm_getlink_mac_parse(struct afs_rtm_desc *desc,
147 struct nlmsghdr *nlhdr)
148{
149 struct ifinfomsg *ifi;
150 struct rtattr *rtattr;
151 const char *name;
152 size_t remain, len;
153 bool set;
154
155 ifi = (struct ifinfomsg *) NLMSG_DATA(nlhdr);
156
157 _enter("{ix=%d}", ifi->ifi_index);
158
159 if (ifi->ifi_index >= desc->mac_index) {
160 _leave(" = 0 [high]");
161 return 0;
162 }
163 if (ifi->ifi_type == ARPHRD_LOOPBACK) {
164 _leave(" = 0 [loopback]");
165 return 0;
166 }
167
168 rtattr = NLMSG_DATA(nlhdr) + NLMSG_ALIGN(sizeof(struct ifinfomsg));
169 remain = NLMSG_PAYLOAD(nlhdr, sizeof(struct ifinfomsg));
170
171 name = "unknown";
172 set = false;
173 for (; RTA_OK(rtattr, remain); rtattr = RTA_NEXT(rtattr, remain)) {
174 switch (rtattr->rta_type) {
175 case IFLA_ADDRESS:
176 len = RTA_PAYLOAD(rtattr);
177 memcpy(desc->mac, RTA_DATA(rtattr),
178 min_t(size_t, len, 6));
179 desc->mac_index = ifi->ifi_index;
180 set = true;
181 break;
182 case IFLA_IFNAME:
183 name = RTA_DATA(rtattr);
184 break;
185 }
186 }
187
188 if (set)
189 _debug("%s: %02x:%02x:%02x:%02x:%02x:%02x",
190 name,
191 desc->mac[0], desc->mac[1], desc->mac[2],
192 desc->mac[3], desc->mac[4], desc->mac[5]);
193
194 _leave(" = 0");
195 return 0;
196}
197
198/*
199 * read the rtnetlink response and pass to parsing routine
200 */
201static int afs_read_rtm(struct afs_rtm_desc *desc)
202{
203 struct nlmsghdr *nlhdr, tmphdr;
204 struct msghdr msg;
205 struct kvec iov[1];
206 void *data;
207 bool last = false;
208 int len, ret, remain;
209
210 _enter("");
211
212 do {
213 /* first of all peek to see how big the packet is */
214 memset(&msg, 0, sizeof(msg));
215 iov[0].iov_base = &tmphdr;
216 iov[0].iov_len = sizeof(tmphdr);
217 len = kernel_recvmsg(desc->nlsock, &msg, iov, 1,
218 sizeof(tmphdr), MSG_PEEK | MSG_TRUNC);
219 if (len < 0) {
220 _leave(" = %d [peek]", len);
221 return len;
222 }
223 if (len == 0)
224 continue;
225 if (len < sizeof(tmphdr) || len < NLMSG_PAYLOAD(&tmphdr, 0)) {
226 _leave(" = -EMSGSIZE");
227 return -EMSGSIZE;
228 }
229
230 if (desc->datamax < len) {
231 kfree(desc->data);
232 desc->data = NULL;
233 data = kmalloc(len, GFP_KERNEL);
234 if (!data)
235 return -ENOMEM;
236 desc->data = data;
237 }
238 desc->datamax = len;
239
240 /* read all the data from this packet */
241 iov[0].iov_base = desc->data;
242 iov[0].iov_len = desc->datamax;
243 desc->datalen = kernel_recvmsg(desc->nlsock, &msg, iov, 1,
244 desc->datamax, 0);
245 if (desc->datalen < 0) {
246 _leave(" = %zd [recv]", desc->datalen);
247 return desc->datalen;
248 }
249
250 nlhdr = desc->data;
251
252 /* check if the header is valid */
253 if (!NLMSG_OK(nlhdr, desc->datalen) ||
254 nlhdr->nlmsg_type == NLMSG_ERROR) {
255 _leave(" = -EIO");
256 return -EIO;
257 }
258
259 /* see if this is the last message */
260 if (nlhdr->nlmsg_type == NLMSG_DONE ||
261 !(nlhdr->nlmsg_flags & NLM_F_MULTI))
262 last = true;
263
264 /* parse the bits we got this time */
265 nlmsg_for_each_msg(nlhdr, desc->data, desc->datalen, remain) {
266 ret = desc->parse(desc, nlhdr);
267 if (ret < 0) {
268 _leave(" = %d [parse]", ret);
269 return ret;
270 }
271 }
272
273 } while (!last);
274
275 _leave(" = 0");
276 return 0;
277}
278
279/*
280 * list the interface bound addresses to get the address and netmask
281 */
282static int afs_rtm_getaddr(struct afs_rtm_desc *desc)
283{
284 struct msghdr msg;
285 struct kvec iov[1];
286 int ret;
287
288 struct {
289 struct nlmsghdr nl_msg __attribute__((aligned(NLMSG_ALIGNTO)));
290 struct ifaddrmsg addr_msg __attribute__((aligned(NLMSG_ALIGNTO)));
291 } request;
292
293 _enter("");
294
295 memset(&request, 0, sizeof(request));
296
297 request.nl_msg.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
298 request.nl_msg.nlmsg_type = RTM_GETADDR;
299 request.nl_msg.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
300 request.nl_msg.nlmsg_seq = desc->msg_seq++;
301 request.nl_msg.nlmsg_pid = 0;
302
303 memset(&msg, 0, sizeof(msg));
304 iov[0].iov_base = &request;
305 iov[0].iov_len = sizeof(request);
306
307 ret = kernel_sendmsg(desc->nlsock, &msg, iov, 1, iov[0].iov_len);
308 _leave(" = %d", ret);
309 return ret;
310}
311
312/*
313 * list the interface link statuses to get the MTUs
314 */
315static int afs_rtm_getlink(struct afs_rtm_desc *desc)
316{
317 struct msghdr msg;
318 struct kvec iov[1];
319 int ret;
320
321 struct {
322 struct nlmsghdr nl_msg __attribute__((aligned(NLMSG_ALIGNTO)));
323 struct ifinfomsg link_msg __attribute__((aligned(NLMSG_ALIGNTO)));
324 } request;
325
326 _enter("");
327
328 memset(&request, 0, sizeof(request));
329
330 request.nl_msg.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
331 request.nl_msg.nlmsg_type = RTM_GETLINK;
332 request.nl_msg.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT;
333 request.nl_msg.nlmsg_seq = desc->msg_seq++;
334 request.nl_msg.nlmsg_pid = 0;
335
336 memset(&msg, 0, sizeof(msg));
337 iov[0].iov_base = &request;
338 iov[0].iov_len = sizeof(request);
339
340 ret = kernel_sendmsg(desc->nlsock, &msg, iov, 1, iov[0].iov_len);
341 _leave(" = %d", ret);
342 return ret;
343}
344
345/*
346 * cull any interface records for which there isn't an MTU value
347 */
348static void afs_cull_interfaces(struct afs_rtm_desc *desc)
349{
350 struct afs_interface *bufs = desc->bufs;
351 size_t nbufs = desc->nbufs;
352 int loop, point = 0;
353
354 _enter("{%zu}", nbufs);
355
356 for (loop = 0; loop < nbufs; loop++) {
357 if (desc->bufs[loop].mtu != 0) {
358 if (loop != point) {
359 ASSERTCMP(loop, >, point);
360 bufs[point] = bufs[loop];
361 }
362 point++;
363 }
364 }
365
366 desc->nbufs = point;
367 _leave(" [%zu/%zu]", desc->nbufs, nbufs);
368}
369
370/*
371 * get a list of this system's interface IPv4 addresses, netmasks and MTUs
372 * - returns the number of interface records in the buffer
373 */
374int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs,
375 bool wantloopback)
376{
377 struct afs_rtm_desc desc;
378 int ret, loop;
379
380 _enter("");
381
382 memset(&desc, 0, sizeof(desc));
383 desc.bufs = bufs;
384 desc.maxbufs = maxbufs;
385 desc.wantloopback = wantloopback;
386
387 ret = sock_create_kern(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE,
388 &desc.nlsock);
389 if (ret < 0) {
390 _leave(" = %d [sock]", ret);
391 return ret;
392 }
393
394 /* issue RTM_GETADDR */
395 desc.parse = afs_rtm_getaddr_parse;
396 ret = afs_rtm_getaddr(&desc);
397 if (ret < 0)
398 goto error;
399 ret = afs_read_rtm(&desc);
400 if (ret < 0)
401 goto error;
402
403 /* issue RTM_GETLINK */
404 desc.parse = afs_rtm_getlink_if_parse;
405 ret = afs_rtm_getlink(&desc);
406 if (ret < 0)
407 goto error;
408 ret = afs_read_rtm(&desc);
409 if (ret < 0)
410 goto error;
411
412 afs_cull_interfaces(&desc);
413 ret = desc.nbufs;
414
415 for (loop = 0; loop < ret; loop++)
416 _debug("[%d] "NIPQUAD_FMT"/"NIPQUAD_FMT" mtu %u",
417 bufs[loop].index,
418 NIPQUAD(bufs[loop].address),
419 NIPQUAD(bufs[loop].netmask),
420 bufs[loop].mtu);
421
422error:
423 kfree(desc.data);
424 sock_release(desc.nlsock);
425 _leave(" = %d", ret);
426 return ret;
427}
428
429/*
430 * get a MAC address from a random ethernet interface that has a real one
431 * - the buffer should be 6 bytes in size
432 */
433int afs_get_MAC_address(u8 mac[6])
434{
435 struct afs_rtm_desc desc;
436 int ret;
437
438 _enter("");
439
440 memset(&desc, 0, sizeof(desc));
441 desc.mac = mac;
442 desc.mac_index = UINT_MAX;
443
444 ret = sock_create_kern(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE,
445 &desc.nlsock);
446 if (ret < 0) {
447 _leave(" = %d [sock]", ret);
448 return ret;
449 }
450
451 /* issue RTM_GETLINK */
452 desc.parse = afs_rtm_getlink_mac_parse;
453 ret = afs_rtm_getlink(&desc);
454 if (ret < 0)
455 goto error;
456 ret = afs_read_rtm(&desc);
457 if (ret < 0)
458 goto error;
459
460 if (desc.mac_index < UINT_MAX) {
461 /* got a MAC address */
462 _debug("[%d] %02x:%02x:%02x:%02x:%02x:%02x",
463 desc.mac_index,
464 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
465 } else {
466 ret = -ENONET;
467 }
468
469error:
470 sock_release(desc.nlsock);
471 _leave(" = %d", ret);
472 return ret;
473}
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c
index 6c8e95a7c2c9..3370cdb72566 100644
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -602,7 +602,7 @@ int __init afs_vlocation_update_init(void)
602/* 602/*
603 * discard all the volume location records for rmmod 603 * discard all the volume location records for rmmod
604 */ 604 */
605void __exit afs_vlocation_purge(void) 605void afs_vlocation_purge(void)
606{ 606{
607 afs_vlocation_timeout = 0; 607 afs_vlocation_timeout = 0;
608 608
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 6f573004cd7d..b00d962de833 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -140,7 +140,7 @@ static int __init configfs_init(void)
140 if (!configfs_dir_cachep) 140 if (!configfs_dir_cachep)
141 goto out; 141 goto out;
142 142
143 kset_set_kset_s(&config_subsys, kernel_subsys); 143 kobj_set_kset_s(&config_subsys, kernel_subsys);
144 err = subsystem_register(&config_subsys); 144 err = subsystem_register(&config_subsys);
145 if (err) { 145 if (err) {
146 kmem_cache_destroy(configfs_dir_cachep); 146 kmem_cache_destroy(configfs_dir_cachep);
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 7b324cfebcb1..ec8896b264de 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -374,7 +374,7 @@ static int __init debugfs_init(void)
374{ 374{
375 int retval; 375 int retval;
376 376
377 kset_set_kset_s(&debug_subsys, kernel_subsys); 377 kobj_set_kset_s(&debug_subsys, kernel_subsys);
378 retval = subsystem_register(&debug_subsys); 378 retval = subsystem_register(&debug_subsys);
379 if (retval) 379 if (retval)
380 return retval; 380 return retval;
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index f40817b53c6f..8e6ad7600236 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -167,7 +167,6 @@ static struct kobj_type dlm_ktype = {
167}; 167};
168 168
169static struct kset dlm_kset = { 169static struct kset dlm_kset = {
170 .subsys = &kernel_subsys,
171 .kobj = {.name = "dlm",}, 170 .kobj = {.name = "dlm",},
172 .ktype = &dlm_ktype, 171 .ktype = &dlm_ktype,
173}; 172};
@@ -218,6 +217,7 @@ int dlm_lockspace_init(void)
218 INIT_LIST_HEAD(&lslist); 217 INIT_LIST_HEAD(&lslist);
219 spin_lock_init(&lslist_lock); 218 spin_lock_init(&lslist_lock);
220 219
220 kobj_set_kset_s(&dlm_kset, kernel_subsys);
221 error = kset_register(&dlm_kset); 221 error = kset_register(&dlm_kset);
222 if (error) 222 if (error)
223 printk("dlm_lockspace_init: cannot register kset %d\n", error); 223 printk("dlm_lockspace_init: cannot register kset %d\n", error);
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index fc4a3a224641..6acc8f4fc588 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -793,7 +793,7 @@ static int do_sysfs_registration(void)
793 "Unable to register ecryptfs sysfs subsystem\n"); 793 "Unable to register ecryptfs sysfs subsystem\n");
794 goto out; 794 goto out;
795 } 795 }
796 rc = sysfs_create_file(&ecryptfs_subsys.kset.kobj, 796 rc = sysfs_create_file(&ecryptfs_subsys.kobj,
797 &sysfs_attr_version.attr); 797 &sysfs_attr_version.attr);
798 if (rc) { 798 if (rc) {
799 printk(KERN_ERR 799 printk(KERN_ERR
@@ -801,12 +801,12 @@ static int do_sysfs_registration(void)
801 subsystem_unregister(&ecryptfs_subsys); 801 subsystem_unregister(&ecryptfs_subsys);
802 goto out; 802 goto out;
803 } 803 }
804 rc = sysfs_create_file(&ecryptfs_subsys.kset.kobj, 804 rc = sysfs_create_file(&ecryptfs_subsys.kobj,
805 &sysfs_attr_version_str.attr); 805 &sysfs_attr_version_str.attr);
806 if (rc) { 806 if (rc) {
807 printk(KERN_ERR 807 printk(KERN_ERR
808 "Unable to create ecryptfs version_str attribute\n"); 808 "Unable to create ecryptfs version_str attribute\n");
809 sysfs_remove_file(&ecryptfs_subsys.kset.kobj, 809 sysfs_remove_file(&ecryptfs_subsys.kobj,
810 &sysfs_attr_version.attr); 810 &sysfs_attr_version.attr);
811 subsystem_unregister(&ecryptfs_subsys); 811 subsystem_unregister(&ecryptfs_subsys);
812 goto out; 812 goto out;
@@ -841,7 +841,7 @@ static int __init ecryptfs_init(void)
841 ecryptfs_free_kmem_caches(); 841 ecryptfs_free_kmem_caches();
842 goto out; 842 goto out;
843 } 843 }
844 kset_set_kset_s(&ecryptfs_subsys, fs_subsys); 844 kobj_set_kset_s(&ecryptfs_subsys, fs_subsys);
845 sysfs_attr_version.attr.owner = THIS_MODULE; 845 sysfs_attr_version.attr.owner = THIS_MODULE;
846 sysfs_attr_version_str.attr.owner = THIS_MODULE; 846 sysfs_attr_version_str.attr.owner = THIS_MODULE;
847 rc = do_sysfs_registration(); 847 rc = do_sysfs_registration();
@@ -862,9 +862,9 @@ out:
862 862
863static void __exit ecryptfs_exit(void) 863static void __exit ecryptfs_exit(void)
864{ 864{
865 sysfs_remove_file(&ecryptfs_subsys.kset.kobj, 865 sysfs_remove_file(&ecryptfs_subsys.kobj,
866 &sysfs_attr_version.attr); 866 &sysfs_attr_version.attr);
867 sysfs_remove_file(&ecryptfs_subsys.kset.kobj, 867 sysfs_remove_file(&ecryptfs_subsys.kobj,
868 &sysfs_attr_version_str.attr); 868 &sysfs_attr_version_str.attr);
869 subsystem_unregister(&ecryptfs_subsys); 869 subsystem_unregister(&ecryptfs_subsys);
870 ecryptfs_release_messaging(ecryptfs_transport); 870 ecryptfs_release_messaging(ecryptfs_transport);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 608db81219a0..bdffe0cfe09a 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -731,12 +731,12 @@ static int fuse_sysfs_init(void)
731{ 731{
732 int err; 732 int err;
733 733
734 kset_set_kset_s(&fuse_subsys, fs_subsys); 734 kobj_set_kset_s(&fuse_subsys, fs_subsys);
735 err = subsystem_register(&fuse_subsys); 735 err = subsystem_register(&fuse_subsys);
736 if (err) 736 if (err)
737 goto out_err; 737 goto out_err;
738 738
739 kset_set_kset_s(&connections_subsys, fuse_subsys); 739 kobj_set_kset_s(&connections_subsys, fuse_subsys);
740 err = subsystem_register(&connections_subsys); 740 err = subsystem_register(&connections_subsys);
741 if (err) 741 if (err)
742 goto out_fuse_unregister; 742 goto out_fuse_unregister;
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index 4746b884662d..d9fe3ca40e18 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -190,7 +190,6 @@ static struct kobj_type gdlm_ktype = {
190}; 190};
191 191
192static struct kset gdlm_kset = { 192static struct kset gdlm_kset = {
193 .subsys = &kernel_subsys,
194 .kobj = {.name = "lock_dlm",}, 193 .kobj = {.name = "lock_dlm",},
195 .ktype = &gdlm_ktype, 194 .ktype = &gdlm_ktype,
196}; 195};
@@ -225,6 +224,7 @@ int gdlm_sysfs_init(void)
225{ 224{
226 int error; 225 int error;
227 226
227 kobj_set_kset_s(&gdlm_kset, kernel_subsys);
228 error = kset_register(&gdlm_kset); 228 error = kset_register(&gdlm_kset);
229 if (error) 229 if (error)
230 printk("lock_dlm: cannot register kset %d\n", error); 230 printk("lock_dlm: cannot register kset %d\n", error);
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index d01f9f0fda26..c26c21b53c19 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -222,7 +222,6 @@ static struct kobj_type gfs2_ktype = {
222}; 222};
223 223
224static struct kset gfs2_kset = { 224static struct kset gfs2_kset = {
225 .subsys = &fs_subsys,
226 .kobj = {.name = "gfs2"}, 225 .kobj = {.name = "gfs2"},
227 .ktype = &gfs2_ktype, 226 .ktype = &gfs2_ktype,
228}; 227};
@@ -554,6 +553,7 @@ int gfs2_sys_init(void)
554{ 553{
555 gfs2_sys_margs = NULL; 554 gfs2_sys_margs = NULL;
556 spin_lock_init(&gfs2_sys_margs_lock); 555 spin_lock_init(&gfs2_sys_margs_lock);
556 kobj_set_kset_s(&gfs2_kset, fs_subsys);
557 return kset_register(&gfs2_kset); 557 return kset_register(&gfs2_kset);
558} 558}
559 559
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index eb243edf8932..2102e2d0134d 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -225,16 +225,13 @@ xdr_decode_stat(struct rpc_rqst *rqstp, __be32 *p, struct nsm_res *resp)
225#define SM_monres_sz 2 225#define SM_monres_sz 2
226#define SM_unmonres_sz 1 226#define SM_unmonres_sz 1
227 227
228#ifndef MAX
229# define MAX(a, b) (((a) > (b))? (a) : (b))
230#endif
231
232static struct rpc_procinfo nsm_procedures[] = { 228static struct rpc_procinfo nsm_procedures[] = {
233[SM_MON] = { 229[SM_MON] = {
234 .p_proc = SM_MON, 230 .p_proc = SM_MON,
235 .p_encode = (kxdrproc_t) xdr_encode_mon, 231 .p_encode = (kxdrproc_t) xdr_encode_mon,
236 .p_decode = (kxdrproc_t) xdr_decode_stat_res, 232 .p_decode = (kxdrproc_t) xdr_decode_stat_res,
237 .p_bufsiz = MAX(SM_mon_sz, SM_monres_sz) << 2, 233 .p_arglen = SM_mon_sz,
234 .p_replen = SM_monres_sz,
238 .p_statidx = SM_MON, 235 .p_statidx = SM_MON,
239 .p_name = "MONITOR", 236 .p_name = "MONITOR",
240 }, 237 },
@@ -242,7 +239,8 @@ static struct rpc_procinfo nsm_procedures[] = {
242 .p_proc = SM_UNMON, 239 .p_proc = SM_UNMON,
243 .p_encode = (kxdrproc_t) xdr_encode_unmon, 240 .p_encode = (kxdrproc_t) xdr_encode_unmon,
244 .p_decode = (kxdrproc_t) xdr_decode_stat, 241 .p_decode = (kxdrproc_t) xdr_decode_stat,
245 .p_bufsiz = MAX(SM_mon_id_sz, SM_unmonres_sz) << 2, 242 .p_arglen = SM_mon_id_sz,
243 .p_replen = SM_unmonres_sz,
246 .p_statidx = SM_UNMON, 244 .p_statidx = SM_UNMON,
247 .p_name = "UNMONITOR", 245 .p_name = "UNMONITOR",
248 }, 246 },
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 34dae5d70738..9702956d206c 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -510,17 +510,20 @@ nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
510 return 0; 510 return 0;
511} 511}
512 512
513#if (NLMCLNT_OHSIZE > XDR_MAX_NETOBJ)
514# error "NLM host name cannot be larger than XDR_MAX_NETOBJ!"
515#endif
516
513/* 517/*
514 * Buffer requirements for NLM 518 * Buffer requirements for NLM
515 */ 519 */
516#define NLM_void_sz 0 520#define NLM_void_sz 0
517#define NLM_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN) 521#define NLM_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN)
518#define NLM_caller_sz 1+XDR_QUADLEN(sizeof(utsname()->nodename)) 522#define NLM_caller_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE)
519#define NLM_netobj_sz 1+XDR_QUADLEN(XDR_MAX_NETOBJ) 523#define NLM_owner_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE)
520/* #define NLM_owner_sz 1+XDR_QUADLEN(NLM_MAXOWNER) */
521#define NLM_fhandle_sz 1+XDR_QUADLEN(NFS2_FHSIZE) 524#define NLM_fhandle_sz 1+XDR_QUADLEN(NFS2_FHSIZE)
522#define NLM_lock_sz 3+NLM_caller_sz+NLM_netobj_sz+NLM_fhandle_sz 525#define NLM_lock_sz 3+NLM_caller_sz+NLM_owner_sz+NLM_fhandle_sz
523#define NLM_holder_sz 4+NLM_netobj_sz 526#define NLM_holder_sz 4+NLM_owner_sz
524 527
525#define NLM_testargs_sz NLM_cookie_sz+1+NLM_lock_sz 528#define NLM_testargs_sz NLM_cookie_sz+1+NLM_lock_sz
526#define NLM_lockargs_sz NLM_cookie_sz+4+NLM_lock_sz 529#define NLM_lockargs_sz NLM_cookie_sz+4+NLM_lock_sz
@@ -531,10 +534,6 @@ nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
531#define NLM_res_sz NLM_cookie_sz+1 534#define NLM_res_sz NLM_cookie_sz+1
532#define NLM_norep_sz 0 535#define NLM_norep_sz 0
533 536
534#ifndef MAX
535# define MAX(a, b) (((a) > (b))? (a) : (b))
536#endif
537
538/* 537/*
539 * For NLM, a void procedure really returns nothing 538 * For NLM, a void procedure really returns nothing
540 */ 539 */
@@ -545,7 +544,8 @@ nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
545 .p_proc = NLMPROC_##proc, \ 544 .p_proc = NLMPROC_##proc, \
546 .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \ 545 .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \
547 .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \ 546 .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \
548 .p_bufsiz = MAX(NLM_##argtype##_sz, NLM_##restype##_sz) << 2, \ 547 .p_arglen = NLM_##argtype##_sz, \
548 .p_replen = NLM_##restype##_sz, \
549 .p_statidx = NLMPROC_##proc, \ 549 .p_statidx = NLMPROC_##proc, \
550 .p_name = #proc, \ 550 .p_name = #proc, \
551 } 551 }
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index a78240551219..ce1efdbe1b3a 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -516,17 +516,24 @@ nlm4clt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
516 return 0; 516 return 0;
517} 517}
518 518
519#if (NLMCLNT_OHSIZE > XDR_MAX_NETOBJ)
520# error "NLM host name cannot be larger than XDR_MAX_NETOBJ!"
521#endif
522
523#if (NLMCLNT_OHSIZE > NLM_MAXSTRLEN)
524# error "NLM host name cannot be larger than NLM's maximum string length!"
525#endif
526
519/* 527/*
520 * Buffer requirements for NLM 528 * Buffer requirements for NLM
521 */ 529 */
522#define NLM4_void_sz 0 530#define NLM4_void_sz 0
523#define NLM4_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN) 531#define NLM4_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN)
524#define NLM4_caller_sz 1+XDR_QUADLEN(NLM_MAXSTRLEN) 532#define NLM4_caller_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE)
525#define NLM4_netobj_sz 1+XDR_QUADLEN(XDR_MAX_NETOBJ) 533#define NLM4_owner_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE)
526/* #define NLM4_owner_sz 1+XDR_QUADLEN(NLM4_MAXOWNER) */
527#define NLM4_fhandle_sz 1+XDR_QUADLEN(NFS3_FHSIZE) 534#define NLM4_fhandle_sz 1+XDR_QUADLEN(NFS3_FHSIZE)
528#define NLM4_lock_sz 5+NLM4_caller_sz+NLM4_netobj_sz+NLM4_fhandle_sz 535#define NLM4_lock_sz 5+NLM4_caller_sz+NLM4_owner_sz+NLM4_fhandle_sz
529#define NLM4_holder_sz 6+NLM4_netobj_sz 536#define NLM4_holder_sz 6+NLM4_owner_sz
530 537
531#define NLM4_testargs_sz NLM4_cookie_sz+1+NLM4_lock_sz 538#define NLM4_testargs_sz NLM4_cookie_sz+1+NLM4_lock_sz
532#define NLM4_lockargs_sz NLM4_cookie_sz+4+NLM4_lock_sz 539#define NLM4_lockargs_sz NLM4_cookie_sz+4+NLM4_lock_sz
@@ -537,10 +544,6 @@ nlm4clt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
537#define NLM4_res_sz NLM4_cookie_sz+1 544#define NLM4_res_sz NLM4_cookie_sz+1
538#define NLM4_norep_sz 0 545#define NLM4_norep_sz 0
539 546
540#ifndef MAX
541# define MAX(a,b) (((a) > (b))? (a) : (b))
542#endif
543
544/* 547/*
545 * For NLM, a void procedure really returns nothing 548 * For NLM, a void procedure really returns nothing
546 */ 549 */
@@ -551,7 +554,8 @@ nlm4clt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
551 .p_proc = NLMPROC_##proc, \ 554 .p_proc = NLMPROC_##proc, \
552 .p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \ 555 .p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \
553 .p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \ 556 .p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \
554 .p_bufsiz = MAX(NLM4_##argtype##_sz, NLM4_##restype##_sz) << 2, \ 557 .p_arglen = NLM4_##argtype##_sz, \
558 .p_replen = NLM4_##restype##_sz, \
555 .p_statidx = NLMPROC_##proc, \ 559 .p_statidx = NLMPROC_##proc, \
556 .p_name = #proc, \ 560 .p_name = #proc, \
557 } 561 }
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 2190e6c2792e..5bd03b97002e 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -618,7 +618,8 @@ static int nfs_init_server(struct nfs_server *server, const struct nfs_mount_dat
618 if (clp->cl_nfsversion == 3) { 618 if (clp->cl_nfsversion == 3) {
619 if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN) 619 if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
620 server->namelen = NFS3_MAXNAMLEN; 620 server->namelen = NFS3_MAXNAMLEN;
621 server->caps |= NFS_CAP_READDIRPLUS; 621 if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
622 server->caps |= NFS_CAP_READDIRPLUS;
622 } else { 623 } else {
623 if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN) 624 if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN)
624 server->namelen = NFS2_MAXNAMLEN; 625 server->namelen = NFS2_MAXNAMLEN;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index cd3469720cbf..e59fd31c9a22 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -154,6 +154,8 @@ typedef struct {
154 decode_dirent_t decode; 154 decode_dirent_t decode;
155 int plus; 155 int plus;
156 int error; 156 int error;
157 unsigned long timestamp;
158 int timestamp_valid;
157} nfs_readdir_descriptor_t; 159} nfs_readdir_descriptor_t;
158 160
159/* Now we cache directories properly, by stuffing the dirent 161/* Now we cache directories properly, by stuffing the dirent
@@ -195,6 +197,8 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
195 } 197 }
196 goto error; 198 goto error;
197 } 199 }
200 desc->timestamp = timestamp;
201 desc->timestamp_valid = 1;
198 SetPageUptodate(page); 202 SetPageUptodate(page);
199 spin_lock(&inode->i_lock); 203 spin_lock(&inode->i_lock);
200 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; 204 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
@@ -225,6 +229,10 @@ int dir_decode(nfs_readdir_descriptor_t *desc)
225 if (IS_ERR(p)) 229 if (IS_ERR(p))
226 return PTR_ERR(p); 230 return PTR_ERR(p);
227 desc->ptr = p; 231 desc->ptr = p;
232 if (desc->timestamp_valid)
233 desc->entry->fattr->time_start = desc->timestamp;
234 else
235 desc->entry->fattr->valid &= ~NFS_ATTR_FATTR;
228 return 0; 236 return 0;
229} 237}
230 238
@@ -316,6 +324,10 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
316 __FUNCTION__, desc->page_index, 324 __FUNCTION__, desc->page_index,
317 (long long) *desc->dir_cookie); 325 (long long) *desc->dir_cookie);
318 326
327 /* If we find the page in the page_cache, we cannot be sure
328 * how fresh the data is, so we will ignore readdir_plus attributes.
329 */
330 desc->timestamp_valid = 0;
319 page = read_cache_page(inode->i_mapping, desc->page_index, 331 page = read_cache_page(inode->i_mapping, desc->page_index,
320 (filler_t *)nfs_readdir_filler, desc); 332 (filler_t *)nfs_readdir_filler, desc);
321 if (IS_ERR(page)) { 333 if (IS_ERR(page)) {
@@ -468,6 +480,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
468 struct rpc_cred *cred = nfs_file_cred(file); 480 struct rpc_cred *cred = nfs_file_cred(file);
469 struct page *page = NULL; 481 struct page *page = NULL;
470 int status; 482 int status;
483 unsigned long timestamp;
471 484
472 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n", 485 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n",
473 (unsigned long long)*desc->dir_cookie); 486 (unsigned long long)*desc->dir_cookie);
@@ -477,6 +490,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
477 status = -ENOMEM; 490 status = -ENOMEM;
478 goto out; 491 goto out;
479 } 492 }
493 timestamp = jiffies;
480 desc->error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, *desc->dir_cookie, 494 desc->error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, *desc->dir_cookie,
481 page, 495 page,
482 NFS_SERVER(inode)->dtsize, 496 NFS_SERVER(inode)->dtsize,
@@ -487,6 +501,8 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
487 desc->page = page; 501 desc->page = page;
488 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */ 502 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */
489 if (desc->error >= 0) { 503 if (desc->error >= 0) {
504 desc->timestamp = timestamp;
505 desc->timestamp_valid = 1;
490 if ((status = dir_decode(desc)) == 0) 506 if ((status = dir_decode(desc)) == 0)
491 desc->entry->prev_cookie = *desc->dir_cookie; 507 desc->entry->prev_cookie = *desc->dir_cookie;
492 } else 508 } else
@@ -849,6 +865,10 @@ static int nfs_dentry_delete(struct dentry *dentry)
849static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) 865static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
850{ 866{
851 nfs_inode_return_delegation(inode); 867 nfs_inode_return_delegation(inode);
868 if (S_ISDIR(inode->i_mode))
869 /* drop any readdir cache as it could easily be old */
870 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
871
852 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { 872 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
853 lock_kernel(); 873 lock_kernel();
854 drop_nlink(inode); 874 drop_nlink(inode);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 2877744cb606..889de60f8a84 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -54,6 +54,7 @@
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55#include <asm/atomic.h> 55#include <asm/atomic.h>
56 56
57#include "internal.h"
57#include "iostat.h" 58#include "iostat.h"
58 59
59#define NFSDBG_FACILITY NFSDBG_VFS 60#define NFSDBG_FACILITY NFSDBG_VFS
@@ -271,7 +272,7 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo
271 bytes = min(rsize,count); 272 bytes = min(rsize,count);
272 273
273 result = -ENOMEM; 274 result = -ENOMEM;
274 data = nfs_readdata_alloc(pgbase + bytes); 275 data = nfs_readdata_alloc(nfs_page_array_len(pgbase, bytes));
275 if (unlikely(!data)) 276 if (unlikely(!data))
276 break; 277 break;
277 278
@@ -602,7 +603,7 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l
602 bytes = min(wsize,count); 603 bytes = min(wsize,count);
603 604
604 result = -ENOMEM; 605 result = -ENOMEM;
605 data = nfs_writedata_alloc(pgbase + bytes); 606 data = nfs_writedata_alloc(nfs_page_array_len(pgbase, bytes));
606 if (unlikely(!data)) 607 if (unlikely(!data))
607 break; 608 break;
608 609
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 6610f2b02077..ad2b40db1e65 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -231,3 +231,15 @@ unsigned int nfs_page_length(struct page *page)
231 } 231 }
232 return 0; 232 return 0;
233} 233}
234
235/*
236 * Determine the number of pages in an array of length 'len' and
237 * with a base offset of 'base'
238 */
239static inline
240unsigned int nfs_page_array_len(unsigned int base, size_t len)
241{
242 return ((unsigned long)len + (unsigned long)base +
243 PAGE_SIZE - 1) >> PAGE_SHIFT;
244}
245
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index f75fe72b4160..ca5a266a3140 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -133,13 +133,15 @@ xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, struct mnt_fhstatus *res)
133 133
134#define MNT_dirpath_sz (1 + 256) 134#define MNT_dirpath_sz (1 + 256)
135#define MNT_fhstatus_sz (1 + 8) 135#define MNT_fhstatus_sz (1 + 8)
136#define MNT_fhstatus3_sz (1 + 16)
136 137
137static struct rpc_procinfo mnt_procedures[] = { 138static struct rpc_procinfo mnt_procedures[] = {
138[MNTPROC_MNT] = { 139[MNTPROC_MNT] = {
139 .p_proc = MNTPROC_MNT, 140 .p_proc = MNTPROC_MNT,
140 .p_encode = (kxdrproc_t) xdr_encode_dirpath, 141 .p_encode = (kxdrproc_t) xdr_encode_dirpath,
141 .p_decode = (kxdrproc_t) xdr_decode_fhstatus, 142 .p_decode = (kxdrproc_t) xdr_decode_fhstatus,
142 .p_bufsiz = MNT_dirpath_sz << 2, 143 .p_arglen = MNT_dirpath_sz,
144 .p_replen = MNT_fhstatus_sz,
143 .p_statidx = MNTPROC_MNT, 145 .p_statidx = MNTPROC_MNT,
144 .p_name = "MOUNT", 146 .p_name = "MOUNT",
145 }, 147 },
@@ -150,7 +152,8 @@ static struct rpc_procinfo mnt3_procedures[] = {
150 .p_proc = MOUNTPROC3_MNT, 152 .p_proc = MOUNTPROC3_MNT,
151 .p_encode = (kxdrproc_t) xdr_encode_dirpath, 153 .p_encode = (kxdrproc_t) xdr_encode_dirpath,
152 .p_decode = (kxdrproc_t) xdr_decode_fhstatus3, 154 .p_decode = (kxdrproc_t) xdr_decode_fhstatus3,
153 .p_bufsiz = MNT_dirpath_sz << 2, 155 .p_arglen = MNT_dirpath_sz,
156 .p_replen = MNT_fhstatus3_sz,
154 .p_statidx = MOUNTPROC3_MNT, 157 .p_statidx = MOUNTPROC3_MNT,
155 .p_name = "MOUNT", 158 .p_name = "MOUNT",
156 }, 159 },
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index 3be4e72a0227..abd9f8b48943 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -687,16 +687,13 @@ nfs_stat_to_errno(int stat)
687 return nfs_errtbl[i].errno; 687 return nfs_errtbl[i].errno;
688} 688}
689 689
690#ifndef MAX
691# define MAX(a, b) (((a) > (b))? (a) : (b))
692#endif
693
694#define PROC(proc, argtype, restype, timer) \ 690#define PROC(proc, argtype, restype, timer) \
695[NFSPROC_##proc] = { \ 691[NFSPROC_##proc] = { \
696 .p_proc = NFSPROC_##proc, \ 692 .p_proc = NFSPROC_##proc, \
697 .p_encode = (kxdrproc_t) nfs_xdr_##argtype, \ 693 .p_encode = (kxdrproc_t) nfs_xdr_##argtype, \
698 .p_decode = (kxdrproc_t) nfs_xdr_##restype, \ 694 .p_decode = (kxdrproc_t) nfs_xdr_##restype, \
699 .p_bufsiz = MAX(NFS_##argtype##_sz,NFS_##restype##_sz) << 2, \ 695 .p_arglen = NFS_##argtype##_sz, \
696 .p_replen = NFS_##restype##_sz, \
700 .p_timer = timer, \ 697 .p_timer = timer, \
701 .p_statidx = NFSPROC_##proc, \ 698 .p_statidx = NFSPROC_##proc, \
702 .p_name = #proc, \ 699 .p_name = #proc, \
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 0ace092d126f..b51df8eb9f01 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -1102,16 +1102,13 @@ nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
1102} 1102}
1103#endif /* CONFIG_NFS_V3_ACL */ 1103#endif /* CONFIG_NFS_V3_ACL */
1104 1104
1105#ifndef MAX
1106# define MAX(a, b) (((a) > (b))? (a) : (b))
1107#endif
1108
1109#define PROC(proc, argtype, restype, timer) \ 1105#define PROC(proc, argtype, restype, timer) \
1110[NFS3PROC_##proc] = { \ 1106[NFS3PROC_##proc] = { \
1111 .p_proc = NFS3PROC_##proc, \ 1107 .p_proc = NFS3PROC_##proc, \
1112 .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \ 1108 .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
1113 .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \ 1109 .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
1114 .p_bufsiz = MAX(NFS3_##argtype##_sz,NFS3_##restype##_sz) << 2, \ 1110 .p_arglen = NFS3_##argtype##_sz, \
1111 .p_replen = NFS3_##restype##_sz, \
1115 .p_timer = timer, \ 1112 .p_timer = timer, \
1116 .p_statidx = NFS3PROC_##proc, \ 1113 .p_statidx = NFS3PROC_##proc, \
1117 .p_name = #proc, \ 1114 .p_name = #proc, \
@@ -1153,7 +1150,8 @@ static struct rpc_procinfo nfs3_acl_procedures[] = {
1153 .p_proc = ACLPROC3_GETACL, 1150 .p_proc = ACLPROC3_GETACL,
1154 .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs, 1151 .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs,
1155 .p_decode = (kxdrproc_t) nfs3_xdr_getaclres, 1152 .p_decode = (kxdrproc_t) nfs3_xdr_getaclres,
1156 .p_bufsiz = MAX(ACL3_getaclargs_sz, ACL3_getaclres_sz) << 2, 1153 .p_arglen = ACL3_getaclargs_sz,
1154 .p_replen = ACL3_getaclres_sz,
1157 .p_timer = 1, 1155 .p_timer = 1,
1158 .p_name = "GETACL", 1156 .p_name = "GETACL",
1159 }, 1157 },
@@ -1161,7 +1159,8 @@ static struct rpc_procinfo nfs3_acl_procedures[] = {
1161 .p_proc = ACLPROC3_SETACL, 1159 .p_proc = ACLPROC3_SETACL,
1162 .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs, 1160 .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs,
1163 .p_decode = (kxdrproc_t) nfs3_xdr_setaclres, 1161 .p_decode = (kxdrproc_t) nfs3_xdr_setaclres,
1164 .p_bufsiz = MAX(ACL3_setaclargs_sz, ACL3_setaclres_sz) << 2, 1162 .p_arglen = ACL3_setaclargs_sz,
1163 .p_replen = ACL3_setaclres_sz,
1165 .p_timer = 0, 1164 .p_timer = 0,
1166 .p_name = "SETACL", 1165 .p_name = "SETACL",
1167 }, 1166 },
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f52cf5c33c6c..3b5ca1b15fe9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2647,8 +2647,7 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
2647 nfs_inode_return_delegation(inode); 2647 nfs_inode_return_delegation(inode);
2648 buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase); 2648 buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase);
2649 ret = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 2649 ret = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
2650 if (ret == 0) 2650 nfs_zap_caches(inode);
2651 nfs4_write_cached_acl(inode, buf, buflen);
2652 return ret; 2651 return ret;
2653} 2652}
2654 2653
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index f02d522fd788..b8c28f2380a5 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4546,16 +4546,13 @@ nfs4_stat_to_errno(int stat)
4546 return stat; 4546 return stat;
4547} 4547}
4548 4548
4549#ifndef MAX
4550# define MAX(a, b) (((a) > (b))? (a) : (b))
4551#endif
4552
4553#define PROC(proc, argtype, restype) \ 4549#define PROC(proc, argtype, restype) \
4554[NFSPROC4_CLNT_##proc] = { \ 4550[NFSPROC4_CLNT_##proc] = { \
4555 .p_proc = NFSPROC4_COMPOUND, \ 4551 .p_proc = NFSPROC4_COMPOUND, \
4556 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \ 4552 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
4557 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \ 4553 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
4558 .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \ 4554 .p_arglen = NFS4_##argtype##_sz, \
4555 .p_replen = NFS4_##restype##_sz, \
4559 .p_statidx = NFSPROC4_CLNT_##proc, \ 4556 .p_statidx = NFSPROC4_CLNT_##proc, \
4560 .p_name = #proc, \ 4557 .p_name = #proc, \
4561 } 4558 }
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index 75f819dc0255..49d1008ce1d7 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -428,7 +428,7 @@ static int __init root_nfs_getport(int program, int version, int proto)
428 printk(KERN_NOTICE "Looking up port of RPC %d/%d on %u.%u.%u.%u\n", 428 printk(KERN_NOTICE "Looking up port of RPC %d/%d on %u.%u.%u.%u\n",
429 program, version, NIPQUAD(servaddr)); 429 program, version, NIPQUAD(servaddr));
430 set_sockaddr(&sin, servaddr, 0); 430 set_sockaddr(&sin, servaddr, 0);
431 return rpc_getport_external(&sin, program, version, proto); 431 return rpcb_getport_external(&sin, program, version, proto);
432} 432}
433 433
434 434
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index ca4b1d4ff42b..388950118f59 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -17,7 +17,8 @@
17#include <linux/nfs_page.h> 17#include <linux/nfs_page.h>
18#include <linux/nfs_fs.h> 18#include <linux/nfs_fs.h>
19#include <linux/nfs_mount.h> 19#include <linux/nfs_mount.h>
20#include <linux/writeback.h> 20
21#include "internal.h"
21 22
22#define NFS_PARANOIA 1 23#define NFS_PARANOIA 1
23 24
@@ -50,9 +51,7 @@ nfs_page_free(struct nfs_page *p)
50 * @count: number of bytes to read/write 51 * @count: number of bytes to read/write
51 * 52 *
52 * The page must be locked by the caller. This makes sure we never 53 * The page must be locked by the caller. This makes sure we never
53 * create two different requests for the same page, and avoids 54 * create two different requests for the same page.
54 * a possible deadlock when we reach the hard limit on the number
55 * of dirty pages.
56 * User should ensure it is safe to sleep in this function. 55 * User should ensure it is safe to sleep in this function.
57 */ 56 */
58struct nfs_page * 57struct nfs_page *
@@ -63,16 +62,12 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
63 struct nfs_server *server = NFS_SERVER(inode); 62 struct nfs_server *server = NFS_SERVER(inode);
64 struct nfs_page *req; 63 struct nfs_page *req;
65 64
66 /* Deal with hard limits. */
67 for (;;) { 65 for (;;) {
68 /* try to allocate the request struct */ 66 /* try to allocate the request struct */
69 req = nfs_page_alloc(); 67 req = nfs_page_alloc();
70 if (req != NULL) 68 if (req != NULL)
71 break; 69 break;
72 70
73 /* Try to free up at least one request in order to stay
74 * below the hard limit
75 */
76 if (signalled() && (server->flags & NFS_MOUNT_INTR)) 71 if (signalled() && (server->flags & NFS_MOUNT_INTR))
77 return ERR_PTR(-ERESTARTSYS); 72 return ERR_PTR(-ERESTARTSYS);
78 yield(); 73 yield();
@@ -223,124 +218,151 @@ out:
223} 218}
224 219
225/** 220/**
226 * nfs_coalesce_requests - Split coalesced requests out from a list. 221 * nfs_pageio_init - initialise a page io descriptor
227 * @head: source list 222 * @desc: pointer to descriptor
228 * @dst: destination list 223 * @inode: pointer to inode
229 * @nmax: maximum number of requests to coalesce 224 * @doio: pointer to io function
230 * 225 * @bsize: io block size
231 * Moves a maximum of 'nmax' elements from one list to another. 226 * @io_flags: extra parameters for the io function
232 * The elements are checked to ensure that they form a contiguous set
233 * of pages, and that the RPC credentials are the same.
234 */ 227 */
235int 228void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
236nfs_coalesce_requests(struct list_head *head, struct list_head *dst, 229 struct inode *inode,
237 unsigned int nmax) 230 int (*doio)(struct inode *, struct list_head *, unsigned int, size_t, int),
231 size_t bsize,
232 int io_flags)
238{ 233{
239 struct nfs_page *req = NULL; 234 INIT_LIST_HEAD(&desc->pg_list);
240 unsigned int npages = 0; 235 desc->pg_bytes_written = 0;
241 236 desc->pg_count = 0;
242 while (!list_empty(head)) { 237 desc->pg_bsize = bsize;
243 struct nfs_page *prev = req; 238 desc->pg_base = 0;
244 239 desc->pg_inode = inode;
245 req = nfs_list_entry(head->next); 240 desc->pg_doio = doio;
246 if (prev) { 241 desc->pg_ioflags = io_flags;
247 if (req->wb_context->cred != prev->wb_context->cred) 242 desc->pg_error = 0;
248 break;
249 if (req->wb_context->lockowner != prev->wb_context->lockowner)
250 break;
251 if (req->wb_context->state != prev->wb_context->state)
252 break;
253 if (req->wb_index != (prev->wb_index + 1))
254 break;
255
256 if (req->wb_pgbase != 0)
257 break;
258 }
259 nfs_list_remove_request(req);
260 nfs_list_add_request(req, dst);
261 npages++;
262 if (req->wb_pgbase + req->wb_bytes != PAGE_CACHE_SIZE)
263 break;
264 if (npages >= nmax)
265 break;
266 }
267 return npages;
268} 243}
269 244
270#define NFS_SCAN_MAXENTRIES 16
271/** 245/**
272 * nfs_scan_dirty - Scan the radix tree for dirty requests 246 * nfs_can_coalesce_requests - test two requests for compatibility
273 * @mapping: pointer to address space 247 * @prev: pointer to nfs_page
274 * @wbc: writeback_control structure 248 * @req: pointer to nfs_page
275 * @dst: Destination list
276 * 249 *
277 * Moves elements from one of the inode request lists. 250 * The nfs_page structures 'prev' and 'req' are compared to ensure that the
278 * If the number of requests is set to 0, the entire address_space 251 * page data area they describe is contiguous, and that their RPC
279 * starting at index idx_start, is scanned. 252 * credentials, NFSv4 open state, and lockowners are the same.
280 * The requests are *not* checked to ensure that they form a contiguous set. 253 *
281 * You must be holding the inode's req_lock when calling this function 254 * Return 'true' if this is the case, else return 'false'.
282 */ 255 */
283long nfs_scan_dirty(struct address_space *mapping, 256static int nfs_can_coalesce_requests(struct nfs_page *prev,
284 struct writeback_control *wbc, 257 struct nfs_page *req)
285 struct list_head *dst)
286{ 258{
287 struct nfs_inode *nfsi = NFS_I(mapping->host); 259 if (req->wb_context->cred != prev->wb_context->cred)
288 struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES];
289 struct nfs_page *req;
290 pgoff_t idx_start, idx_end;
291 long res = 0;
292 int found, i;
293
294 if (nfsi->ndirty == 0)
295 return 0; 260 return 0;
296 if (wbc->range_cyclic) { 261 if (req->wb_context->lockowner != prev->wb_context->lockowner)
297 idx_start = 0; 262 return 0;
298 idx_end = ULONG_MAX; 263 if (req->wb_context->state != prev->wb_context->state)
299 } else if (wbc->range_end == 0) { 264 return 0;
300 idx_start = wbc->range_start >> PAGE_CACHE_SHIFT; 265 if (req->wb_index != (prev->wb_index + 1))
301 idx_end = ULONG_MAX; 266 return 0;
302 } else { 267 if (req->wb_pgbase != 0)
303 idx_start = wbc->range_start >> PAGE_CACHE_SHIFT; 268 return 0;
304 idx_end = wbc->range_end >> PAGE_CACHE_SHIFT; 269 if (prev->wb_pgbase + prev->wb_bytes != PAGE_CACHE_SIZE)
305 } 270 return 0;
271 return 1;
272}
306 273
307 for (;;) { 274/**
308 unsigned int toscan = NFS_SCAN_MAXENTRIES; 275 * nfs_pageio_do_add_request - Attempt to coalesce a request into a page list.
276 * @desc: destination io descriptor
277 * @req: request
278 *
279 * Returns true if the request 'req' was successfully coalesced into the
280 * existing list of pages 'desc'.
281 */
282static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
283 struct nfs_page *req)
284{
285 size_t newlen = req->wb_bytes;
309 286
310 found = radix_tree_gang_lookup_tag(&nfsi->nfs_page_tree, 287 if (desc->pg_count != 0) {
311 (void **)&pgvec[0], idx_start, toscan, 288 struct nfs_page *prev;
312 NFS_PAGE_TAG_DIRTY);
313 289
314 /* Did we make progress? */ 290 /*
315 if (found <= 0) 291 * FIXME: ideally we should be able to coalesce all requests
316 break; 292 * that are not block boundary aligned, but currently this
293 * is problematic for the case of bsize < PAGE_CACHE_SIZE,
294 * since nfs_flush_multi and nfs_pagein_multi assume you
295 * can have only one struct nfs_page.
296 */
297 if (desc->pg_bsize < PAGE_SIZE)
298 return 0;
299 newlen += desc->pg_count;
300 if (newlen > desc->pg_bsize)
301 return 0;
302 prev = nfs_list_entry(desc->pg_list.prev);
303 if (!nfs_can_coalesce_requests(prev, req))
304 return 0;
305 } else
306 desc->pg_base = req->wb_pgbase;
307 nfs_list_remove_request(req);
308 nfs_list_add_request(req, &desc->pg_list);
309 desc->pg_count = newlen;
310 return 1;
311}
317 312
318 for (i = 0; i < found; i++) { 313/*
319 req = pgvec[i]; 314 * Helper for nfs_pageio_add_request and nfs_pageio_complete
320 if (!wbc->range_cyclic && req->wb_index > idx_end) 315 */
321 goto out; 316static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc)
317{
318 if (!list_empty(&desc->pg_list)) {
319 int error = desc->pg_doio(desc->pg_inode,
320 &desc->pg_list,
321 nfs_page_array_len(desc->pg_base,
322 desc->pg_count),
323 desc->pg_count,
324 desc->pg_ioflags);
325 if (error < 0)
326 desc->pg_error = error;
327 else
328 desc->pg_bytes_written += desc->pg_count;
329 }
330 if (list_empty(&desc->pg_list)) {
331 desc->pg_count = 0;
332 desc->pg_base = 0;
333 }
334}
322 335
323 /* Try to lock request and mark it for writeback */ 336/**
324 if (!nfs_set_page_writeback_locked(req)) 337 * nfs_pageio_add_request - Attempt to coalesce a request into a page list.
325 goto next; 338 * @desc: destination io descriptor
326 radix_tree_tag_clear(&nfsi->nfs_page_tree, 339 * @req: request
327 req->wb_index, NFS_PAGE_TAG_DIRTY); 340 *
328 nfsi->ndirty--; 341 * Returns true if the request 'req' was successfully coalesced into the
329 nfs_list_remove_request(req); 342 * existing list of pages 'desc'.
330 nfs_list_add_request(req, dst); 343 */
331 res++; 344int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
332 if (res == LONG_MAX) 345 struct nfs_page *req)
333 goto out; 346{
334next: 347 while (!nfs_pageio_do_add_request(desc, req)) {
335 idx_start = req->wb_index + 1; 348 nfs_pageio_doio(desc);
336 } 349 if (desc->pg_error < 0)
350 return 0;
337 } 351 }
338out: 352 return 1;
339 WARN_ON ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty));
340 return res;
341} 353}
342 354
343/** 355/**
356 * nfs_pageio_complete - Complete I/O on an nfs_pageio_descriptor
357 * @desc: pointer to io descriptor
358 */
359void nfs_pageio_complete(struct nfs_pageio_descriptor *desc)
360{
361 nfs_pageio_doio(desc);
362}
363
364#define NFS_SCAN_MAXENTRIES 16
365/**
344 * nfs_scan_list - Scan a list for matching requests 366 * nfs_scan_list - Scan a list for matching requests
345 * @nfsi: NFS inode 367 * @nfsi: NFS inode
346 * @head: One of the NFS inode request lists 368 * @head: One of the NFS inode request lists
@@ -355,12 +377,12 @@ out:
355 * You must be holding the inode's req_lock when calling this function 377 * You must be holding the inode's req_lock when calling this function
356 */ 378 */
357int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *head, 379int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *head,
358 struct list_head *dst, unsigned long idx_start, 380 struct list_head *dst, pgoff_t idx_start,
359 unsigned int npages) 381 unsigned int npages)
360{ 382{
361 struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES]; 383 struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES];
362 struct nfs_page *req; 384 struct nfs_page *req;
363 unsigned long idx_end; 385 pgoff_t idx_end;
364 int found, i; 386 int found, i;
365 int res; 387 int res;
366 388
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6ab4d5a9edf2..9a55807b2a70 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -27,7 +27,8 @@
27 27
28#define NFSDBG_FACILITY NFSDBG_PAGECACHE 28#define NFSDBG_FACILITY NFSDBG_PAGECACHE
29 29
30static int nfs_pagein_one(struct list_head *, struct inode *); 30static int nfs_pagein_multi(struct inode *, struct list_head *, unsigned int, size_t, int);
31static int nfs_pagein_one(struct inode *, struct list_head *, unsigned int, size_t, int);
31static const struct rpc_call_ops nfs_read_partial_ops; 32static const struct rpc_call_ops nfs_read_partial_ops;
32static const struct rpc_call_ops nfs_read_full_ops; 33static const struct rpc_call_ops nfs_read_full_ops;
33 34
@@ -36,9 +37,8 @@ static mempool_t *nfs_rdata_mempool;
36 37
37#define MIN_POOL_READ (32) 38#define MIN_POOL_READ (32)
38 39
39struct nfs_read_data *nfs_readdata_alloc(size_t len) 40struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
40{ 41{
41 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
42 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_NOFS); 42 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_NOFS);
43 43
44 if (p) { 44 if (p) {
@@ -133,7 +133,10 @@ static int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
133 memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len); 133 memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len);
134 134
135 nfs_list_add_request(new, &one_request); 135 nfs_list_add_request(new, &one_request);
136 nfs_pagein_one(&one_request, inode); 136 if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE)
137 nfs_pagein_multi(inode, &one_request, 1, len, 0);
138 else
139 nfs_pagein_one(inode, &one_request, 1, len, 0);
137 return 0; 140 return 0;
138} 141}
139 142
@@ -230,7 +233,7 @@ static void nfs_execute_read(struct nfs_read_data *data)
230 * won't see the new data until our attribute cache is updated. This is more 233 * won't see the new data until our attribute cache is updated. This is more
231 * or less conventional NFS client behavior. 234 * or less conventional NFS client behavior.
232 */ 235 */
233static int nfs_pagein_multi(struct list_head *head, struct inode *inode) 236static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int flags)
234{ 237{
235 struct nfs_page *req = nfs_list_entry(head->next); 238 struct nfs_page *req = nfs_list_entry(head->next);
236 struct page *page = req->wb_page; 239 struct page *page = req->wb_page;
@@ -242,11 +245,11 @@ static int nfs_pagein_multi(struct list_head *head, struct inode *inode)
242 245
243 nfs_list_remove_request(req); 246 nfs_list_remove_request(req);
244 247
245 nbytes = req->wb_bytes; 248 nbytes = count;
246 do { 249 do {
247 size_t len = min(nbytes,rsize); 250 size_t len = min(nbytes,rsize);
248 251
249 data = nfs_readdata_alloc(len); 252 data = nfs_readdata_alloc(1);
250 if (!data) 253 if (!data)
251 goto out_bad; 254 goto out_bad;
252 INIT_LIST_HEAD(&data->pages); 255 INIT_LIST_HEAD(&data->pages);
@@ -258,23 +261,19 @@ static int nfs_pagein_multi(struct list_head *head, struct inode *inode)
258 261
259 ClearPageError(page); 262 ClearPageError(page);
260 offset = 0; 263 offset = 0;
261 nbytes = req->wb_bytes; 264 nbytes = count;
262 do { 265 do {
263 data = list_entry(list.next, struct nfs_read_data, pages); 266 data = list_entry(list.next, struct nfs_read_data, pages);
264 list_del_init(&data->pages); 267 list_del_init(&data->pages);
265 268
266 data->pagevec[0] = page; 269 data->pagevec[0] = page;
267 270
268 if (nbytes > rsize) { 271 if (nbytes < rsize)
269 nfs_read_rpcsetup(req, data, &nfs_read_partial_ops, 272 rsize = nbytes;
270 rsize, offset); 273 nfs_read_rpcsetup(req, data, &nfs_read_partial_ops,
271 offset += rsize; 274 rsize, offset);
272 nbytes -= rsize; 275 offset += rsize;
273 } else { 276 nbytes -= rsize;
274 nfs_read_rpcsetup(req, data, &nfs_read_partial_ops,
275 nbytes, offset);
276 nbytes = 0;
277 }
278 nfs_execute_read(data); 277 nfs_execute_read(data);
279 } while (nbytes != 0); 278 } while (nbytes != 0);
280 279
@@ -291,30 +290,24 @@ out_bad:
291 return -ENOMEM; 290 return -ENOMEM;
292} 291}
293 292
294static int nfs_pagein_one(struct list_head *head, struct inode *inode) 293static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int flags)
295{ 294{
296 struct nfs_page *req; 295 struct nfs_page *req;
297 struct page **pages; 296 struct page **pages;
298 struct nfs_read_data *data; 297 struct nfs_read_data *data;
299 unsigned int count;
300 298
301 if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE) 299 data = nfs_readdata_alloc(npages);
302 return nfs_pagein_multi(head, inode);
303
304 data = nfs_readdata_alloc(NFS_SERVER(inode)->rsize);
305 if (!data) 300 if (!data)
306 goto out_bad; 301 goto out_bad;
307 302
308 INIT_LIST_HEAD(&data->pages); 303 INIT_LIST_HEAD(&data->pages);
309 pages = data->pagevec; 304 pages = data->pagevec;
310 count = 0;
311 while (!list_empty(head)) { 305 while (!list_empty(head)) {
312 req = nfs_list_entry(head->next); 306 req = nfs_list_entry(head->next);
313 nfs_list_remove_request(req); 307 nfs_list_remove_request(req);
314 nfs_list_add_request(req, &data->pages); 308 nfs_list_add_request(req, &data->pages);
315 ClearPageError(req->wb_page); 309 ClearPageError(req->wb_page);
316 *pages++ = req->wb_page; 310 *pages++ = req->wb_page;
317 count += req->wb_bytes;
318 } 311 }
319 req = nfs_list_entry(data->pages.next); 312 req = nfs_list_entry(data->pages.next);
320 313
@@ -327,28 +320,6 @@ out_bad:
327 return -ENOMEM; 320 return -ENOMEM;
328} 321}
329 322
330static int
331nfs_pagein_list(struct list_head *head, int rpages)
332{
333 LIST_HEAD(one_request);
334 struct nfs_page *req;
335 int error = 0;
336 unsigned int pages = 0;
337
338 while (!list_empty(head)) {
339 pages += nfs_coalesce_requests(head, &one_request, rpages);
340 req = nfs_list_entry(one_request.next);
341 error = nfs_pagein_one(&one_request, req->wb_context->dentry->d_inode);
342 if (error < 0)
343 break;
344 }
345 if (error >= 0)
346 return pages;
347
348 nfs_async_read_error(head);
349 return error;
350}
351
352/* 323/*
353 * This is the callback from RPC telling us whether a reply was 324 * This is the callback from RPC telling us whether a reply was
354 * received or some error occurred (timeout or socket shutdown). 325 * received or some error occurred (timeout or socket shutdown).
@@ -538,7 +509,7 @@ out_error:
538} 509}
539 510
540struct nfs_readdesc { 511struct nfs_readdesc {
541 struct list_head *head; 512 struct nfs_pageio_descriptor *pgio;
542 struct nfs_open_context *ctx; 513 struct nfs_open_context *ctx;
543}; 514};
544 515
@@ -562,19 +533,21 @@ readpage_async_filler(void *data, struct page *page)
562 } 533 }
563 if (len < PAGE_CACHE_SIZE) 534 if (len < PAGE_CACHE_SIZE)
564 memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len); 535 memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len);
565 nfs_list_add_request(new, desc->head); 536 nfs_pageio_add_request(desc->pgio, new);
566 return 0; 537 return 0;
567} 538}
568 539
569int nfs_readpages(struct file *filp, struct address_space *mapping, 540int nfs_readpages(struct file *filp, struct address_space *mapping,
570 struct list_head *pages, unsigned nr_pages) 541 struct list_head *pages, unsigned nr_pages)
571{ 542{
572 LIST_HEAD(head); 543 struct nfs_pageio_descriptor pgio;
573 struct nfs_readdesc desc = { 544 struct nfs_readdesc desc = {
574 .head = &head, 545 .pgio = &pgio,
575 }; 546 };
576 struct inode *inode = mapping->host; 547 struct inode *inode = mapping->host;
577 struct nfs_server *server = NFS_SERVER(inode); 548 struct nfs_server *server = NFS_SERVER(inode);
549 size_t rsize = server->rsize;
550 unsigned long npages;
578 int ret = -ESTALE; 551 int ret = -ESTALE;
579 552
580 dprintk("NFS: nfs_readpages (%s/%Ld %d)\n", 553 dprintk("NFS: nfs_readpages (%s/%Ld %d)\n",
@@ -593,13 +566,16 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
593 } else 566 } else
594 desc.ctx = get_nfs_open_context((struct nfs_open_context *) 567 desc.ctx = get_nfs_open_context((struct nfs_open_context *)
595 filp->private_data); 568 filp->private_data);
569 if (rsize < PAGE_CACHE_SIZE)
570 nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0);
571 else
572 nfs_pageio_init(&pgio, inode, nfs_pagein_one, rsize, 0);
573
596 ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); 574 ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);
597 if (!list_empty(&head)) { 575
598 int err = nfs_pagein_list(&head, server->rpages); 576 nfs_pageio_complete(&pgio);
599 if (!ret) 577 npages = (pgio.pg_bytes_written + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
600 nfs_add_stats(inode, NFSIOS_READPAGES, err); 578 nfs_add_stats(inode, NFSIOS_READPAGES, npages);
601 ret = err;
602 }
603 put_nfs_open_context(desc.ctx); 579 put_nfs_open_context(desc.ctx);
604out: 580out:
605 return ret; 581 return ret;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f1eae44b9a1a..ca20d3cc2609 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -204,9 +204,9 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
204 lock_kernel(); 204 lock_kernel();
205 205
206 error = server->nfs_client->rpc_ops->statfs(server, fh, &res); 206 error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
207 buf->f_type = NFS_SUPER_MAGIC;
208 if (error < 0) 207 if (error < 0)
209 goto out_err; 208 goto out_err;
209 buf->f_type = NFS_SUPER_MAGIC;
210 210
211 /* 211 /*
212 * Current versions of glibc do not correctly handle the 212 * Current versions of glibc do not correctly handle the
@@ -233,15 +233,14 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
233 buf->f_ffree = res.afiles; 233 buf->f_ffree = res.afiles;
234 234
235 buf->f_namelen = server->namelen; 235 buf->f_namelen = server->namelen;
236 out: 236
237 unlock_kernel(); 237 unlock_kernel();
238 return 0; 238 return 0;
239 239
240 out_err: 240 out_err:
241 dprintk("%s: statfs error = %d\n", __FUNCTION__, -error); 241 dprintk("%s: statfs error = %d\n", __FUNCTION__, -error);
242 buf->f_bsize = buf->f_blocks = buf->f_bfree = buf->f_bavail = -1; 242 unlock_kernel();
243 goto out; 243 return error;
244
245} 244}
246 245
247/* 246/*
@@ -291,6 +290,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
291 { NFS_MOUNT_NOAC, ",noac", "" }, 290 { NFS_MOUNT_NOAC, ",noac", "" },
292 { NFS_MOUNT_NONLM, ",nolock", "" }, 291 { NFS_MOUNT_NONLM, ",nolock", "" },
293 { NFS_MOUNT_NOACL, ",noacl", "" }, 292 { NFS_MOUNT_NOACL, ",noacl", "" },
293 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
294 { 0, NULL, NULL } 294 { 0, NULL, NULL }
295 }; 295 };
296 const struct proc_nfs_info *nfs_infop; 296 const struct proc_nfs_info *nfs_infop;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 797558941745..5d44b8bd1070 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -38,7 +38,8 @@
38static struct nfs_page * nfs_update_request(struct nfs_open_context*, 38static struct nfs_page * nfs_update_request(struct nfs_open_context*,
39 struct page *, 39 struct page *,
40 unsigned int, unsigned int); 40 unsigned int, unsigned int);
41static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how); 41static void nfs_pageio_init_write(struct nfs_pageio_descriptor *desc,
42 struct inode *inode, int ioflags);
42static const struct rpc_call_ops nfs_write_partial_ops; 43static const struct rpc_call_ops nfs_write_partial_ops;
43static const struct rpc_call_ops nfs_write_full_ops; 44static const struct rpc_call_ops nfs_write_full_ops;
44static const struct rpc_call_ops nfs_commit_ops; 45static const struct rpc_call_ops nfs_commit_ops;
@@ -71,9 +72,8 @@ void nfs_commit_free(struct nfs_write_data *wdata)
71 call_rcu_bh(&wdata->task.u.tk_rcu, nfs_commit_rcu_free); 72 call_rcu_bh(&wdata->task.u.tk_rcu, nfs_commit_rcu_free);
72} 73}
73 74
74struct nfs_write_data *nfs_writedata_alloc(size_t len) 75struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
75{ 76{
76 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
77 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS); 77 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS);
78 78
79 if (p) { 79 if (p) {
@@ -139,7 +139,7 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c
139{ 139{
140 struct inode *inode = page->mapping->host; 140 struct inode *inode = page->mapping->host;
141 loff_t end, i_size = i_size_read(inode); 141 loff_t end, i_size = i_size_read(inode);
142 unsigned long end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 142 pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
143 143
144 if (i_size > 0 && page->index < end_index) 144 if (i_size > 0 && page->index < end_index)
145 return; 145 return;
@@ -201,7 +201,7 @@ static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page,
201static int wb_priority(struct writeback_control *wbc) 201static int wb_priority(struct writeback_control *wbc)
202{ 202{
203 if (wbc->for_reclaim) 203 if (wbc->for_reclaim)
204 return FLUSH_HIGHPRI; 204 return FLUSH_HIGHPRI | FLUSH_STABLE;
205 if (wbc->for_kupdate) 205 if (wbc->for_kupdate)
206 return FLUSH_LOWPRI; 206 return FLUSH_LOWPRI;
207 return 0; 207 return 0;
@@ -251,7 +251,8 @@ static void nfs_end_page_writeback(struct page *page)
251 * was not tagged. 251 * was not tagged.
252 * May also return an error if the user signalled nfs_wait_on_request(). 252 * May also return an error if the user signalled nfs_wait_on_request().
253 */ 253 */
254static int nfs_page_mark_flush(struct page *page) 254static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
255 struct page *page)
255{ 256{
256 struct nfs_page *req; 257 struct nfs_page *req;
257 struct nfs_inode *nfsi = NFS_I(page->mapping->host); 258 struct nfs_inode *nfsi = NFS_I(page->mapping->host);
@@ -273,6 +274,8 @@ static int nfs_page_mark_flush(struct page *page)
273 * request as dirty (in which case we don't care). 274 * request as dirty (in which case we don't care).
274 */ 275 */
275 spin_unlock(req_lock); 276 spin_unlock(req_lock);
277 /* Prevent deadlock! */
278 nfs_pageio_complete(pgio);
276 ret = nfs_wait_on_request(req); 279 ret = nfs_wait_on_request(req);
277 nfs_release_request(req); 280 nfs_release_request(req);
278 if (ret != 0) 281 if (ret != 0)
@@ -283,21 +286,18 @@ static int nfs_page_mark_flush(struct page *page)
283 /* This request is marked for commit */ 286 /* This request is marked for commit */
284 spin_unlock(req_lock); 287 spin_unlock(req_lock);
285 nfs_unlock_request(req); 288 nfs_unlock_request(req);
289 nfs_pageio_complete(pgio);
286 return 1; 290 return 1;
287 } 291 }
288 if (nfs_set_page_writeback(page) == 0) { 292 if (nfs_set_page_writeback(page) != 0) {
289 nfs_list_remove_request(req);
290 /* add the request to the inode's dirty list. */
291 radix_tree_tag_set(&nfsi->nfs_page_tree,
292 req->wb_index, NFS_PAGE_TAG_DIRTY);
293 nfs_list_add_request(req, &nfsi->dirty);
294 nfsi->ndirty++;
295 spin_unlock(req_lock);
296 __mark_inode_dirty(page->mapping->host, I_DIRTY_PAGES);
297 } else
298 spin_unlock(req_lock); 293 spin_unlock(req_lock);
294 BUG();
295 }
296 radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index,
297 NFS_PAGE_TAG_WRITEBACK);
299 ret = test_bit(PG_NEED_FLUSH, &req->wb_flags); 298 ret = test_bit(PG_NEED_FLUSH, &req->wb_flags);
300 nfs_unlock_request(req); 299 spin_unlock(req_lock);
300 nfs_pageio_add_request(pgio, req);
301 return ret; 301 return ret;
302} 302}
303 303
@@ -306,6 +306,7 @@ static int nfs_page_mark_flush(struct page *page)
306 */ 306 */
307static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc) 307static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc)
308{ 308{
309 struct nfs_pageio_descriptor mypgio, *pgio;
309 struct nfs_open_context *ctx; 310 struct nfs_open_context *ctx;
310 struct inode *inode = page->mapping->host; 311 struct inode *inode = page->mapping->host;
311 unsigned offset; 312 unsigned offset;
@@ -314,7 +315,14 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
314 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE); 315 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
315 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1); 316 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
316 317
317 err = nfs_page_mark_flush(page); 318 if (wbc->for_writepages)
319 pgio = wbc->fs_private;
320 else {
321 nfs_pageio_init_write(&mypgio, inode, wb_priority(wbc));
322 pgio = &mypgio;
323 }
324
325 err = nfs_page_async_flush(pgio, page);
318 if (err <= 0) 326 if (err <= 0)
319 goto out; 327 goto out;
320 err = 0; 328 err = 0;
@@ -331,12 +339,12 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
331 put_nfs_open_context(ctx); 339 put_nfs_open_context(ctx);
332 if (err != 0) 340 if (err != 0)
333 goto out; 341 goto out;
334 err = nfs_page_mark_flush(page); 342 err = nfs_page_async_flush(pgio, page);
335 if (err > 0) 343 if (err > 0)
336 err = 0; 344 err = 0;
337out: 345out:
338 if (!wbc->for_writepages) 346 if (!wbc->for_writepages)
339 nfs_flush_mapping(page->mapping, wbc, FLUSH_STABLE|wb_priority(wbc)); 347 nfs_pageio_complete(pgio);
340 return err; 348 return err;
341} 349}
342 350
@@ -352,20 +360,20 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc)
352int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) 360int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
353{ 361{
354 struct inode *inode = mapping->host; 362 struct inode *inode = mapping->host;
363 struct nfs_pageio_descriptor pgio;
355 int err; 364 int err;
356 365
357 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES); 366 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES);
358 367
368 nfs_pageio_init_write(&pgio, inode, wb_priority(wbc));
369 wbc->fs_private = &pgio;
359 err = generic_writepages(mapping, wbc); 370 err = generic_writepages(mapping, wbc);
371 nfs_pageio_complete(&pgio);
360 if (err) 372 if (err)
361 return err; 373 return err;
362 err = nfs_flush_mapping(mapping, wbc, wb_priority(wbc)); 374 if (pgio.pg_error)
363 if (err < 0) 375 return pgio.pg_error;
364 goto out; 376 return 0;
365 nfs_add_stats(inode, NFSIOS_WRITEPAGES, err);
366 err = 0;
367out:
368 return err;
369} 377}
370 378
371/* 379/*
@@ -503,11 +511,11 @@ int nfs_reschedule_unstable_write(struct nfs_page *req)
503 * 511 *
504 * Interruptible by signals only if mounted with intr flag. 512 * Interruptible by signals only if mounted with intr flag.
505 */ 513 */
506static int nfs_wait_on_requests_locked(struct inode *inode, unsigned long idx_start, unsigned int npages) 514static int nfs_wait_on_requests_locked(struct inode *inode, pgoff_t idx_start, unsigned int npages)
507{ 515{
508 struct nfs_inode *nfsi = NFS_I(inode); 516 struct nfs_inode *nfsi = NFS_I(inode);
509 struct nfs_page *req; 517 struct nfs_page *req;
510 unsigned long idx_end, next; 518 pgoff_t idx_end, next;
511 unsigned int res = 0; 519 unsigned int res = 0;
512 int error; 520 int error;
513 521
@@ -536,18 +544,6 @@ static int nfs_wait_on_requests_locked(struct inode *inode, unsigned long idx_st
536 return res; 544 return res;
537} 545}
538 546
539static void nfs_cancel_dirty_list(struct list_head *head)
540{
541 struct nfs_page *req;
542 while(!list_empty(head)) {
543 req = nfs_list_entry(head->next);
544 nfs_list_remove_request(req);
545 nfs_end_page_writeback(req->wb_page);
546 nfs_inode_remove_request(req);
547 nfs_clear_page_writeback(req);
548 }
549}
550
551static void nfs_cancel_commit_list(struct list_head *head) 547static void nfs_cancel_commit_list(struct list_head *head)
552{ 548{
553 struct nfs_page *req; 549 struct nfs_page *req;
@@ -574,7 +570,7 @@ static void nfs_cancel_commit_list(struct list_head *head)
574 * The requests are *not* checked to ensure that they form a contiguous set. 570 * The requests are *not* checked to ensure that they form a contiguous set.
575 */ 571 */
576static int 572static int
577nfs_scan_commit(struct inode *inode, struct list_head *dst, unsigned long idx_start, unsigned int npages) 573nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, unsigned int npages)
578{ 574{
579 struct nfs_inode *nfsi = NFS_I(inode); 575 struct nfs_inode *nfsi = NFS_I(inode);
580 int res = 0; 576 int res = 0;
@@ -588,40 +584,12 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst, unsigned long idx_st
588 return res; 584 return res;
589} 585}
590#else 586#else
591static inline int nfs_scan_commit(struct inode *inode, struct list_head *dst, unsigned long idx_start, unsigned int npages) 587static inline int nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, unsigned int npages)
592{ 588{
593 return 0; 589 return 0;
594} 590}
595#endif 591#endif
596 592
597static int nfs_wait_on_write_congestion(struct address_space *mapping)
598{
599 struct inode *inode = mapping->host;
600 struct backing_dev_info *bdi = mapping->backing_dev_info;
601 int ret = 0;
602
603 might_sleep();
604
605 if (!bdi_write_congested(bdi))
606 return 0;
607
608 nfs_inc_stats(inode, NFSIOS_CONGESTIONWAIT);
609
610 do {
611 struct rpc_clnt *clnt = NFS_CLIENT(inode);
612 sigset_t oldset;
613
614 rpc_clnt_sigmask(clnt, &oldset);
615 ret = congestion_wait_interruptible(WRITE, HZ/10);
616 rpc_clnt_sigunmask(clnt, &oldset);
617 if (ret == -ERESTARTSYS)
618 break;
619 ret = 0;
620 } while (bdi_write_congested(bdi));
621
622 return ret;
623}
624
625/* 593/*
626 * Try to update any existing write request, or create one if there is none. 594 * Try to update any existing write request, or create one if there is none.
627 * In order to match, the request's credentials must match those of 595 * In order to match, the request's credentials must match those of
@@ -636,12 +604,10 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
636 struct inode *inode = mapping->host; 604 struct inode *inode = mapping->host;
637 struct nfs_inode *nfsi = NFS_I(inode); 605 struct nfs_inode *nfsi = NFS_I(inode);
638 struct nfs_page *req, *new = NULL; 606 struct nfs_page *req, *new = NULL;
639 unsigned long rqend, end; 607 pgoff_t rqend, end;
640 608
641 end = offset + bytes; 609 end = offset + bytes;
642 610
643 if (nfs_wait_on_write_congestion(mapping))
644 return ERR_PTR(-ERESTARTSYS);
645 for (;;) { 611 for (;;) {
646 /* Loop over all inode entries and see if we find 612 /* Loop over all inode entries and see if we find
647 * A request for the page we wish to update 613 * A request for the page we wish to update
@@ -865,7 +831,7 @@ static void nfs_execute_write(struct nfs_write_data *data)
865 * Generate multiple small requests to write out a single 831 * Generate multiple small requests to write out a single
866 * contiguous dirty area on one page. 832 * contiguous dirty area on one page.
867 */ 833 */
868static int nfs_flush_multi(struct inode *inode, struct list_head *head, int how) 834static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int how)
869{ 835{
870 struct nfs_page *req = nfs_list_entry(head->next); 836 struct nfs_page *req = nfs_list_entry(head->next);
871 struct page *page = req->wb_page; 837 struct page *page = req->wb_page;
@@ -877,11 +843,11 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, int how)
877 843
878 nfs_list_remove_request(req); 844 nfs_list_remove_request(req);
879 845
880 nbytes = req->wb_bytes; 846 nbytes = count;
881 do { 847 do {
882 size_t len = min(nbytes, wsize); 848 size_t len = min(nbytes, wsize);
883 849
884 data = nfs_writedata_alloc(len); 850 data = nfs_writedata_alloc(1);
885 if (!data) 851 if (!data)
886 goto out_bad; 852 goto out_bad;
887 list_add(&data->pages, &list); 853 list_add(&data->pages, &list);
@@ -892,23 +858,19 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, int how)
892 858
893 ClearPageError(page); 859 ClearPageError(page);
894 offset = 0; 860 offset = 0;
895 nbytes = req->wb_bytes; 861 nbytes = count;
896 do { 862 do {
897 data = list_entry(list.next, struct nfs_write_data, pages); 863 data = list_entry(list.next, struct nfs_write_data, pages);
898 list_del_init(&data->pages); 864 list_del_init(&data->pages);
899 865
900 data->pagevec[0] = page; 866 data->pagevec[0] = page;
901 867
902 if (nbytes > wsize) { 868 if (nbytes < wsize)
903 nfs_write_rpcsetup(req, data, &nfs_write_partial_ops, 869 wsize = nbytes;
904 wsize, offset, how); 870 nfs_write_rpcsetup(req, data, &nfs_write_partial_ops,
905 offset += wsize; 871 wsize, offset, how);
906 nbytes -= wsize; 872 offset += wsize;
907 } else { 873 nbytes -= wsize;
908 nfs_write_rpcsetup(req, data, &nfs_write_partial_ops,
909 nbytes, offset, how);
910 nbytes = 0;
911 }
912 nfs_execute_write(data); 874 nfs_execute_write(data);
913 } while (nbytes != 0); 875 } while (nbytes != 0);
914 876
@@ -934,26 +896,23 @@ out_bad:
934 * This is the case if nfs_updatepage detects a conflicting request 896 * This is the case if nfs_updatepage detects a conflicting request
935 * that has been written but not committed. 897 * that has been written but not committed.
936 */ 898 */
937static int nfs_flush_one(struct inode *inode, struct list_head *head, int how) 899static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int how)
938{ 900{
939 struct nfs_page *req; 901 struct nfs_page *req;
940 struct page **pages; 902 struct page **pages;
941 struct nfs_write_data *data; 903 struct nfs_write_data *data;
942 unsigned int count;
943 904
944 data = nfs_writedata_alloc(NFS_SERVER(inode)->wsize); 905 data = nfs_writedata_alloc(npages);
945 if (!data) 906 if (!data)
946 goto out_bad; 907 goto out_bad;
947 908
948 pages = data->pagevec; 909 pages = data->pagevec;
949 count = 0;
950 while (!list_empty(head)) { 910 while (!list_empty(head)) {
951 req = nfs_list_entry(head->next); 911 req = nfs_list_entry(head->next);
952 nfs_list_remove_request(req); 912 nfs_list_remove_request(req);
953 nfs_list_add_request(req, &data->pages); 913 nfs_list_add_request(req, &data->pages);
954 ClearPageError(req->wb_page); 914 ClearPageError(req->wb_page);
955 *pages++ = req->wb_page; 915 *pages++ = req->wb_page;
956 count += req->wb_bytes;
957 } 916 }
958 req = nfs_list_entry(data->pages.next); 917 req = nfs_list_entry(data->pages.next);
959 918
@@ -973,40 +932,15 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, int how)
973 return -ENOMEM; 932 return -ENOMEM;
974} 933}
975 934
976static int nfs_flush_list(struct inode *inode, struct list_head *head, int npages, int how) 935static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
936 struct inode *inode, int ioflags)
977{ 937{
978 LIST_HEAD(one_request);
979 int (*flush_one)(struct inode *, struct list_head *, int);
980 struct nfs_page *req;
981 int wpages = NFS_SERVER(inode)->wpages;
982 int wsize = NFS_SERVER(inode)->wsize; 938 int wsize = NFS_SERVER(inode)->wsize;
983 int error;
984 939
985 flush_one = nfs_flush_one;
986 if (wsize < PAGE_CACHE_SIZE) 940 if (wsize < PAGE_CACHE_SIZE)
987 flush_one = nfs_flush_multi; 941 nfs_pageio_init(pgio, inode, nfs_flush_multi, wsize, ioflags);
988 /* For single writes, FLUSH_STABLE is more efficient */ 942 else
989 if (npages <= wpages && npages == NFS_I(inode)->npages 943 nfs_pageio_init(pgio, inode, nfs_flush_one, wsize, ioflags);
990 && nfs_list_entry(head->next)->wb_bytes <= wsize)
991 how |= FLUSH_STABLE;
992
993 do {
994 nfs_coalesce_requests(head, &one_request, wpages);
995 req = nfs_list_entry(one_request.next);
996 error = flush_one(inode, &one_request, how);
997 if (error < 0)
998 goto out_err;
999 } while (!list_empty(head));
1000 return 0;
1001out_err:
1002 while (!list_empty(head)) {
1003 req = nfs_list_entry(head->next);
1004 nfs_list_remove_request(req);
1005 nfs_redirty_request(req);
1006 nfs_end_page_writeback(req->wb_page);
1007 nfs_clear_page_writeback(req);
1008 }
1009 return error;
1010} 944}
1011 945
1012/* 946/*
@@ -1330,31 +1264,7 @@ static const struct rpc_call_ops nfs_commit_ops = {
1330 .rpc_call_done = nfs_commit_done, 1264 .rpc_call_done = nfs_commit_done,
1331 .rpc_release = nfs_commit_release, 1265 .rpc_release = nfs_commit_release,
1332}; 1266};
1333#else
1334static inline int nfs_commit_list(struct inode *inode, struct list_head *head, int how)
1335{
1336 return 0;
1337}
1338#endif
1339
1340static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how)
1341{
1342 struct nfs_inode *nfsi = NFS_I(mapping->host);
1343 LIST_HEAD(head);
1344 long res;
1345
1346 spin_lock(&nfsi->req_lock);
1347 res = nfs_scan_dirty(mapping, wbc, &head);
1348 spin_unlock(&nfsi->req_lock);
1349 if (res) {
1350 int error = nfs_flush_list(mapping->host, &head, res, how);
1351 if (error < 0)
1352 return error;
1353 }
1354 return res;
1355}
1356 1267
1357#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
1358int nfs_commit_inode(struct inode *inode, int how) 1268int nfs_commit_inode(struct inode *inode, int how)
1359{ 1269{
1360 struct nfs_inode *nfsi = NFS_I(inode); 1270 struct nfs_inode *nfsi = NFS_I(inode);
@@ -1371,13 +1281,18 @@ int nfs_commit_inode(struct inode *inode, int how)
1371 } 1281 }
1372 return res; 1282 return res;
1373} 1283}
1284#else
1285static inline int nfs_commit_list(struct inode *inode, struct list_head *head, int how)
1286{
1287 return 0;
1288}
1374#endif 1289#endif
1375 1290
1376long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_control *wbc, int how) 1291long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_control *wbc, int how)
1377{ 1292{
1378 struct inode *inode = mapping->host; 1293 struct inode *inode = mapping->host;
1379 struct nfs_inode *nfsi = NFS_I(inode); 1294 struct nfs_inode *nfsi = NFS_I(inode);
1380 unsigned long idx_start, idx_end; 1295 pgoff_t idx_start, idx_end;
1381 unsigned int npages = 0; 1296 unsigned int npages = 0;
1382 LIST_HEAD(head); 1297 LIST_HEAD(head);
1383 int nocommit = how & FLUSH_NOCOMMIT; 1298 int nocommit = how & FLUSH_NOCOMMIT;
@@ -1390,41 +1305,24 @@ long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_contr
1390 idx_start = wbc->range_start >> PAGE_CACHE_SHIFT; 1305 idx_start = wbc->range_start >> PAGE_CACHE_SHIFT;
1391 idx_end = wbc->range_end >> PAGE_CACHE_SHIFT; 1306 idx_end = wbc->range_end >> PAGE_CACHE_SHIFT;
1392 if (idx_end > idx_start) { 1307 if (idx_end > idx_start) {
1393 unsigned long l_npages = 1 + idx_end - idx_start; 1308 pgoff_t l_npages = 1 + idx_end - idx_start;
1394 npages = l_npages; 1309 npages = l_npages;
1395 if (sizeof(npages) != sizeof(l_npages) && 1310 if (sizeof(npages) != sizeof(l_npages) &&
1396 (unsigned long)npages != l_npages) 1311 (pgoff_t)npages != l_npages)
1397 npages = 0; 1312 npages = 0;
1398 } 1313 }
1399 } 1314 }
1400 how &= ~FLUSH_NOCOMMIT; 1315 how &= ~FLUSH_NOCOMMIT;
1401 spin_lock(&nfsi->req_lock); 1316 spin_lock(&nfsi->req_lock);
1402 do { 1317 do {
1403 wbc->pages_skipped = 0;
1404 ret = nfs_wait_on_requests_locked(inode, idx_start, npages); 1318 ret = nfs_wait_on_requests_locked(inode, idx_start, npages);
1405 if (ret != 0) 1319 if (ret != 0)
1406 continue; 1320 continue;
1407 pages = nfs_scan_dirty(mapping, wbc, &head);
1408 if (pages != 0) {
1409 spin_unlock(&nfsi->req_lock);
1410 if (how & FLUSH_INVALIDATE) {
1411 nfs_cancel_dirty_list(&head);
1412 ret = pages;
1413 } else
1414 ret = nfs_flush_list(inode, &head, pages, how);
1415 spin_lock(&nfsi->req_lock);
1416 continue;
1417 }
1418 if (wbc->pages_skipped != 0)
1419 continue;
1420 if (nocommit) 1321 if (nocommit)
1421 break; 1322 break;
1422 pages = nfs_scan_commit(inode, &head, idx_start, npages); 1323 pages = nfs_scan_commit(inode, &head, idx_start, npages);
1423 if (pages == 0) { 1324 if (pages == 0)
1424 if (wbc->pages_skipped != 0)
1425 continue;
1426 break; 1325 break;
1427 }
1428 if (how & FLUSH_INVALIDATE) { 1326 if (how & FLUSH_INVALIDATE) {
1429 spin_unlock(&nfsi->req_lock); 1327 spin_unlock(&nfsi->req_lock);
1430 nfs_cancel_commit_list(&head); 1328 nfs_cancel_commit_list(&head);
@@ -1456,7 +1354,7 @@ int nfs_wb_all(struct inode *inode)
1456 }; 1354 };
1457 int ret; 1355 int ret;
1458 1356
1459 ret = generic_writepages(mapping, &wbc); 1357 ret = nfs_writepages(mapping, &wbc);
1460 if (ret < 0) 1358 if (ret < 0)
1461 goto out; 1359 goto out;
1462 ret = nfs_sync_mapping_wait(mapping, &wbc, 0); 1360 ret = nfs_sync_mapping_wait(mapping, &wbc, 0);
@@ -1479,11 +1377,9 @@ int nfs_sync_mapping_range(struct address_space *mapping, loff_t range_start, lo
1479 }; 1377 };
1480 int ret; 1378 int ret;
1481 1379
1482 if (!(how & FLUSH_NOWRITEPAGE)) { 1380 ret = nfs_writepages(mapping, &wbc);
1483 ret = generic_writepages(mapping, &wbc); 1381 if (ret < 0)
1484 if (ret < 0) 1382 goto out;
1485 goto out;
1486 }
1487 ret = nfs_sync_mapping_wait(mapping, &wbc, how); 1383 ret = nfs_sync_mapping_wait(mapping, &wbc, how);
1488 if (ret >= 0) 1384 if (ret >= 0)
1489 return 0; 1385 return 0;
@@ -1506,7 +1402,7 @@ int nfs_wb_page_priority(struct inode *inode, struct page *page, int how)
1506 int ret; 1402 int ret;
1507 1403
1508 BUG_ON(!PageLocked(page)); 1404 BUG_ON(!PageLocked(page));
1509 if (!(how & FLUSH_NOWRITEPAGE) && clear_page_dirty_for_io(page)) { 1405 if (clear_page_dirty_for_io(page)) {
1510 ret = nfs_writepage_locked(page, &wbc); 1406 ret = nfs_writepage_locked(page, &wbc);
1511 if (ret < 0) 1407 if (ret < 0)
1512 goto out; 1408 goto out;
@@ -1531,10 +1427,18 @@ int nfs_wb_page(struct inode *inode, struct page* page)
1531 1427
1532int nfs_set_page_dirty(struct page *page) 1428int nfs_set_page_dirty(struct page *page)
1533{ 1429{
1534 spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock; 1430 struct address_space *mapping = page->mapping;
1431 struct inode *inode;
1432 spinlock_t *req_lock;
1535 struct nfs_page *req; 1433 struct nfs_page *req;
1536 int ret; 1434 int ret;
1537 1435
1436 if (!mapping)
1437 goto out_raced;
1438 inode = mapping->host;
1439 if (!inode)
1440 goto out_raced;
1441 req_lock = &NFS_I(inode)->req_lock;
1538 spin_lock(req_lock); 1442 spin_lock(req_lock);
1539 req = nfs_page_find_request_locked(page); 1443 req = nfs_page_find_request_locked(page);
1540 if (req != NULL) { 1444 if (req != NULL) {
@@ -1547,6 +1451,8 @@ int nfs_set_page_dirty(struct page *page)
1547 ret = __set_page_dirty_nobuffers(page); 1451 ret = __set_page_dirty_nobuffers(page);
1548 spin_unlock(req_lock); 1452 spin_unlock(req_lock);
1549 return ret; 1453 return ret;
1454out_raced:
1455 return !TestSetPageDirty(page);
1550} 1456}
1551 1457
1552 1458
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index fb14d68eacab..32ffea033c7a 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -315,16 +315,13 @@ out:
315/* 315/*
316 * RPC procedure tables 316 * RPC procedure tables
317 */ 317 */
318#ifndef MAX
319# define MAX(a, b) (((a) > (b))? (a) : (b))
320#endif
321
322#define PROC(proc, call, argtype, restype) \ 318#define PROC(proc, call, argtype, restype) \
323[NFSPROC4_CLNT_##proc] = { \ 319[NFSPROC4_CLNT_##proc] = { \
324 .p_proc = NFSPROC4_CB_##call, \ 320 .p_proc = NFSPROC4_CB_##call, \
325 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \ 321 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
326 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \ 322 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
327 .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \ 323 .p_arglen = NFS4_##argtype##_sz, \
324 .p_replen = NFS4_##restype##_sz, \
328 .p_statidx = NFSPROC4_CB_##call, \ 325 .p_statidx = NFSPROC4_CB_##call, \
329 .p_name = #proc, \ 326 .p_name = #proc, \
330} 327}
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index a0c8667caa72..19712a7d145f 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -2869,7 +2869,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
2869 tl = &tl_copy->id2.i_dealloc; 2869 tl = &tl_copy->id2.i_dealloc;
2870 num_recs = le16_to_cpu(tl->tl_used); 2870 num_recs = le16_to_cpu(tl->tl_used);
2871 mlog(0, "cleanup %u records from %llu\n", num_recs, 2871 mlog(0, "cleanup %u records from %llu\n", num_recs,
2872 (unsigned long long)tl_copy->i_blkno); 2872 (unsigned long long)le64_to_cpu(tl_copy->i_blkno));
2873 2873
2874 mutex_lock(&tl_inode->i_mutex); 2874 mutex_lock(&tl_inode->i_mutex);
2875 for(i = 0; i < num_recs; i++) { 2875 for(i = 0; i < num_recs; i++) {
@@ -3801,8 +3801,8 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
3801 fe = (struct ocfs2_dinode *) fe_bh->b_data; 3801 fe = (struct ocfs2_dinode *) fe_bh->b_data;
3802 3802
3803 mlog(0, "fe->i_clusters = %u, new_i_clusters = %u, fe->i_size =" 3803 mlog(0, "fe->i_clusters = %u, new_i_clusters = %u, fe->i_size ="
3804 "%llu\n", fe->i_clusters, new_i_clusters, 3804 "%llu\n", le32_to_cpu(fe->i_clusters), new_i_clusters,
3805 (unsigned long long)fe->i_size); 3805 (unsigned long long)le64_to_cpu(fe->i_size));
3806 3806
3807 *tc = kzalloc(sizeof(struct ocfs2_truncate_context), GFP_KERNEL); 3807 *tc = kzalloc(sizeof(struct ocfs2_truncate_context), GFP_KERNEL);
3808 if (!(*tc)) { 3808 if (!(*tc)) {
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 56963e6c46c0..8e7cafb5fc6c 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -78,7 +78,8 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
78 78
79 if (!OCFS2_IS_VALID_DINODE(fe)) { 79 if (!OCFS2_IS_VALID_DINODE(fe)) {
80 mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n", 80 mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
81 (unsigned long long)fe->i_blkno, 7, fe->i_signature); 81 (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
82 fe->i_signature);
82 goto bail; 83 goto bail;
83 } 84 }
84 85
@@ -939,9 +940,9 @@ out:
939 * Returns a negative error code or the number of bytes copied into 940 * Returns a negative error code or the number of bytes copied into
940 * the page. 941 * the page.
941 */ 942 */
942int ocfs2_write_data_page(struct inode *inode, handle_t *handle, 943static int ocfs2_write_data_page(struct inode *inode, handle_t *handle,
943 u64 *p_blkno, struct page *page, 944 u64 *p_blkno, struct page *page,
944 struct ocfs2_write_ctxt *wc, int new) 945 struct ocfs2_write_ctxt *wc, int new)
945{ 946{
946 int ret, copied = 0; 947 int ret, copied = 0;
947 unsigned int from = 0, to = 0; 948 unsigned int from = 0, to = 0;
@@ -1086,7 +1087,7 @@ static ssize_t ocfs2_write(struct file *file, u32 phys, handle_t *handle,
1086 for(i = 0; i < numpages; i++) { 1087 for(i = 0; i < numpages; i++) {
1087 index = start + i; 1088 index = start + i;
1088 1089
1089 cpages[i] = grab_cache_page(mapping, index); 1090 cpages[i] = find_or_create_page(mapping, index, GFP_NOFS);
1090 if (!cpages[i]) { 1091 if (!cpages[i]) {
1091 ret = -ENOMEM; 1092 ret = -ENOMEM;
1092 mlog_errno(ret); 1093 mlog_errno(ret);
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index eba282da500e..979113479c66 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -438,7 +438,7 @@ static inline void o2hb_prepare_block(struct o2hb_region *reg,
438 hb_block)); 438 hb_block));
439 439
440 mlog(ML_HB_BIO, "our node generation = 0x%llx, cksum = 0x%x\n", 440 mlog(ML_HB_BIO, "our node generation = 0x%llx, cksum = 0x%x\n",
441 (long long)cpu_to_le64(generation), 441 (long long)generation,
442 le32_to_cpu(hb_block->hb_cksum)); 442 le32_to_cpu(hb_block->hb_cksum));
443} 443}
444 444
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
index 636593bf4d17..2e975c0a35e1 100644
--- a/fs/ocfs2/cluster/masklog.c
+++ b/fs/ocfs2/cluster/masklog.c
@@ -147,7 +147,7 @@ static struct kset mlog_kset = {
147 .kobj = {.name = "logmask", .ktype = &mlog_ktype}, 147 .kobj = {.name = "logmask", .ktype = &mlog_ktype},
148}; 148};
149 149
150int mlog_sys_init(struct subsystem *o2cb_subsys) 150int mlog_sys_init(struct kset *o2cb_subsys)
151{ 151{
152 int i = 0; 152 int i = 0;
153 153
@@ -157,7 +157,7 @@ int mlog_sys_init(struct subsystem *o2cb_subsys)
157 } 157 }
158 mlog_attr_ptrs[i] = NULL; 158 mlog_attr_ptrs[i] = NULL;
159 159
160 mlog_kset.subsys = o2cb_subsys; 160 kobj_set_kset_s(&mlog_kset, o2cb_subsys);
161 return kset_register(&mlog_kset); 161 return kset_register(&mlog_kset);
162} 162}
163 163
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h
index a42628ba9ddf..75cd877f6d42 100644
--- a/fs/ocfs2/cluster/masklog.h
+++ b/fs/ocfs2/cluster/masklog.h
@@ -278,7 +278,7 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits;
278 278
279#include <linux/kobject.h> 279#include <linux/kobject.h>
280#include <linux/sysfs.h> 280#include <linux/sysfs.h>
281int mlog_sys_init(struct subsystem *o2cb_subsys); 281int mlog_sys_init(struct kset *o2cb_subsys);
282void mlog_sys_shutdown(void); 282void mlog_sys_shutdown(void);
283 283
284#endif /* O2CLUSTER_MASKLOG_H */ 284#endif /* O2CLUSTER_MASKLOG_H */
diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c
index 1d9f6acafa2e..64f6f378fd09 100644
--- a/fs/ocfs2/cluster/sys.c
+++ b/fs/ocfs2/cluster/sys.c
@@ -42,7 +42,6 @@ struct o2cb_attribute {
42#define O2CB_ATTR(_name, _mode, _show, _store) \ 42#define O2CB_ATTR(_name, _mode, _show, _store) \
43struct o2cb_attribute o2cb_attr_##_name = __ATTR(_name, _mode, _show, _store) 43struct o2cb_attribute o2cb_attr_##_name = __ATTR(_name, _mode, _show, _store)
44 44
45#define to_o2cb_subsys(k) container_of(to_kset(k), struct subsystem, kset)
46#define to_o2cb_attr(_attr) container_of(_attr, struct o2cb_attribute, attr) 45#define to_o2cb_attr(_attr) container_of(_attr, struct o2cb_attribute, attr)
47 46
48static ssize_t o2cb_interface_revision_show(char *buf) 47static ssize_t o2cb_interface_revision_show(char *buf)
@@ -79,7 +78,7 @@ static ssize_t
79o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer) 78o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer)
80{ 79{
81 struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr); 80 struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr);
82 struct subsystem *sbs = to_o2cb_subsys(kobj); 81 struct kset *sbs = to_kset(kobj);
83 82
84 BUG_ON(sbs != &o2cb_subsys); 83 BUG_ON(sbs != &o2cb_subsys);
85 84
@@ -93,7 +92,7 @@ o2cb_store(struct kobject * kobj, struct attribute * attr,
93 const char * buffer, size_t count) 92 const char * buffer, size_t count)
94{ 93{
95 struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr); 94 struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr);
96 struct subsystem *sbs = to_o2cb_subsys(kobj); 95 struct kset *sbs = to_kset(kobj);
97 96
98 BUG_ON(sbs != &o2cb_subsys); 97 BUG_ON(sbs != &o2cb_subsys);
99 98
@@ -112,7 +111,7 @@ int o2cb_sys_init(void)
112{ 111{
113 int ret; 112 int ret;
114 113
115 o2cb_subsys.kset.kobj.ktype = &o2cb_subsys_type; 114 o2cb_subsys.kobj.ktype = &o2cb_subsys_type;
116 ret = subsystem_register(&o2cb_subsys); 115 ret = subsystem_register(&o2cb_subsys);
117 if (ret) 116 if (ret)
118 return ret; 117 return ret;
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 69caf3e12fea..0b229a9c7952 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -1496,7 +1496,7 @@ static void o2net_start_connect(struct work_struct *work)
1496 sock->sk->sk_allocation = GFP_ATOMIC; 1496 sock->sk->sk_allocation = GFP_ATOMIC;
1497 1497
1498 myaddr.sin_family = AF_INET; 1498 myaddr.sin_family = AF_INET;
1499 myaddr.sin_addr.s_addr = (__force u32)mynode->nd_ipv4_address; 1499 myaddr.sin_addr.s_addr = mynode->nd_ipv4_address;
1500 myaddr.sin_port = (__force u16)htons(0); /* any port */ 1500 myaddr.sin_port = (__force u16)htons(0); /* any port */
1501 1501
1502 ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr, 1502 ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr,
@@ -1521,8 +1521,8 @@ static void o2net_start_connect(struct work_struct *work)
1521 spin_unlock(&nn->nn_lock); 1521 spin_unlock(&nn->nn_lock);
1522 1522
1523 remoteaddr.sin_family = AF_INET; 1523 remoteaddr.sin_family = AF_INET;
1524 remoteaddr.sin_addr.s_addr = (__force u32)node->nd_ipv4_address; 1524 remoteaddr.sin_addr.s_addr = node->nd_ipv4_address;
1525 remoteaddr.sin_port = (__force u16)node->nd_ipv4_port; 1525 remoteaddr.sin_port = node->nd_ipv4_port;
1526 1526
1527 ret = sc->sc_sock->ops->connect(sc->sc_sock, 1527 ret = sc->sc_sock->ops->connect(sc->sc_sock,
1528 (struct sockaddr *)&remoteaddr, 1528 (struct sockaddr *)&remoteaddr,
@@ -1810,8 +1810,8 @@ static int o2net_open_listening_sock(__be32 addr, __be16 port)
1810 int ret; 1810 int ret;
1811 struct sockaddr_in sin = { 1811 struct sockaddr_in sin = {
1812 .sin_family = PF_INET, 1812 .sin_family = PF_INET,
1813 .sin_addr = { .s_addr = (__force u32)addr }, 1813 .sin_addr = { .s_addr = addr },
1814 .sin_port = (__force u16)port, 1814 .sin_port = port,
1815 }; 1815 };
1816 1816
1817 ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); 1817 ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 67e6866a2a4f..c441ef1f2bad 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -403,7 +403,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
403 struct buffer_head **new_de_bh) 403 struct buffer_head **new_de_bh)
404{ 404{
405 int status = 0; 405 int status = 0;
406 int credits, num_free_extents; 406 int credits, num_free_extents, drop_alloc_sem = 0;
407 loff_t dir_i_size; 407 loff_t dir_i_size;
408 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data; 408 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
409 struct ocfs2_alloc_context *data_ac = NULL; 409 struct ocfs2_alloc_context *data_ac = NULL;
@@ -452,6 +452,9 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
452 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS; 452 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS;
453 } 453 }
454 454
455 down_write(&OCFS2_I(dir)->ip_alloc_sem);
456 drop_alloc_sem = 1;
457
455 handle = ocfs2_start_trans(osb, credits); 458 handle = ocfs2_start_trans(osb, credits);
456 if (IS_ERR(handle)) { 459 if (IS_ERR(handle)) {
457 status = PTR_ERR(handle); 460 status = PTR_ERR(handle);
@@ -497,6 +500,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
497 *new_de_bh = new_bh; 500 *new_de_bh = new_bh;
498 get_bh(*new_de_bh); 501 get_bh(*new_de_bh);
499bail: 502bail:
503 if (drop_alloc_sem)
504 up_write(&OCFS2_I(dir)->ip_alloc_sem);
500 if (handle) 505 if (handle)
501 ocfs2_commit_trans(osb, handle); 506 ocfs2_commit_trans(osb, handle);
502 507
diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c
index 241cad342a48..2fd8bded38f3 100644
--- a/fs/ocfs2/dlm/dlmast.c
+++ b/fs/ocfs2/dlm/dlmast.c
@@ -312,8 +312,8 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
312 past->type != DLM_BAST) { 312 past->type != DLM_BAST) {
313 mlog(ML_ERROR, "Unknown ast type! %d, cookie=%u:%llu" 313 mlog(ML_ERROR, "Unknown ast type! %d, cookie=%u:%llu"
314 "name=%.*s\n", past->type, 314 "name=%.*s\n", past->type,
315 dlm_get_lock_cookie_node(be64_to_cpu(cookie)), 315 dlm_get_lock_cookie_node(cookie),
316 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)), 316 dlm_get_lock_cookie_seq(cookie),
317 locklen, name); 317 locklen, name);
318 ret = DLM_IVLOCKID; 318 ret = DLM_IVLOCKID;
319 goto leave; 319 goto leave;
@@ -324,8 +324,8 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
324 mlog(0, "got %sast for unknown lockres! " 324 mlog(0, "got %sast for unknown lockres! "
325 "cookie=%u:%llu, name=%.*s, namelen=%u\n", 325 "cookie=%u:%llu, name=%.*s, namelen=%u\n",
326 past->type == DLM_AST ? "" : "b", 326 past->type == DLM_AST ? "" : "b",
327 dlm_get_lock_cookie_node(be64_to_cpu(cookie)), 327 dlm_get_lock_cookie_node(cookie),
328 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)), 328 dlm_get_lock_cookie_seq(cookie),
329 locklen, name, locklen); 329 locklen, name, locklen);
330 ret = DLM_IVLOCKID; 330 ret = DLM_IVLOCKID;
331 goto leave; 331 goto leave;
@@ -370,8 +370,8 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
370 370
371 mlog(0, "got %sast for unknown lock! cookie=%u:%llu, " 371 mlog(0, "got %sast for unknown lock! cookie=%u:%llu, "
372 "name=%.*s, namelen=%u\n", past->type == DLM_AST ? "" : "b", 372 "name=%.*s, namelen=%u\n", past->type == DLM_AST ? "" : "b",
373 dlm_get_lock_cookie_node(be64_to_cpu(cookie)), 373 dlm_get_lock_cookie_node(cookie),
374 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)), 374 dlm_get_lock_cookie_seq(cookie),
375 locklen, name, locklen); 375 locklen, name, locklen);
376 376
377 ret = DLM_NORMAL; 377 ret = DLM_NORMAL;
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index c1807a42c49f..671c4ed58ee2 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1769,7 +1769,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
1769 /* lock is always created locally first, and 1769 /* lock is always created locally first, and
1770 * destroyed locally last. it must be on the list */ 1770 * destroyed locally last. it must be on the list */
1771 if (!lock) { 1771 if (!lock) {
1772 u64 c = ml->cookie; 1772 __be64 c = ml->cookie;
1773 mlog(ML_ERROR, "could not find local lock " 1773 mlog(ML_ERROR, "could not find local lock "
1774 "with cookie %u:%llu!\n", 1774 "with cookie %u:%llu!\n",
1775 dlm_get_lock_cookie_node(be64_to_cpu(c)), 1775 dlm_get_lock_cookie_node(be64_to_cpu(c)),
@@ -1878,7 +1878,7 @@ skip_lvb:
1878 spin_lock(&res->spinlock); 1878 spin_lock(&res->spinlock);
1879 list_for_each_entry(lock, queue, list) { 1879 list_for_each_entry(lock, queue, list) {
1880 if (lock->ml.cookie == ml->cookie) { 1880 if (lock->ml.cookie == ml->cookie) {
1881 u64 c = lock->ml.cookie; 1881 __be64 c = lock->ml.cookie;
1882 mlog(ML_ERROR, "%s:%.*s: %u:%llu: lock already " 1882 mlog(ML_ERROR, "%s:%.*s: %u:%llu: lock already "
1883 "exists on this lockres!\n", dlm->name, 1883 "exists on this lockres!\n", dlm->name,
1884 res->lockname.len, res->lockname.name, 1884 res->lockname.len, res->lockname.name,
diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c
index 2b264c6ba039..cebd089f8955 100644
--- a/fs/ocfs2/dlm/dlmthread.c
+++ b/fs/ocfs2/dlm/dlmthread.c
@@ -76,7 +76,7 @@ repeat:
76 goto repeat; 76 goto repeat;
77 } 77 }
78 remove_wait_queue(&res->wq, &wait); 78 remove_wait_queue(&res->wq, &wait);
79 current->state = TASK_RUNNING; 79 __set_current_state(TASK_RUNNING);
80} 80}
81 81
82int __dlm_lockres_has_locks(struct dlm_lock_resource *res) 82int __dlm_lockres_has_locks(struct dlm_lock_resource *res)
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 27e43b0c0eae..024777abc8e3 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -104,6 +104,35 @@ static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
104static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb, 104static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
105 struct ocfs2_lock_res *lockres); 105 struct ocfs2_lock_res *lockres);
106 106
107
108#define mlog_meta_lvb(__level, __lockres) ocfs2_dump_meta_lvb_info(__level, __PRETTY_FUNCTION__, __LINE__, __lockres)
109
110/* This aids in debugging situations where a bad LVB might be involved. */
111static void ocfs2_dump_meta_lvb_info(u64 level,
112 const char *function,
113 unsigned int line,
114 struct ocfs2_lock_res *lockres)
115{
116 struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb;
117
118 mlog(level, "LVB information for %s (called from %s:%u):\n",
119 lockres->l_name, function, line);
120 mlog(level, "version: %u, clusters: %u, generation: 0x%x\n",
121 lvb->lvb_version, be32_to_cpu(lvb->lvb_iclusters),
122 be32_to_cpu(lvb->lvb_igeneration));
123 mlog(level, "size: %llu, uid %u, gid %u, mode 0x%x\n",
124 (unsigned long long)be64_to_cpu(lvb->lvb_isize),
125 be32_to_cpu(lvb->lvb_iuid), be32_to_cpu(lvb->lvb_igid),
126 be16_to_cpu(lvb->lvb_imode));
127 mlog(level, "nlink %u, atime_packed 0x%llx, ctime_packed 0x%llx, "
128 "mtime_packed 0x%llx iattr 0x%x\n", be16_to_cpu(lvb->lvb_inlink),
129 (long long)be64_to_cpu(lvb->lvb_iatime_packed),
130 (long long)be64_to_cpu(lvb->lvb_ictime_packed),
131 (long long)be64_to_cpu(lvb->lvb_imtime_packed),
132 be32_to_cpu(lvb->lvb_iattr));
133}
134
135
107/* 136/*
108 * OCFS2 Lock Resource Operations 137 * OCFS2 Lock Resource Operations
109 * 138 *
@@ -3078,28 +3107,3 @@ static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
3078 3107
3079 mlog_exit_void(); 3108 mlog_exit_void();
3080} 3109}
3081
3082/* This aids in debugging situations where a bad LVB might be involved. */
3083void ocfs2_dump_meta_lvb_info(u64 level,
3084 const char *function,
3085 unsigned int line,
3086 struct ocfs2_lock_res *lockres)
3087{
3088 struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb;
3089
3090 mlog(level, "LVB information for %s (called from %s:%u):\n",
3091 lockres->l_name, function, line);
3092 mlog(level, "version: %u, clusters: %u, generation: 0x%x\n",
3093 lvb->lvb_version, be32_to_cpu(lvb->lvb_iclusters),
3094 be32_to_cpu(lvb->lvb_igeneration));
3095 mlog(level, "size: %llu, uid %u, gid %u, mode 0x%x\n",
3096 (unsigned long long)be64_to_cpu(lvb->lvb_isize),
3097 be32_to_cpu(lvb->lvb_iuid), be32_to_cpu(lvb->lvb_igid),
3098 be16_to_cpu(lvb->lvb_imode));
3099 mlog(level, "nlink %u, atime_packed 0x%llx, ctime_packed 0x%llx, "
3100 "mtime_packed 0x%llx iattr 0x%x\n", be16_to_cpu(lvb->lvb_inlink),
3101 (long long)be64_to_cpu(lvb->lvb_iatime_packed),
3102 (long long)be64_to_cpu(lvb->lvb_ictime_packed),
3103 (long long)be64_to_cpu(lvb->lvb_imtime_packed),
3104 be32_to_cpu(lvb->lvb_iattr));
3105}
diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h
index 59cb566e7983..492bad32a8c0 100644
--- a/fs/ocfs2/dlmglue.h
+++ b/fs/ocfs2/dlmglue.h
@@ -119,11 +119,4 @@ void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
119struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void); 119struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void);
120void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug); 120void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug);
121 121
122/* aids in debugging and tracking lvbs */
123void ocfs2_dump_meta_lvb_info(u64 level,
124 const char *function,
125 unsigned int line,
126 struct ocfs2_lock_res *lockres);
127#define mlog_meta_lvb(__level, __lockres) ocfs2_dump_meta_lvb_info(__level, __PRETTY_FUNCTION__, __LINE__, __lockres)
128
129#endif /* DLMGLUE_H */ 122#endif /* DLMGLUE_H */
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index 56e1fefc1205..bc48177bd183 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -140,7 +140,7 @@ bail:
140 return parent; 140 return parent;
141} 141}
142 142
143static int ocfs2_encode_fh(struct dentry *dentry, __be32 *fh, int *max_len, 143static int ocfs2_encode_fh(struct dentry *dentry, u32 *fh_in, int *max_len,
144 int connectable) 144 int connectable)
145{ 145{
146 struct inode *inode = dentry->d_inode; 146 struct inode *inode = dentry->d_inode;
@@ -148,6 +148,7 @@ static int ocfs2_encode_fh(struct dentry *dentry, __be32 *fh, int *max_len,
148 int type = 1; 148 int type = 1;
149 u64 blkno; 149 u64 blkno;
150 u32 generation; 150 u32 generation;
151 __le32 *fh = (__force __le32 *) fh_in;
151 152
152 mlog_entry("(0x%p, '%.*s', 0x%p, %d, %d)\n", dentry, 153 mlog_entry("(0x%p, '%.*s', 0x%p, %d, %d)\n", dentry,
153 dentry->d_name.len, dentry->d_name.name, 154 dentry->d_name.len, dentry->d_name.name,
@@ -199,7 +200,7 @@ bail:
199 return type; 200 return type;
200} 201}
201 202
202static struct dentry *ocfs2_decode_fh(struct super_block *sb, __be32 *fh, 203static struct dentry *ocfs2_decode_fh(struct super_block *sb, u32 *fh_in,
203 int fh_len, int fileid_type, 204 int fh_len, int fileid_type,
204 int (*acceptable)(void *context, 205 int (*acceptable)(void *context,
205 struct dentry *de), 206 struct dentry *de),
@@ -207,6 +208,7 @@ static struct dentry *ocfs2_decode_fh(struct super_block *sb, __be32 *fh,
207{ 208{
208 struct ocfs2_inode_handle handle, parent; 209 struct ocfs2_inode_handle handle, parent;
209 struct dentry *ret = NULL; 210 struct dentry *ret = NULL;
211 __le32 *fh = (__force __le32 *) fh_in;
210 212
211 mlog_entry("(0x%p, 0x%p, %d, %d, 0x%p, 0x%p)\n", 213 mlog_entry("(0x%p, 0x%p, %d, %d, 0x%p, 0x%p)\n",
212 sb, fh, fh_len, fileid_type, acceptable, context); 214 sb, fh, fh_len, fileid_type, acceptable, context);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 520a2a6d7670..9395b4fa547d 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -207,10 +207,10 @@ out:
207 return ret; 207 return ret;
208} 208}
209 209
210int ocfs2_set_inode_size(handle_t *handle, 210static int ocfs2_set_inode_size(handle_t *handle,
211 struct inode *inode, 211 struct inode *inode,
212 struct buffer_head *fe_bh, 212 struct buffer_head *fe_bh,
213 u64 new_i_size) 213 u64 new_i_size)
214{ 214{
215 int status; 215 int status;
216 216
@@ -713,7 +713,8 @@ restarted_transaction:
713 } 713 }
714 714
715 mlog(0, "fe: i_clusters = %u, i_size=%llu\n", 715 mlog(0, "fe: i_clusters = %u, i_size=%llu\n",
716 fe->i_clusters, (unsigned long long)fe->i_size); 716 le32_to_cpu(fe->i_clusters),
717 (unsigned long long)le64_to_cpu(fe->i_size));
717 mlog(0, "inode: ip_clusters=%u, i_size=%lld\n", 718 mlog(0, "inode: ip_clusters=%u, i_size=%lld\n",
718 OCFS2_I(inode)->ip_clusters, i_size_read(inode)); 719 OCFS2_I(inode)->ip_clusters, i_size_read(inode));
719 720
@@ -1853,6 +1854,9 @@ const struct file_operations ocfs2_fops = {
1853 .aio_read = ocfs2_file_aio_read, 1854 .aio_read = ocfs2_file_aio_read,
1854 .aio_write = ocfs2_file_aio_write, 1855 .aio_write = ocfs2_file_aio_write,
1855 .ioctl = ocfs2_ioctl, 1856 .ioctl = ocfs2_ioctl,
1857#ifdef CONFIG_COMPAT
1858 .compat_ioctl = ocfs2_compat_ioctl,
1859#endif
1856 .splice_read = ocfs2_file_splice_read, 1860 .splice_read = ocfs2_file_splice_read,
1857 .splice_write = ocfs2_file_splice_write, 1861 .splice_write = ocfs2_file_splice_write,
1858}; 1862};
@@ -1862,4 +1866,7 @@ const struct file_operations ocfs2_dops = {
1862 .readdir = ocfs2_readdir, 1866 .readdir = ocfs2_readdir,
1863 .fsync = ocfs2_sync_file, 1867 .fsync = ocfs2_sync_file,
1864 .ioctl = ocfs2_ioctl, 1868 .ioctl = ocfs2_ioctl,
1869#ifdef CONFIG_COMPAT
1870 .compat_ioctl = ocfs2_compat_ioctl,
1871#endif
1865}; 1872};
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index 2c4460fced52..a4dd1fa1822b 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -56,11 +56,6 @@ int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
56int ocfs2_permission(struct inode *inode, int mask, 56int ocfs2_permission(struct inode *inode, int mask,
57 struct nameidata *nd); 57 struct nameidata *nd);
58 58
59int ocfs2_set_inode_size(handle_t *handle,
60 struct inode *inode,
61 struct buffer_head *fe_bh,
62 u64 new_i_size);
63
64int ocfs2_should_update_atime(struct inode *inode, 59int ocfs2_should_update_atime(struct inode *inode,
65 struct vfsmount *vfsmnt); 60 struct vfsmount *vfsmnt);
66int ocfs2_update_inode_atime(struct inode *inode, 61int ocfs2_update_inode_atime(struct inode *inode,
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 21a605079c62..bc844bfe607c 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -89,6 +89,25 @@ void ocfs2_set_inode_flags(struct inode *inode)
89 inode->i_flags |= S_DIRSYNC; 89 inode->i_flags |= S_DIRSYNC;
90} 90}
91 91
92/* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
93void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
94{
95 unsigned int flags = oi->vfs_inode.i_flags;
96
97 oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
98 OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
99 if (flags & S_SYNC)
100 oi->ip_attr |= OCFS2_SYNC_FL;
101 if (flags & S_APPEND)
102 oi->ip_attr |= OCFS2_APPEND_FL;
103 if (flags & S_IMMUTABLE)
104 oi->ip_attr |= OCFS2_IMMUTABLE_FL;
105 if (flags & S_NOATIME)
106 oi->ip_attr |= OCFS2_NOATIME_FL;
107 if (flags & S_DIRSYNC)
108 oi->ip_attr |= OCFS2_DIRSYNC_FL;
109}
110
92struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags) 111struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
93{ 112{
94 struct inode *inode = NULL; 113 struct inode *inode = NULL;
@@ -196,7 +215,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
196 int status = -EINVAL; 215 int status = -EINVAL;
197 216
198 mlog_entry("(0x%p, size:%llu)\n", inode, 217 mlog_entry("(0x%p, size:%llu)\n", inode,
199 (unsigned long long)fe->i_size); 218 (unsigned long long)le64_to_cpu(fe->i_size));
200 219
201 sb = inode->i_sb; 220 sb = inode->i_sb;
202 osb = OCFS2_SB(sb); 221 osb = OCFS2_SB(sb);
@@ -248,7 +267,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
248 mlog(ML_ERROR, 267 mlog(ML_ERROR,
249 "ip_blkno %llu != i_blkno %llu!\n", 268 "ip_blkno %llu != i_blkno %llu!\n",
250 (unsigned long long)OCFS2_I(inode)->ip_blkno, 269 (unsigned long long)OCFS2_I(inode)->ip_blkno,
251 (unsigned long long)fe->i_blkno); 270 (unsigned long long)le64_to_cpu(fe->i_blkno));
252 271
253 inode->i_nlink = le16_to_cpu(fe->i_links_count); 272 inode->i_nlink = le16_to_cpu(fe->i_links_count);
254 273
@@ -301,7 +320,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
301 * the generation argument to 320 * the generation argument to
302 * ocfs2_inode_lock_res_init() will have to change. 321 * ocfs2_inode_lock_res_init() will have to change.
303 */ 322 */
304 BUG_ON(fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)); 323 BUG_ON(le32_to_cpu(fe->i_flags) & OCFS2_SYSTEM_FL);
305 324
306 ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres, 325 ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres,
307 OCFS2_LOCK_TYPE_META, 0, inode); 326 OCFS2_LOCK_TYPE_META, 0, inode);
@@ -437,7 +456,8 @@ static int ocfs2_read_locked_inode(struct inode *inode,
437 fe = (struct ocfs2_dinode *) bh->b_data; 456 fe = (struct ocfs2_dinode *) bh->b_data;
438 if (!OCFS2_IS_VALID_DINODE(fe)) { 457 if (!OCFS2_IS_VALID_DINODE(fe)) {
439 mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n", 458 mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
440 (unsigned long long)fe->i_blkno, 7, fe->i_signature); 459 (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
460 fe->i_signature);
441 goto bail; 461 goto bail;
442 } 462 }
443 463
@@ -812,8 +832,8 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
812 "Inode %llu (on-disk %llu) not orphaned! " 832 "Inode %llu (on-disk %llu) not orphaned! "
813 "Disk flags 0x%x, inode flags 0x%x\n", 833 "Disk flags 0x%x, inode flags 0x%x\n",
814 (unsigned long long)oi->ip_blkno, 834 (unsigned long long)oi->ip_blkno,
815 (unsigned long long)di->i_blkno, di->i_flags, 835 (unsigned long long)le64_to_cpu(di->i_blkno),
816 oi->ip_flags); 836 le32_to_cpu(di->i_flags), oi->ip_flags);
817 goto bail; 837 goto bail;
818 } 838 }
819 839
@@ -1106,8 +1126,10 @@ struct buffer_head *ocfs2_bread(struct inode *inode,
1106 return NULL; 1126 return NULL;
1107 } 1127 }
1108 1128
1129 down_read(&OCFS2_I(inode)->ip_alloc_sem);
1109 tmperr = ocfs2_extent_map_get_blocks(inode, block, &p_blkno, NULL, 1130 tmperr = ocfs2_extent_map_get_blocks(inode, block, &p_blkno, NULL,
1110 NULL); 1131 NULL);
1132 up_read(&OCFS2_I(inode)->ip_alloc_sem);
1111 if (tmperr < 0) { 1133 if (tmperr < 0) {
1112 mlog_errno(tmperr); 1134 mlog_errno(tmperr);
1113 goto fail; 1135 goto fail;
@@ -1197,6 +1219,7 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
1197 1219
1198 spin_lock(&OCFS2_I(inode)->ip_lock); 1220 spin_lock(&OCFS2_I(inode)->ip_lock);
1199 fe->i_clusters = cpu_to_le32(OCFS2_I(inode)->ip_clusters); 1221 fe->i_clusters = cpu_to_le32(OCFS2_I(inode)->ip_clusters);
1222 ocfs2_get_inode_flags(OCFS2_I(inode));
1200 fe->i_attr = cpu_to_le32(OCFS2_I(inode)->ip_attr); 1223 fe->i_attr = cpu_to_le32(OCFS2_I(inode)->ip_attr);
1201 spin_unlock(&OCFS2_I(inode)->ip_lock); 1224 spin_unlock(&OCFS2_I(inode)->ip_lock);
1202 1225
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 03ae075869ee..a41d0817121b 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -141,6 +141,7 @@ int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb);
141int ocfs2_aio_write(struct file *file, struct kiocb *req, struct iocb *iocb); 141int ocfs2_aio_write(struct file *file, struct kiocb *req, struct iocb *iocb);
142 142
143void ocfs2_set_inode_flags(struct inode *inode); 143void ocfs2_set_inode_flags(struct inode *inode);
144void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
144 145
145static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode) 146static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
146{ 147{
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 4768be5f3086..f3ad21ad9aed 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -31,6 +31,7 @@ static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags)
31 mlog_errno(status); 31 mlog_errno(status);
32 return status; 32 return status;
33 } 33 }
34 ocfs2_get_inode_flags(OCFS2_I(inode));
34 *flags = OCFS2_I(inode)->ip_attr; 35 *flags = OCFS2_I(inode)->ip_attr;
35 ocfs2_meta_unlock(inode, 0); 36 ocfs2_meta_unlock(inode, 0);
36 37
@@ -134,3 +135,26 @@ int ocfs2_ioctl(struct inode * inode, struct file * filp,
134 } 135 }
135} 136}
136 137
138#ifdef CONFIG_COMPAT
139long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
140{
141 struct inode *inode = file->f_path.dentry->d_inode;
142 int ret;
143
144 switch (cmd) {
145 case OCFS2_IOC32_GETFLAGS:
146 cmd = OCFS2_IOC_GETFLAGS;
147 break;
148 case OCFS2_IOC32_SETFLAGS:
149 cmd = OCFS2_IOC_SETFLAGS;
150 break;
151 default:
152 return -ENOIOCTLCMD;
153 }
154
155 lock_kernel();
156 ret = ocfs2_ioctl(inode, file, cmd, arg);
157 unlock_kernel();
158 return ret;
159}
160#endif
diff --git a/fs/ocfs2/ioctl.h b/fs/ocfs2/ioctl.h
index 4a7c82931dba..4d6c4f430d0d 100644
--- a/fs/ocfs2/ioctl.h
+++ b/fs/ocfs2/ioctl.h
@@ -12,5 +12,6 @@
12 12
13int ocfs2_ioctl(struct inode * inode, struct file * filp, 13int ocfs2_ioctl(struct inode * inode, struct file * filp,
14 unsigned int cmd, unsigned long arg); 14 unsigned int cmd, unsigned long arg);
15long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
15 16
16#endif /* OCFS2_IOCTL_H */ 17#endif /* OCFS2_IOCTL_H */
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 5a8a90d1c787..dc1188081720 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -435,7 +435,8 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
435 * handle the errors in a specific manner, so no need 435 * handle the errors in a specific manner, so no need
436 * to call ocfs2_error() here. */ 436 * to call ocfs2_error() here. */
437 mlog(ML_ERROR, "Journal dinode %llu has invalid " 437 mlog(ML_ERROR, "Journal dinode %llu has invalid "
438 "signature: %.*s", (unsigned long long)fe->i_blkno, 7, 438 "signature: %.*s",
439 (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
439 fe->i_signature); 440 fe->i_signature);
440 status = -EIO; 441 status = -EIO;
441 goto out; 442 goto out;
@@ -742,7 +743,7 @@ void ocfs2_complete_recovery(struct work_struct *work)
742 la_dinode = item->lri_la_dinode; 743 la_dinode = item->lri_la_dinode;
743 if (la_dinode) { 744 if (la_dinode) {
744 mlog(0, "Clean up local alloc %llu\n", 745 mlog(0, "Clean up local alloc %llu\n",
745 (unsigned long long)la_dinode->i_blkno); 746 (unsigned long long)le64_to_cpu(la_dinode->i_blkno));
746 747
747 ret = ocfs2_complete_local_alloc_recovery(osb, 748 ret = ocfs2_complete_local_alloc_recovery(osb,
748 la_dinode); 749 la_dinode);
@@ -755,7 +756,7 @@ void ocfs2_complete_recovery(struct work_struct *work)
755 tl_dinode = item->lri_tl_dinode; 756 tl_dinode = item->lri_tl_dinode;
756 if (tl_dinode) { 757 if (tl_dinode) {
757 mlog(0, "Clean up truncate log %llu\n", 758 mlog(0, "Clean up truncate log %llu\n",
758 (unsigned long long)tl_dinode->i_blkno); 759 (unsigned long long)le64_to_cpu(tl_dinode->i_blkno));
759 760
760 ret = ocfs2_complete_truncate_log_recovery(osb, 761 ret = ocfs2_complete_truncate_log_recovery(osb,
761 tl_dinode); 762 tl_dinode);
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 2bcf353fd7c5..36289e6295ce 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -578,8 +578,9 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
578 if (ocfs2_populate_inode(inode, fe, 1) < 0) { 578 if (ocfs2_populate_inode(inode, fe, 1) < 0) {
579 mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, " 579 mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, "
580 "i_blkno=%llu, i_ino=%lu\n", 580 "i_blkno=%llu, i_ino=%lu\n",
581 (unsigned long long) (*new_fe_bh)->b_blocknr, 581 (unsigned long long)(*new_fe_bh)->b_blocknr,
582 (unsigned long long)fe->i_blkno, inode->i_ino); 582 (unsigned long long)le64_to_cpu(fe->i_blkno),
583 inode->i_ino);
583 BUG(); 584 BUG();
584 } 585 }
585 586
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 82cc92dcf8a6..a860633e833f 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -363,9 +363,9 @@ static inline int ocfs2_mount_local(struct ocfs2_super *osb)
363 typeof(__di) ____di = (__di); \ 363 typeof(__di) ____di = (__di); \
364 ocfs2_error((__sb), \ 364 ocfs2_error((__sb), \
365 "Dinode # %llu has bad signature %.*s", \ 365 "Dinode # %llu has bad signature %.*s", \
366 (unsigned long long)(____di)->i_blkno, 7, \ 366 (unsigned long long)le64_to_cpu((____di)->i_blkno), 7, \
367 (____di)->i_signature); \ 367 (____di)->i_signature); \
368} while (0); 368} while (0)
369 369
370#define OCFS2_IS_VALID_EXTENT_BLOCK(ptr) \ 370#define OCFS2_IS_VALID_EXTENT_BLOCK(ptr) \
371 (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE)) 371 (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE))
@@ -374,9 +374,9 @@ static inline int ocfs2_mount_local(struct ocfs2_super *osb)
374 typeof(__eb) ____eb = (__eb); \ 374 typeof(__eb) ____eb = (__eb); \
375 ocfs2_error((__sb), \ 375 ocfs2_error((__sb), \
376 "Extent Block # %llu has bad signature %.*s", \ 376 "Extent Block # %llu has bad signature %.*s", \
377 (unsigned long long)(____eb)->h_blkno, 7, \ 377 (unsigned long long)le64_to_cpu((____eb)->h_blkno), 7, \
378 (____eb)->h_signature); \ 378 (____eb)->h_signature); \
379} while (0); 379} while (0)
380 380
381#define OCFS2_IS_VALID_GROUP_DESC(ptr) \ 381#define OCFS2_IS_VALID_GROUP_DESC(ptr) \
382 (!strcmp((ptr)->bg_signature, OCFS2_GROUP_DESC_SIGNATURE)) 382 (!strcmp((ptr)->bg_signature, OCFS2_GROUP_DESC_SIGNATURE))
@@ -385,9 +385,9 @@ static inline int ocfs2_mount_local(struct ocfs2_super *osb)
385 typeof(__gd) ____gd = (__gd); \ 385 typeof(__gd) ____gd = (__gd); \
386 ocfs2_error((__sb), \ 386 ocfs2_error((__sb), \
387 "Group Descriptor # %llu has bad signature %.*s", \ 387 "Group Descriptor # %llu has bad signature %.*s", \
388 (unsigned long long)(____gd)->bg_blkno, 7, \ 388 (unsigned long long)le64_to_cpu((____gd)->bg_blkno), 7, \
389 (____gd)->bg_signature); \ 389 (____gd)->bg_signature); \
390} while (0); 390} while (0)
391 391
392static inline unsigned long ino_from_blkno(struct super_block *sb, 392static inline unsigned long ino_from_blkno(struct super_block *sb,
393 u64 blkno) 393 u64 blkno)
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
index 71306479c68f..f0d9eb08547a 100644
--- a/fs/ocfs2/ocfs2_fs.h
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -166,6 +166,8 @@
166 */ 166 */
167#define OCFS2_IOC_GETFLAGS _IOR('f', 1, long) 167#define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
168#define OCFS2_IOC_SETFLAGS _IOW('f', 2, long) 168#define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
169#define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int)
170#define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int)
169 171
170/* 172/*
171 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags) 173 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 0da655ae5d6f..e3437626d183 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -849,9 +849,9 @@ static int ocfs2_relink_block_group(handle_t *handle,
849 } 849 }
850 850
851 mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n", 851 mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n",
852 (unsigned long long)fe->i_blkno, chain, 852 (unsigned long long)le64_to_cpu(fe->i_blkno), chain,
853 (unsigned long long)bg->bg_blkno, 853 (unsigned long long)le64_to_cpu(bg->bg_blkno),
854 (unsigned long long)prev_bg->bg_blkno); 854 (unsigned long long)le64_to_cpu(prev_bg->bg_blkno));
855 855
856 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); 856 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno);
857 bg_ptr = le64_to_cpu(bg->bg_next_group); 857 bg_ptr = le64_to_cpu(bg->bg_next_group);
@@ -1162,7 +1162,7 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1162 } 1162 }
1163 1163
1164 mlog(0, "alloc succeeds: we give %u bits from block group %llu\n", 1164 mlog(0, "alloc succeeds: we give %u bits from block group %llu\n",
1165 tmp_bits, (unsigned long long)bg->bg_blkno); 1165 tmp_bits, (unsigned long long)le64_to_cpu(bg->bg_blkno));
1166 1166
1167 *num_bits = tmp_bits; 1167 *num_bits = tmp_bits;
1168 1168
@@ -1227,7 +1227,7 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1227 } 1227 }
1228 1228
1229 mlog(0, "Allocated %u bits from suballocator %llu\n", *num_bits, 1229 mlog(0, "Allocated %u bits from suballocator %llu\n", *num_bits,
1230 (unsigned long long)fe->i_blkno); 1230 (unsigned long long)le64_to_cpu(fe->i_blkno));
1231 1231
1232 *bg_blkno = le64_to_cpu(bg->bg_blkno); 1232 *bg_blkno = le64_to_cpu(bg->bg_blkno);
1233 *bits_left = le16_to_cpu(bg->bg_free_bits_count); 1233 *bits_left = le16_to_cpu(bg->bg_free_bits_count);
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 5c9e8243691f..f5493540d94f 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1538,7 +1538,7 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di,
1538 } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) { 1538 } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) {
1539 mlog(ML_ERROR, "bad block number on superblock: " 1539 mlog(ML_ERROR, "bad block number on superblock: "
1540 "found %llu, should be %llu\n", 1540 "found %llu, should be %llu\n",
1541 (unsigned long long)di->i_blkno, 1541 (unsigned long long)le64_to_cpu(di->i_blkno),
1542 (unsigned long long)bh->b_blocknr); 1542 (unsigned long long)bh->b_blocknr);
1543 } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 || 1543 } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 ||
1544 le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) { 1544 le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) {
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 8a7d0035ad7a..f01572fca02f 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -312,7 +312,7 @@ static struct attribute * default_attrs[] = {
312 NULL, 312 NULL,
313}; 313};
314 314
315extern struct subsystem block_subsys; 315extern struct kset block_subsys;
316 316
317static void part_release(struct kobject *kobj) 317static void part_release(struct kobject *kobj)
318{ 318{
@@ -388,7 +388,7 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
388 kobject_add(&p->kobj); 388 kobject_add(&p->kobj);
389 if (!disk->part_uevent_suppress) 389 if (!disk->part_uevent_suppress)
390 kobject_uevent(&p->kobj, KOBJ_ADD); 390 kobject_uevent(&p->kobj, KOBJ_ADD);
391 sysfs_create_link(&p->kobj, &block_subsys.kset.kobj, "subsystem"); 391 sysfs_create_link(&p->kobj, &block_subsys.kobj, "subsystem");
392 if (flags & ADDPART_FLAG_WHOLEDISK) { 392 if (flags & ADDPART_FLAG_WHOLEDISK) {
393 static struct attribute addpartattr = { 393 static struct attribute addpartattr = {
394 .name = "whole_disk", 394 .name = "whole_disk",
@@ -444,7 +444,7 @@ static int disk_sysfs_symlinks(struct gendisk *disk)
444 goto err_out_dev_link; 444 goto err_out_dev_link;
445 } 445 }
446 446
447 err = sysfs_create_link(&disk->kobj, &block_subsys.kset.kobj, 447 err = sysfs_create_link(&disk->kobj, &block_subsys.kobj,
448 "subsystem"); 448 "subsystem");
449 if (err) 449 if (err)
450 goto err_out_disk_name_lnk; 450 goto err_out_disk_name_lnk;
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 8ea2a51ce883..d3b9f5f07db1 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -59,7 +59,7 @@ read(struct file * file, char __user * userbuf, size_t count, loff_t * off)
59 if (copy_to_user(userbuf, buffer, count)) 59 if (copy_to_user(userbuf, buffer, count))
60 return -EFAULT; 60 return -EFAULT;
61 61
62 pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count); 62 pr_debug("offs = %lld, *off = %lld, count = %zd\n", offs, *off, count);
63 63
64 *off = offs + count; 64 *off = offs + count;
65 65
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index db0413a411d6..0e637adc2b87 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -13,8 +13,7 @@
13 13
14#include "sysfs.h" 14#include "sysfs.h"
15 15
16#define to_subsys(k) container_of(k,struct subsystem,kset.kobj) 16#define to_sattr(a) container_of(a,struct subsys_attribute, attr)
17#define to_sattr(a) container_of(a,struct subsys_attribute,attr)
18 17
19/* 18/*
20 * Subsystem file operations. 19 * Subsystem file operations.
@@ -24,12 +23,12 @@
24static ssize_t 23static ssize_t
25subsys_attr_show(struct kobject * kobj, struct attribute * attr, char * page) 24subsys_attr_show(struct kobject * kobj, struct attribute * attr, char * page)
26{ 25{
27 struct subsystem * s = to_subsys(kobj); 26 struct kset *kset = to_kset(kobj);
28 struct subsys_attribute * sattr = to_sattr(attr); 27 struct subsys_attribute * sattr = to_sattr(attr);
29 ssize_t ret = -EIO; 28 ssize_t ret = -EIO;
30 29
31 if (sattr->show) 30 if (sattr->show)
32 ret = sattr->show(s,page); 31 ret = sattr->show(kset, page);
33 return ret; 32 return ret;
34} 33}
35 34
@@ -37,12 +36,12 @@ static ssize_t
37subsys_attr_store(struct kobject * kobj, struct attribute * attr, 36subsys_attr_store(struct kobject * kobj, struct attribute * attr,
38 const char * page, size_t count) 37 const char * page, size_t count)
39{ 38{
40 struct subsystem * s = to_subsys(kobj); 39 struct kset *kset = to_kset(kobj);
41 struct subsys_attribute * sattr = to_sattr(attr); 40 struct subsys_attribute * sattr = to_sattr(attr);
42 ssize_t ret = -EIO; 41 ssize_t ret = -EIO;
43 42
44 if (sattr->store) 43 if (sattr->store)
45 ret = sattr->store(s,page,count); 44 ret = sattr->store(kset, page, count);
46 return ret; 45 return ret;
47} 46}
48 47
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 0d9f984a60a1..16c3c441256e 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -316,7 +316,7 @@ struct acpi_bus_event {
316 u32 data; 316 u32 data;
317}; 317};
318 318
319extern struct subsystem acpi_subsys; 319extern struct kset acpi_subsys;
320 320
321/* 321/*
322 * External Functions 322 * External Functions
diff --git a/include/asm-alpha/scatterlist.h b/include/asm-alpha/scatterlist.h
index 6afb8bd3aaf9..917365405e83 100644
--- a/include/asm-alpha/scatterlist.h
+++ b/include/asm-alpha/scatterlist.h
@@ -2,6 +2,7 @@
2#define _ALPHA_SCATTERLIST_H 2#define _ALPHA_SCATTERLIST_H
3 3
4#include <asm/page.h> 4#include <asm/page.h>
5#include <asm/types.h>
5 6
6struct scatterlist { 7struct scatterlist {
7 struct page *page; 8 struct page *page;
diff --git a/include/asm-arm/arch-imx/mmc.h b/include/asm-arm/arch-imx/mmc.h
index 1937151665c7..84c726934ace 100644
--- a/include/asm-arm/arch-imx/mmc.h
+++ b/include/asm-arm/arch-imx/mmc.h
@@ -1,7 +1,7 @@
1#ifndef ASMARM_ARCH_MMC_H 1#ifndef ASMARM_ARCH_MMC_H
2#define ASMARM_ARCH_MMC_H 2#define ASMARM_ARCH_MMC_H
3 3
4#include <linux/mmc/protocol.h> 4#include <linux/mmc/host.h>
5 5
6struct imxmmc_platform_data { 6struct imxmmc_platform_data {
7 int (*card_present)(void); 7 int (*card_present)(void);
diff --git a/include/asm-arm/arch-ixp4xx/dma.h b/include/asm-arm/arch-ixp4xx/dma.h
index 789f7f53c357..2c7f5327d80f 100644
--- a/include/asm-arm/arch-ixp4xx/dma.h
+++ b/include/asm-arm/arch-ixp4xx/dma.h
@@ -12,7 +12,6 @@
12#define __ASM_ARCH_DMA_H 12#define __ASM_ARCH_DMA_H
13 13
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/pci.h>
16#include <asm/page.h> 15#include <asm/page.h>
17#include <asm/sizes.h> 16#include <asm/sizes.h>
18#include <asm/hardware.h> 17#include <asm/hardware.h>
diff --git a/include/asm-arm/arch-pxa/mmc.h b/include/asm-arm/arch-pxa/mmc.h
index a38a28c4bbd8..ef4f570381d1 100644
--- a/include/asm-arm/arch-pxa/mmc.h
+++ b/include/asm-arm/arch-pxa/mmc.h
@@ -1,7 +1,7 @@
1#ifndef ASMARM_ARCH_MMC_H 1#ifndef ASMARM_ARCH_MMC_H
2#define ASMARM_ARCH_MMC_H 2#define ASMARM_ARCH_MMC_H
3 3
4#include <linux/mmc/protocol.h> 4#include <linux/mmc/host.h>
5#include <linux/interrupt.h> 5#include <linux/interrupt.h>
6 6
7struct device; 7struct device;
diff --git a/include/asm-arm/arch-pxa/pxa27x_keyboard.h b/include/asm-arm/arch-pxa/pxa27x_keyboard.h
new file mode 100644
index 000000000000..3aaff923b2ca
--- /dev/null
+++ b/include/asm-arm/arch-pxa/pxa27x_keyboard.h
@@ -0,0 +1,13 @@
1#define PXAKBD_MAXROW 8
2#define PXAKBD_MAXCOL 8
3
4struct pxa27x_keyboard_platform_data {
5 int nr_rows, nr_cols;
6 int keycodes[PXAKBD_MAXROW][PXAKBD_MAXCOL];
7 int gpio_modes[PXAKBD_MAXROW + PXAKBD_MAXCOL];
8
9#ifdef CONFIG_PM
10 u32 reg_kpc;
11 u32 reg_kprec;
12#endif
13};
diff --git a/include/asm-arm/mach/mmc.h b/include/asm-arm/mach/mmc.h
index 1b3555d4b41e..eb91145c00c4 100644
--- a/include/asm-arm/mach/mmc.h
+++ b/include/asm-arm/mach/mmc.h
@@ -4,7 +4,7 @@
4#ifndef ASMARM_MACH_MMC_H 4#ifndef ASMARM_MACH_MMC_H
5#define ASMARM_MACH_MMC_H 5#define ASMARM_MACH_MMC_H
6 6
7#include <linux/mmc/protocol.h> 7#include <linux/mmc/host.h>
8 8
9struct mmc_platform_data { 9struct mmc_platform_data {
10 unsigned int ocr_mask; /* available voltages */ 10 unsigned int ocr_mask; /* available voltages */
diff --git a/include/asm-avr32/scatterlist.h b/include/asm-avr32/scatterlist.h
index bfe7d753423c..c6d5ce3b3a25 100644
--- a/include/asm-avr32/scatterlist.h
+++ b/include/asm-avr32/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_AVR32_SCATTERLIST_H 1#ifndef __ASM_AVR32_SCATTERLIST_H
2#define __ASM_AVR32_SCATTERLIST_H 2#define __ASM_AVR32_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h
index fb38fd329a5f..8e827fa853f1 100644
--- a/include/asm-frv/scatterlist.h
+++ b/include/asm-frv/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_SCATTERLIST_H 1#ifndef _ASM_SCATTERLIST_H
2#define _ASM_SCATTERLIST_H 2#define _ASM_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4/* 6/*
5 * Drivers must set either ->address or (preferred) ->page and ->offset 7 * Drivers must set either ->address or (preferred) ->page and ->offset
6 * to indicate where data must be transferred to/from. 8 * to indicate where data must be transferred to/from.
diff --git a/include/asm-h8300/scatterlist.h b/include/asm-h8300/scatterlist.h
index 7627f0cd1a2f..985fdf54eaca 100644
--- a/include/asm-h8300/scatterlist.h
+++ b/include/asm-h8300/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _H8300_SCATTERLIST_H 1#ifndef _H8300_SCATTERLIST_H
2#define _H8300_SCATTERLIST_H 2#define _H8300_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-i386/agp.h b/include/asm-i386/agp.h
index 9075083bab76..6af173dbf123 100644
--- a/include/asm-i386/agp.h
+++ b/include/asm-i386/agp.h
@@ -12,8 +12,10 @@
12 * data corruption on some CPUs. 12 * data corruption on some CPUs.
13 */ 13 */
14 14
15int map_page_into_agp(struct page *page); 15/* Caller's responsibility to call global_flush_tlb() for
16int unmap_page_from_agp(struct page *page); 16 * performance reasons */
17#define map_page_into_agp(page) change_page_attr(page, 1, PAGE_KERNEL_NOCACHE)
18#define unmap_page_from_agp(page) change_page_attr(page, 1, PAGE_KERNEL)
17#define flush_agp_mappings() global_flush_tlb() 19#define flush_agp_mappings() global_flush_tlb()
18 20
19/* Could use CLFLUSH here if the cpu supports it. But then it would 21/* Could use CLFLUSH here if the cpu supports it. But then it would
diff --git a/include/asm-i386/scatterlist.h b/include/asm-i386/scatterlist.h
index 55d6c953a76e..d7e45a8f1aae 100644
--- a/include/asm-i386/scatterlist.h
+++ b/include/asm-i386/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _I386_SCATTERLIST_H 1#ifndef _I386_SCATTERLIST_H
2#define _I386_SCATTERLIST_H 2#define _I386_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-i386/voyager.h b/include/asm-i386/voyager.h
index 5b27838905b2..91a9932937ab 100644
--- a/include/asm-i386/voyager.h
+++ b/include/asm-i386/voyager.h
@@ -487,15 +487,11 @@ extern struct voyager_qic_cpi *voyager_quad_cpi_addr[NR_CPUS];
487extern struct voyager_SUS *voyager_SUS; 487extern struct voyager_SUS *voyager_SUS;
488 488
489/* variables exported always */ 489/* variables exported always */
490extern struct task_struct *voyager_thread;
490extern int voyager_level; 491extern int voyager_level;
491extern int kvoyagerd_running;
492extern struct semaphore kvoyagerd_sem;
493extern struct voyager_status voyager_status; 492extern struct voyager_status voyager_status;
494 493
495
496
497/* functions exported by the voyager and voyager_smp modules */ 494/* functions exported by the voyager and voyager_smp modules */
498
499extern int voyager_cat_readb(__u8 module, __u8 asic, int reg); 495extern int voyager_cat_readb(__u8 module, __u8 asic, int reg);
500extern void voyager_cat_init(void); 496extern void voyager_cat_init(void);
501extern void voyager_detect(struct voyager_bios_info *); 497extern void voyager_detect(struct voyager_bios_info *);
diff --git a/include/asm-ia64/scatterlist.h b/include/asm-ia64/scatterlist.h
index 9dbea8844d5e..a452ea24205a 100644
--- a/include/asm-ia64/scatterlist.h
+++ b/include/asm-ia64/scatterlist.h
@@ -6,6 +6,8 @@
6 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co 6 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
7 */ 7 */
8 8
9#include <asm/types.h>
10
9struct scatterlist { 11struct scatterlist {
10 struct page *page; 12 struct page *page;
11 unsigned int offset; 13 unsigned int offset;
diff --git a/include/asm-m32r/scatterlist.h b/include/asm-m32r/scatterlist.h
index c2de96cb69ed..352415ff5eb9 100644
--- a/include/asm-m32r/scatterlist.h
+++ b/include/asm-m32r/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_M32R_SCATTERLIST_H 1#ifndef _ASM_M32R_SCATTERLIST_H
2#define _ASM_M32R_SCATTERLIST_H 2#define _ASM_M32R_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 char * address; /* Location data is to be transferred to, NULL for 7 char * address; /* Location data is to be transferred to, NULL for
6 * highmem page */ 8 * highmem page */
diff --git a/include/asm-m68k/adb.h b/include/asm-m68k/adb.h
deleted file mode 100644
index 9176b55185bb..000000000000
--- a/include/asm-m68k/adb.h
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * Definitions for talking to ADB and CUDA. The CUDA is a microcontroller
3 * which controls the ADB, system power, RTC, and various other things on
4 * later Macintoshes
5 *
6 * Copyright (C) 1996 Paul Mackerras.
7 */
8
9/* First byte sent to or received from CUDA */
10#define ADB_PACKET 0
11#define CUDA_PACKET 1
12#define ERROR_PACKET 2
13#define TIMER_PACKET 3
14#define POWER_PACKET 4
15#define MACIIC_PACKET 5
16
17/* ADB commands (2nd byte) */
18#define ADB_BUSRESET 0
19#define ADB_FLUSH(id) (1 + ((id) << 4))
20#define ADB_WRITEREG(id, reg) (8 + (reg) + ((id) << 4))
21#define ADB_READREG(id, reg) (0xc + (reg) + ((id) << 4))
22
23/* ADB default device IDs (upper 4 bits of 2nd byte) */
24#define ADB_DONGLE 1 /* "software execution control" devices */
25#define ADB_KEYBOARD 2
26#define ADB_MOUSE 3
27#define ADB_TABLET 4
28#define ADB_MODEM 5
29#define ADB_MISC 7 /* maybe a monitor */
30
31/* CUDA commands (2nd byte) */
32#define CUDA_WARM_START 0
33#define CUDA_AUTOPOLL 1
34#define CUDA_GET_6805_ADDR 2
35#define CUDA_GET_TIME 3
36#define CUDA_GET_PRAM 7
37#define CUDA_SET_6805_ADDR 8
38#define CUDA_SET_TIME 9
39#define CUDA_POWERDOWN 0xa
40#define CUDA_POWERUP_TIME 0xb
41#define CUDA_SET_PRAM 0xc
42#define CUDA_MS_RESET 0xd
43#define CUDA_SEND_DFAC 0xe
44#define CUDA_RESET_SYSTEM 0x11
45#define CUDA_SET_IPL 0x12
46#define CUDA_SET_AUTO_RATE 0x14
47#define CUDA_GET_AUTO_RATE 0x16
48#define CUDA_SET_DEVICE_LIST 0x19
49#define CUDA_GET_DEVICE_LIST 0x1a
50#define CUDA_GET_SET_IIC 0x22
51
52#ifdef __KERNEL__
53
54struct adb_request {
55 unsigned char data[16];
56 int nbytes;
57 unsigned char reply[16];
58 int reply_len;
59 unsigned char reply_expected;
60 unsigned char sent;
61 unsigned char got_reply;
62 void (*done)(struct adb_request *);
63 void *arg;
64 struct adb_request *next;
65};
66
67void via_adb_init(void);
68int adb_request(struct adb_request *req,
69 void (*done)(struct adb_request *), int nbytes, ...);
70int adb_send_request(struct adb_request *req);
71void adb_poll(void);
72int adb_register(int default_id,
73 void (*handler)(unsigned char *, int, struct pt_regs *));
74
75#endif /* __KERNEL */
diff --git a/include/asm-m68k/atarikb.h b/include/asm-m68k/atarikb.h
index 18926058fde7..546e7da5804f 100644
--- a/include/asm-m68k/atarikb.h
+++ b/include/asm-m68k/atarikb.h
@@ -36,5 +36,11 @@ void ikbd_joystick_disable(void);
36extern void (*atari_MIDI_interrupt_hook) (void); 36extern void (*atari_MIDI_interrupt_hook) (void);
37/* Hook for mouse driver */ 37/* Hook for mouse driver */
38extern void (*atari_mouse_interrupt_hook) (char *); 38extern void (*atari_mouse_interrupt_hook) (char *);
39/* Hook for keyboard inputdev driver */
40extern void (*atari_input_keyboard_interrupt_hook) (unsigned char, char);
41/* Hook for mouse inputdev driver */
42extern void (*atari_input_mouse_interrupt_hook) (char *);
43
44int atari_keyb_init(void);
39 45
40#endif /* _LINUX_ATARIKB_H */ 46#endif /* _LINUX_ATARIKB_H */
diff --git a/include/asm-m68knommu/scatterlist.h b/include/asm-m68knommu/scatterlist.h
index 2085d6ff8782..4da79d3d3f34 100644
--- a/include/asm-m68knommu/scatterlist.h
+++ b/include/asm-m68knommu/scatterlist.h
@@ -2,6 +2,7 @@
2#define _M68KNOMMU_SCATTERLIST_H 2#define _M68KNOMMU_SCATTERLIST_H
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <asm/types.h>
5 6
6struct scatterlist { 7struct scatterlist {
7 struct page *page; 8 struct page *page;
diff --git a/include/asm-mips/scatterlist.h b/include/asm-mips/scatterlist.h
index 22634706e9d5..7af104c95b20 100644
--- a/include/asm-mips/scatterlist.h
+++ b/include/asm-mips/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_SCATTERLIST_H 1#ifndef __ASM_SCATTERLIST_H
2#define __ASM_SCATTERLIST_H 2#define __ASM_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page * page; 7 struct page * page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-parisc/scatterlist.h b/include/asm-parisc/scatterlist.h
index 236c1d0fba33..e7211c748446 100644
--- a/include/asm-parisc/scatterlist.h
+++ b/include/asm-parisc/scatterlist.h
@@ -2,6 +2,7 @@
2#define _ASM_PARISC_SCATTERLIST_H 2#define _ASM_PARISC_SCATTERLIST_H
3 3
4#include <asm/page.h> 4#include <asm/page.h>
5#include <asm/types.h>
5 6
6struct scatterlist { 7struct scatterlist {
7 struct page *page; 8 struct page *page;
diff --git a/include/asm-powerpc/ps3av.h b/include/asm-powerpc/ps3av.h
index 43e90ea96136..9efc40f1c778 100644
--- a/include/asm-powerpc/ps3av.h
+++ b/include/asm-powerpc/ps3av.h
@@ -18,8 +18,6 @@
18#ifndef _ASM_POWERPC_PS3AV_H_ 18#ifndef _ASM_POWERPC_PS3AV_H_
19#define _ASM_POWERPC_PS3AV_H_ 19#define _ASM_POWERPC_PS3AV_H_
20 20
21#include <linux/mutex.h>
22
23/** command for ioctl() **/ 21/** command for ioctl() **/
24#define PS3AV_VERSION 0x205 /* version of ps3av command */ 22#define PS3AV_VERSION 0x205 /* version of ps3av command */
25 23
@@ -643,24 +641,6 @@ struct ps3av_pkt_avb_param {
643 u8 buf[PS3AV_PKT_AVB_PARAM_MAX_BUF_SIZE]; 641 u8 buf[PS3AV_PKT_AVB_PARAM_MAX_BUF_SIZE];
644}; 642};
645 643
646struct ps3av {
647 int available;
648 struct semaphore sem;
649 struct semaphore ping;
650 struct semaphore pong;
651 struct mutex mutex;
652 int open_count;
653 struct ps3_vuart_port_device *dev;
654
655 int region;
656 struct ps3av_pkt_av_get_hw_conf av_hw_conf;
657 u32 av_port[PS3AV_AV_PORT_MAX + PS3AV_OPT_PORT_MAX];
658 u32 opt_port[PS3AV_OPT_PORT_MAX];
659 u32 head[PS3AV_HEAD_MAX];
660 u32 audio_port;
661 int ps3av_mode;
662 int ps3av_mode_old;
663};
664 644
665/** command status **/ 645/** command status **/
666#define PS3AV_STATUS_SUCCESS 0x0000 /* success */ 646#define PS3AV_STATUS_SUCCESS 0x0000 /* success */
@@ -718,6 +698,7 @@ static inline void ps3av_cmd_av_monitor_info_dump(const struct ps3av_pkt_av_get_
718extern int ps3av_cmd_video_get_monitor_info(struct ps3av_pkt_av_get_monitor_info *, 698extern int ps3av_cmd_video_get_monitor_info(struct ps3av_pkt_av_get_monitor_info *,
719 u32); 699 u32);
720 700
701struct ps3_vuart_port_device;
721extern int ps3av_vuart_write(struct ps3_vuart_port_device *dev, 702extern int ps3av_vuart_write(struct ps3_vuart_port_device *dev,
722 const void *buf, unsigned long size); 703 const void *buf, unsigned long size);
723extern int ps3av_vuart_read(struct ps3_vuart_port_device *dev, void *buf, 704extern int ps3av_vuart_read(struct ps3_vuart_port_device *dev, void *buf,
@@ -725,6 +706,7 @@ extern int ps3av_vuart_read(struct ps3_vuart_port_device *dev, void *buf,
725 706
726extern int ps3av_set_video_mode(u32, int); 707extern int ps3av_set_video_mode(u32, int);
727extern int ps3av_set_audio_mode(u32, u32, u32, u32, u32); 708extern int ps3av_set_audio_mode(u32, u32, u32, u32, u32);
709extern int ps3av_get_auto_mode(int);
728extern int ps3av_set_mode(u32, int); 710extern int ps3av_set_mode(u32, int);
729extern int ps3av_get_mode(void); 711extern int ps3av_get_mode(void);
730extern int ps3av_get_scanmode(int); 712extern int ps3av_get_scanmode(int);
diff --git a/include/asm-s390/ccwdev.h b/include/asm-s390/ccwdev.h
index cfc81533b9ba..6795ecefd15b 100644
--- a/include/asm-s390/ccwdev.h
+++ b/include/asm-s390/ccwdev.h
@@ -164,9 +164,9 @@ extern int ccw_device_resume(struct ccw_device *);
164extern int ccw_device_halt(struct ccw_device *, unsigned long); 164extern int ccw_device_halt(struct ccw_device *, unsigned long);
165extern int ccw_device_clear(struct ccw_device *, unsigned long); 165extern int ccw_device_clear(struct ccw_device *, unsigned long);
166 166
167extern int read_dev_chars(struct ccw_device *cdev, void **buffer, int length); 167extern int __deprecated read_dev_chars(struct ccw_device *cdev, void **buffer, int length);
168extern int read_conf_data(struct ccw_device *cdev, void **buffer, int *length); 168extern int __deprecated read_conf_data(struct ccw_device *cdev, void **buffer, int *length);
169extern int read_conf_data_lpm(struct ccw_device *cdev, void **buffer, 169extern int __deprecated read_conf_data_lpm(struct ccw_device *cdev, void **buffer,
170 int *length, __u8 lpm); 170 int *length, __u8 lpm);
171 171
172extern int ccw_device_set_online(struct ccw_device *cdev); 172extern int ccw_device_set_online(struct ccw_device *cdev);
diff --git a/include/asm-s390/elf.h b/include/asm-s390/elf.h
index c0d629d61d3e..91d06325cc79 100644
--- a/include/asm-s390/elf.h
+++ b/include/asm-s390/elf.h
@@ -188,7 +188,8 @@ static inline int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
188/* This yields a mask that user programs can use to figure out what 188/* This yields a mask that user programs can use to figure out what
189 instruction set this CPU supports. */ 189 instruction set this CPU supports. */
190 190
191#define ELF_HWCAP (0) 191extern unsigned long elf_hwcap;
192#define ELF_HWCAP (elf_hwcap)
192 193
193/* This yields a string that ld.so will use to load implementation 194/* This yields a string that ld.so will use to load implementation
194 specific libraries for optimization. This is more specific in 195 specific libraries for optimization. This is more specific in
@@ -197,7 +198,9 @@ static inline int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
197 For the moment, we have only optimizations for the Intel generations, 198 For the moment, we have only optimizations for the Intel generations,
198 but that could change... */ 199 but that could change... */
199 200
200#define ELF_PLATFORM (NULL) 201#define ELF_PLATFORM_SIZE 8
202extern char elf_platform[];
203#define ELF_PLATFORM (elf_platform)
201 204
202#ifndef __s390x__ 205#ifndef __s390x__
203#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 206#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
diff --git a/include/asm-s390/kdebug.h b/include/asm-s390/kdebug.h
index 1b50f89819a4..d2d7ad276148 100644
--- a/include/asm-s390/kdebug.h
+++ b/include/asm-s390/kdebug.h
@@ -22,8 +22,21 @@ struct die_args {
22 */ 22 */
23extern int register_die_notifier(struct notifier_block *); 23extern int register_die_notifier(struct notifier_block *);
24extern int unregister_die_notifier(struct notifier_block *); 24extern int unregister_die_notifier(struct notifier_block *);
25extern int register_page_fault_notifier(struct notifier_block *); 25
26extern int unregister_page_fault_notifier(struct notifier_block *); 26/*
27 * These are only here because kprobes.c wants them to implement a
28 * blatant layering violation. Will hopefully go away soon once all
29 * architectures are updated.
30 */
31static inline int register_page_fault_notifier(struct notifier_block *nb)
32{
33 return 0;
34}
35static inline int unregister_page_fault_notifier(struct notifier_block *nb)
36{
37 return 0;
38}
39
27extern struct atomic_notifier_head s390die_chain; 40extern struct atomic_notifier_head s390die_chain;
28 41
29enum die_val { 42enum die_val {
@@ -39,7 +52,6 @@ enum die_val {
39 DIE_GPF, 52 DIE_GPF,
40 DIE_CALL, 53 DIE_CALL,
41 DIE_NMI_IPI, 54 DIE_NMI_IPI,
42 DIE_PAGE_FAULT,
43}; 55};
44 56
45static inline int notify_die(enum die_val val, const char *str, 57static inline int notify_die(enum die_val val, const char *str,
diff --git a/include/asm-s390/kprobes.h b/include/asm-s390/kprobes.h
index b847ff0ec3fa..830fe4c4eea6 100644
--- a/include/asm-s390/kprobes.h
+++ b/include/asm-s390/kprobes.h
@@ -97,18 +97,10 @@ void kretprobe_trampoline(void);
97int is_prohibited_opcode(kprobe_opcode_t *instruction); 97int is_prohibited_opcode(kprobe_opcode_t *instruction);
98void get_instruction_type(struct arch_specific_insn *ainsn); 98void get_instruction_type(struct arch_specific_insn *ainsn);
99 99
100int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
101int kprobe_exceptions_notify(struct notifier_block *self,
102 unsigned long val, void *data);
103
100#define flush_insn_slot(p) do { } while (0) 104#define flush_insn_slot(p) do { } while (0)
101 105
102#endif /* _ASM_S390_KPROBES_H */ 106#endif /* _ASM_S390_KPROBES_H */
103
104#ifdef CONFIG_KPROBES
105
106extern int kprobe_exceptions_notify(struct notifier_block *self,
107 unsigned long val, void *data);
108#else /* !CONFIG_KPROBES */
109static inline int kprobe_exceptions_notify(struct notifier_block *self,
110 unsigned long val, void *data)
111{
112 return 0;
113}
114#endif
diff --git a/include/asm-s390/lowcore.h b/include/asm-s390/lowcore.h
index ffc9788a21a7..801a6fd35b5b 100644
--- a/include/asm-s390/lowcore.h
+++ b/include/asm-s390/lowcore.h
@@ -229,17 +229,19 @@ struct _lowcore
229 __u16 subchannel_nr; /* 0x0ba */ 229 __u16 subchannel_nr; /* 0x0ba */
230 __u32 io_int_parm; /* 0x0bc */ 230 __u32 io_int_parm; /* 0x0bc */
231 __u32 io_int_word; /* 0x0c0 */ 231 __u32 io_int_word; /* 0x0c0 */
232 __u8 pad3[0xD4-0xC4]; /* 0x0c4 */ 232 __u8 pad3[0xc8-0xc4]; /* 0x0c4 */
233 __u32 stfl_fac_list; /* 0x0c8 */
234 __u8 pad4[0xd4-0xcc]; /* 0x0cc */
233 __u32 extended_save_area_addr; /* 0x0d4 */ 235 __u32 extended_save_area_addr; /* 0x0d4 */
234 __u32 cpu_timer_save_area[2]; /* 0x0d8 */ 236 __u32 cpu_timer_save_area[2]; /* 0x0d8 */
235 __u32 clock_comp_save_area[2]; /* 0x0e0 */ 237 __u32 clock_comp_save_area[2]; /* 0x0e0 */
236 __u32 mcck_interruption_code[2]; /* 0x0e8 */ 238 __u32 mcck_interruption_code[2]; /* 0x0e8 */
237 __u8 pad4[0xf4-0xf0]; /* 0x0f0 */ 239 __u8 pad5[0xf4-0xf0]; /* 0x0f0 */
238 __u32 external_damage_code; /* 0x0f4 */ 240 __u32 external_damage_code; /* 0x0f4 */
239 __u32 failing_storage_address; /* 0x0f8 */ 241 __u32 failing_storage_address; /* 0x0f8 */
240 __u8 pad5[0x100-0xfc]; /* 0x0fc */ 242 __u8 pad6[0x100-0xfc]; /* 0x0fc */
241 __u32 st_status_fixed_logout[4];/* 0x100 */ 243 __u32 st_status_fixed_logout[4];/* 0x100 */
242 __u8 pad6[0x120-0x110]; /* 0x110 */ 244 __u8 pad7[0x120-0x110]; /* 0x110 */
243 __u32 access_regs_save_area[16];/* 0x120 */ 245 __u32 access_regs_save_area[16];/* 0x120 */
244 __u32 floating_pt_save_area[8]; /* 0x160 */ 246 __u32 floating_pt_save_area[8]; /* 0x160 */
245 __u32 gpregs_save_area[16]; /* 0x180 */ 247 __u32 gpregs_save_area[16]; /* 0x180 */
diff --git a/include/asm-sh/scatterlist.h b/include/asm-sh/scatterlist.h
index d19e7cd3b023..b9ae53c38365 100644
--- a/include/asm-sh/scatterlist.h
+++ b/include/asm-sh/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_SH_SCATTERLIST_H 1#ifndef __ASM_SH_SCATTERLIST_H
2#define __ASM_SH_SCATTERLIST_H 2#define __ASM_SH_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page * page; /* Location for highmem page, if any */ 7 struct page * page; /* Location for highmem page, if any */
6 unsigned int offset;/* for highmem, page offset */ 8 unsigned int offset;/* for highmem, page offset */
diff --git a/include/asm-sh64/scatterlist.h b/include/asm-sh64/scatterlist.h
index 5d8fa32d2e9d..1c723f2d7a95 100644
--- a/include/asm-sh64/scatterlist.h
+++ b/include/asm-sh64/scatterlist.h
@@ -11,6 +11,8 @@
11#ifndef __ASM_SH64_SCATTERLIST_H 11#ifndef __ASM_SH64_SCATTERLIST_H
12#define __ASM_SH64_SCATTERLIST_H 12#define __ASM_SH64_SCATTERLIST_H
13 13
14#include <asm/types.h>
15
14struct scatterlist { 16struct scatterlist {
15 struct page * page; /* Location for highmem page, if any */ 17 struct page * page; /* Location for highmem page, if any */
16 unsigned int offset;/* for highmem, page offset */ 18 unsigned int offset;/* for highmem, page offset */
diff --git a/include/asm-sparc64/scatterlist.h b/include/asm-sparc64/scatterlist.h
index ec4f3c63fe98..048fdb40e81d 100644
--- a/include/asm-sparc64/scatterlist.h
+++ b/include/asm-sparc64/scatterlist.h
@@ -3,6 +3,7 @@
3#define _SPARC64_SCATTERLIST_H 3#define _SPARC64_SCATTERLIST_H
4 4
5#include <asm/page.h> 5#include <asm/page.h>
6#include <asm/types.h>
6 7
7struct scatterlist { 8struct scatterlist {
8 struct page *page; 9 struct page *page;
diff --git a/include/asm-v850/scatterlist.h b/include/asm-v850/scatterlist.h
index af1cba69a526..56f402920db9 100644
--- a/include/asm-v850/scatterlist.h
+++ b/include/asm-v850/scatterlist.h
@@ -14,6 +14,8 @@
14#ifndef __V850_SCATTERLIST_H__ 14#ifndef __V850_SCATTERLIST_H__
15#define __V850_SCATTERLIST_H__ 15#define __V850_SCATTERLIST_H__
16 16
17#include <asm/types.h>
18
17struct scatterlist { 19struct scatterlist {
18 struct page *page; 20 struct page *page;
19 unsigned offset; 21 unsigned offset;
diff --git a/include/asm-x86_64/agp.h b/include/asm-x86_64/agp.h
index 06c52ee9c06b..de338666f3f9 100644
--- a/include/asm-x86_64/agp.h
+++ b/include/asm-x86_64/agp.h
@@ -10,8 +10,10 @@
10 * with different cachability attributes for the same page. 10 * with different cachability attributes for the same page.
11 */ 11 */
12 12
13int map_page_into_agp(struct page *page); 13/* Caller's responsibility to call global_flush_tlb() for
14int unmap_page_from_agp(struct page *page); 14 * performance reasons */
15#define map_page_into_agp(page) change_page_attr(page, 1, PAGE_KERNEL_NOCACHE)
16#define unmap_page_from_agp(page) change_page_attr(page, 1, PAGE_KERNEL)
15#define flush_agp_mappings() global_flush_tlb() 17#define flush_agp_mappings() global_flush_tlb()
16 18
17/* Could use CLFLUSH here if the cpu supports it. But then it would 19/* Could use CLFLUSH here if the cpu supports it. But then it would
diff --git a/include/asm-x86_64/scatterlist.h b/include/asm-x86_64/scatterlist.h
index 49d89f8129cd..eaf7ada27e14 100644
--- a/include/asm-x86_64/scatterlist.h
+++ b/include/asm-x86_64/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _X8664_SCATTERLIST_H 1#ifndef _X8664_SCATTERLIST_H
2#define _X8664_SCATTERLIST_H 2#define _X8664_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-xtensa/scatterlist.h b/include/asm-xtensa/scatterlist.h
index 38a2b9acd658..ca337a294290 100644
--- a/include/asm-xtensa/scatterlist.h
+++ b/include/asm-xtensa/scatterlist.h
@@ -11,6 +11,8 @@
11#ifndef _XTENSA_SCATTERLIST_H 11#ifndef _XTENSA_SCATTERLIST_H
12#define _XTENSA_SCATTERLIST_H 12#define _XTENSA_SCATTERLIST_H
13 13
14#include <asm/types.h>
15
14struct scatterlist { 16struct scatterlist {
15 struct page *page; 17 struct page *page;
16 unsigned int offset; 18 unsigned int offset;
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 4e05e93ff681..b2b1e6efd812 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -13,8 +13,11 @@
13#define _CRYPTO_ALGAPI_H 13#define _CRYPTO_ALGAPI_H
14 14
15#include <linux/crypto.h> 15#include <linux/crypto.h>
16#include <linux/list.h>
17#include <linux/kernel.h>
16 18
17struct module; 19struct module;
20struct rtattr;
18struct seq_file; 21struct seq_file;
19 22
20struct crypto_type { 23struct crypto_type {
@@ -38,7 +41,7 @@ struct crypto_template {
38 struct hlist_head instances; 41 struct hlist_head instances;
39 struct module *module; 42 struct module *module;
40 43
41 struct crypto_instance *(*alloc)(void *param, unsigned int len); 44 struct crypto_instance *(*alloc)(struct rtattr **tb);
42 void (*free)(struct crypto_instance *inst); 45 void (*free)(struct crypto_instance *inst);
43 46
44 char name[CRYPTO_MAX_ALG_NAME]; 47 char name[CRYPTO_MAX_ALG_NAME];
@@ -48,6 +51,15 @@ struct crypto_spawn {
48 struct list_head list; 51 struct list_head list;
49 struct crypto_alg *alg; 52 struct crypto_alg *alg;
50 struct crypto_instance *inst; 53 struct crypto_instance *inst;
54 u32 mask;
55};
56
57struct crypto_queue {
58 struct list_head list;
59 struct list_head *backlog;
60
61 unsigned int qlen;
62 unsigned int max_qlen;
51}; 63};
52 64
53struct scatter_walk { 65struct scatter_walk {
@@ -81,6 +93,7 @@ struct blkcipher_walk {
81 int flags; 93 int flags;
82}; 94};
83 95
96extern const struct crypto_type crypto_ablkcipher_type;
84extern const struct crypto_type crypto_blkcipher_type; 97extern const struct crypto_type crypto_blkcipher_type;
85extern const struct crypto_type crypto_hash_type; 98extern const struct crypto_type crypto_hash_type;
86 99
@@ -91,16 +104,23 @@ void crypto_unregister_template(struct crypto_template *tmpl);
91struct crypto_template *crypto_lookup_template(const char *name); 104struct crypto_template *crypto_lookup_template(const char *name);
92 105
93int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, 106int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
94 struct crypto_instance *inst); 107 struct crypto_instance *inst, u32 mask);
95void crypto_drop_spawn(struct crypto_spawn *spawn); 108void crypto_drop_spawn(struct crypto_spawn *spawn);
96struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, 109struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
97 u32 mask); 110 u32 mask);
98 111
99struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len, 112struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb);
100 u32 type, u32 mask); 113int crypto_check_attr_type(struct rtattr **tb, u32 type);
114struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask);
101struct crypto_instance *crypto_alloc_instance(const char *name, 115struct crypto_instance *crypto_alloc_instance(const char *name,
102 struct crypto_alg *alg); 116 struct crypto_alg *alg);
103 117
118void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen);
119int crypto_enqueue_request(struct crypto_queue *queue,
120 struct crypto_async_request *request);
121struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue);
122int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm);
123
104int blkcipher_walk_done(struct blkcipher_desc *desc, 124int blkcipher_walk_done(struct blkcipher_desc *desc,
105 struct blkcipher_walk *walk, int err); 125 struct blkcipher_walk *walk, int err);
106int blkcipher_walk_virt(struct blkcipher_desc *desc, 126int blkcipher_walk_virt(struct blkcipher_desc *desc,
@@ -118,11 +138,37 @@ static inline void *crypto_tfm_ctx_aligned(struct crypto_tfm *tfm)
118 return (void *)ALIGN(addr, align); 138 return (void *)ALIGN(addr, align);
119} 139}
120 140
141static inline struct crypto_instance *crypto_tfm_alg_instance(
142 struct crypto_tfm *tfm)
143{
144 return container_of(tfm->__crt_alg, struct crypto_instance, alg);
145}
146
121static inline void *crypto_instance_ctx(struct crypto_instance *inst) 147static inline void *crypto_instance_ctx(struct crypto_instance *inst)
122{ 148{
123 return inst->__ctx; 149 return inst->__ctx;
124} 150}
125 151
152static inline struct ablkcipher_alg *crypto_ablkcipher_alg(
153 struct crypto_ablkcipher *tfm)
154{
155 return &crypto_ablkcipher_tfm(tfm)->__crt_alg->cra_ablkcipher;
156}
157
158static inline void *crypto_ablkcipher_ctx(struct crypto_ablkcipher *tfm)
159{
160 return crypto_tfm_ctx(&tfm->base);
161}
162
163static inline struct crypto_blkcipher *crypto_spawn_blkcipher(
164 struct crypto_spawn *spawn)
165{
166 u32 type = CRYPTO_ALG_TYPE_BLKCIPHER;
167 u32 mask = CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC;
168
169 return __crypto_blkcipher_cast(crypto_spawn_tfm(spawn, type, mask));
170}
171
126static inline void *crypto_blkcipher_ctx(struct crypto_blkcipher *tfm) 172static inline void *crypto_blkcipher_ctx(struct crypto_blkcipher *tfm)
127{ 173{
128 return crypto_tfm_ctx(&tfm->base); 174 return crypto_tfm_ctx(&tfm->base);
@@ -170,5 +216,35 @@ static inline void blkcipher_walk_init(struct blkcipher_walk *walk,
170 walk->total = nbytes; 216 walk->total = nbytes;
171} 217}
172 218
219static inline struct crypto_async_request *crypto_get_backlog(
220 struct crypto_queue *queue)
221{
222 return queue->backlog == &queue->list ? NULL :
223 container_of(queue->backlog, struct crypto_async_request, list);
224}
225
226static inline int ablkcipher_enqueue_request(struct ablkcipher_alg *alg,
227 struct ablkcipher_request *request)
228{
229 return crypto_enqueue_request(alg->queue, &request->base);
230}
231
232static inline struct ablkcipher_request *ablkcipher_dequeue_request(
233 struct ablkcipher_alg *alg)
234{
235 return ablkcipher_request_cast(crypto_dequeue_request(alg->queue));
236}
237
238static inline void *ablkcipher_request_ctx(struct ablkcipher_request *req)
239{
240 return req->__ctx;
241}
242
243static inline int ablkcipher_tfm_in_queue(struct crypto_ablkcipher *tfm)
244{
245 return crypto_tfm_in_queue(crypto_ablkcipher_alg(tfm)->queue,
246 crypto_ablkcipher_tfm(tfm));
247}
248
173#endif /* _CRYPTO_ALGAPI_H */ 249#endif /* _CRYPTO_ALGAPI_H */
174 250
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index cb9b2ec8849c..963051a967d6 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -265,7 +265,6 @@ struct freq_attr {
265/********************************************************************* 265/*********************************************************************
266 * CPUFREQ 2.6. INTERFACE * 266 * CPUFREQ 2.6. INTERFACE *
267 *********************************************************************/ 267 *********************************************************************/
268int cpufreq_set_policy(struct cpufreq_policy *policy);
269int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); 268int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
270int cpufreq_update_policy(unsigned int cpu); 269int cpufreq_update_policy(unsigned int cpu);
271 270
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 779aa78ee643..0de7e2ace822 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -56,6 +56,7 @@
56 56
57#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100 57#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
58#define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200 58#define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200
59#define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
59#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000 60#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
60#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 61#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
61#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 62#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
@@ -88,11 +89,38 @@
88#endif 89#endif
89 90
90struct scatterlist; 91struct scatterlist;
92struct crypto_ablkcipher;
93struct crypto_async_request;
91struct crypto_blkcipher; 94struct crypto_blkcipher;
92struct crypto_hash; 95struct crypto_hash;
96struct crypto_queue;
93struct crypto_tfm; 97struct crypto_tfm;
94struct crypto_type; 98struct crypto_type;
95 99
100typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);
101
102struct crypto_async_request {
103 struct list_head list;
104 crypto_completion_t complete;
105 void *data;
106 struct crypto_tfm *tfm;
107
108 u32 flags;
109};
110
111struct ablkcipher_request {
112 struct crypto_async_request base;
113
114 unsigned int nbytes;
115
116 void *info;
117
118 struct scatterlist *src;
119 struct scatterlist *dst;
120
121 void *__ctx[] CRYPTO_MINALIGN_ATTR;
122};
123
96struct blkcipher_desc { 124struct blkcipher_desc {
97 struct crypto_blkcipher *tfm; 125 struct crypto_blkcipher *tfm;
98 void *info; 126 void *info;
@@ -116,6 +144,19 @@ struct hash_desc {
116 * Algorithms: modular crypto algorithm implementations, managed 144 * Algorithms: modular crypto algorithm implementations, managed
117 * via crypto_register_alg() and crypto_unregister_alg(). 145 * via crypto_register_alg() and crypto_unregister_alg().
118 */ 146 */
147struct ablkcipher_alg {
148 int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key,
149 unsigned int keylen);
150 int (*encrypt)(struct ablkcipher_request *req);
151 int (*decrypt)(struct ablkcipher_request *req);
152
153 struct crypto_queue *queue;
154
155 unsigned int min_keysize;
156 unsigned int max_keysize;
157 unsigned int ivsize;
158};
159
119struct blkcipher_alg { 160struct blkcipher_alg {
120 int (*setkey)(struct crypto_tfm *tfm, const u8 *key, 161 int (*setkey)(struct crypto_tfm *tfm, const u8 *key,
121 unsigned int keylen); 162 unsigned int keylen);
@@ -170,6 +211,7 @@ struct compress_alg {
170 unsigned int slen, u8 *dst, unsigned int *dlen); 211 unsigned int slen, u8 *dst, unsigned int *dlen);
171}; 212};
172 213
214#define cra_ablkcipher cra_u.ablkcipher
173#define cra_blkcipher cra_u.blkcipher 215#define cra_blkcipher cra_u.blkcipher
174#define cra_cipher cra_u.cipher 216#define cra_cipher cra_u.cipher
175#define cra_digest cra_u.digest 217#define cra_digest cra_u.digest
@@ -194,6 +236,7 @@ struct crypto_alg {
194 const struct crypto_type *cra_type; 236 const struct crypto_type *cra_type;
195 237
196 union { 238 union {
239 struct ablkcipher_alg ablkcipher;
197 struct blkcipher_alg blkcipher; 240 struct blkcipher_alg blkcipher;
198 struct cipher_alg cipher; 241 struct cipher_alg cipher;
199 struct digest_alg digest; 242 struct digest_alg digest;
@@ -232,6 +275,15 @@ static inline int crypto_has_alg(const char *name, u32 type, u32 mask)
232 * crypto_free_*(), as well as the various helpers below. 275 * crypto_free_*(), as well as the various helpers below.
233 */ 276 */
234 277
278struct ablkcipher_tfm {
279 int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key,
280 unsigned int keylen);
281 int (*encrypt)(struct ablkcipher_request *req);
282 int (*decrypt)(struct ablkcipher_request *req);
283 unsigned int ivsize;
284 unsigned int reqsize;
285};
286
235struct blkcipher_tfm { 287struct blkcipher_tfm {
236 void *iv; 288 void *iv;
237 int (*setkey)(struct crypto_tfm *tfm, const u8 *key, 289 int (*setkey)(struct crypto_tfm *tfm, const u8 *key,
@@ -290,6 +342,7 @@ struct compress_tfm {
290 u8 *dst, unsigned int *dlen); 342 u8 *dst, unsigned int *dlen);
291}; 343};
292 344
345#define crt_ablkcipher crt_u.ablkcipher
293#define crt_blkcipher crt_u.blkcipher 346#define crt_blkcipher crt_u.blkcipher
294#define crt_cipher crt_u.cipher 347#define crt_cipher crt_u.cipher
295#define crt_hash crt_u.hash 348#define crt_hash crt_u.hash
@@ -300,6 +353,7 @@ struct crypto_tfm {
300 u32 crt_flags; 353 u32 crt_flags;
301 354
302 union { 355 union {
356 struct ablkcipher_tfm ablkcipher;
303 struct blkcipher_tfm blkcipher; 357 struct blkcipher_tfm blkcipher;
304 struct cipher_tfm cipher; 358 struct cipher_tfm cipher;
305 struct hash_tfm hash; 359 struct hash_tfm hash;
@@ -311,6 +365,10 @@ struct crypto_tfm {
311 void *__crt_ctx[] CRYPTO_MINALIGN_ATTR; 365 void *__crt_ctx[] CRYPTO_MINALIGN_ATTR;
312}; 366};
313 367
368struct crypto_ablkcipher {
369 struct crypto_tfm base;
370};
371
314struct crypto_blkcipher { 372struct crypto_blkcipher {
315 struct crypto_tfm base; 373 struct crypto_tfm base;
316}; 374};
@@ -330,12 +388,21 @@ struct crypto_hash {
330enum { 388enum {
331 CRYPTOA_UNSPEC, 389 CRYPTOA_UNSPEC,
332 CRYPTOA_ALG, 390 CRYPTOA_ALG,
391 CRYPTOA_TYPE,
392 __CRYPTOA_MAX,
333}; 393};
334 394
395#define CRYPTOA_MAX (__CRYPTOA_MAX - 1)
396
335struct crypto_attr_alg { 397struct crypto_attr_alg {
336 char name[CRYPTO_MAX_ALG_NAME]; 398 char name[CRYPTO_MAX_ALG_NAME];
337}; 399};
338 400
401struct crypto_attr_type {
402 u32 type;
403 u32 mask;
404};
405
339/* 406/*
340 * Transform user interface. 407 * Transform user interface.
341 */ 408 */
@@ -411,6 +478,167 @@ static inline unsigned int crypto_tfm_ctx_alignment(void)
411/* 478/*
412 * API wrappers. 479 * API wrappers.
413 */ 480 */
481static inline struct crypto_ablkcipher *__crypto_ablkcipher_cast(
482 struct crypto_tfm *tfm)
483{
484 return (struct crypto_ablkcipher *)tfm;
485}
486
487static inline struct crypto_ablkcipher *crypto_alloc_ablkcipher(
488 const char *alg_name, u32 type, u32 mask)
489{
490 type &= ~CRYPTO_ALG_TYPE_MASK;
491 type |= CRYPTO_ALG_TYPE_BLKCIPHER;
492 mask |= CRYPTO_ALG_TYPE_MASK;
493
494 return __crypto_ablkcipher_cast(
495 crypto_alloc_base(alg_name, type, mask));
496}
497
498static inline struct crypto_tfm *crypto_ablkcipher_tfm(
499 struct crypto_ablkcipher *tfm)
500{
501 return &tfm->base;
502}
503
504static inline void crypto_free_ablkcipher(struct crypto_ablkcipher *tfm)
505{
506 crypto_free_tfm(crypto_ablkcipher_tfm(tfm));
507}
508
509static inline int crypto_has_ablkcipher(const char *alg_name, u32 type,
510 u32 mask)
511{
512 type &= ~CRYPTO_ALG_TYPE_MASK;
513 type |= CRYPTO_ALG_TYPE_BLKCIPHER;
514 mask |= CRYPTO_ALG_TYPE_MASK;
515
516 return crypto_has_alg(alg_name, type, mask);
517}
518
519static inline struct ablkcipher_tfm *crypto_ablkcipher_crt(
520 struct crypto_ablkcipher *tfm)
521{
522 return &crypto_ablkcipher_tfm(tfm)->crt_ablkcipher;
523}
524
525static inline unsigned int crypto_ablkcipher_ivsize(
526 struct crypto_ablkcipher *tfm)
527{
528 return crypto_ablkcipher_crt(tfm)->ivsize;
529}
530
531static inline unsigned int crypto_ablkcipher_blocksize(
532 struct crypto_ablkcipher *tfm)
533{
534 return crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(tfm));
535}
536
537static inline unsigned int crypto_ablkcipher_alignmask(
538 struct crypto_ablkcipher *tfm)
539{
540 return crypto_tfm_alg_alignmask(crypto_ablkcipher_tfm(tfm));
541}
542
543static inline u32 crypto_ablkcipher_get_flags(struct crypto_ablkcipher *tfm)
544{
545 return crypto_tfm_get_flags(crypto_ablkcipher_tfm(tfm));
546}
547
548static inline void crypto_ablkcipher_set_flags(struct crypto_ablkcipher *tfm,
549 u32 flags)
550{
551 crypto_tfm_set_flags(crypto_ablkcipher_tfm(tfm), flags);
552}
553
554static inline void crypto_ablkcipher_clear_flags(struct crypto_ablkcipher *tfm,
555 u32 flags)
556{
557 crypto_tfm_clear_flags(crypto_ablkcipher_tfm(tfm), flags);
558}
559
560static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm,
561 const u8 *key, unsigned int keylen)
562{
563 return crypto_ablkcipher_crt(tfm)->setkey(tfm, key, keylen);
564}
565
566static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm(
567 struct ablkcipher_request *req)
568{
569 return __crypto_ablkcipher_cast(req->base.tfm);
570}
571
572static inline int crypto_ablkcipher_encrypt(struct ablkcipher_request *req)
573{
574 struct ablkcipher_tfm *crt =
575 crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req));
576 return crt->encrypt(req);
577}
578
579static inline int crypto_ablkcipher_decrypt(struct ablkcipher_request *req)
580{
581 struct ablkcipher_tfm *crt =
582 crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req));
583 return crt->decrypt(req);
584}
585
586static inline int crypto_ablkcipher_reqsize(struct crypto_ablkcipher *tfm)
587{
588 return crypto_ablkcipher_crt(tfm)->reqsize;
589}
590
591static inline void ablkcipher_request_set_tfm(
592 struct ablkcipher_request *req, struct crypto_ablkcipher *tfm)
593{
594 req->base.tfm = crypto_ablkcipher_tfm(tfm);
595}
596
597static inline struct ablkcipher_request *ablkcipher_request_cast(
598 struct crypto_async_request *req)
599{
600 return container_of(req, struct ablkcipher_request, base);
601}
602
603static inline struct ablkcipher_request *ablkcipher_request_alloc(
604 struct crypto_ablkcipher *tfm, gfp_t gfp)
605{
606 struct ablkcipher_request *req;
607
608 req = kmalloc(sizeof(struct ablkcipher_request) +
609 crypto_ablkcipher_reqsize(tfm), gfp);
610
611 if (likely(req))
612 ablkcipher_request_set_tfm(req, tfm);
613
614 return req;
615}
616
617static inline void ablkcipher_request_free(struct ablkcipher_request *req)
618{
619 kfree(req);
620}
621
622static inline void ablkcipher_request_set_callback(
623 struct ablkcipher_request *req,
624 u32 flags, crypto_completion_t complete, void *data)
625{
626 req->base.complete = complete;
627 req->base.data = data;
628 req->base.flags = flags;
629}
630
631static inline void ablkcipher_request_set_crypt(
632 struct ablkcipher_request *req,
633 struct scatterlist *src, struct scatterlist *dst,
634 unsigned int nbytes, void *iv)
635{
636 req->src = src;
637 req->dst = dst;
638 req->nbytes = nbytes;
639 req->info = iv;
640}
641
414static inline struct crypto_blkcipher *__crypto_blkcipher_cast( 642static inline struct crypto_blkcipher *__crypto_blkcipher_cast(
415 struct crypto_tfm *tfm) 643 struct crypto_tfm *tfm)
416{ 644{
@@ -427,9 +655,9 @@ static inline struct crypto_blkcipher *crypto_blkcipher_cast(
427static inline struct crypto_blkcipher *crypto_alloc_blkcipher( 655static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
428 const char *alg_name, u32 type, u32 mask) 656 const char *alg_name, u32 type, u32 mask)
429{ 657{
430 type &= ~CRYPTO_ALG_TYPE_MASK; 658 type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
431 type |= CRYPTO_ALG_TYPE_BLKCIPHER; 659 type |= CRYPTO_ALG_TYPE_BLKCIPHER;
432 mask |= CRYPTO_ALG_TYPE_MASK; 660 mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC;
433 661
434 return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask)); 662 return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask));
435} 663}
@@ -447,9 +675,9 @@ static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm)
447 675
448static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask) 676static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask)
449{ 677{
450 type &= ~CRYPTO_ALG_TYPE_MASK; 678 type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
451 type |= CRYPTO_ALG_TYPE_BLKCIPHER; 679 type |= CRYPTO_ALG_TYPE_BLKCIPHER;
452 mask |= CRYPTO_ALG_TYPE_MASK; 680 mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC;
453 681
454 return crypto_has_alg(alg_name, type, mask); 682 return crypto_has_alg(alg_name, type, mask);
455} 683}
diff --git a/include/linux/device.h b/include/linux/device.h
index a0cd2ced31a9..6579068134d1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -53,7 +53,7 @@ struct bus_type {
53 const char * name; 53 const char * name;
54 struct module * owner; 54 struct module * owner;
55 55
56 struct subsystem subsys; 56 struct kset subsys;
57 struct kset drivers; 57 struct kset drivers;
58 struct kset devices; 58 struct kset devices;
59 struct klist klist_devices; 59 struct klist klist_devices;
@@ -80,7 +80,6 @@ struct bus_type {
80 int (*resume)(struct device * dev); 80 int (*resume)(struct device * dev);
81 81
82 unsigned int drivers_autoprobe:1; 82 unsigned int drivers_autoprobe:1;
83 unsigned int multithread_probe:1;
84}; 83};
85 84
86extern int __must_check bus_register(struct bus_type * bus); 85extern int __must_check bus_register(struct bus_type * bus);
@@ -179,7 +178,7 @@ struct class {
179 const char * name; 178 const char * name;
180 struct module * owner; 179 struct module * owner;
181 180
182 struct subsystem subsys; 181 struct kset subsys;
183 struct list_head children; 182 struct list_head children;
184 struct list_head devices; 183 struct list_head devices;
185 struct list_head interfaces; 184 struct list_head interfaces;
@@ -559,8 +558,8 @@ extern void device_shutdown(void);
559 558
560 559
561/* drivers/base/firmware.c */ 560/* drivers/base/firmware.c */
562extern int __must_check firmware_register(struct subsystem *); 561extern int __must_check firmware_register(struct kset *);
563extern void firmware_unregister(struct subsystem *); 562extern void firmware_unregister(struct kset *);
564 563
565/* debugging and troubleshooting/diagnostic helpers. */ 564/* debugging and troubleshooting/diagnostic helpers. */
566extern const char *dev_driver_string(struct device *dev); 565extern const char *dev_driver_string(struct device *dev);
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index c6310aef5ab0..f2d248f8cc92 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -434,6 +434,7 @@ struct ethtool_ops {
434#define SUPPORTED_10000baseT_Full (1 << 12) 434#define SUPPORTED_10000baseT_Full (1 << 12)
435#define SUPPORTED_Pause (1 << 13) 435#define SUPPORTED_Pause (1 << 13)
436#define SUPPORTED_Asym_Pause (1 << 14) 436#define SUPPORTED_Asym_Pause (1 << 14)
437#define SUPPORTED_2500baseX_Full (1 << 15)
437 438
438/* Indicates what features are advertised by the interface. */ 439/* Indicates what features are advertised by the interface. */
439#define ADVERTISED_10baseT_Half (1 << 0) 440#define ADVERTISED_10baseT_Half (1 << 0)
@@ -451,6 +452,7 @@ struct ethtool_ops {
451#define ADVERTISED_10000baseT_Full (1 << 12) 452#define ADVERTISED_10000baseT_Full (1 << 12)
452#define ADVERTISED_Pause (1 << 13) 453#define ADVERTISED_Pause (1 << 13)
453#define ADVERTISED_Asym_Pause (1 << 14) 454#define ADVERTISED_Asym_Pause (1 << 14)
455#define ADVERTISED_2500baseX_Full (1 << 15)
454 456
455/* The following are all involved in forcing a particular link 457/* The following are all involved in forcing a particular link
456 * mode for the device for setting things. When getting the 458 * mode for the device for setting things. When getting the
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 095a9c9a64fb..7c0077f06e24 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1416,7 +1416,7 @@ extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *,
1416extern int vfs_statfs(struct dentry *, struct kstatfs *); 1416extern int vfs_statfs(struct dentry *, struct kstatfs *);
1417 1417
1418/* /sys/fs */ 1418/* /sys/fs */
1419extern struct subsystem fs_subsys; 1419extern struct kset fs_subsys;
1420 1420
1421#define FLOCK_VERIFY_READ 1 1421#define FLOCK_VERIFY_READ 1
1422#define FLOCK_VERIFY_WRITE 2 1422#define FLOCK_VERIFY_WRITE 2
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index 2b217c7b9312..265d17830a0f 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -3,10 +3,11 @@
3 3
4struct gpio_keys_button { 4struct gpio_keys_button {
5 /* Configuration parameters */ 5 /* Configuration parameters */
6 int keycode; 6 int code; /* input event code (KEY_*, SW_*) */
7 int gpio; 7 int gpio;
8 int active_low; 8 int active_low;
9 char *desc; 9 char *desc;
10 int type; /* input event type (EV_KEY, EV_SW) */
10}; 11};
11 12
12struct gpio_keys_platform_data { 13struct gpio_keys_platform_data {
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index bca8e2dfa355..a515eb0afdfb 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -44,8 +44,13 @@ static inline void *kmap(struct page *page)
44 44
45#define kunmap(page) do { (void) (page); } while (0) 45#define kunmap(page) do { (void) (page); } while (0)
46 46
47#define kmap_atomic(page, idx) \ 47#include <asm/kmap_types.h>
48 ({ pagefault_disable(); page_address(page); }) 48
49static inline void *kmap_atomic(struct page *page, enum km_type idx)
50{
51 pagefault_disable();
52 return page_address(page);
53}
49#define kmap_atomic_prot(page, idx, prot) kmap_atomic(page, idx) 54#define kmap_atomic_prot(page, idx, prot) kmap_atomic(page, idx)
50 55
51#define kunmap_atomic(addr, idx) do { pagefault_enable(); } while (0) 56#define kunmap_atomic(addr, idx) do { pagefault_enable(); } while (0)
diff --git a/include/linux/hp_sdc.h b/include/linux/hp_sdc.h
index debd71515312..9db3d454887f 100644
--- a/include/linux/hp_sdc.h
+++ b/include/linux/hp_sdc.h
@@ -71,6 +71,7 @@ typedef struct {
71 struct semaphore *semaphore; /* Semaphore to sleep on. */ 71 struct semaphore *semaphore; /* Semaphore to sleep on. */
72 } act; 72 } act;
73} hp_sdc_transaction; 73} hp_sdc_transaction;
74int __hp_sdc_enqueue_transaction(hp_sdc_transaction *this);
74int hp_sdc_enqueue_transaction(hp_sdc_transaction *this); 75int hp_sdc_enqueue_transaction(hp_sdc_transaction *this);
75int hp_sdc_dequeue_transaction(hp_sdc_transaction *this); 76int hp_sdc_dequeue_transaction(hp_sdc_transaction *this);
76 77
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h
index 937da70cb4c4..9ee0f800592f 100644
--- a/include/linux/i2c-algo-bit.h
+++ b/include/linux/i2c-algo-bit.h
@@ -38,11 +38,14 @@ struct i2c_algo_bit_data {
38 int (*getscl) (void *data); 38 int (*getscl) (void *data);
39 39
40 /* local settings */ 40 /* local settings */
41 int udelay; /* half-clock-cycle time in microsecs */ 41 int udelay; /* half clock cycle time in us,
42 /* i.e. clock is (500 / udelay) KHz */ 42 minimum 2 us for fast-mode I2C,
43 minimum 5 us for standard-mode I2C and SMBus,
44 maximum 50 us for SMBus */
43 int timeout; /* in jiffies */ 45 int timeout; /* in jiffies */
44}; 46};
45 47
46int i2c_bit_add_bus(struct i2c_adapter *); 48int i2c_bit_add_bus(struct i2c_adapter *);
49int i2c_bit_add_numbered_bus(struct i2c_adapter *);
47 50
48#endif /* _LINUX_I2C_ALGO_BIT_H */ 51#endif /* _LINUX_I2C_ALGO_BIT_H */
diff --git a/include/linux/i2c-gpio.h b/include/linux/i2c-gpio.h
new file mode 100644
index 000000000000..c1bcb1f1d73b
--- /dev/null
+++ b/include/linux/i2c-gpio.h
@@ -0,0 +1,38 @@
1/*
2 * i2c-gpio interface to platform code
3 *
4 * Copyright (C) 2007 Atmel 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 version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef _LINUX_I2C_GPIO_H
11#define _LINUX_I2C_GPIO_H
12
13/**
14 * struct i2c_gpio_platform_data - Platform-dependent data for i2c-gpio
15 * @sda_pin: GPIO pin ID to use for SDA
16 * @scl_pin: GPIO pin ID to use for SCL
17 * @udelay: signal toggle delay. SCL frequency is (500 / udelay) kHz
18 * @timeout: clock stretching timeout in jiffies. If the slave keeps
19 * SCL low for longer than this, the transfer will time out.
20 * @sda_is_open_drain: SDA is configured as open drain, i.e. the pin
21 * isn't actively driven high when setting the output value high.
22 * gpio_get_value() must return the actual pin state even if the
23 * pin is configured as an output.
24 * @scl_is_open_drain: SCL is set up as open drain. Same requirements
25 * as for sda_is_open_drain apply.
26 * @scl_is_output_only: SCL output drivers cannot be turned off.
27 */
28struct i2c_gpio_platform_data {
29 unsigned int sda_pin;
30 unsigned int scl_pin;
31 int udelay;
32 int timeout;
33 unsigned int sda_is_open_drain:1;
34 unsigned int scl_is_open_drain:1;
35 unsigned int scl_is_output_only:1;
36};
37
38#endif /* _LINUX_I2C_GPIO_H */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 9c21dc793d7b..0e8da684ce68 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -258,8 +258,9 @@
258/* --- MCP107 adapter */ 258/* --- MCP107 adapter */
259#define I2C_HW_MPC107 0x0d0000 259#define I2C_HW_MPC107 0x0d0000
260 260
261/* --- Marvell mv64xxx i2c adapter */ 261/* --- Embedded adapters */
262#define I2C_HW_MV64XXX 0x190000 262#define I2C_HW_MV64XXX 0x190000
263#define I2C_HW_BLACKFIN 0x190001 /* ADI Blackfin I2C TWI driver */
263 264
264/* --- Miscellaneous adapters */ 265/* --- Miscellaneous adapters */
265#define I2C_HW_SAA7146 0x060000 /* SAA7146 video decoder bus */ 266#define I2C_HW_SAA7146 0x060000 /* SAA7146 video decoder bus */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 9428092017e3..cae7d618030c 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -35,11 +35,6 @@
35#include <linux/sched.h> /* for completion */ 35#include <linux/sched.h> /* for completion */
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37 37
38/* --- For i2c-isa ---------------------------------------------------- */
39
40extern void i2c_adapter_dev_release(struct device *dev);
41extern struct device_driver i2c_adapter_driver;
42extern struct class i2c_adapter_class;
43extern struct bus_type i2c_bus_type; 38extern struct bus_type i2c_bus_type;
44 39
45/* --- General options ------------------------------------------------ */ 40/* --- General options ------------------------------------------------ */
@@ -87,6 +82,9 @@ extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
87extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 82extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
88extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 83extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
89 u8 command, u16 value); 84 u8 command, u16 value);
85/* Returns the number of read bytes */
86extern s32 i2c_smbus_read_block_data(struct i2c_client *client,
87 u8 command, u8 *values);
90extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 88extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
91 u8 command, u8 length, 89 u8 command, u8 length,
92 const u8 *values); 90 const u8 *values);
@@ -114,7 +112,7 @@ struct i2c_driver {
114 * can be used by the driver to test if the bus meets its conditions 112 * can be used by the driver to test if the bus meets its conditions
115 * & seek for the presence of the chip(s) it supports. If found, it 113 * & seek for the presence of the chip(s) it supports. If found, it
116 * registers the client(s) that are on the bus to the i2c admin. via 114 * registers the client(s) that are on the bus to the i2c admin. via
117 * i2c_attach_client. 115 * i2c_attach_client. (LEGACY I2C DRIVERS ONLY)
118 */ 116 */
119 int (*attach_adapter)(struct i2c_adapter *); 117 int (*attach_adapter)(struct i2c_adapter *);
120 int (*detach_adapter)(struct i2c_adapter *); 118 int (*detach_adapter)(struct i2c_adapter *);
@@ -122,10 +120,17 @@ struct i2c_driver {
122 /* tells the driver that a client is about to be deleted & gives it 120 /* tells the driver that a client is about to be deleted & gives it
123 * the chance to remove its private data. Also, if the client struct 121 * the chance to remove its private data. Also, if the client struct
124 * has been dynamically allocated by the driver in the function above, 122 * has been dynamically allocated by the driver in the function above,
125 * it must be freed here. 123 * it must be freed here. (LEGACY I2C DRIVERS ONLY)
126 */ 124 */
127 int (*detach_client)(struct i2c_client *); 125 int (*detach_client)(struct i2c_client *);
128 126
127 /* Standard driver model interfaces, for "new style" i2c drivers.
128 * With the driver model, device enumeration is NEVER done by drivers;
129 * it's done by infrastructure. (NEW STYLE DRIVERS ONLY)
130 */
131 int (*probe)(struct i2c_client *);
132 int (*remove)(struct i2c_client *);
133
129 /* driver model interfaces that don't relate to enumeration */ 134 /* driver model interfaces that don't relate to enumeration */
130 void (*shutdown)(struct i2c_client *); 135 void (*shutdown)(struct i2c_client *);
131 int (*suspend)(struct i2c_client *, pm_message_t mesg); 136 int (*suspend)(struct i2c_client *, pm_message_t mesg);
@@ -141,25 +146,34 @@ struct i2c_driver {
141}; 146};
142#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) 147#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
143 148
144#define I2C_NAME_SIZE 50 149#define I2C_NAME_SIZE 20
145 150
146/* 151/**
147 * i2c_client identifies a single device (i.e. chip) that is connected to an 152 * struct i2c_client - represent an I2C slave device
148 * i2c bus. The behaviour is defined by the routines of the driver. This 153 * @addr: Address used on the I2C bus connected to the parent adapter.
149 * function is mainly used for lookup & other admin. functions. 154 * @name: Indicates the type of the device, usually a chip name that's
155 * generic enough to hide second-sourcing and compatible revisions.
156 * @dev: Driver model device node for the slave.
157 * @driver_name: Identifies new-style driver used with this device; also
158 * used as the module name for hotplug/coldplug modprobe support.
159 *
160 * An i2c_client identifies a single device (i.e. chip) connected to an
161 * i2c bus. The behaviour is defined by the routines of the driver.
150 */ 162 */
151struct i2c_client { 163struct i2c_client {
152 unsigned int flags; /* div., see below */ 164 unsigned short flags; /* div., see below */
153 unsigned short addr; /* chip address - NOTE: 7bit */ 165 unsigned short addr; /* chip address - NOTE: 7bit */
154 /* addresses are stored in the */ 166 /* addresses are stored in the */
155 /* _LOWER_ 7 bits */ 167 /* _LOWER_ 7 bits */
168 char name[I2C_NAME_SIZE];
156 struct i2c_adapter *adapter; /* the adapter we sit on */ 169 struct i2c_adapter *adapter; /* the adapter we sit on */
157 struct i2c_driver *driver; /* and our access routines */ 170 struct i2c_driver *driver; /* and our access routines */
158 int usage_count; /* How many accesses currently */ 171 int usage_count; /* How many accesses currently */
159 /* to the client */ 172 /* to the client */
160 struct device dev; /* the device structure */ 173 struct device dev; /* the device structure */
174 int irq; /* irq issued by device (or -1) */
175 char driver_name[KOBJ_NAME_LEN];
161 struct list_head list; 176 struct list_head list;
162 char name[I2C_NAME_SIZE];
163 struct completion released; 177 struct completion released;
164}; 178};
165#define to_i2c_client(d) container_of(d, struct i2c_client, dev) 179#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
@@ -179,6 +193,76 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
179 dev_set_drvdata (&dev->dev, data); 193 dev_set_drvdata (&dev->dev, data);
180} 194}
181 195
196/**
197 * struct i2c_board_info - template for device creation
198 * @driver_name: identifies the driver to be bound to the device
199 * @type: optional chip type information, to initialize i2c_client.name
200 * @flags: to initialize i2c_client.flags
201 * @addr: stored in i2c_client.addr
202 * @platform_data: stored in i2c_client.dev.platform_data
203 * @irq: stored in i2c_client.irq
204
205 * I2C doesn't actually support hardware probing, although controllers and
206 * devices may be able to use I2C_SMBUS_QUICK to tell whether or not there's
207 * a device at a given address. Drivers commonly need more information than
208 * that, such as chip type, configuration, associated IRQ, and so on.
209 *
210 * i2c_board_info is used to build tables of information listing I2C devices
211 * that are present. This information is used to grow the driver model tree
212 * for "new style" I2C drivers. For mainboards this is done statically using
213 * i2c_register_board_info(), where @bus_num represents an adapter that isn't
214 * yet available. For add-on boards, i2c_new_device() does this dynamically
215 * with the adapter already known.
216 */
217struct i2c_board_info {
218 char driver_name[KOBJ_NAME_LEN];
219 char type[I2C_NAME_SIZE];
220 unsigned short flags;
221 unsigned short addr;
222 void *platform_data;
223 int irq;
224};
225
226/**
227 * I2C_BOARD_INFO - macro used to list an i2c device and its driver
228 * @driver: identifies the driver to use with the device
229 * @dev_addr: the device's address on the bus.
230 *
231 * This macro initializes essential fields of a struct i2c_board_info,
232 * declaring what has been provided on a particular board. Optional
233 * fields (such as the chip type, its associated irq, or device-specific
234 * platform_data) are provided using conventional syntax.
235 */
236#define I2C_BOARD_INFO(driver,dev_addr) \
237 .driver_name = (driver), .addr = (dev_addr)
238
239
240/* Add-on boards should register/unregister their devices; e.g. a board
241 * with integrated I2C, a config eeprom, sensors, and a codec that's
242 * used in conjunction with the primary hardware.
243 */
244extern struct i2c_client *
245i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info);
246
247/* If you don't know the exact address of an I2C device, use this variant
248 * instead, which can probe for device presence in a list of possible
249 * addresses.
250 */
251extern struct i2c_client *
252i2c_new_probed_device(struct i2c_adapter *adap,
253 struct i2c_board_info *info,
254 unsigned short const *addr_list);
255
256extern void i2c_unregister_device(struct i2c_client *);
257
258/* Mainboard arch_initcall() code should register all its I2C devices.
259 * This is done at arch_initcall time, before declaring any i2c adapters.
260 * Modules for add-on boards must use other calls.
261 */
262extern int
263i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n);
264
265
182/* 266/*
183 * The following structs are for those who like to implement new bus drivers: 267 * The following structs are for those who like to implement new bus drivers:
184 * i2c_algorithm is the interface to a class of hardware solutions which can 268 * i2c_algorithm is the interface to a class of hardware solutions which can
@@ -228,17 +312,14 @@ struct i2c_adapter {
228 int timeout; 312 int timeout;
229 int retries; 313 int retries;
230 struct device dev; /* the adapter device */ 314 struct device dev; /* the adapter device */
231 struct class_device class_dev; /* the class device */
232 315
233 int nr; 316 int nr;
234 struct list_head clients; 317 struct list_head clients;
235 struct list_head list; 318 struct list_head list;
236 char name[I2C_NAME_SIZE]; 319 char name[48];
237 struct completion dev_released; 320 struct completion dev_released;
238 struct completion class_dev_released;
239}; 321};
240#define dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 322#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
241#define class_dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, class_dev)
242 323
243static inline void *i2c_get_adapdata (struct i2c_adapter *dev) 324static inline void *i2c_get_adapdata (struct i2c_adapter *dev)
244{ 325{
@@ -290,9 +371,10 @@ struct i2c_client_address_data {
290 */ 371 */
291extern int i2c_add_adapter(struct i2c_adapter *); 372extern int i2c_add_adapter(struct i2c_adapter *);
292extern int i2c_del_adapter(struct i2c_adapter *); 373extern int i2c_del_adapter(struct i2c_adapter *);
374extern int i2c_add_numbered_adapter(struct i2c_adapter *);
293 375
294extern int i2c_register_driver(struct module *, struct i2c_driver *); 376extern int i2c_register_driver(struct module *, struct i2c_driver *);
295extern int i2c_del_driver(struct i2c_driver *); 377extern void i2c_del_driver(struct i2c_driver *);
296 378
297static inline int i2c_add_driver(struct i2c_driver *driver) 379static inline int i2c_add_driver(struct i2c_driver *driver)
298{ 380{
@@ -365,6 +447,7 @@ struct i2c_msg {
365#define I2C_M_REV_DIR_ADDR 0x2000 447#define I2C_M_REV_DIR_ADDR 0x2000
366#define I2C_M_IGNORE_NAK 0x1000 448#define I2C_M_IGNORE_NAK 0x1000
367#define I2C_M_NO_RD_ACK 0x0800 449#define I2C_M_NO_RD_ACK 0x0800
450#define I2C_M_RECV_LEN 0x0400 /* length will be first received byte */
368 __u16 len; /* msg length */ 451 __u16 len; /* msg length */
369 __u8 *buf; /* pointer to msg data */ 452 __u8 *buf; /* pointer to msg data */
370}; 453};
diff --git a/include/linux/ide.h b/include/linux/ide.h
index d3bbc7188b6a..418dfb5adadd 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -613,7 +613,6 @@ typedef struct ide_drive_s {
613 613
614 u8 quirk_list; /* considered quirky, set for a specific host */ 614 u8 quirk_list; /* considered quirky, set for a specific host */
615 u8 init_speed; /* transfer rate set at boot */ 615 u8 init_speed; /* transfer rate set at boot */
616 u8 pio_speed; /* unused by core, used by some drivers for fallback from DMA */
617 u8 current_speed; /* current transfer rate set */ 616 u8 current_speed; /* current transfer rate set */
618 u8 desired_speed; /* desired transfer rate set */ 617 u8 desired_speed; /* desired transfer rate set */
619 u8 dn; /* now wide spread use */ 618 u8 dn; /* now wide spread use */
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
new file mode 100644
index 000000000000..ecd61e8438a5
--- /dev/null
+++ b/include/linux/ieee80211.h
@@ -0,0 +1,342 @@
1/*
2 * IEEE 802.11 defines
3 *
4 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
5 * <jkmaline@cc.hut.fi>
6 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
7 * Copyright (c) 2005, Devicescape Software, Inc.
8 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
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 version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#ifndef IEEE80211_H
16#define IEEE80211_H
17
18#include <linux/types.h>
19
20#define FCS_LEN 4
21
22#define IEEE80211_FCTL_VERS 0x0003
23#define IEEE80211_FCTL_FTYPE 0x000c
24#define IEEE80211_FCTL_STYPE 0x00f0
25#define IEEE80211_FCTL_TODS 0x0100
26#define IEEE80211_FCTL_FROMDS 0x0200
27#define IEEE80211_FCTL_MOREFRAGS 0x0400
28#define IEEE80211_FCTL_RETRY 0x0800
29#define IEEE80211_FCTL_PM 0x1000
30#define IEEE80211_FCTL_MOREDATA 0x2000
31#define IEEE80211_FCTL_PROTECTED 0x4000
32#define IEEE80211_FCTL_ORDER 0x8000
33
34#define IEEE80211_SCTL_FRAG 0x000F
35#define IEEE80211_SCTL_SEQ 0xFFF0
36
37#define IEEE80211_FTYPE_MGMT 0x0000
38#define IEEE80211_FTYPE_CTL 0x0004
39#define IEEE80211_FTYPE_DATA 0x0008
40
41/* management */
42#define IEEE80211_STYPE_ASSOC_REQ 0x0000
43#define IEEE80211_STYPE_ASSOC_RESP 0x0010
44#define IEEE80211_STYPE_REASSOC_REQ 0x0020
45#define IEEE80211_STYPE_REASSOC_RESP 0x0030
46#define IEEE80211_STYPE_PROBE_REQ 0x0040
47#define IEEE80211_STYPE_PROBE_RESP 0x0050
48#define IEEE80211_STYPE_BEACON 0x0080
49#define IEEE80211_STYPE_ATIM 0x0090
50#define IEEE80211_STYPE_DISASSOC 0x00A0
51#define IEEE80211_STYPE_AUTH 0x00B0
52#define IEEE80211_STYPE_DEAUTH 0x00C0
53#define IEEE80211_STYPE_ACTION 0x00D0
54
55/* control */
56#define IEEE80211_STYPE_PSPOLL 0x00A0
57#define IEEE80211_STYPE_RTS 0x00B0
58#define IEEE80211_STYPE_CTS 0x00C0
59#define IEEE80211_STYPE_ACK 0x00D0
60#define IEEE80211_STYPE_CFEND 0x00E0
61#define IEEE80211_STYPE_CFENDACK 0x00F0
62
63/* data */
64#define IEEE80211_STYPE_DATA 0x0000
65#define IEEE80211_STYPE_DATA_CFACK 0x0010
66#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
67#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
68#define IEEE80211_STYPE_NULLFUNC 0x0040
69#define IEEE80211_STYPE_CFACK 0x0050
70#define IEEE80211_STYPE_CFPOLL 0x0060
71#define IEEE80211_STYPE_CFACKPOLL 0x0070
72#define IEEE80211_STYPE_QOS_DATA 0x0080
73#define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
74#define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
75#define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
76#define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
77#define IEEE80211_STYPE_QOS_CFACK 0x00D0
78#define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
79#define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
80
81
82/* miscellaneous IEEE 802.11 constants */
83#define IEEE80211_MAX_FRAG_THRESHOLD 2346
84#define IEEE80211_MAX_RTS_THRESHOLD 2347
85#define IEEE80211_MAX_AID 2007
86#define IEEE80211_MAX_TIM_LEN 251
87#define IEEE80211_MAX_DATA_LEN 2304
88/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
89 6.2.1.1.2.
90
91 The figure in section 7.1.2 suggests a body size of up to 2312
92 bytes is allowed, which is a bit confusing, I suspect this
93 represents the 2304 bytes of real data, plus a possible 8 bytes of
94 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
95
96#define IEEE80211_MAX_SSID_LEN 32
97
98struct ieee80211_hdr {
99 __le16 frame_control;
100 __le16 duration_id;
101 u8 addr1[6];
102 u8 addr2[6];
103 u8 addr3[6];
104 __le16 seq_ctrl;
105 u8 addr4[6];
106} __attribute__ ((packed));
107
108
109struct ieee80211_mgmt {
110 __le16 frame_control;
111 __le16 duration;
112 u8 da[6];
113 u8 sa[6];
114 u8 bssid[6];
115 __le16 seq_ctrl;
116 union {
117 struct {
118 __le16 auth_alg;
119 __le16 auth_transaction;
120 __le16 status_code;
121 /* possibly followed by Challenge text */
122 u8 variable[0];
123 } __attribute__ ((packed)) auth;
124 struct {
125 __le16 reason_code;
126 } __attribute__ ((packed)) deauth;
127 struct {
128 __le16 capab_info;
129 __le16 listen_interval;
130 /* followed by SSID and Supported rates */
131 u8 variable[0];
132 } __attribute__ ((packed)) assoc_req;
133 struct {
134 __le16 capab_info;
135 __le16 status_code;
136 __le16 aid;
137 /* followed by Supported rates */
138 u8 variable[0];
139 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
140 struct {
141 __le16 capab_info;
142 __le16 listen_interval;
143 u8 current_ap[6];
144 /* followed by SSID and Supported rates */
145 u8 variable[0];
146 } __attribute__ ((packed)) reassoc_req;
147 struct {
148 __le16 reason_code;
149 } __attribute__ ((packed)) disassoc;
150 struct {
151 __le64 timestamp;
152 __le16 beacon_int;
153 __le16 capab_info;
154 /* followed by some of SSID, Supported rates,
155 * FH Params, DS Params, CF Params, IBSS Params, TIM */
156 u8 variable[0];
157 } __attribute__ ((packed)) beacon;
158 struct {
159 /* only variable items: SSID, Supported rates */
160 u8 variable[0];
161 } __attribute__ ((packed)) probe_req;
162 struct {
163 __le64 timestamp;
164 __le16 beacon_int;
165 __le16 capab_info;
166 /* followed by some of SSID, Supported rates,
167 * FH Params, DS Params, CF Params, IBSS Params */
168 u8 variable[0];
169 } __attribute__ ((packed)) probe_resp;
170 struct {
171 u8 category;
172 union {
173 struct {
174 u8 action_code;
175 u8 dialog_token;
176 u8 status_code;
177 u8 variable[0];
178 } __attribute__ ((packed)) wme_action;
179 struct{
180 u8 action_code;
181 u8 element_id;
182 u8 length;
183 u8 switch_mode;
184 u8 new_chan;
185 u8 switch_count;
186 } __attribute__((packed)) chan_switch;
187 } u;
188 } __attribute__ ((packed)) action;
189 } u;
190} __attribute__ ((packed));
191
192
193/* Control frames */
194struct ieee80211_rts {
195 __le16 frame_control;
196 __le16 duration;
197 u8 ra[6];
198 u8 ta[6];
199} __attribute__ ((packed));
200
201struct ieee80211_cts {
202 __le16 frame_control;
203 __le16 duration;
204 u8 ra[6];
205} __attribute__ ((packed));
206
207
208/* Authentication algorithms */
209#define WLAN_AUTH_OPEN 0
210#define WLAN_AUTH_SHARED_KEY 1
211#define WLAN_AUTH_FAST_BSS_TRANSITION 2
212#define WLAN_AUTH_LEAP 128
213
214#define WLAN_AUTH_CHALLENGE_LEN 128
215
216#define WLAN_CAPABILITY_ESS (1<<0)
217#define WLAN_CAPABILITY_IBSS (1<<1)
218#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
219#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
220#define WLAN_CAPABILITY_PRIVACY (1<<4)
221#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
222#define WLAN_CAPABILITY_PBCC (1<<6)
223#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
224/* 802.11h */
225#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
226#define WLAN_CAPABILITY_QOS (1<<9)
227#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
228#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
229
230/* Status codes */
231enum ieee80211_statuscode {
232 WLAN_STATUS_SUCCESS = 0,
233 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
234 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
235 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
236 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
237 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
238 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
239 WLAN_STATUS_CHALLENGE_FAIL = 15,
240 WLAN_STATUS_AUTH_TIMEOUT = 16,
241 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
242 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
243 /* 802.11b */
244 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
245 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
246 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
247 /* 802.11h */
248 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
249 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
250 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
251 /* 802.11g */
252 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
253 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
254 /* 802.11i */
255 WLAN_STATUS_INVALID_IE = 40,
256 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
257 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
258 WLAN_STATUS_INVALID_AKMP = 43,
259 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
260 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
261 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
262};
263
264
265/* Reason codes */
266enum ieee80211_reasoncode {
267 WLAN_REASON_UNSPECIFIED = 1,
268 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
269 WLAN_REASON_DEAUTH_LEAVING = 3,
270 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
271 WLAN_REASON_DISASSOC_AP_BUSY = 5,
272 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
273 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
274 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
275 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
276 /* 802.11h */
277 WLAN_REASON_DISASSOC_BAD_POWER = 10,
278 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
279 /* 802.11i */
280 WLAN_REASON_INVALID_IE = 13,
281 WLAN_REASON_MIC_FAILURE = 14,
282 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
283 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
284 WLAN_REASON_IE_DIFFERENT = 17,
285 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
286 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
287 WLAN_REASON_INVALID_AKMP = 20,
288 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
289 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
290 WLAN_REASON_IEEE8021X_FAILED = 23,
291 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
292};
293
294
295/* Information Element IDs */
296enum ieee80211_eid {
297 WLAN_EID_SSID = 0,
298 WLAN_EID_SUPP_RATES = 1,
299 WLAN_EID_FH_PARAMS = 2,
300 WLAN_EID_DS_PARAMS = 3,
301 WLAN_EID_CF_PARAMS = 4,
302 WLAN_EID_TIM = 5,
303 WLAN_EID_IBSS_PARAMS = 6,
304 WLAN_EID_CHALLENGE = 16,
305 /* 802.11d */
306 WLAN_EID_COUNTRY = 7,
307 WLAN_EID_HP_PARAMS = 8,
308 WLAN_EID_HP_TABLE = 9,
309 WLAN_EID_REQUEST = 10,
310 /* 802.11h */
311 WLAN_EID_PWR_CONSTRAINT = 32,
312 WLAN_EID_PWR_CAPABILITY = 33,
313 WLAN_EID_TPC_REQUEST = 34,
314 WLAN_EID_TPC_REPORT = 35,
315 WLAN_EID_SUPPORTED_CHANNELS = 36,
316 WLAN_EID_CHANNEL_SWITCH = 37,
317 WLAN_EID_MEASURE_REQUEST = 38,
318 WLAN_EID_MEASURE_REPORT = 39,
319 WLAN_EID_QUIET = 40,
320 WLAN_EID_IBSS_DFS = 41,
321 /* 802.11g */
322 WLAN_EID_ERP_INFO = 42,
323 WLAN_EID_EXT_SUPP_RATES = 50,
324 /* 802.11i */
325 WLAN_EID_RSN = 48,
326 WLAN_EID_WPA = 221,
327 WLAN_EID_GENERIC = 221,
328 WLAN_EID_VENDOR_SPECIFIC = 221,
329 WLAN_EID_QOS_PARAMETER = 222
330};
331
332/* cipher suite selectors */
333#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
334#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
335#define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
336/* reserved: 0x000FAC03 */
337#define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
338#define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
339
340#define WLAN_MAX_KEY_LEN 32
341
342#endif /* IEEE80211_H */
diff --git a/include/linux/input-polldev.h b/include/linux/input-polldev.h
new file mode 100644
index 000000000000..597a0077b3c5
--- /dev/null
+++ b/include/linux/input-polldev.h
@@ -0,0 +1,46 @@
1#ifndef _INPUT_POLLDEV_H
2#define _INPUT_POLLDEV_H
3
4/*
5 * Copyright (c) 2007 Dmitry Torokhov
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 version 2 as published by
9 * the Free Software Foundation.
10 */
11
12#include <linux/input.h>
13#include <linux/workqueue.h>
14
15/**
16 * struct input_polled_dev - simple polled input device
17 * @private: private driver data
18 * @flush: driver-supplied method that flushes device's state upon
19 * opening (optional)
20 * @poll: driver-supplied method that polls the device and posts
21 * input events (mandatory).
22 * @poll_interval: specifies how often the poll() method shoudl be called.
23 * @input: input device structire associated with the polled device.
24 * Must be properly initialized by the driver (id, name, phys, bits).
25 *
26 * Polled input device provides a skeleton for supporting simple input
27 * devices that do not raise interrupts but have to be periodically
28 * scanned or polled to detect changes in their state.
29 */
30struct input_polled_dev {
31 void *private;
32
33 void (*flush)(struct input_polled_dev *dev);
34 void (*poll)(struct input_polled_dev *dev);
35 unsigned int poll_interval; /* msec */
36
37 struct input_dev *input;
38 struct delayed_work work;
39};
40
41struct input_polled_dev *input_allocate_polled_device(void);
42void input_free_polled_device(struct input_polled_dev *dev);
43int input_register_polled_device(struct input_polled_dev *dev);
44void input_unregister_polled_device(struct input_polled_dev *dev);
45
46#endif
diff --git a/include/linux/input.h b/include/linux/input.h
index bde65c8a3519..439954d09752 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -506,6 +506,7 @@ struct input_absinfo {
506#define KEY_VOICEMAIL 0x1ac 506#define KEY_VOICEMAIL 0x1ac
507#define KEY_ADDRESSBOOK 0x1ad 507#define KEY_ADDRESSBOOK 0x1ad
508#define KEY_MESSENGER 0x1ae 508#define KEY_MESSENGER 0x1ae
509#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
509 510
510#define KEY_DEL_EOL 0x1c0 511#define KEY_DEL_EOL 0x1c0
511#define KEY_DEL_EOS 0x1c1 512#define KEY_DEL_EOS 0x1c1
@@ -676,6 +677,7 @@ struct input_absinfo {
676#define BUS_I2C 0x18 677#define BUS_I2C 0x18
677#define BUS_HOST 0x19 678#define BUS_HOST 0x19
678#define BUS_GSC 0x1A 679#define BUS_GSC 0x1A
680#define BUS_ATARI 0x1B
679 681
680/* 682/*
681 * Values describing the status of a force-feedback effect 683 * Values describing the status of a force-feedback effect
@@ -913,33 +915,6 @@ struct ff_effect {
913#define BIT(x) (1UL<<((x)%BITS_PER_LONG)) 915#define BIT(x) (1UL<<((x)%BITS_PER_LONG))
914#define LONG(x) ((x)/BITS_PER_LONG) 916#define LONG(x) ((x)/BITS_PER_LONG)
915 917
916#define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \
917 ((dev->keycodesize == 2) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode])))
918
919#define SET_INPUT_KEYCODE(dev, scancode, val) \
920 ({ unsigned __old; \
921 switch (dev->keycodesize) { \
922 case 1: { \
923 u8 *k = (u8 *)dev->keycode; \
924 __old = k[scancode]; \
925 k[scancode] = val; \
926 break; \
927 } \
928 case 2: { \
929 u16 *k = (u16 *)dev->keycode; \
930 __old = k[scancode]; \
931 k[scancode] = val; \
932 break; \
933 } \
934 default: { \
935 u32 *k = (u32 *)dev->keycode; \
936 __old = k[scancode]; \
937 k[scancode] = val; \
938 break; \
939 } \
940 } \
941 __old; })
942
943struct input_dev { 918struct input_dev {
944 919
945 void *private; 920 void *private;
@@ -962,6 +937,8 @@ struct input_dev {
962 unsigned int keycodemax; 937 unsigned int keycodemax;
963 unsigned int keycodesize; 938 unsigned int keycodesize;
964 void *keycode; 939 void *keycode;
940 int (*setkeycode)(struct input_dev *dev, int scancode, int keycode);
941 int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode);
965 942
966 struct ff_device *ff; 943 struct ff_device *ff;
967 944
@@ -996,6 +973,9 @@ struct input_dev {
996 unsigned int users; 973 unsigned int users;
997 974
998 struct class_device cdev; 975 struct class_device cdev;
976 union { /* temporarily so while we switching to struct device */
977 struct device *parent;
978 } dev;
999 979
1000 struct list_head h_list; 980 struct list_head h_list;
1001 struct list_head node; 981 struct list_head node;
@@ -1074,7 +1054,7 @@ struct input_handler {
1074 void *private; 1054 void *private;
1075 1055
1076 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 1056 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
1077 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id); 1057 int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
1078 void (*disconnect)(struct input_handle *handle); 1058 void (*disconnect)(struct input_handle *handle);
1079 void (*start)(struct input_handle *handle); 1059 void (*start)(struct input_handle *handle);
1080 1060
@@ -1104,7 +1084,7 @@ struct input_handle {
1104}; 1084};
1105 1085
1106#define to_dev(n) container_of(n,struct input_dev,node) 1086#define to_dev(n) container_of(n,struct input_dev,node)
1107#define to_handler(n) container_of(n,struct input_handler,node); 1087#define to_handler(n) container_of(n,struct input_handler,node)
1108#define to_handle(n) container_of(n,struct input_handle,d_node) 1088#define to_handle(n) container_of(n,struct input_handle,d_node)
1109#define to_handle_h(n) container_of(n,struct input_handle,h_node) 1089#define to_handle_h(n) container_of(n,struct input_handle,h_node)
1110 1090
@@ -1121,12 +1101,25 @@ static inline void input_put_device(struct input_dev *dev)
1121 class_device_put(&dev->cdev); 1101 class_device_put(&dev->cdev);
1122} 1102}
1123 1103
1104static inline void *input_get_drvdata(struct input_dev *dev)
1105{
1106 return dev->private;
1107}
1108
1109static inline void input_set_drvdata(struct input_dev *dev, void *data)
1110{
1111 dev->private = data;
1112}
1113
1124int input_register_device(struct input_dev *); 1114int input_register_device(struct input_dev *);
1125void input_unregister_device(struct input_dev *); 1115void input_unregister_device(struct input_dev *);
1126 1116
1127int input_register_handler(struct input_handler *); 1117int input_register_handler(struct input_handler *);
1128void input_unregister_handler(struct input_handler *); 1118void input_unregister_handler(struct input_handler *);
1129 1119
1120int input_register_handle(struct input_handle *);
1121void input_unregister_handle(struct input_handle *);
1122
1130int input_grab_device(struct input_handle *); 1123int input_grab_device(struct input_handle *);
1131void input_release_device(struct input_handle *); 1124void input_release_device(struct input_handle *);
1132 1125
@@ -1168,6 +1161,8 @@ static inline void input_sync(struct input_dev *dev)
1168 input_event(dev, EV_SYN, SYN_REPORT, 0); 1161 input_event(dev, EV_SYN, SYN_REPORT, 0);
1169} 1162}
1170 1163
1164void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
1165
1171static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) 1166static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
1172{ 1167{
1173 dev->absmin[axis] = min; 1168 dev->absmin[axis] = min;
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 838cf5a5bd7f..0319f665dd3f 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -185,10 +185,14 @@ static inline int disable_irq_wake(unsigned int irq)
185 * validator need to define the methods below in their asm/irq.h 185 * validator need to define the methods below in their asm/irq.h
186 * files, under an #ifdef CONFIG_LOCKDEP section. 186 * files, under an #ifdef CONFIG_LOCKDEP section.
187 */ 187 */
188# ifndef CONFIG_LOCKDEP 188#ifndef CONFIG_LOCKDEP
189# define disable_irq_nosync_lockdep(irq) disable_irq_nosync(irq) 189# define disable_irq_nosync_lockdep(irq) disable_irq_nosync(irq)
190# define disable_irq_nosync_lockdep_irqsave(irq, flags) \
191 disable_irq_nosync(irq)
190# define disable_irq_lockdep(irq) disable_irq(irq) 192# define disable_irq_lockdep(irq) disable_irq(irq)
191# define enable_irq_lockdep(irq) enable_irq(irq) 193# define enable_irq_lockdep(irq) enable_irq(irq)
194# define enable_irq_lockdep_irqrestore(irq, flags) \
195 enable_irq(irq)
192# endif 196# endif
193 197
194#endif /* CONFIG_GENERIC_HARDIRQS */ 198#endif /* CONFIG_GENERIC_HARDIRQS */
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index eb0e63ef297f..c288e41ba331 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -124,7 +124,6 @@ struct kset_uevent_ops {
124}; 124};
125 125
126struct kset { 126struct kset {
127 struct subsystem * subsys;
128 struct kobj_type * ktype; 127 struct kobj_type * ktype;
129 struct list_head list; 128 struct list_head list;
130 spinlock_t list_lock; 129 spinlock_t list_lock;
@@ -171,32 +170,23 @@ extern struct kobject * kset_find_obj(struct kset *, const char *);
171#define set_kset_name(str) .kset = { .kobj = { .name = str } } 170#define set_kset_name(str) .kset = { .kobj = { .name = str } }
172 171
173 172
174
175struct subsystem {
176 struct kset kset;
177};
178
179#define decl_subsys(_name,_type,_uevent_ops) \ 173#define decl_subsys(_name,_type,_uevent_ops) \
180struct subsystem _name##_subsys = { \ 174struct kset _name##_subsys = { \
181 .kset = { \ 175 .kobj = { .name = __stringify(_name) }, \
182 .kobj = { .name = __stringify(_name) }, \ 176 .ktype = _type, \
183 .ktype = _type, \ 177 .uevent_ops =_uevent_ops, \
184 .uevent_ops =_uevent_ops, \
185 } \
186} 178}
187#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \ 179#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \
188struct subsystem _varname##_subsys = { \ 180struct kset _varname##_subsys = { \
189 .kset = { \ 181 .kobj = { .name = __stringify(_name) }, \
190 .kobj = { .name = __stringify(_name) }, \ 182 .ktype = _type, \
191 .ktype = _type, \ 183 .uevent_ops =_uevent_ops, \
192 .uevent_ops =_uevent_ops, \
193 } \
194} 184}
195 185
196/* The global /sys/kernel/ subsystem for people to chain off of */ 186/* The global /sys/kernel/ subsystem for people to chain off of */
197extern struct subsystem kernel_subsys; 187extern struct kset kernel_subsys;
198/* The global /sys/hypervisor/ subsystem */ 188/* The global /sys/hypervisor/ subsystem */
199extern struct subsystem hypervisor_subsys; 189extern struct kset hypervisor_subsys;
200 190
201/** 191/**
202 * Helpers for setting the kset of registered objects. 192 * Helpers for setting the kset of registered objects.
@@ -214,7 +204,7 @@ extern struct subsystem hypervisor_subsys;
214 */ 204 */
215 205
216#define kobj_set_kset_s(obj,subsys) \ 206#define kobj_set_kset_s(obj,subsys) \
217 (obj)->kobj.kset = &(subsys).kset 207 (obj)->kobj.kset = &(subsys)
218 208
219/** 209/**
220 * kset_set_kset_s(obj,subsys) - set kset for embedded kset. 210 * kset_set_kset_s(obj,subsys) - set kset for embedded kset.
@@ -228,7 +218,7 @@ extern struct subsystem hypervisor_subsys;
228 */ 218 */
229 219
230#define kset_set_kset_s(obj,subsys) \ 220#define kset_set_kset_s(obj,subsys) \
231 (obj)->kset.kobj.kset = &(subsys).kset 221 (obj)->kset.kobj.kset = &(subsys)
232 222
233/** 223/**
234 * subsys_set_kset(obj,subsys) - set kset for subsystem 224 * subsys_set_kset(obj,subsys) - set kset for subsystem
@@ -241,29 +231,31 @@ extern struct subsystem hypervisor_subsys;
241 */ 231 */
242 232
243#define subsys_set_kset(obj,_subsys) \ 233#define subsys_set_kset(obj,_subsys) \
244 (obj)->subsys.kset.kobj.kset = &(_subsys).kset 234 (obj)->subsys.kobj.kset = &(_subsys)
245 235
246extern void subsystem_init(struct subsystem *); 236extern void subsystem_init(struct kset *);
247extern int __must_check subsystem_register(struct subsystem *); 237extern int __must_check subsystem_register(struct kset *);
248extern void subsystem_unregister(struct subsystem *); 238extern void subsystem_unregister(struct kset *);
249 239
250static inline struct subsystem * subsys_get(struct subsystem * s) 240static inline struct kset *subsys_get(struct kset *s)
251{ 241{
252 return s ? container_of(kset_get(&s->kset),struct subsystem,kset) : NULL; 242 if (s)
243 return kset_get(s);
244 return NULL;
253} 245}
254 246
255static inline void subsys_put(struct subsystem * s) 247static inline void subsys_put(struct kset *s)
256{ 248{
257 kset_put(&s->kset); 249 kset_put(s);
258} 250}
259 251
260struct subsys_attribute { 252struct subsys_attribute {
261 struct attribute attr; 253 struct attribute attr;
262 ssize_t (*show)(struct subsystem *, char *); 254 ssize_t (*show)(struct kset *, char *);
263 ssize_t (*store)(struct subsystem *, const char *, size_t); 255 ssize_t (*store)(struct kset *, const char *, size_t);
264}; 256};
265 257
266extern int __must_check subsys_create_file(struct subsystem * , 258extern int __must_check subsys_create_file(struct kset *,
267 struct subsys_attribute *); 259 struct subsys_attribute *);
268 260
269#if defined(CONFIG_HOTPLUG) 261#if defined(CONFIG_HOTPLUG)
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index ac25b5649c59..f6a81e0b1b93 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -88,7 +88,7 @@ struct nlm_wait;
88/* 88/*
89 * Memory chunk for NLM client RPC request. 89 * Memory chunk for NLM client RPC request.
90 */ 90 */
91#define NLMCLNT_OHSIZE (sizeof(utsname()->nodename)+10) 91#define NLMCLNT_OHSIZE ((__NEW_UTS_LEN) + 10u)
92struct nlm_rqst { 92struct nlm_rqst {
93 unsigned int a_flags; /* initial RPC task flags */ 93 unsigned int a_flags; /* initial RPC task flags */
94 struct nlm_host * a_host; /* host handle */ 94 struct nlm_host * a_host; /* host handle */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index e45712acfac5..badf702fcff4 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -10,7 +10,7 @@
10#ifndef LINUX_MMC_CARD_H 10#ifndef LINUX_MMC_CARD_H
11#define LINUX_MMC_CARD_H 11#define LINUX_MMC_CARD_H
12 12
13#include <linux/mmc/mmc.h> 13#include <linux/mmc/core.h>
14 14
15struct mmc_cid { 15struct mmc_cid {
16 unsigned int manfid; 16 unsigned int manfid;
@@ -41,6 +41,7 @@ struct mmc_csd {
41 41
42struct mmc_ext_csd { 42struct mmc_ext_csd {
43 unsigned int hs_max_dtr; 43 unsigned int hs_max_dtr;
44 unsigned int sectors;
44}; 45};
45 46
46struct sd_scr { 47struct sd_scr {
@@ -60,18 +61,17 @@ struct mmc_host;
60 * MMC device 61 * MMC device
61 */ 62 */
62struct mmc_card { 63struct mmc_card {
63 struct list_head node; /* node in hosts devices list */
64 struct mmc_host *host; /* the host this device belongs to */ 64 struct mmc_host *host; /* the host this device belongs to */
65 struct device dev; /* the device */ 65 struct device dev; /* the device */
66 unsigned int rca; /* relative card address of device */ 66 unsigned int rca; /* relative card address of device */
67 unsigned int type; /* card type */
68#define MMC_TYPE_MMC 0 /* MMC card */
69#define MMC_TYPE_SD 1 /* SD card */
67 unsigned int state; /* (our) card state */ 70 unsigned int state; /* (our) card state */
68#define MMC_STATE_PRESENT (1<<0) /* present in sysfs */ 71#define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
69#define MMC_STATE_DEAD (1<<1) /* device no longer in stack */ 72#define MMC_STATE_READONLY (1<<1) /* card is read-only */
70#define MMC_STATE_BAD (1<<2) /* unrecognised device */ 73#define MMC_STATE_HIGHSPEED (1<<2) /* card is in high speed mode */
71#define MMC_STATE_SDCARD (1<<3) /* is an SD card */ 74#define MMC_STATE_BLOCKADDR (1<<3) /* card uses block-addressing */
72#define MMC_STATE_READONLY (1<<4) /* card is read-only */
73#define MMC_STATE_HIGHSPEED (1<<5) /* card is in high speed mode */
74#define MMC_STATE_BLOCKADDR (1<<6) /* card uses block-addressing */
75 u32 raw_cid[4]; /* raw card CID */ 75 u32 raw_cid[4]; /* raw card CID */
76 u32 raw_csd[4]; /* raw card CSD */ 76 u32 raw_csd[4]; /* raw card CSD */
77 u32 raw_scr[2]; /* raw card SCR */ 77 u32 raw_scr[2]; /* raw card SCR */
@@ -82,18 +82,15 @@ struct mmc_card {
82 struct sd_switch_caps sw_caps; /* switch (CMD6) caps */ 82 struct sd_switch_caps sw_caps; /* switch (CMD6) caps */
83}; 83};
84 84
85#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
86#define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD)
87
85#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) 88#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
86#define mmc_card_dead(c) ((c)->state & MMC_STATE_DEAD)
87#define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
88#define mmc_card_sd(c) ((c)->state & MMC_STATE_SDCARD)
89#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) 89#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
90#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED) 90#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED)
91#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) 91#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
92 92
93#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) 93#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
94#define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
95#define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
96#define mmc_card_set_sd(c) ((c)->state |= MMC_STATE_SDCARD)
97#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) 94#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
98#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) 95#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED)
99#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) 96#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
@@ -119,11 +116,4 @@ struct mmc_driver {
119extern int mmc_register_driver(struct mmc_driver *); 116extern int mmc_register_driver(struct mmc_driver *);
120extern void mmc_unregister_driver(struct mmc_driver *); 117extern void mmc_unregister_driver(struct mmc_driver *);
121 118
122static inline int mmc_card_claim_host(struct mmc_card *card)
123{
124 return __mmc_claim_host(card->host, card);
125}
126
127#define mmc_card_release_host(c) mmc_release_host((c)->host)
128
129#endif 119#endif
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
new file mode 100644
index 000000000000..04bbe12fae8d
--- /dev/null
+++ b/include/linux/mmc/core.h
@@ -0,0 +1,112 @@
1/*
2 * linux/include/linux/mmc/core.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef LINUX_MMC_CORE_H
9#define LINUX_MMC_CORE_H
10
11#include <linux/interrupt.h>
12#include <linux/device.h>
13
14struct request;
15struct mmc_data;
16struct mmc_request;
17
18struct mmc_command {
19 u32 opcode;
20 u32 arg;
21 u32 resp[4];
22 unsigned int flags; /* expected response type */
23#define MMC_RSP_PRESENT (1 << 0)
24#define MMC_RSP_136 (1 << 1) /* 136 bit response */
25#define MMC_RSP_CRC (1 << 2) /* expect valid crc */
26#define MMC_RSP_BUSY (1 << 3) /* card may send busy */
27#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */
28#define MMC_CMD_MASK (3 << 5) /* command type */
29#define MMC_CMD_AC (0 << 5)
30#define MMC_CMD_ADTC (1 << 5)
31#define MMC_CMD_BC (2 << 5)
32#define MMC_CMD_BCR (3 << 5)
33
34/*
35 * These are the response types, and correspond to valid bit
36 * patterns of the above flags. One additional valid pattern
37 * is all zeros, which means we don't expect a response.
38 */
39#define MMC_RSP_NONE (0)
40#define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
41#define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY)
42#define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)
43#define MMC_RSP_R3 (MMC_RSP_PRESENT)
44#define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
45#define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
46
47#define mmc_resp_type(cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
48
49/*
50 * These are the command types.
51 */
52#define mmc_cmd_type(cmd) ((cmd)->flags & MMC_CMD_MASK)
53
54 unsigned int retries; /* max number of retries */
55 unsigned int error; /* command error */
56
57#define MMC_ERR_NONE 0
58#define MMC_ERR_TIMEOUT 1
59#define MMC_ERR_BADCRC 2
60#define MMC_ERR_FIFO 3
61#define MMC_ERR_FAILED 4
62#define MMC_ERR_INVALID 5
63
64 struct mmc_data *data; /* data segment associated with cmd */
65 struct mmc_request *mrq; /* associated request */
66};
67
68struct mmc_data {
69 unsigned int timeout_ns; /* data timeout (in ns, max 80ms) */
70 unsigned int timeout_clks; /* data timeout (in clocks) */
71 unsigned int blksz; /* data block size */
72 unsigned int blocks; /* number of blocks */
73 unsigned int error; /* data error */
74 unsigned int flags;
75
76#define MMC_DATA_WRITE (1 << 8)
77#define MMC_DATA_READ (1 << 9)
78#define MMC_DATA_STREAM (1 << 10)
79#define MMC_DATA_MULTI (1 << 11)
80
81 unsigned int bytes_xfered;
82
83 struct mmc_command *stop; /* stop command */
84 struct mmc_request *mrq; /* associated request */
85
86 unsigned int sg_len; /* size of scatter list */
87 struct scatterlist *sg; /* I/O scatter list */
88};
89
90struct mmc_request {
91 struct mmc_command *cmd;
92 struct mmc_data *data;
93 struct mmc_command *stop;
94
95 void *done_data; /* completion data */
96 void (*done)(struct mmc_request *);/* completion function */
97};
98
99struct mmc_host;
100struct mmc_card;
101
102extern int mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
103extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
104extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
105 struct mmc_command *, int);
106
107extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *, int);
108
109extern void mmc_claim_host(struct mmc_host *host);
110extern void mmc_release_host(struct mmc_host *host);
111
112#endif
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index bfcef8a1ad8b..b1350dfd3e91 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -10,36 +10,13 @@
10#ifndef LINUX_MMC_HOST_H 10#ifndef LINUX_MMC_HOST_H
11#define LINUX_MMC_HOST_H 11#define LINUX_MMC_HOST_H
12 12
13#include <linux/mmc/mmc.h> 13#include <linux/mmc/core.h>
14 14
15struct mmc_ios { 15struct mmc_ios {
16 unsigned int clock; /* clock rate */ 16 unsigned int clock; /* clock rate */
17 unsigned short vdd; 17 unsigned short vdd;
18 18
19#define MMC_VDD_150 0 19/* vdd stores the bit number of the selected voltage range from below. */
20#define MMC_VDD_155 1
21#define MMC_VDD_160 2
22#define MMC_VDD_165 3
23#define MMC_VDD_170 4
24#define MMC_VDD_180 5
25#define MMC_VDD_190 6
26#define MMC_VDD_200 7
27#define MMC_VDD_210 8
28#define MMC_VDD_220 9
29#define MMC_VDD_230 10
30#define MMC_VDD_240 11
31#define MMC_VDD_250 12
32#define MMC_VDD_260 13
33#define MMC_VDD_270 14
34#define MMC_VDD_280 15
35#define MMC_VDD_290 16
36#define MMC_VDD_300 17
37#define MMC_VDD_310 18
38#define MMC_VDD_320 19
39#define MMC_VDD_330 20
40#define MMC_VDD_340 21
41#define MMC_VDD_350 22
42#define MMC_VDD_360 23
43 20
44 unsigned char bus_mode; /* command output mode */ 21 unsigned char bus_mode; /* command output mode */
45 22
@@ -88,6 +65,24 @@ struct mmc_host {
88 unsigned int f_max; 65 unsigned int f_max;
89 u32 ocr_avail; 66 u32 ocr_avail;
90 67
68#define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */
69#define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */
70#define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */
71#define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */
72#define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */
73#define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */
74#define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */
75#define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */
76#define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */
77#define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */
78#define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */
79#define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */
80#define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */
81#define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */
82#define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */
83#define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */
84#define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */
85
91 unsigned long caps; /* Host capabilities */ 86 unsigned long caps; /* Host capabilities */
92 87
93#define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */ 88#define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */
@@ -106,6 +101,8 @@ struct mmc_host {
106 unsigned int max_blk_count; /* maximum number of blocks in one req */ 101 unsigned int max_blk_count; /* maximum number of blocks in one req */
107 102
108 /* private data */ 103 /* private data */
104 spinlock_t lock; /* lock for claim and bus ops */
105
109 struct mmc_ios ios; /* current io bus settings */ 106 struct mmc_ios ios; /* current io bus settings */
110 u32 ocr; /* the current OCR setting */ 107 u32 ocr; /* the current OCR setting */
111 108
@@ -113,15 +110,19 @@ struct mmc_host {
113#define MMC_MODE_MMC 0 110#define MMC_MODE_MMC 0
114#define MMC_MODE_SD 1 111#define MMC_MODE_SD 1
115 112
116 struct list_head cards; /* devices attached to this host */ 113 struct mmc_card *card; /* device attached to this host */
117 114
118 wait_queue_head_t wq; 115 wait_queue_head_t wq;
119 spinlock_t lock; /* claimed lock */
120 unsigned int claimed:1; /* host exclusively claimed */ 116 unsigned int claimed:1; /* host exclusively claimed */
121 117
122 struct mmc_card *card_selected; /* the selected MMC card */
123
124 struct delayed_work detect; 118 struct delayed_work detect;
119#ifdef CONFIG_MMC_DEBUG
120 unsigned int removed:1; /* host is being removed */
121#endif
122
123 const struct mmc_bus_ops *bus_ops; /* current bus driver */
124 unsigned int bus_refs; /* reference counter */
125 unsigned int bus_dead:1; /* bus has been released */
125 126
126 unsigned long private[0] ____cacheline_aligned; 127 unsigned long private[0] ____cacheline_aligned;
127}; 128};
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index cdc54be804f1..e3ed9b95040e 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -1,119 +1,257 @@
1/* 1/*
2 * linux/include/linux/mmc/mmc.h 2 * Header for MultiMediaCard (MMC)
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * Copyright 2002 Hewlett-Packard Company
5 * it under the terms of the GNU General Public License version 2 as 5 *
6 * published by the Free Software Foundation. 6 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is
8 * preserved in its entirety in all copies and derived works.
9 *
10 * HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
11 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
12 * FITNESS FOR ANY PARTICULAR PURPOSE.
13 *
14 * Many thanks to Alessandro Rubini and Jonathan Corbet!
15 *
16 * Based strongly on code by:
17 *
18 * Author: Yong-iL Joh <tolkien@mizi.com>
19 * Date : $Date: 2002/06/18 12:37:30 $
20 *
21 * Author: Andrew Christian
22 * 15 May 2002
7 */ 23 */
8#ifndef MMC_H 24
9#define MMC_H 25#ifndef MMC_MMC_H
10 26#define MMC_MMC_H
11#include <linux/list.h> 27
12#include <linux/interrupt.h> 28/* Standard MMC commands (4.1) type argument response */
13#include <linux/device.h> 29 /* class 1 */
14 30#define MMC_GO_IDLE_STATE 0 /* bc */
15struct request; 31#define MMC_SEND_OP_COND 1 /* bcr [31:0] OCR R3 */
16struct mmc_data; 32#define MMC_ALL_SEND_CID 2 /* bcr R2 */
17struct mmc_request; 33#define MMC_SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */
18 34#define MMC_SET_DSR 4 /* bc [31:16] RCA */
19struct mmc_command { 35#define MMC_SWITCH 6 /* ac [31:0] See below R1b */
20 u32 opcode; 36#define MMC_SELECT_CARD 7 /* ac [31:16] RCA R1 */
21 u32 arg; 37#define MMC_SEND_EXT_CSD 8 /* adtc R1 */
22 u32 resp[4]; 38#define MMC_SEND_CSD 9 /* ac [31:16] RCA R2 */
23 unsigned int flags; /* expected response type */ 39#define MMC_SEND_CID 10 /* ac [31:16] RCA R2 */
24#define MMC_RSP_PRESENT (1 << 0) 40#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
25#define MMC_RSP_136 (1 << 1) /* 136 bit response */ 41#define MMC_STOP_TRANSMISSION 12 /* ac R1b */
26#define MMC_RSP_CRC (1 << 2) /* expect valid crc */ 42#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */
27#define MMC_RSP_BUSY (1 << 3) /* card may send busy */ 43#define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */
28#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */ 44
29#define MMC_CMD_MASK (3 << 5) /* command type */ 45 /* class 2 */
30#define MMC_CMD_AC (0 << 5) 46#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */
31#define MMC_CMD_ADTC (1 << 5) 47#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */
32#define MMC_CMD_BC (2 << 5) 48#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */
33#define MMC_CMD_BCR (3 << 5) 49
50 /* class 3 */
51#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
52
53 /* class 4 */
54#define MMC_SET_BLOCK_COUNT 23 /* adtc [31:0] data addr R1 */
55#define MMC_WRITE_BLOCK 24 /* adtc [31:0] data addr R1 */
56#define MMC_WRITE_MULTIPLE_BLOCK 25 /* adtc R1 */
57#define MMC_PROGRAM_CID 26 /* adtc R1 */
58#define MMC_PROGRAM_CSD 27 /* adtc R1 */
59
60 /* class 6 */
61#define MMC_SET_WRITE_PROT 28 /* ac [31:0] data addr R1b */
62#define MMC_CLR_WRITE_PROT 29 /* ac [31:0] data addr R1b */
63#define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */
64
65 /* class 5 */
66#define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */
67#define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */
68#define MMC_ERASE 38 /* ac R1b */
69
70 /* class 9 */
71#define MMC_FAST_IO 39 /* ac <Complex> R4 */
72#define MMC_GO_IRQ_STATE 40 /* bcr R5 */
73
74 /* class 7 */
75#define MMC_LOCK_UNLOCK 42 /* adtc R1b */
76
77 /* class 8 */
78#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */
79#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */
34 80
35/* 81/*
36 * These are the response types, and correspond to valid bit 82 * MMC_SWITCH argument format:
37 * patterns of the above flags. One additional valid pattern 83 *
38 * is all zeros, which means we don't expect a response. 84 * [31:26] Always 0
85 * [25:24] Access Mode
86 * [23:16] Location of target Byte in EXT_CSD
87 * [15:08] Value Byte
88 * [07:03] Always 0
89 * [02:00] Command Set
39 */ 90 */
40#define MMC_RSP_NONE (0)
41#define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
42#define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY)
43#define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)
44#define MMC_RSP_R3 (MMC_RSP_PRESENT)
45#define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
46#define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
47
48#define mmc_resp_type(cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
49 91
50/* 92/*
51 * These are the command types. 93 MMC status in R1
94 Type
95 e : error bit
96 s : status bit
97 r : detected and set for the actual command response
98 x : detected and set during command execution. the host must poll
99 the card by sending status command in order to read these bits.
100 Clear condition
101 a : according to the card state
102 b : always related to the previous command. Reception of
103 a valid command will clear it (with a delay of one command)
104 c : clear by read
52 */ 105 */
53#define mmc_cmd_type(cmd) ((cmd)->flags & MMC_CMD_MASK)
54 106
55 unsigned int retries; /* max number of retries */ 107#define R1_OUT_OF_RANGE (1 << 31) /* er, c */
56 unsigned int error; /* command error */ 108#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */
109#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */
110#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */
111#define R1_ERASE_PARAM (1 << 27) /* ex, c */
112#define R1_WP_VIOLATION (1 << 26) /* erx, c */
113#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */
114#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */
115#define R1_COM_CRC_ERROR (1 << 23) /* er, b */
116#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */
117#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */
118#define R1_CC_ERROR (1 << 20) /* erx, c */
119#define R1_ERROR (1 << 19) /* erx, c */
120#define R1_UNDERRUN (1 << 18) /* ex, c */
121#define R1_OVERRUN (1 << 17) /* ex, c */
122#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */
123#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */
124#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */
125#define R1_ERASE_RESET (1 << 13) /* sr, c */
126#define R1_STATUS(x) (x & 0xFFFFE000)
127#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
128#define R1_READY_FOR_DATA (1 << 8) /* sx, a */
129#define R1_APP_CMD (1 << 5) /* sr, c */
57 130
58#define MMC_ERR_NONE 0 131/* These are unpacked versions of the actual responses */
59#define MMC_ERR_TIMEOUT 1
60#define MMC_ERR_BADCRC 2
61#define MMC_ERR_FIFO 3
62#define MMC_ERR_FAILED 4
63#define MMC_ERR_INVALID 5
64 132
65 struct mmc_data *data; /* data segment associated with cmd */ 133struct _mmc_csd {
66 struct mmc_request *mrq; /* associated request */ 134 u8 csd_structure;
135 u8 spec_vers;
136 u8 taac;
137 u8 nsac;
138 u8 tran_speed;
139 u16 ccc;
140 u8 read_bl_len;
141 u8 read_bl_partial;
142 u8 write_blk_misalign;
143 u8 read_blk_misalign;
144 u8 dsr_imp;
145 u16 c_size;
146 u8 vdd_r_curr_min;
147 u8 vdd_r_curr_max;
148 u8 vdd_w_curr_min;
149 u8 vdd_w_curr_max;
150 u8 c_size_mult;
151 union {
152 struct { /* MMC system specification version 3.1 */
153 u8 erase_grp_size;
154 u8 erase_grp_mult;
155 } v31;
156 struct { /* MMC system specification version 2.2 */
157 u8 sector_size;
158 u8 erase_grp_size;
159 } v22;
160 } erase;
161 u8 wp_grp_size;
162 u8 wp_grp_enable;
163 u8 default_ecc;
164 u8 r2w_factor;
165 u8 write_bl_len;
166 u8 write_bl_partial;
167 u8 file_format_grp;
168 u8 copy;
169 u8 perm_write_protect;
170 u8 tmp_write_protect;
171 u8 file_format;
172 u8 ecc;
67}; 173};
68 174
69struct mmc_data { 175/*
70 unsigned int timeout_ns; /* data timeout (in ns, max 80ms) */ 176 * OCR bits are mostly in host.h
71 unsigned int timeout_clks; /* data timeout (in clocks) */ 177 */
72 unsigned int blksz; /* data block size */ 178#define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
73 unsigned int blocks; /* number of blocks */
74 unsigned int error; /* data error */
75 unsigned int flags;
76 179
77#define MMC_DATA_WRITE (1 << 8) 180/*
78#define MMC_DATA_READ (1 << 9) 181 * Card Command Classes (CCC)
79#define MMC_DATA_STREAM (1 << 10) 182 */
80#define MMC_DATA_MULTI (1 << 11) 183#define CCC_BASIC (1<<0) /* (0) Basic protocol functions */
184 /* (CMD0,1,2,3,4,7,9,10,12,13,15) */
185#define CCC_STREAM_READ (1<<1) /* (1) Stream read commands */
186 /* (CMD11) */
187#define CCC_BLOCK_READ (1<<2) /* (2) Block read commands */
188 /* (CMD16,17,18) */
189#define CCC_STREAM_WRITE (1<<3) /* (3) Stream write commands */
190 /* (CMD20) */
191#define CCC_BLOCK_WRITE (1<<4) /* (4) Block write commands */
192 /* (CMD16,24,25,26,27) */
193#define CCC_ERASE (1<<5) /* (5) Ability to erase blocks */
194 /* (CMD32,33,34,35,36,37,38,39) */
195#define CCC_WRITE_PROT (1<<6) /* (6) Able to write protect blocks */
196 /* (CMD28,29,30) */
197#define CCC_LOCK_CARD (1<<7) /* (7) Able to lock down card */
198 /* (CMD16,CMD42) */
199#define CCC_APP_SPEC (1<<8) /* (8) Application specific */
200 /* (CMD55,56,57,ACMD*) */
201#define CCC_IO_MODE (1<<9) /* (9) I/O mode */
202 /* (CMD5,39,40,52,53) */
203#define CCC_SWITCH (1<<10) /* (10) High speed switch */
204 /* (CMD6,34,35,36,37,50) */
205 /* (11) Reserved */
206 /* (CMD?) */
81 207
82 unsigned int bytes_xfered; 208/*
209 * CSD field definitions
210 */
83 211
84 struct mmc_command *stop; /* stop command */ 212#define CSD_STRUCT_VER_1_0 0 /* Valid for system specification 1.0 - 1.2 */
85 struct mmc_request *mrq; /* associated request */ 213#define CSD_STRUCT_VER_1_1 1 /* Valid for system specification 1.4 - 2.2 */
214#define CSD_STRUCT_VER_1_2 2 /* Valid for system specification 3.1 - 3.2 - 3.31 - 4.0 - 4.1 */
215#define CSD_STRUCT_EXT_CSD 3 /* Version is coded in CSD_STRUCTURE in EXT_CSD */
86 216
87 unsigned int sg_len; /* size of scatter list */ 217#define CSD_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.2 */
88 struct scatterlist *sg; /* I/O scatter list */ 218#define CSD_SPEC_VER_1 1 /* Implements system specification 1.4 */
89}; 219#define CSD_SPEC_VER_2 2 /* Implements system specification 2.0 - 2.2 */
220#define CSD_SPEC_VER_3 3 /* Implements system specification 3.1 - 3.2 - 3.31 */
221#define CSD_SPEC_VER_4 4 /* Implements system specification 4.0 - 4.1 */
90 222
91struct mmc_request { 223/*
92 struct mmc_command *cmd; 224 * EXT_CSD fields
93 struct mmc_data *data; 225 */
94 struct mmc_command *stop;
95 226
96 void *done_data; /* completion data */ 227#define EXT_CSD_BUS_WIDTH 183 /* R/W */
97 void (*done)(struct mmc_request *);/* completion function */ 228#define EXT_CSD_HS_TIMING 185 /* R/W */
98}; 229#define EXT_CSD_CARD_TYPE 196 /* RO */
230#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
231
232/*
233 * EXT_CSD field definitions
234 */
99 235
100struct mmc_host; 236#define EXT_CSD_CMD_SET_NORMAL (1<<0)
101struct mmc_card; 237#define EXT_CSD_CMD_SET_SECURE (1<<1)
238#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
102 239
103extern int mmc_wait_for_req(struct mmc_host *, struct mmc_request *); 240#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
104extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); 241#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
105extern int mmc_wait_for_app_cmd(struct mmc_host *, unsigned int,
106 struct mmc_command *, int);
107 242
108extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *, int); 243#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
244#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
245#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
109 246
110extern int __mmc_claim_host(struct mmc_host *host, struct mmc_card *card); 247/*
248 * MMC_SWITCH access modes
249 */
111 250
112static inline void mmc_claim_host(struct mmc_host *host) 251#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */
113{ 252#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */
114 __mmc_claim_host(host, (struct mmc_card *)-1); 253#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */
115} 254#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */
116 255
117extern void mmc_release_host(struct mmc_host *host); 256#endif /* MMC_MMC_PROTOCOL_H */
118 257
119#endif
diff --git a/include/linux/mmc/protocol.h b/include/linux/mmc/protocol.h
deleted file mode 100644
index c90b6768329d..000000000000
--- a/include/linux/mmc/protocol.h
+++ /dev/null
@@ -1,327 +0,0 @@
1/*
2 * Header for MultiMediaCard (MMC)
3 *
4 * Copyright 2002 Hewlett-Packard Company
5 *
6 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is
8 * preserved in its entirety in all copies and derived works.
9 *
10 * HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
11 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
12 * FITNESS FOR ANY PARTICULAR PURPOSE.
13 *
14 * Many thanks to Alessandro Rubini and Jonathan Corbet!
15 *
16 * Based strongly on code by:
17 *
18 * Author: Yong-iL Joh <tolkien@mizi.com>
19 * Date : $Date: 2002/06/18 12:37:30 $
20 *
21 * Author: Andrew Christian
22 * 15 May 2002
23 */
24
25#ifndef MMC_MMC_PROTOCOL_H
26#define MMC_MMC_PROTOCOL_H
27
28/* Standard MMC commands (4.1) type argument response */
29 /* class 1 */
30#define MMC_GO_IDLE_STATE 0 /* bc */
31#define MMC_SEND_OP_COND 1 /* bcr [31:0] OCR R3 */
32#define MMC_ALL_SEND_CID 2 /* bcr R2 */
33#define MMC_SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */
34#define MMC_SET_DSR 4 /* bc [31:16] RCA */
35#define MMC_SWITCH 6 /* ac [31:0] See below R1b */
36#define MMC_SELECT_CARD 7 /* ac [31:16] RCA R1 */
37#define MMC_SEND_EXT_CSD 8 /* adtc R1 */
38#define MMC_SEND_CSD 9 /* ac [31:16] RCA R2 */
39#define MMC_SEND_CID 10 /* ac [31:16] RCA R2 */
40#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
41#define MMC_STOP_TRANSMISSION 12 /* ac R1b */
42#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */
43#define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */
44
45 /* class 2 */
46#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */
47#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */
48#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */
49
50 /* class 3 */
51#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
52
53 /* class 4 */
54#define MMC_SET_BLOCK_COUNT 23 /* adtc [31:0] data addr R1 */
55#define MMC_WRITE_BLOCK 24 /* adtc [31:0] data addr R1 */
56#define MMC_WRITE_MULTIPLE_BLOCK 25 /* adtc R1 */
57#define MMC_PROGRAM_CID 26 /* adtc R1 */
58#define MMC_PROGRAM_CSD 27 /* adtc R1 */
59
60 /* class 6 */
61#define MMC_SET_WRITE_PROT 28 /* ac [31:0] data addr R1b */
62#define MMC_CLR_WRITE_PROT 29 /* ac [31:0] data addr R1b */
63#define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */
64
65 /* class 5 */
66#define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */
67#define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */
68#define MMC_ERASE 38 /* ac R1b */
69
70 /* class 9 */
71#define MMC_FAST_IO 39 /* ac <Complex> R4 */
72#define MMC_GO_IRQ_STATE 40 /* bcr R5 */
73
74 /* class 7 */
75#define MMC_LOCK_UNLOCK 42 /* adtc R1b */
76
77 /* class 8 */
78#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */
79#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */
80
81/* SD commands type argument response */
82 /* class 0 */
83/* This is basically the same command as for MMC with some quirks. */
84#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */
85#define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */
86
87 /* class 10 */
88#define SD_SWITCH 6 /* adtc [31:0] See below R1 */
89
90 /* Application commands */
91#define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
92#define SD_APP_SEND_NUM_WR_BLKS 22 /* adtc R1 */
93#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */
94#define SD_APP_SEND_SCR 51 /* adtc R1 */
95
96/*
97 * MMC_SWITCH argument format:
98 *
99 * [31:26] Always 0
100 * [25:24] Access Mode
101 * [23:16] Location of target Byte in EXT_CSD
102 * [15:08] Value Byte
103 * [07:03] Always 0
104 * [02:00] Command Set
105 */
106
107/*
108 * SD_SWITCH argument format:
109 *
110 * [31] Check (0) or switch (1)
111 * [30:24] Reserved (0)
112 * [23:20] Function group 6
113 * [19:16] Function group 5
114 * [15:12] Function group 4
115 * [11:8] Function group 3
116 * [7:4] Function group 2
117 * [3:0] Function group 1
118 */
119
120/*
121 * SD_SEND_IF_COND argument format:
122 *
123 * [31:12] Reserved (0)
124 * [11:8] Host Voltage Supply Flags
125 * [7:0] Check Pattern (0xAA)
126 */
127
128/*
129 MMC status in R1
130 Type
131 e : error bit
132 s : status bit
133 r : detected and set for the actual command response
134 x : detected and set during command execution. the host must poll
135 the card by sending status command in order to read these bits.
136 Clear condition
137 a : according to the card state
138 b : always related to the previous command. Reception of
139 a valid command will clear it (with a delay of one command)
140 c : clear by read
141 */
142
143#define R1_OUT_OF_RANGE (1 << 31) /* er, c */
144#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */
145#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */
146#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */
147#define R1_ERASE_PARAM (1 << 27) /* ex, c */
148#define R1_WP_VIOLATION (1 << 26) /* erx, c */
149#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */
150#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */
151#define R1_COM_CRC_ERROR (1 << 23) /* er, b */
152#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */
153#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */
154#define R1_CC_ERROR (1 << 20) /* erx, c */
155#define R1_ERROR (1 << 19) /* erx, c */
156#define R1_UNDERRUN (1 << 18) /* ex, c */
157#define R1_OVERRUN (1 << 17) /* ex, c */
158#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */
159#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */
160#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */
161#define R1_ERASE_RESET (1 << 13) /* sr, c */
162#define R1_STATUS(x) (x & 0xFFFFE000)
163#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
164#define R1_READY_FOR_DATA (1 << 8) /* sx, a */
165#define R1_APP_CMD (1 << 5) /* sr, c */
166
167/* These are unpacked versions of the actual responses */
168
169struct _mmc_csd {
170 u8 csd_structure;
171 u8 spec_vers;
172 u8 taac;
173 u8 nsac;
174 u8 tran_speed;
175 u16 ccc;
176 u8 read_bl_len;
177 u8 read_bl_partial;
178 u8 write_blk_misalign;
179 u8 read_blk_misalign;
180 u8 dsr_imp;
181 u16 c_size;
182 u8 vdd_r_curr_min;
183 u8 vdd_r_curr_max;
184 u8 vdd_w_curr_min;
185 u8 vdd_w_curr_max;
186 u8 c_size_mult;
187 union {
188 struct { /* MMC system specification version 3.1 */
189 u8 erase_grp_size;
190 u8 erase_grp_mult;
191 } v31;
192 struct { /* MMC system specification version 2.2 */
193 u8 sector_size;
194 u8 erase_grp_size;
195 } v22;
196 } erase;
197 u8 wp_grp_size;
198 u8 wp_grp_enable;
199 u8 default_ecc;
200 u8 r2w_factor;
201 u8 write_bl_len;
202 u8 write_bl_partial;
203 u8 file_format_grp;
204 u8 copy;
205 u8 perm_write_protect;
206 u8 tmp_write_protect;
207 u8 file_format;
208 u8 ecc;
209};
210
211#define MMC_VDD_145_150 0x00000001 /* VDD voltage 1.45 - 1.50 */
212#define MMC_VDD_150_155 0x00000002 /* VDD voltage 1.50 - 1.55 */
213#define MMC_VDD_155_160 0x00000004 /* VDD voltage 1.55 - 1.60 */
214#define MMC_VDD_160_165 0x00000008 /* VDD voltage 1.60 - 1.65 */
215#define MMC_VDD_165_170 0x00000010 /* VDD voltage 1.65 - 1.70 */
216#define MMC_VDD_17_18 0x00000020 /* VDD voltage 1.7 - 1.8 */
217#define MMC_VDD_18_19 0x00000040 /* VDD voltage 1.8 - 1.9 */
218#define MMC_VDD_19_20 0x00000080 /* VDD voltage 1.9 - 2.0 */
219#define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */
220#define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */
221#define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */
222#define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */
223#define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */
224#define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */
225#define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */
226#define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */
227#define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */
228#define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */
229#define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */
230#define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */
231#define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */
232#define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */
233#define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */
234#define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */
235#define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
236
237/*
238 * Card Command Classes (CCC)
239 */
240#define CCC_BASIC (1<<0) /* (0) Basic protocol functions */
241 /* (CMD0,1,2,3,4,7,9,10,12,13,15) */
242#define CCC_STREAM_READ (1<<1) /* (1) Stream read commands */
243 /* (CMD11) */
244#define CCC_BLOCK_READ (1<<2) /* (2) Block read commands */
245 /* (CMD16,17,18) */
246#define CCC_STREAM_WRITE (1<<3) /* (3) Stream write commands */
247 /* (CMD20) */
248#define CCC_BLOCK_WRITE (1<<4) /* (4) Block write commands */
249 /* (CMD16,24,25,26,27) */
250#define CCC_ERASE (1<<5) /* (5) Ability to erase blocks */
251 /* (CMD32,33,34,35,36,37,38,39) */
252#define CCC_WRITE_PROT (1<<6) /* (6) Able to write protect blocks */
253 /* (CMD28,29,30) */
254#define CCC_LOCK_CARD (1<<7) /* (7) Able to lock down card */
255 /* (CMD16,CMD42) */
256#define CCC_APP_SPEC (1<<8) /* (8) Application specific */
257 /* (CMD55,56,57,ACMD*) */
258#define CCC_IO_MODE (1<<9) /* (9) I/O mode */
259 /* (CMD5,39,40,52,53) */
260#define CCC_SWITCH (1<<10) /* (10) High speed switch */
261 /* (CMD6,34,35,36,37,50) */
262 /* (11) Reserved */
263 /* (CMD?) */
264
265/*
266 * CSD field definitions
267 */
268
269#define CSD_STRUCT_VER_1_0 0 /* Valid for system specification 1.0 - 1.2 */
270#define CSD_STRUCT_VER_1_1 1 /* Valid for system specification 1.4 - 2.2 */
271#define CSD_STRUCT_VER_1_2 2 /* Valid for system specification 3.1 - 3.2 - 3.31 - 4.0 - 4.1 */
272#define CSD_STRUCT_EXT_CSD 3 /* Version is coded in CSD_STRUCTURE in EXT_CSD */
273
274#define CSD_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.2 */
275#define CSD_SPEC_VER_1 1 /* Implements system specification 1.4 */
276#define CSD_SPEC_VER_2 2 /* Implements system specification 2.0 - 2.2 */
277#define CSD_SPEC_VER_3 3 /* Implements system specification 3.1 - 3.2 - 3.31 */
278#define CSD_SPEC_VER_4 4 /* Implements system specification 4.0 - 4.1 */
279
280/*
281 * EXT_CSD fields
282 */
283
284#define EXT_CSD_BUS_WIDTH 183 /* R/W */
285#define EXT_CSD_HS_TIMING 185 /* R/W */
286#define EXT_CSD_CARD_TYPE 196 /* RO */
287
288/*
289 * EXT_CSD field definitions
290 */
291
292#define EXT_CSD_CMD_SET_NORMAL (1<<0)
293#define EXT_CSD_CMD_SET_SECURE (1<<1)
294#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
295
296#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
297#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
298
299#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
300#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
301#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
302
303/*
304 * MMC_SWITCH access modes
305 */
306
307#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */
308#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */
309#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */
310#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */
311
312/*
313 * SCR field definitions
314 */
315
316#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */
317#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */
318#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */
319
320/*
321 * SD bus widths
322 */
323#define SD_BUS_WIDTH_1 0
324#define SD_BUS_WIDTH_4 2
325
326#endif /* MMC_MMC_PROTOCOL_H */
327
diff --git a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h
new file mode 100644
index 000000000000..f310062cffb4
--- /dev/null
+++ b/include/linux/mmc/sd.h
@@ -0,0 +1,83 @@
1/*
2 * include/linux/mmc/sd.h
3 *
4 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 */
11
12#ifndef MMC_SD_H
13#define MMC_SD_H
14
15/* SD commands type argument response */
16 /* class 0 */
17/* This is basically the same command as for MMC with some quirks. */
18#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */
19#define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */
20
21 /* class 10 */
22#define SD_SWITCH 6 /* adtc [31:0] See below R1 */
23
24 /* Application commands */
25#define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
26#define SD_APP_SEND_NUM_WR_BLKS 22 /* adtc R1 */
27#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */
28#define SD_APP_SEND_SCR 51 /* adtc R1 */
29
30/*
31 * SD_SWITCH argument format:
32 *
33 * [31] Check (0) or switch (1)
34 * [30:24] Reserved (0)
35 * [23:20] Function group 6
36 * [19:16] Function group 5
37 * [15:12] Function group 4
38 * [11:8] Function group 3
39 * [7:4] Function group 2
40 * [3:0] Function group 1
41 */
42
43/*
44 * SD_SEND_IF_COND argument format:
45 *
46 * [31:12] Reserved (0)
47 * [11:8] Host Voltage Supply Flags
48 * [7:0] Check Pattern (0xAA)
49 */
50
51/*
52 * SCR field definitions
53 */
54
55#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */
56#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */
57#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */
58
59/*
60 * SD bus widths
61 */
62#define SD_BUS_WIDTH_1 0
63#define SD_BUS_WIDTH_4 2
64
65/*
66 * SD_SWITCH mode
67 */
68#define SD_SWITCH_CHECK 0
69#define SD_SWITCH_SET 1
70
71/*
72 * SD_SWITCH function groups
73 */
74#define SD_SWITCH_GRP_ACCESS 0
75
76/*
77 * SD_SWITCH access modes
78 */
79#define SD_SWITCH_ACCESS_DEF 0
80#define SD_SWITCH_ACCESS_HS 1
81
82#endif
83
diff --git a/include/linux/module.h b/include/linux/module.h
index 95679eb8571e..f0b0faf42d5d 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -568,7 +568,7 @@ struct device_driver;
568#ifdef CONFIG_SYSFS 568#ifdef CONFIG_SYSFS
569struct module; 569struct module;
570 570
571extern struct subsystem module_subsys; 571extern struct kset module_subsys;
572 572
573int mod_sysfs_init(struct module *mod); 573int mod_sysfs_init(struct module *mod);
574int mod_sysfs_setup(struct module *mod, 574int mod_sysfs_setup(struct module *mod,
diff --git a/include/linux/msi.h b/include/linux/msi.h
index e38fe6822cb4..94bb46d82efd 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -1,6 +1,8 @@
1#ifndef LINUX_MSI_H 1#ifndef LINUX_MSI_H
2#define LINUX_MSI_H 2#define LINUX_MSI_H
3 3
4#include <linux/list.h>
5
4struct msi_msg { 6struct msi_msg {
5 u32 address_lo; /* low 32 bits of msi message address */ 7 u32 address_lo; /* low 32 bits of msi message address */
6 u32 address_hi; /* high 32 bits of msi message address */ 8 u32 address_hi; /* high 32 bits of msi message address */
@@ -24,10 +26,8 @@ struct msi_desc {
24 unsigned default_irq; /* default pre-assigned irq */ 26 unsigned default_irq; /* default pre-assigned irq */
25 }msi_attrib; 27 }msi_attrib;
26 28
27 struct { 29 unsigned int irq;
28 __u16 head; 30 struct list_head list;
29 __u16 tail;
30 }link;
31 31
32 void __iomem *mask_base; 32 void __iomem *mask_base;
33 struct pci_dev *dev; 33 struct pci_dev *dev;
@@ -41,6 +41,9 @@ struct msi_desc {
41 */ 41 */
42int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc); 42int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
43void arch_teardown_msi_irq(unsigned int irq); 43void arch_teardown_msi_irq(unsigned int irq);
44extern int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
45extern void arch_teardown_msi_irqs(struct pci_dev *dev);
46extern int arch_msi_check_device(struct pci_dev* dev, int nvec, int type);
44 47
45 48
46#endif /* LINUX_MSI_H */ 49#endif /* LINUX_MSI_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ac0c92b1e002..30446222b396 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -304,7 +304,7 @@ struct net_device
304 304
305 unsigned long state; 305 unsigned long state;
306 306
307 struct net_device *next; 307 struct list_head dev_list;
308 308
309 /* The device initialization function. Called only once. */ 309 /* The device initialization function. Called only once. */
310 int (*init)(struct net_device *dev); 310 int (*init)(struct net_device *dev);
@@ -575,13 +575,36 @@ struct packet_type {
575#include <linux/notifier.h> 575#include <linux/notifier.h>
576 576
577extern struct net_device loopback_dev; /* The loopback */ 577extern struct net_device loopback_dev; /* The loopback */
578extern struct net_device *dev_base; /* All devices */ 578extern struct list_head dev_base_head; /* All devices */
579extern rwlock_t dev_base_lock; /* Device list lock */ 579extern rwlock_t dev_base_lock; /* Device list lock */
580 580
581#define for_each_netdev(d) \
582 list_for_each_entry(d, &dev_base_head, dev_list)
583#define for_each_netdev_safe(d, n) \
584 list_for_each_entry_safe(d, n, &dev_base_head, dev_list)
585#define for_each_netdev_continue(d) \
586 list_for_each_entry_continue(d, &dev_base_head, dev_list)
587#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
588
589static inline struct net_device *next_net_device(struct net_device *dev)
590{
591 struct list_head *lh;
592
593 lh = dev->dev_list.next;
594 return lh == &dev_base_head ? NULL : net_device_entry(lh);
595}
596
597static inline struct net_device *first_net_device(void)
598{
599 return list_empty(&dev_base_head) ? NULL :
600 net_device_entry(dev_base_head.next);
601}
602
581extern int netdev_boot_setup_check(struct net_device *dev); 603extern int netdev_boot_setup_check(struct net_device *dev);
582extern unsigned long netdev_boot_base(const char *prefix, int unit); 604extern unsigned long netdev_boot_base(const char *prefix, int unit);
583extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr); 605extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);
584extern struct net_device *dev_getfirstbyhwtype(unsigned short type); 606extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
607extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
585extern void dev_add_pack(struct packet_type *pt); 608extern void dev_add_pack(struct packet_type *pt);
586extern void dev_remove_pack(struct packet_type *pt); 609extern void dev_remove_pack(struct packet_type *pt);
587extern void __dev_remove_pack(struct packet_type *pt); 610extern void __dev_remove_pack(struct packet_type *pt);
diff --git a/include/linux/netfilter/nf_conntrack_proto_gre.h b/include/linux/netfilter/nf_conntrack_proto_gre.h
index 4e6bbce04ff8..535e4219d2bb 100644
--- a/include/linux/netfilter/nf_conntrack_proto_gre.h
+++ b/include/linux/netfilter/nf_conntrack_proto_gre.h
@@ -87,24 +87,6 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
87/* delete keymap entries */ 87/* delete keymap entries */
88void nf_ct_gre_keymap_destroy(struct nf_conn *ct); 88void nf_ct_gre_keymap_destroy(struct nf_conn *ct);
89 89
90/* get pointer to gre key, if present */
91static inline __be32 *gre_key(struct gre_hdr *greh)
92{
93 if (!greh->key)
94 return NULL;
95 if (greh->csum || greh->routing)
96 return (__be32 *)(greh+sizeof(*greh)+4);
97 return (__be32 *)(greh+sizeof(*greh));
98}
99
100/* get pointer ot gre csum, if present */
101static inline __sum16 *gre_csum(struct gre_hdr *greh)
102{
103 if (!greh->csum)
104 return NULL;
105 return (__sum16 *)(greh+sizeof(*greh));
106}
107
108extern void nf_ct_gre_keymap_flush(void); 90extern void nf_ct_gre_keymap_flush(void);
109extern void nf_nat_need_gre(void); 91extern void nf_nat_need_gre(void);
110 92
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index 19060030bac9..533ee351a273 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -55,18 +55,25 @@ static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb)
55 return 0; 55 return 0;
56} 56}
57 57
58static inline unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb)
59{
60 switch (skb->protocol) {
61 case __constant_htons(ETH_P_8021Q):
62 return VLAN_HLEN;
63 case __constant_htons(ETH_P_PPP_SES):
64 return PPPOE_SES_HLEN;
65 default:
66 return 0;
67 }
68}
69
58/* This is called by the IP fragmenting code and it ensures there is 70/* This is called by the IP fragmenting code and it ensures there is
59 * enough room for the encapsulating header (if there is one). */ 71 * enough room for the encapsulating header (if there is one). */
60static inline int nf_bridge_pad(const struct sk_buff *skb) 72static inline unsigned int nf_bridge_pad(const struct sk_buff *skb)
61{ 73{
62 int padding = 0; 74 if (skb->nf_bridge)
63 75 return nf_bridge_encap_header_len(skb);
64 if (skb->nf_bridge && skb->protocol == htons(ETH_P_8021Q)) 76 return 0;
65 padding = VLAN_HLEN;
66 else if (skb->nf_bridge && skb->protocol == htons(ETH_P_PPP_SES))
67 padding = PPPOE_SES_HLEN;
68
69 return padding;
70} 77}
71 78
72struct bridge_skb_cb { 79struct bridge_skb_cb {
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index f41688f56632..2e23353c28a5 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -31,7 +31,7 @@ struct sockaddr_nl
31{ 31{
32 sa_family_t nl_family; /* AF_NETLINK */ 32 sa_family_t nl_family; /* AF_NETLINK */
33 unsigned short nl_pad; /* zero */ 33 unsigned short nl_pad; /* zero */
34 __u32 nl_pid; /* process pid */ 34 __u32 nl_pid; /* port ID */
35 __u32 nl_groups; /* multicast groups mask */ 35 __u32 nl_groups; /* multicast groups mask */
36}; 36};
37 37
@@ -41,7 +41,7 @@ struct nlmsghdr
41 __u16 nlmsg_type; /* Message content */ 41 __u16 nlmsg_type; /* Message content */
42 __u16 nlmsg_flags; /* Additional flags */ 42 __u16 nlmsg_flags; /* Additional flags */
43 __u32 nlmsg_seq; /* Sequence number */ 43 __u32 nlmsg_seq; /* Sequence number */
44 __u32 nlmsg_pid; /* Sending process PID */ 44 __u32 nlmsg_pid; /* Sending process port ID */
45}; 45};
46 46
47/* Flags values */ 47/* Flags values */
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index e9ae0c6e2c62..0543439a97af 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -455,7 +455,7 @@ nfs_have_writebacks(struct inode *inode)
455/* 455/*
456 * Allocate nfs_write_data structures 456 * Allocate nfs_write_data structures
457 */ 457 */
458extern struct nfs_write_data *nfs_writedata_alloc(size_t len); 458extern struct nfs_write_data *nfs_writedata_alloc(unsigned int npages);
459 459
460/* 460/*
461 * linux/fs/nfs/read.c 461 * linux/fs/nfs/read.c
@@ -469,7 +469,7 @@ extern void nfs_readdata_release(void *data);
469/* 469/*
470 * Allocate nfs_read_data structures 470 * Allocate nfs_read_data structures
471 */ 471 */
472extern struct nfs_read_data *nfs_readdata_alloc(size_t len); 472extern struct nfs_read_data *nfs_readdata_alloc(unsigned int npages);
473 473
474/* 474/*
475 * linux/fs/nfs3proc.c 475 * linux/fs/nfs3proc.c
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index 659c75438454..cc8b9c59acb8 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -61,6 +61,7 @@ struct nfs_mount_data {
61#define NFS_MOUNT_NOACL 0x0800 /* 4 */ 61#define NFS_MOUNT_NOACL 0x0800 /* 4 */
62#define NFS_MOUNT_STRICTLOCK 0x1000 /* reserved for NFSv4 */ 62#define NFS_MOUNT_STRICTLOCK 0x1000 /* reserved for NFSv4 */
63#define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */ 63#define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
64#define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
64#define NFS_MOUNT_FLAGMASK 0xFFFF 65#define NFS_MOUNT_FLAGMASK 0xFFFF
65 66
66#endif 67#endif
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 16b0266b14fd..41afab6b5f09 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -21,8 +21,7 @@
21/* 21/*
22 * Valid flags for the radix tree 22 * Valid flags for the radix tree
23 */ 23 */
24#define NFS_PAGE_TAG_DIRTY 0 24#define NFS_PAGE_TAG_WRITEBACK 0
25#define NFS_PAGE_TAG_WRITEBACK 1
26 25
27/* 26/*
28 * Valid flags for a dirty buffer 27 * Valid flags for a dirty buffer
@@ -39,7 +38,7 @@ struct nfs_page {
39 struct page *wb_page; /* page to read in/write out */ 38 struct page *wb_page; /* page to read in/write out */
40 struct nfs_open_context *wb_context; /* File state context info */ 39 struct nfs_open_context *wb_context; /* File state context info */
41 atomic_t wb_complete; /* i/os we're waiting for */ 40 atomic_t wb_complete; /* i/os we're waiting for */
42 unsigned long wb_index; /* Offset >> PAGE_CACHE_SHIFT */ 41 pgoff_t wb_index; /* Offset >> PAGE_CACHE_SHIFT */
43 unsigned int wb_offset, /* Offset & ~PAGE_CACHE_MASK */ 42 unsigned int wb_offset, /* Offset & ~PAGE_CACHE_MASK */
44 wb_pgbase, /* Start of page data */ 43 wb_pgbase, /* Start of page data */
45 wb_bytes; /* Length of request */ 44 wb_bytes; /* Length of request */
@@ -48,6 +47,19 @@ struct nfs_page {
48 struct nfs_writeverf wb_verf; /* Commit cookie */ 47 struct nfs_writeverf wb_verf; /* Commit cookie */
49}; 48};
50 49
50struct nfs_pageio_descriptor {
51 struct list_head pg_list;
52 unsigned long pg_bytes_written;
53 size_t pg_count;
54 size_t pg_bsize;
55 unsigned int pg_base;
56
57 struct inode *pg_inode;
58 int (*pg_doio)(struct inode *, struct list_head *, unsigned int, size_t, int);
59 int pg_ioflags;
60 int pg_error;
61};
62
51#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags)) 63#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
52 64
53extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx, 65extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
@@ -59,13 +71,16 @@ extern void nfs_clear_request(struct nfs_page *req);
59extern void nfs_release_request(struct nfs_page *req); 71extern void nfs_release_request(struct nfs_page *req);
60 72
61 73
62extern long nfs_scan_dirty(struct address_space *mapping,
63 struct writeback_control *wbc,
64 struct list_head *dst);
65extern int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *head, struct list_head *dst, 74extern int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *head, struct list_head *dst,
66 unsigned long idx_start, unsigned int npages); 75 pgoff_t idx_start, unsigned int npages);
67extern int nfs_coalesce_requests(struct list_head *, struct list_head *, 76extern void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
68 unsigned int); 77 struct inode *inode,
78 int (*doio)(struct inode *, struct list_head *, unsigned int, size_t, int),
79 size_t bsize,
80 int how);
81extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *,
82 struct nfs_page *);
83extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc);
69extern int nfs_wait_on_request(struct nfs_page *); 84extern int nfs_wait_on_request(struct nfs_page *);
70extern void nfs_unlock_request(struct nfs_page *req); 85extern void nfs_unlock_request(struct nfs_page *req);
71extern int nfs_set_page_writeback_locked(struct nfs_page *req); 86extern int nfs_set_page_writeback_locked(struct nfs_page *req);
diff --git a/include/linux/nubus.h b/include/linux/nubus.h
index 870e66a96286..cdb3e9b8db54 100644
--- a/include/linux/nubus.h
+++ b/include/linux/nubus.h
@@ -28,18 +28,18 @@ enum nubus_category {
28}; 28};
29 29
30enum nubus_type_network { 30enum nubus_type_network {
31 NUBUS_TYPE_ETHERNET = 0x0001, 31 NUBUS_TYPE_ETHERNET = 0x0001,
32 NUBUS_TYPE_RS232 = 0x0002 32 NUBUS_TYPE_RS232 = 0x0002
33}; 33};
34 34
35enum nubus_type_display { 35enum nubus_type_display {
36 NUBUS_TYPE_VIDEO = 0x0001 36 NUBUS_TYPE_VIDEO = 0x0001
37}; 37};
38 38
39enum nubus_type_cpu { 39enum nubus_type_cpu {
40 NUBUS_TYPE_68020 = 0x0003, 40 NUBUS_TYPE_68020 = 0x0003,
41 NUBUS_TYPE_68030 = 0x0004, 41 NUBUS_TYPE_68030 = 0x0004,
42 NUBUS_TYPE_68040 = 0x0005 42 NUBUS_TYPE_68040 = 0x0005
43}; 43};
44 44
45/* Known <Cat,Type,SW,HW> tuples: (according to TattleTech and Slots) 45/* Known <Cat,Type,SW,HW> tuples: (according to TattleTech and Slots)
@@ -56,6 +56,7 @@ enum nubus_type_cpu {
56 * 56 *
57 * SONIC comm-slot/on-board and DuoDock Ethernet: <4,1,1,272> 57 * SONIC comm-slot/on-board and DuoDock Ethernet: <4,1,1,272>
58 * SONIC LC-PDS Ethernet (Dayna, but like Apple 16-bit, sort of): <4,1,1,271> 58 * SONIC LC-PDS Ethernet (Dayna, but like Apple 16-bit, sort of): <4,1,1,271>
59 * Apple SONIC LC-PDS Ethernet ("Apple Ethernet LC Twisted-Pair Card"): <4,1,0,281>
59 * Sonic Systems Ethernet A-Series Card: <4,1,268,256> 60 * Sonic Systems Ethernet A-Series Card: <4,1,268,256>
60 * Asante MacCon NuBus-A: <4,1,260,256> (alpha-1.0,1.1 revision) 61 * Asante MacCon NuBus-A: <4,1,260,256> (alpha-1.0,1.1 revision)
61 * ROM on the above card: <2,1,0,0> 62 * ROM on the above card: <2,1,0,0>
@@ -80,24 +81,26 @@ enum nubus_type_cpu {
80/* Add known DrSW values here */ 81/* Add known DrSW values here */
81enum nubus_drsw { 82enum nubus_drsw {
82 /* NUBUS_CAT_DISPLAY */ 83 /* NUBUS_CAT_DISPLAY */
83 NUBUS_DRSW_APPLE = 0x0001, 84 NUBUS_DRSW_APPLE = 0x0001,
84 NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */ 85 NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */
85 86
86 /* NUBUS_CAT_NETWORK */ 87 /* NUBUS_CAT_NETWORK */
87 NUBUS_DRSW_CABLETRON = 0x0001, 88 NUBUS_DRSW_3COM = 0x0000,
88 NUBUS_DRSW_SONIC_LC = 0x0001, 89 NUBUS_DRSW_CABLETRON = 0x0001,
89 NUBUS_DRSW_KINETICS = 0x0103, 90 NUBUS_DRSW_SONIC_LC = 0x0001,
90 NUBUS_DRSW_ASANTE = 0x0104, 91 NUBUS_DRSW_KINETICS = 0x0103,
91 NUBUS_DRSW_DAYNA = 0x010b, 92 NUBUS_DRSW_ASANTE = 0x0104,
92 NUBUS_DRSW_FARALLON = 0x010c, 93 NUBUS_DRSW_TECHWORKS = 0x0109,
93 NUBUS_DRSW_APPLE_SN = 0x010f, 94 NUBUS_DRSW_DAYNA = 0x010b,
94 NUBUS_DRSW_DAYNA2 = 0x0115, 95 NUBUS_DRSW_FARALLON = 0x010c,
96 NUBUS_DRSW_APPLE_SN = 0x010f,
97 NUBUS_DRSW_DAYNA2 = 0x0115,
95 NUBUS_DRSW_FOCUS = 0x011a, 98 NUBUS_DRSW_FOCUS = 0x011a,
96 NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */ 99 NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */
97 NUBUS_DRSW_DAYNA_LC = 0x011e, 100 NUBUS_DRSW_DAYNA_LC = 0x011e,
98 101
99 /* NUBUS_CAT_CPU */ 102 /* NUBUS_CAT_CPU */
100 NUBUS_DRSW_NONE = 0x0000, 103 NUBUS_DRSW_NONE = 0x0000,
101}; 104};
102 105
103/* DrHW: Uniquely identifies the hardware interface to a board (or at 106/* DrHW: Uniquely identifies the hardware interface to a board (or at
@@ -107,27 +110,48 @@ enum nubus_drsw {
107/* Add known DrHW values here */ 110/* Add known DrHW values here */
108enum nubus_drhw { 111enum nubus_drhw {
109 /* NUBUS_CAT_DISPLAY */ 112 /* NUBUS_CAT_DISPLAY */
110 NUBUS_DRHW_APPLE_TFB = 0x0001, /* Toby frame buffer card */ 113 NUBUS_DRHW_APPLE_TFB = 0x0001, /* Toby frame buffer card */
111 NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High Res Video card */ 114 NUBUS_DRHW_APPLE_WVC = 0x0006, /* Apple Workstation Video Card */
112 NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */ 115 NUBUS_DRHW_SIGMA_CLRMAX = 0x0007, /* Sigma Design ColorMax */
113 NUBUS_DRHW_APPLE_MDC = 0x0019, /* Macintosh Display Card */ 116 NUBUS_DRHW_APPLE_SE30 = 0x0009, /* Apple SE/30 video */
114 NUBUS_DRHW_APPLE_SONORA = 0x0022, /* Sonora built-in video */ 117 NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High-Res Video Card */
115 NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */ 118 NUBUS_DRHW_APPLE_PVC = 0x0017, /* Mac II Portrait Video Card */
119 NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */
120 NUBUS_DRHW_APPLE_MDC = 0x0019, /* Macintosh Display Card */
121 NUBUS_DRHW_APPLE_SONORA = 0x0022, /* Sonora built-in video */
122 NUBUS_DRHW_APPLE_24AC = 0x002b, /* Mac 24AC Video Card */
116 NUBUS_DRHW_APPLE_VALKYRIE = 0x002e, 123 NUBUS_DRHW_APPLE_VALKYRIE = 0x002e,
117 NUBUS_DRHW_THUNDER24 = 0x02cb, /* SuperMac Thunder/24 */ 124 NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */
125 NUBUS_DRHW_SMAC_GFX = 0x0105, /* SuperMac GFX */
126 NUBUS_DRHW_RASTER_CB264 = 0x013B, /* RasterOps ColorBoard 264 */
127 NUBUS_DRHW_MICRON_XCEED = 0x0146, /* Micron Exceed color */
128 NUBUS_DRHW_RDIUS_GSC = 0x0153, /* Radius GS/C */
129 NUBUS_DRHW_SMAC_SPEC8 = 0x017B, /* SuperMac Spectrum/8 */
130 NUBUS_DRHW_SMAC_SPEC24 = 0x017C, /* SuperMac Spectrum/24 */
131 NUBUS_DRHW_RASTER_CB364 = 0x026F, /* RasterOps ColorBoard 364 */
132 NUBUS_DRHW_RDIUS_DCGX = 0x027C, /* Radius DirectColor/GX */
133 NUBUS_DRHW_RDIUS_PC8 = 0x0291, /* Radius PrecisionColor 8 */
134 NUBUS_DRHW_LAPIS_PCS8 = 0x0292, /* Lapis ProColorServer 8 */
135 NUBUS_DRHW_RASTER_24LXI = 0x02A0, /* RasterOps 8/24 XLi */
136 NUBUS_DRHW_RASTER_PBPGT = 0x02A5, /* RasterOps PaintBoard Prism GT */
137 NUBUS_DRHW_EMACH_FSX = 0x02AE, /* E-Machines Futura SX */
138 NUBUS_DRHW_SMAC_THUND24 = 0x02CB, /* SuperMac Thunder/24 */
139 NUBUS_DRHW_RDIUS_PC24XP = 0x0406, /* Radius PrecisionColor 24Xp */
140 NUBUS_DRHW_RDIUS_PC24X = 0x040A, /* Radius PrecisionColor 24X */
141 NUBUS_DRHW_RDIUS_PC8XJ = 0x040B, /* Radius PrecisionColor 8XJ */
118 142
119 /* NUBUS_CAT_NETWORK */ 143 /* NUBUS_CAT_NETWORK */
120 NUBUS_DRHW_INTERLAN = 0x0100, 144 NUBUS_DRHW_INTERLAN = 0x0100,
121 NUBUS_DRHW_SMC9194 = 0x0101, 145 NUBUS_DRHW_SMC9194 = 0x0101,
122 NUBUS_DRHW_KINETICS = 0x0106, 146 NUBUS_DRHW_KINETICS = 0x0106,
123 NUBUS_DRHW_CABLETRON = 0x0109, 147 NUBUS_DRHW_CABLETRON = 0x0109,
124 NUBUS_DRHW_ASANTE_LC = 0x010f, 148 NUBUS_DRHW_ASANTE_LC = 0x010f,
125 NUBUS_DRHW_SONIC = 0x0110, 149 NUBUS_DRHW_SONIC = 0x0110,
126 NUBUS_DRHW_SONIC_NB = 0x0118, 150 NUBUS_DRHW_TECHWORKS = 0x0112,
127 NUBUS_DRHW_SONIC_LC = 0x0119, 151 NUBUS_DRHW_APPLE_SONIC_NB = 0x0118,
128 152 NUBUS_DRHW_APPLE_SONIC_LC = 0x0119,
129 /* NUBUS_CAT_COMMUNICATIONS */ 153 NUBUS_DRHW_FOCUS = 0x011c,
130 NUBUS_DRHW_DOVEFAX = 0x0100, 154 NUBUS_DRHW_SONNET = 0x011d,
131}; 155};
132 156
133/* Resource IDs: These are the identifiers for the various weird and 157/* Resource IDs: These are the identifiers for the various weird and
@@ -153,17 +177,17 @@ enum nubus_res_id {
153 177
154/* Category-specific resources. */ 178/* Category-specific resources. */
155enum nubus_board_res_id { 179enum nubus_board_res_id {
156 NUBUS_RESID_BOARDID = 0x0020, 180 NUBUS_RESID_BOARDID = 0x0020,
157 NUBUS_RESID_PRAMINITDATA = 0x0021, 181 NUBUS_RESID_PRAMINITDATA = 0x0021,
158 NUBUS_RESID_PRIMARYINIT = 0x0022, 182 NUBUS_RESID_PRIMARYINIT = 0x0022,
159 NUBUS_RESID_TIMEOUTCONST = 0x0023, 183 NUBUS_RESID_TIMEOUTCONST = 0x0023,
160 NUBUS_RESID_VENDORINFO = 0x0024, 184 NUBUS_RESID_VENDORINFO = 0x0024,
161 NUBUS_RESID_BOARDFLAGS = 0x0025, 185 NUBUS_RESID_BOARDFLAGS = 0x0025,
162 NUBUS_RESID_SECONDINIT = 0x0026, 186 NUBUS_RESID_SECONDINIT = 0x0026,
163 187
164 /* Not sure why Apple put these next two in here */ 188 /* Not sure why Apple put these next two in here */
165 NUBUS_RESID_VIDNAMES = 0x0041, 189 NUBUS_RESID_VIDNAMES = 0x0041,
166 NUBUS_RESID_VIDMODES = 0x007e 190 NUBUS_RESID_VIDMODES = 0x007e
167}; 191};
168 192
169/* Fields within the vendor info directory */ 193/* Fields within the vendor info directory */
@@ -185,13 +209,13 @@ enum nubus_cpu_res_id {
185}; 209};
186 210
187enum nubus_display_res_id { 211enum nubus_display_res_id {
188 NUBUS_RESID_GAMMADIR = 0x0040, 212 NUBUS_RESID_GAMMADIR = 0x0040,
189 NUBUS_RESID_FIRSTMODE = 0x0080, 213 NUBUS_RESID_FIRSTMODE = 0x0080,
190 NUBUS_RESID_SECONDMODE = 0x0081, 214 NUBUS_RESID_SECONDMODE = 0x0081,
191 NUBUS_RESID_THIRDMODE = 0x0082, 215 NUBUS_RESID_THIRDMODE = 0x0082,
192 NUBUS_RESID_FOURTHMODE = 0x0083, 216 NUBUS_RESID_FOURTHMODE = 0x0083,
193 NUBUS_RESID_FIFTHMODE = 0x0084, 217 NUBUS_RESID_FIFTHMODE = 0x0084,
194 NUBUS_RESID_SIXTHMODE = 0x0085 218 NUBUS_RESID_SIXTHMODE = 0x0085
195}; 219};
196 220
197struct nubus_dir 221struct nubus_dir
@@ -214,7 +238,7 @@ struct nubus_board {
214 struct nubus_board* next; 238 struct nubus_board* next;
215 struct nubus_dev* first_dev; 239 struct nubus_dev* first_dev;
216 240
217 /* Only 9-E actually exist, though 0-8 are also theoretically 241 /* Only 9-E actually exist, though 0-8 are also theoretically
218 possible, and 0 is a special case which represents the 242 possible, and 0 is a special case which represents the
219 motherboard and onboard peripherals (Ethernet, video) */ 243 motherboard and onboard peripherals (Ethernet, video) */
220 int slot; 244 int slot;
diff --git a/include/linux/parser.h b/include/linux/parser.h
index fa3332861a09..26b2bdfcaf06 100644
--- a/include/linux/parser.h
+++ b/include/linux/parser.h
@@ -11,7 +11,7 @@
11/* associates an integer enumerator with a pattern string. */ 11/* associates an integer enumerator with a pattern string. */
12struct match_token { 12struct match_token {
13 int token; 13 int token;
14 char *pattern; 14 const char *pattern;
15}; 15};
16 16
17typedef struct match_token match_table_t[]; 17typedef struct match_token match_table_t[];
@@ -29,5 +29,5 @@ int match_token(char *, match_table_t table, substring_t args[]);
29int match_int(substring_t *, int *result); 29int match_int(substring_t *, int *result);
30int match_octal(substring_t *, int *result); 30int match_octal(substring_t *, int *result);
31int match_hex(substring_t *, int *result); 31int match_hex(substring_t *, int *result);
32void match_strcpy(char *, substring_t *); 32void match_strcpy(char *, const substring_t *);
33char *match_strdup(substring_t *); 33char *match_strdup(const substring_t *);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 972491089ac9..fbf3766dac1e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -96,6 +96,19 @@ enum pci_channel_state {
96 pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, 96 pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
97}; 97};
98 98
99typedef unsigned int __bitwise pcie_reset_state_t;
100
101enum pcie_reset_state {
102 /* Reset is NOT asserted (Use to deassert reset) */
103 pcie_deassert_reset = (__force pcie_reset_state_t) 1,
104
105 /* Use #PERST to reset PCI-E device */
106 pcie_warm_reset = (__force pcie_reset_state_t) 2,
107
108 /* Use PCI-E Hot Reset to reset device */
109 pcie_hot_reset = (__force pcie_reset_state_t) 3
110};
111
99typedef unsigned short __bitwise pci_bus_flags_t; 112typedef unsigned short __bitwise pci_bus_flags_t;
100enum pci_bus_flags { 113enum pci_bus_flags {
101 PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1, 114 PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -176,10 +189,12 @@ struct pci_dev {
176 int rom_attr_enabled; /* has display of the rom attribute been enabled? */ 189 int rom_attr_enabled; /* has display of the rom attribute been enabled? */
177 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ 190 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */
178#ifdef CONFIG_PCI_MSI 191#ifdef CONFIG_PCI_MSI
179 unsigned int first_msi_irq; 192 struct list_head msi_list;
180#endif 193#endif
181}; 194};
182 195
196extern struct pci_dev *alloc_pci_dev(void);
197
183#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list) 198#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
184#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) 199#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
185#define to_pci_dev(n) container_of(n, struct pci_dev, dev) 200#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
@@ -392,12 +407,6 @@ struct pci_driver {
392 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \ 407 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
393 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID 408 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
394 409
395/*
396 * pci_module_init is obsolete, this stays here till we fix up all usages of it
397 * in the tree.
398 */
399#define pci_module_init pci_register_driver
400
401/** 410/**
402 * PCI_VDEVICE - macro used to describe a specific pci device in short form 411 * PCI_VDEVICE - macro used to describe a specific pci device in short form
403 * @vend: the vendor name 412 * @vend: the vendor name
@@ -532,6 +541,7 @@ static inline int pci_is_managed(struct pci_dev *pdev)
532 541
533void pci_disable_device(struct pci_dev *dev); 542void pci_disable_device(struct pci_dev *dev);
534void pci_set_master(struct pci_dev *dev); 543void pci_set_master(struct pci_dev *dev);
544int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
535#define HAVE_PCI_SET_MWI 545#define HAVE_PCI_SET_MWI
536int __must_check pci_set_mwi(struct pci_dev *dev); 546int __must_check pci_set_mwi(struct pci_dev *dev);
537void pci_clear_mwi(struct pci_dev *dev); 547void pci_clear_mwi(struct pci_dev *dev);
@@ -730,6 +740,9 @@ static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) {
730static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; } 740static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; }
731static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } 741static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; }
732 742
743static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) { return -EIO; }
744static inline void pci_release_regions(struct pci_dev *dev) { }
745
733#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) 746#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
734 747
735static inline void pci_block_user_cfg_access(struct pci_dev *dev) { } 748static inline void pci_block_user_cfg_access(struct pci_dev *dev) { }
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index a675a05c4091..ab4cb6ecd47c 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -174,7 +174,7 @@ extern int pci_hp_register (struct hotplug_slot *slot);
174extern int pci_hp_deregister (struct hotplug_slot *slot); 174extern int pci_hp_deregister (struct hotplug_slot *slot);
175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, 175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot,
176 struct hotplug_slot_info *info); 176 struct hotplug_slot_info *info);
177extern struct subsystem pci_hotplug_slots_subsys; 177extern struct kset pci_hotplug_slots_subsys;
178 178
179/* PCI Setting Record (Type 0) */ 179/* PCI Setting Record (Type 0) */
180struct hpp_type0 { 180struct hpp_type0 {
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 1b0ddbb8a804..ae849f0d4430 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1213,11 +1213,13 @@
1213#define PCI_DEVICE_ID_NVIDIA_NVENET_16 0x03E5 1213#define PCI_DEVICE_ID_NVIDIA_NVENET_16 0x03E5
1214#define PCI_DEVICE_ID_NVIDIA_NVENET_17 0x03E6 1214#define PCI_DEVICE_ID_NVIDIA_NVENET_17 0x03E6
1215#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA 0x03E7 1215#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA 0x03E7
1216#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SMBUS 0x03EB
1216#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE 0x03EC 1217#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE 0x03EC
1217#define PCI_DEVICE_ID_NVIDIA_NVENET_18 0x03EE 1218#define PCI_DEVICE_ID_NVIDIA_NVENET_18 0x03EE
1218#define PCI_DEVICE_ID_NVIDIA_NVENET_19 0x03EF 1219#define PCI_DEVICE_ID_NVIDIA_NVENET_19 0x03EF
1219#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2 0x03F6 1220#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2 0x03F6
1220#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3 0x03F7 1221#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3 0x03F7
1222#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_SMBUS 0x0446
1221#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE 0x0448 1223#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE 0x0448
1222#define PCI_DEVICE_ID_NVIDIA_NVENET_20 0x0450 1224#define PCI_DEVICE_ID_NVIDIA_NVENET_20 0x0450
1223#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451 1225#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451
@@ -1924,6 +1926,7 @@
1924#define PCI_DEVICE_ID_TIGON3_5752 0x1600 1926#define PCI_DEVICE_ID_TIGON3_5752 0x1600
1925#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 1927#define PCI_DEVICE_ID_TIGON3_5752M 0x1601
1926#define PCI_DEVICE_ID_NX2_5709 0x1639 1928#define PCI_DEVICE_ID_NX2_5709 0x1639
1929#define PCI_DEVICE_ID_NX2_5709S 0x163a
1927#define PCI_DEVICE_ID_TIGON3_5700 0x1644 1930#define PCI_DEVICE_ID_TIGON3_5700 0x1644
1928#define PCI_DEVICE_ID_TIGON3_5701 0x1645 1931#define PCI_DEVICE_ID_TIGON3_5701 0x1645
1929#define PCI_DEVICE_ID_TIGON3_5702 0x1646 1932#define PCI_DEVICE_ID_TIGON3_5702 0x1646
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 253a2b9be9d6..e7367c74e1bb 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -197,7 +197,7 @@ typedef unsigned char *sk_buff_data_t;
197 * @tstamp: Time we arrived 197 * @tstamp: Time we arrived
198 * @dev: Device we arrived on/are leaving by 198 * @dev: Device we arrived on/are leaving by
199 * @iif: ifindex of device we arrived on 199 * @iif: ifindex of device we arrived on
200 * @h: Transport layer header 200 * @transport_header: Transport layer header
201 * @network_header: Network layer header 201 * @network_header: Network layer header
202 * @mac_header: Link layer header 202 * @mac_header: Link layer header
203 * @dst: destination entry 203 * @dst: destination entry
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index c7a78eef2b4f..66611423c8ee 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -84,7 +84,8 @@ struct rpc_procinfo {
84 u32 p_proc; /* RPC procedure number */ 84 u32 p_proc; /* RPC procedure number */
85 kxdrproc_t p_encode; /* XDR encode function */ 85 kxdrproc_t p_encode; /* XDR encode function */
86 kxdrproc_t p_decode; /* XDR decode function */ 86 kxdrproc_t p_decode; /* XDR decode function */
87 unsigned int p_bufsiz; /* req. buffer size */ 87 unsigned int p_arglen; /* argument hdr length (u32) */
88 unsigned int p_replen; /* reply hdr length (u32) */
88 unsigned int p_count; /* call count */ 89 unsigned int p_count; /* call count */
89 unsigned int p_timer; /* Which RTT timer to use */ 90 unsigned int p_timer; /* Which RTT timer to use */
90 u32 p_statidx; /* Which procedure to account */ 91 u32 p_statidx; /* Which procedure to account */
@@ -121,8 +122,8 @@ struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
121int rpc_shutdown_client(struct rpc_clnt *); 122int rpc_shutdown_client(struct rpc_clnt *);
122int rpc_destroy_client(struct rpc_clnt *); 123int rpc_destroy_client(struct rpc_clnt *);
123void rpc_release_client(struct rpc_clnt *); 124void rpc_release_client(struct rpc_clnt *);
124void rpc_getport(struct rpc_task *); 125int rpcb_register(u32, u32, int, unsigned short, int *);
125int rpc_register(u32, u32, int, unsigned short, int *); 126void rpcb_getport(struct rpc_task *);
126 127
127void rpc_call_setup(struct rpc_task *, struct rpc_message *, int); 128void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
128 129
@@ -144,7 +145,7 @@ char * rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
144/* 145/*
145 * Helper function for NFSroot support 146 * Helper function for NFSroot support
146 */ 147 */
147int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int); 148int rpcb_getport_external(struct sockaddr_in *, __u32, __u32, int);
148 149
149#endif /* __KERNEL__ */ 150#endif /* __KERNEL__ */
150#endif /* _LINUX_SUNRPC_CLNT_H */ 151#endif /* _LINUX_SUNRPC_CLNT_H */
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index b7c7307ceec6..3912cf16361e 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -17,7 +17,7 @@
17#define RPCDBG_DEBUG 0x0004 17#define RPCDBG_DEBUG 0x0004
18#define RPCDBG_NFS 0x0008 18#define RPCDBG_NFS 0x0008
19#define RPCDBG_AUTH 0x0010 19#define RPCDBG_AUTH 0x0010
20#define RPCDBG_PMAP 0x0020 20#define RPCDBG_BIND 0x0020
21#define RPCDBG_SCHED 0x0040 21#define RPCDBG_SCHED 0x0040
22#define RPCDBG_TRANS 0x0080 22#define RPCDBG_TRANS 0x0080
23#define RPCDBG_SVCSOCK 0x0100 23#define RPCDBG_SVCSOCK 0x0100
diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h
index 606cb2165232..784d4c3ef651 100644
--- a/include/linux/sunrpc/msg_prot.h
+++ b/include/linux/sunrpc/msg_prot.h
@@ -78,10 +78,6 @@ enum rpc_auth_stat {
78 RPCSEC_GSS_CTXPROBLEM = 14 78 RPCSEC_GSS_CTXPROBLEM = 14
79}; 79};
80 80
81#define RPC_PMAP_PROGRAM 100000
82#define RPC_PMAP_VERSION 2
83#define RPC_PMAP_PORT 111
84
85#define RPC_MAXNETNAMELEN 256 81#define RPC_MAXNETNAMELEN 256
86 82
87/* 83/*
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 3069ecca0129..2047fb202a13 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -264,7 +264,7 @@ struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *);
264void rpc_wake_up_status(struct rpc_wait_queue *, int); 264void rpc_wake_up_status(struct rpc_wait_queue *, int);
265void rpc_delay(struct rpc_task *, unsigned long); 265void rpc_delay(struct rpc_task *, unsigned long);
266void * rpc_malloc(struct rpc_task *, size_t); 266void * rpc_malloc(struct rpc_task *, size_t);
267void rpc_free(struct rpc_task *); 267void rpc_free(void *);
268int rpciod_up(void); 268int rpciod_up(void);
269void rpciod_down(void); 269void rpciod_down(void);
270int __rpc_wait_for_completion_task(struct rpc_task *task, int (*)(void *)); 270int __rpc_wait_for_completion_task(struct rpc_task *task, int (*)(void *));
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index f780e72fc417..fa89ce6ce076 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -84,7 +84,9 @@ struct rpc_rqst {
84 struct list_head rq_list; 84 struct list_head rq_list;
85 85
86 __u32 * rq_buffer; /* XDR encode buffer */ 86 __u32 * rq_buffer; /* XDR encode buffer */
87 size_t rq_bufsize; 87 size_t rq_bufsize,
88 rq_callsize,
89 rq_rcvsize;
88 90
89 struct xdr_buf rq_private_buf; /* The receive buffer 91 struct xdr_buf rq_private_buf; /* The receive buffer
90 * used in the softirq. 92 * used in the softirq.
@@ -112,7 +114,7 @@ struct rpc_xprt_ops {
112 void (*set_port)(struct rpc_xprt *xprt, unsigned short port); 114 void (*set_port)(struct rpc_xprt *xprt, unsigned short port);
113 void (*connect)(struct rpc_task *task); 115 void (*connect)(struct rpc_task *task);
114 void * (*buf_alloc)(struct rpc_task *task, size_t size); 116 void * (*buf_alloc)(struct rpc_task *task, size_t size);
115 void (*buf_free)(struct rpc_task *task); 117 void (*buf_free)(void *buffer);
116 int (*send_request)(struct rpc_task *task); 118 int (*send_request)(struct rpc_task *task);
117 void (*set_retrans_timeout)(struct rpc_task *task); 119 void (*set_retrans_timeout)(struct rpc_task *task);
118 void (*timer)(struct rpc_task *task); 120 void (*timer)(struct rpc_task *task);
@@ -150,6 +152,7 @@ struct rpc_xprt {
150 unsigned long state; /* transport state */ 152 unsigned long state; /* transport state */
151 unsigned char shutdown : 1, /* being shut down */ 153 unsigned char shutdown : 1, /* being shut down */
152 resvport : 1; /* use a reserved port */ 154 resvport : 1; /* use a reserved port */
155 unsigned int bind_index; /* bind function index */
153 156
154 /* 157 /*
155 * Connection of transports 158 * Connection of transports
diff --git a/include/linux/tifm.h b/include/linux/tifm.h
index 3deb0a6c1370..2a196982601f 100644
--- a/include/linux/tifm.h
+++ b/include/linux/tifm.h
@@ -14,16 +14,16 @@
14 14
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/wait.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/pci.h> 18#include <linux/pci.h>
20#include <linux/kthread.h> 19#include <linux/workqueue.h>
21 20
22/* Host registers (relative to pci base address): */ 21/* Host registers (relative to pci base address): */
23enum { 22enum {
24 FM_SET_INTERRUPT_ENABLE = 0x008, 23 FM_SET_INTERRUPT_ENABLE = 0x008,
25 FM_CLEAR_INTERRUPT_ENABLE = 0x00c, 24 FM_CLEAR_INTERRUPT_ENABLE = 0x00c,
26 FM_INTERRUPT_STATUS = 0x014 }; 25 FM_INTERRUPT_STATUS = 0x014
26};
27 27
28/* Socket registers (relative to socket base address): */ 28/* Socket registers (relative to socket base address): */
29enum { 29enum {
@@ -58,14 +58,8 @@ enum {
58 SOCK_MS_DATA = 0x188, 58 SOCK_MS_DATA = 0x188,
59 SOCK_MS_STATUS = 0x18c, 59 SOCK_MS_STATUS = 0x18c,
60 SOCK_MS_SYSTEM = 0x190, 60 SOCK_MS_SYSTEM = 0x190,
61 SOCK_FIFO_ACCESS = 0x200 }; 61 SOCK_FIFO_ACCESS = 0x200
62 62};
63
64#define TIFM_IRQ_ENABLE 0x80000000
65#define TIFM_IRQ_SOCKMASK(x) (x)
66#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
67#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
68#define TIFM_IRQ_SETALL 0xffffffff
69 63
70#define TIFM_CTRL_LED 0x00000040 64#define TIFM_CTRL_LED 0x00000040
71#define TIFM_CTRL_FAST_CLK 0x00000100 65#define TIFM_CTRL_FAST_CLK 0x00000100
@@ -73,63 +67,76 @@ enum {
73#define TIFM_SOCK_STATE_OCCUPIED 0x00000008 67#define TIFM_SOCK_STATE_OCCUPIED 0x00000008
74#define TIFM_SOCK_STATE_POWERED 0x00000080 68#define TIFM_SOCK_STATE_POWERED 0x00000080
75 69
76#define TIFM_FIFO_ENABLE 0x00000001 /* Meaning of this constant is unverified */ 70#define TIFM_FIFO_ENABLE 0x00000001
71#define TIFM_FIFO_READY 0x00000001
77#define TIFM_FIFO_INT_SETALL 0x0000ffff 72#define TIFM_FIFO_INT_SETALL 0x0000ffff
78#define TIFM_FIFO_INTMASK 0x00000005 /* Meaning of this constant is unverified */ 73#define TIFM_FIFO_INTMASK 0x00000005
74
75#define TIFM_DMA_RESET 0x00000002
76#define TIFM_DMA_TX 0x00008000
77#define TIFM_DMA_EN 0x00000001
78#define TIFM_DMA_TSIZE 0x0000007f
79 79
80#define TIFM_DMA_RESET 0x00000002 /* Meaning of this constant is unverified */ 80#define TIFM_TYPE_XD 1
81#define TIFM_DMA_TX 0x00008000 /* Meaning of this constant is unverified */ 81#define TIFM_TYPE_MS 2
82#define TIFM_DMA_EN 0x00000001 /* Meaning of this constant is unverified */ 82#define TIFM_TYPE_SD 3
83 83
84typedef enum {FM_NULL = 0, FM_XD = 0x01, FM_MS = 0x02, FM_SD = 0x03} tifm_media_id; 84struct tifm_device_id {
85 unsigned char type;
86};
85 87
86struct tifm_driver; 88struct tifm_driver;
87struct tifm_dev { 89struct tifm_dev {
88 char __iomem *addr; 90 char __iomem *addr;
89 spinlock_t lock; 91 spinlock_t lock;
90 tifm_media_id media_id; 92 unsigned char type;
91 unsigned int socket_id; 93 unsigned int socket_id;
92 94
93 void (*signal_irq)(struct tifm_dev *sock, 95 void (*card_event)(struct tifm_dev *sock);
94 unsigned int sock_irq_status); 96 void (*data_event)(struct tifm_dev *sock);
95 97
96 struct tifm_driver *drv; 98 struct device dev;
97 struct device dev;
98}; 99};
99 100
100struct tifm_driver { 101struct tifm_driver {
101 tifm_media_id *id_table; 102 struct tifm_device_id *id_table;
102 int (*probe)(struct tifm_dev *dev); 103 int (*probe)(struct tifm_dev *dev);
103 void (*remove)(struct tifm_dev *dev); 104 void (*remove)(struct tifm_dev *dev);
104 int (*suspend)(struct tifm_dev *dev, 105 int (*suspend)(struct tifm_dev *dev,
105 pm_message_t state); 106 pm_message_t state);
106 int (*resume)(struct tifm_dev *dev); 107 int (*resume)(struct tifm_dev *dev);
107 108
108 struct device_driver driver; 109 struct device_driver driver;
109}; 110};
110 111
111struct tifm_adapter { 112struct tifm_adapter {
112 char __iomem *addr; 113 char __iomem *addr;
113 spinlock_t lock; 114 spinlock_t lock;
114 unsigned int irq_status; 115 unsigned int irq_status;
115 unsigned int socket_change_set; 116 unsigned int socket_change_set;
116 wait_queue_head_t change_set_notify; 117 unsigned int id;
117 unsigned int id; 118 unsigned int num_sockets;
118 unsigned int num_sockets; 119 struct completion *finish_me;
119 struct tifm_dev **sockets; 120
120 struct task_struct *media_switcher; 121 struct work_struct media_switcher;
121 struct class_device cdev; 122 struct class_device cdev;
122 struct device *dev; 123
123 124 void (*eject)(struct tifm_adapter *fm,
124 void (*eject)(struct tifm_adapter *fm, struct tifm_dev *sock); 125 struct tifm_dev *sock);
126
127 struct tifm_dev *sockets[0];
125}; 128};
126 129
127struct tifm_adapter *tifm_alloc_adapter(void); 130struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
128void tifm_free_device(struct device *dev); 131 struct device *dev);
129void tifm_free_adapter(struct tifm_adapter *fm); 132int tifm_add_adapter(struct tifm_adapter *fm);
130int tifm_add_adapter(struct tifm_adapter *fm, int (*mediathreadfn)(void *data));
131void tifm_remove_adapter(struct tifm_adapter *fm); 133void tifm_remove_adapter(struct tifm_adapter *fm);
132struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm); 134void tifm_free_adapter(struct tifm_adapter *fm);
135
136void tifm_free_device(struct device *dev);
137struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id,
138 unsigned char type);
139
133int tifm_register_driver(struct tifm_driver *drv); 140int tifm_register_driver(struct tifm_driver *drv);
134void tifm_unregister_driver(struct tifm_driver *drv); 141void tifm_unregister_driver(struct tifm_driver *drv);
135void tifm_eject(struct tifm_dev *sock); 142void tifm_eject(struct tifm_dev *sock);
@@ -137,11 +144,11 @@ int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
137 int direction); 144 int direction);
138void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, 145void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
139 int direction); 146 int direction);
140 147void tifm_queue_work(struct work_struct *work);
141 148
142static inline void *tifm_get_drvdata(struct tifm_dev *dev) 149static inline void *tifm_get_drvdata(struct tifm_dev *dev)
143{ 150{
144 return dev_get_drvdata(&dev->dev); 151 return dev_get_drvdata(&dev->dev);
145} 152}
146 153
147static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data) 154static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)
@@ -149,8 +156,4 @@ static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)
149 dev_set_drvdata(&dev->dev, data); 156 dev_set_drvdata(&dev->dev, data);
150} 157}
151 158
152struct tifm_device_id {
153 tifm_media_id media_id;
154};
155
156#endif 159#endif
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index 0c78f7f4a976..daa6c125f66e 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -59,6 +59,8 @@ struct writeback_control {
59 unsigned for_reclaim:1; /* Invoked from the page allocator */ 59 unsigned for_reclaim:1; /* Invoked from the page allocator */
60 unsigned for_writepages:1; /* This is a writepages() call */ 60 unsigned for_writepages:1; /* This is a writepages() call */
61 unsigned range_cyclic:1; /* range_start is cyclic */ 61 unsigned range_cyclic:1; /* range_start is cyclic */
62
63 void *fs_private; /* For use by ->writepages() */
62}; 64};
63 65
64/* 66/*
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index a5d53e0fe152..b58adc52448d 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -243,17 +243,6 @@ enum xfrm_ae_ftype_t {
243#define XFRM_AE_MAX (__XFRM_AE_MAX - 1) 243#define XFRM_AE_MAX (__XFRM_AE_MAX - 1)
244}; 244};
245 245
246/* SAD Table filter flags */
247enum xfrm_sad_ftype_t {
248 XFRM_SAD_UNSPEC,
249 XFRM_SAD_HMASK=1,
250 XFRM_SAD_HMAX=2,
251 XFRM_SAD_CNT=4,
252 __XFRM_SAD_MAX
253
254#define XFRM_SAD_MAX (__XFRM_SAD_MAX - 1)
255};
256
257struct xfrm_userpolicy_type { 246struct xfrm_userpolicy_type {
258 __u8 type; 247 __u8 type;
259 __u16 reserved1; 248 __u16 reserved1;
@@ -287,44 +276,41 @@ enum xfrm_attr_type_t {
287 276
288enum xfrm_sadattr_type_t { 277enum xfrm_sadattr_type_t {
289 XFRMA_SAD_UNSPEC, 278 XFRMA_SAD_UNSPEC,
290 XFRMA_SADHMASK, 279 XFRMA_SAD_CNT,
291 XFRMA_SADHMAX, 280 XFRMA_SAD_HINFO,
292 XFRMA_SADCNT,
293 __XFRMA_SAD_MAX 281 __XFRMA_SAD_MAX
294 282
295#define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1) 283#define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1)
296}; 284};
297 285
298/* SPD Table filter flags */ 286struct xfrmu_sadhinfo {
299enum xfrm_spd_ftype_t { 287 __u32 sadhcnt; /* current hash bkts */
300 XFRM_SPD_UNSPEC, 288 __u32 sadhmcnt; /* max allowed hash bkts */
301 XFRM_SPD_HMASK=1,
302 XFRM_SPD_HMAX=2,
303 XFRM_SPD_ICNT=4,
304 XFRM_SPD_OCNT=8,
305 XFRM_SPD_FCNT=16,
306 XFRM_SPD_ISCNT=32,
307 XFRM_SPD_OSCNT=64,
308 XFRM_SPD_FSCNT=128,
309 __XFRM_SPD_MAX
310
311#define XFRM_SPD_MAX (__XFRM_SPD_MAX - 1)
312}; 289};
290
313enum xfrm_spdattr_type_t { 291enum xfrm_spdattr_type_t {
314 XFRMA_SPD_UNSPEC, 292 XFRMA_SPD_UNSPEC,
315 XFRMA_SPDHMASK, 293 XFRMA_SPD_INFO,
316 XFRMA_SPDHMAX, 294 XFRMA_SPD_HINFO,
317 XFRMA_SPDICNT,
318 XFRMA_SPDOCNT,
319 XFRMA_SPDFCNT,
320 XFRMA_SPDISCNT,
321 XFRMA_SPDOSCNT,
322 XFRMA_SPDFSCNT,
323 __XFRMA_SPD_MAX 295 __XFRMA_SPD_MAX
324 296
325#define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1) 297#define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1)
326}; 298};
327 299
300struct xfrmu_spdinfo {
301 __u32 incnt;
302 __u32 outcnt;
303 __u32 fwdcnt;
304 __u32 inscnt;
305 __u32 outscnt;
306 __u32 fwdscnt;
307};
308
309struct xfrmu_spdhinfo {
310 __u32 spdhcnt;
311 __u32 spdhmcnt;
312};
313
328struct xfrm_usersa_info { 314struct xfrm_usersa_info {
329 struct xfrm_selector sel; 315 struct xfrm_selector sel;
330 struct xfrm_id id; 316 struct xfrm_id id;
diff --git a/include/media/ovcamchip.h b/include/media/ovcamchip.h
index 0f43451f8bb3..05b9569ef1c8 100644
--- a/include/media/ovcamchip.h
+++ b/include/media/ovcamchip.h
@@ -16,7 +16,6 @@
16 16
17#include <linux/videodev.h> 17#include <linux/videodev.h>
18#include <media/v4l2-common.h> 18#include <media/v4l2-common.h>
19#include <linux/i2c.h>
20 19
21/* --------------------------------- */ 20/* --------------------------------- */
22/* ENUMERATIONS */ 21/* ENUMERATIONS */
diff --git a/include/media/tuner.h b/include/media/tuner.h
index a41ac41113ac..6dcf3c45707d 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -23,6 +23,7 @@
23#define _TUNER_H 23#define _TUNER_H
24 24
25#include <linux/videodev2.h> 25#include <linux/videodev2.h>
26#include <linux/i2c.h>
26#include <media/tuner-types.h> 27#include <media/tuner-types.h>
27 28
28extern int tuner_debug; 29extern int tuner_debug;
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index f70afef9c3cc..4fa5dfe886c4 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -204,9 +204,9 @@ struct ip6_flowlabel
204{ 204{
205 struct ip6_flowlabel *next; 205 struct ip6_flowlabel *next;
206 __be32 label; 206 __be32 label;
207 atomic_t users;
207 struct in6_addr dst; 208 struct in6_addr dst;
208 struct ipv6_txoptions *opt; 209 struct ipv6_txoptions *opt;
209 atomic_t users;
210 unsigned long linger; 210 unsigned long linger;
211 u8 share; 211 u8 share;
212 u32 owner; 212 u32 owner;
@@ -291,7 +291,7 @@ static inline int ipv6_addr_src_scope(const struct in6_addr *addr)
291 291
292static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2) 292static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
293{ 293{
294 return memcmp((const void *) a1, (const void *) a2, sizeof(struct in6_addr)); 294 return memcmp(a1, a2, sizeof(struct in6_addr));
295} 295}
296 296
297static inline int 297static inline int
@@ -308,7 +308,7 @@ ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m,
308 308
309static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) 309static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2)
310{ 310{
311 memcpy((void *) a1, (const void *) a2, sizeof(struct in6_addr)); 311 memcpy(a1, a2, sizeof(struct in6_addr));
312} 312}
313 313
314static inline void ipv6_addr_prefix(struct in6_addr *pfx, 314static inline void ipv6_addr_prefix(struct in6_addr *pfx,
@@ -319,16 +319,12 @@ static inline void ipv6_addr_prefix(struct in6_addr *pfx,
319 int o = plen >> 3, 319 int o = plen >> 3,
320 b = plen & 0x7; 320 b = plen & 0x7;
321 321
322 memset(pfx->s6_addr, 0, sizeof(pfx->s6_addr));
322 memcpy(pfx->s6_addr, addr, o); 323 memcpy(pfx->s6_addr, addr, o);
323 if (b != 0) { 324 if (b != 0)
324 pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b); 325 pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b);
325 o++;
326 }
327 if (o < 16)
328 memset(pfx->s6_addr + o, 0, 16 - o);
329} 326}
330 327
331#ifndef __HAVE_ARCH_ADDR_SET
332static inline void ipv6_addr_set(struct in6_addr *addr, 328static inline void ipv6_addr_set(struct in6_addr *addr,
333 __be32 w1, __be32 w2, 329 __be32 w1, __be32 w2,
334 __be32 w3, __be32 w4) 330 __be32 w3, __be32 w4)
@@ -338,7 +334,6 @@ static inline void ipv6_addr_set(struct in6_addr *addr,
338 addr->s6_addr32[2] = w3; 334 addr->s6_addr32[2] = w3;
339 addr->s6_addr32[3] = w4; 335 addr->s6_addr32[3] = w4;
340} 336}
341#endif
342 337
343static inline int ipv6_addr_equal(const struct in6_addr *a1, 338static inline int ipv6_addr_equal(const struct in6_addr *a1,
344 const struct in6_addr *a2) 339 const struct in6_addr *a2)
diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
index 04d1abb72d25..f9bd11be1891 100644
--- a/include/net/iucv/af_iucv.h
+++ b/include/net/iucv/af_iucv.h
@@ -28,6 +28,7 @@ enum {
28 IUCV_LISTEN, 28 IUCV_LISTEN,
29 IUCV_SEVERED, 29 IUCV_SEVERED,
30 IUCV_DISCONN, 30 IUCV_DISCONN,
31 IUCV_CLOSING,
31 IUCV_CLOSED 32 IUCV_CLOSED
32}; 33};
33 34
@@ -62,6 +63,7 @@ struct iucv_sock {
62 struct sock *parent; 63 struct sock *parent;
63 struct iucv_path *path; 64 struct iucv_path *path;
64 struct sk_buff_head send_skb_q; 65 struct sk_buff_head send_skb_q;
66 struct sk_buff_head backlog_skb_q;
65 unsigned int send_tag; 67 unsigned int send_tag;
66}; 68};
67 69
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
new file mode 100644
index 000000000000..a7f122b79948
--- /dev/null
+++ b/include/net/mac80211.h
@@ -0,0 +1,1045 @@
1/*
2 * Low-level hardware driver -- IEEE 802.11 driver (80211.o) interface
3 * Copyright 2002-2005, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef MAC80211_H
12#define MAC80211_H
13
14#include <linux/kernel.h>
15#include <linux/if_ether.h>
16#include <linux/skbuff.h>
17#include <linux/wireless.h>
18#include <linux/device.h>
19#include <linux/ieee80211.h>
20#include <net/wireless.h>
21#include <net/cfg80211.h>
22
23/* Note! Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
24 * called in hardware interrupt context. The low-level driver must not call any
25 * other functions in hardware interrupt context. If there is a need for such
26 * call, the low-level driver should first ACK the interrupt and perform the
27 * IEEE 802.11 code call after this, e.g., from a scheduled tasklet (in
28 * software interrupt context).
29 */
30
31/*
32 * Frame format used when passing frame between low-level hardware drivers
33 * and IEEE 802.11 driver the same as used in the wireless media, i.e.,
34 * buffers start with IEEE 802.11 header and include the same octets that
35 * are sent over air.
36 *
37 * If hardware uses IEEE 802.3 headers (and perform 802.3 <-> 802.11
38 * conversion in firmware), upper layer 802.11 code needs to be changed to
39 * support this.
40 *
41 * If the receive frame format is not the same as the real frame sent
42 * on the wireless media (e.g., due to padding etc.), upper layer 802.11 code
43 * could be updated to provide support for such format assuming this would
44 * optimize the performance, e.g., by removing need to re-allocation and
45 * copying of the data.
46 */
47
48#define IEEE80211_CHAN_W_SCAN 0x00000001
49#define IEEE80211_CHAN_W_ACTIVE_SCAN 0x00000002
50#define IEEE80211_CHAN_W_IBSS 0x00000004
51
52/* Channel information structure. Low-level driver is expected to fill in chan,
53 * freq, and val fields. Other fields will be filled in by 80211.o based on
54 * hostapd information and low-level driver does not need to use them. The
55 * limits for each channel will be provided in 'struct ieee80211_conf' when
56 * configuring the low-level driver with hw->config callback. If a device has
57 * a default regulatory domain, IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED
58 * can be set to let the driver configure all fields */
59struct ieee80211_channel {
60 short chan; /* channel number (IEEE 802.11) */
61 short freq; /* frequency in MHz */
62 int val; /* hw specific value for the channel */
63 int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */
64 unsigned char power_level;
65 unsigned char antenna_max;
66};
67
68#define IEEE80211_RATE_ERP 0x00000001
69#define IEEE80211_RATE_BASIC 0x00000002
70#define IEEE80211_RATE_PREAMBLE2 0x00000004
71#define IEEE80211_RATE_SUPPORTED 0x00000010
72#define IEEE80211_RATE_OFDM 0x00000020
73#define IEEE80211_RATE_CCK 0x00000040
74#define IEEE80211_RATE_TURBO 0x00000080
75#define IEEE80211_RATE_MANDATORY 0x00000100
76
77#define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2)
78#define IEEE80211_RATE_MODULATION(f) \
79 (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM))
80
81/* Low-level driver should set PREAMBLE2, OFDM, CCK, and TURBO flags.
82 * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the
83 * configuration. */
84struct ieee80211_rate {
85 int rate; /* rate in 100 kbps */
86 int val; /* hw specific value for the rate */
87 int flags; /* IEEE80211_RATE_ flags */
88 int val2; /* hw specific value for the rate when using short preamble
89 * (only when IEEE80211_RATE_PREAMBLE2 flag is set, i.e., for
90 * 2, 5.5, and 11 Mbps) */
91 signed char min_rssi_ack;
92 unsigned char min_rssi_ack_delta;
93
94 /* following fields are set by 80211.o and need not be filled by the
95 * low-level driver */
96 int rate_inv; /* inverse of the rate (LCM(all rates) / rate) for
97 * optimizing channel utilization estimates */
98};
99
100/* 802.11g is backwards-compatible with 802.11b, so a wlan card can
101 * actually be both in 11b and 11g modes at the same time. */
102enum {
103 MODE_IEEE80211A, /* IEEE 802.11a */
104 MODE_IEEE80211B, /* IEEE 802.11b only */
105 MODE_ATHEROS_TURBO, /* Atheros Turbo mode (2x.11a at 5 GHz) */
106 MODE_IEEE80211G, /* IEEE 802.11g (and 802.11b compatibility) */
107 MODE_ATHEROS_TURBOG, /* Atheros Turbo mode (2x.11g at 2.4 GHz) */
108
109 /* keep last */
110 NUM_IEEE80211_MODES
111};
112
113struct ieee80211_hw_mode {
114 int mode; /* MODE_IEEE80211... */
115 int num_channels; /* Number of channels (below) */
116 struct ieee80211_channel *channels; /* Array of supported channels */
117 int num_rates; /* Number of rates (below) */
118 struct ieee80211_rate *rates; /* Array of supported rates */
119
120 struct list_head list; /* Internal, don't touch */
121};
122
123struct ieee80211_tx_queue_params {
124 int aifs; /* 0 .. 255; -1 = use default */
125 int cw_min; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */
126 int cw_max; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */
127 int burst_time; /* maximum burst time in 0.1 ms (i.e., 10 = 1 ms);
128 * 0 = disabled */
129};
130
131struct ieee80211_tx_queue_stats_data {
132 unsigned int len; /* num packets in queue */
133 unsigned int limit; /* queue len (soft) limit */
134 unsigned int count; /* total num frames sent */
135};
136
137enum {
138 IEEE80211_TX_QUEUE_DATA0,
139 IEEE80211_TX_QUEUE_DATA1,
140 IEEE80211_TX_QUEUE_DATA2,
141 IEEE80211_TX_QUEUE_DATA3,
142 IEEE80211_TX_QUEUE_DATA4,
143 IEEE80211_TX_QUEUE_SVP,
144
145 NUM_TX_DATA_QUEUES,
146
147/* due to stupidity in the sub-ioctl userspace interface, the items in
148 * this struct need to have fixed values. As soon as it is removed, we can
149 * fix these entries. */
150 IEEE80211_TX_QUEUE_AFTER_BEACON = 6,
151 IEEE80211_TX_QUEUE_BEACON = 7
152};
153
154struct ieee80211_tx_queue_stats {
155 struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES];
156};
157
158struct ieee80211_low_level_stats {
159 unsigned int dot11ACKFailureCount;
160 unsigned int dot11RTSFailureCount;
161 unsigned int dot11FCSErrorCount;
162 unsigned int dot11RTSSuccessCount;
163};
164
165/* Transmit control fields. This data structure is passed to low-level driver
166 * with each TX frame. The low-level driver is responsible for configuring
167 * the hardware to use given values (depending on what is supported). */
168#define HW_KEY_IDX_INVALID -1
169
170struct ieee80211_tx_control {
171 int tx_rate; /* Transmit rate, given as the hw specific value for the
172 * rate (from struct ieee80211_rate) */
173 int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw
174 * specific value for the rate (from
175 * struct ieee80211_rate) */
176
177#define IEEE80211_TXCTL_REQ_TX_STATUS (1<<0)/* request TX status callback for
178 * this frame */
179#define IEEE80211_TXCTL_DO_NOT_ENCRYPT (1<<1) /* send this frame without
180 * encryption; e.g., for EAPOL
181 * frames */
182#define IEEE80211_TXCTL_USE_RTS_CTS (1<<2) /* use RTS-CTS before sending
183 * frame */
184#define IEEE80211_TXCTL_USE_CTS_PROTECT (1<<3) /* use CTS protection for the
185 * frame (e.g., for combined
186 * 802.11g / 802.11b networks) */
187#define IEEE80211_TXCTL_NO_ACK (1<<4) /* tell the low level not to
188 * wait for an ack */
189#define IEEE80211_TXCTL_RATE_CTRL_PROBE (1<<5)
190#define IEEE80211_TXCTL_CLEAR_DST_MASK (1<<6)
191#define IEEE80211_TXCTL_REQUEUE (1<<7)
192#define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of
193 * the frame */
194#define IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY (1<<9)
195 u32 flags; /* tx control flags defined
196 * above */
197 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. */
198 u8 power_level; /* per-packet transmit power level, in dBm */
199 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
200 s8 key_idx; /* -1 = do not encrypt, >= 0 keyidx from
201 * hw->set_key() */
202 u8 icv_len; /* length of the ICV/MIC field in octets */
203 u8 iv_len; /* length of the IV field in octets */
204 u8 tkip_key[16]; /* generated phase2/phase1 key for hw TKIP */
205 u8 queue; /* hardware queue to use for this frame;
206 * 0 = highest, hw->queues-1 = lowest */
207 u8 sw_retry_attempt; /* number of times hw has tried to
208 * transmit frame (not incl. hw retries) */
209
210 struct ieee80211_rate *rate; /* internal 80211.o rate */
211 struct ieee80211_rate *rts_rate; /* internal 80211.o rate
212 * for RTS/CTS */
213 int alt_retry_rate; /* retry rate for the last retries, given as the
214 * hw specific value for the rate (from
215 * struct ieee80211_rate). To be used to limit
216 * packet dropping when probing higher rates, if hw
217 * supports multiple retry rates. -1 = not used */
218 int type; /* internal */
219 int ifindex; /* internal */
220};
221
222/* Receive status. The low-level driver should provide this information
223 * (the subset supported by hardware) to the 802.11 code with each received
224 * frame. */
225struct ieee80211_rx_status {
226 u64 mactime;
227 int freq; /* receive frequency in Mhz */
228 int channel;
229 int phymode;
230 int ssi;
231 int signal; /* used as qual in statistics reporting */
232 int noise;
233 int antenna;
234 int rate;
235#define RX_FLAG_MMIC_ERROR (1<<0)
236#define RX_FLAG_DECRYPTED (1<<1)
237#define RX_FLAG_RADIOTAP (1<<2)
238 int flag;
239};
240
241/* Transmit status. The low-level driver should provide this information
242 * (the subset supported by hardware) to the 802.11 code for each transmit
243 * frame. */
244struct ieee80211_tx_status {
245 /* copied ieee80211_tx_control structure */
246 struct ieee80211_tx_control control;
247
248#define IEEE80211_TX_STATUS_TX_FILTERED (1<<0)
249#define IEEE80211_TX_STATUS_ACK (1<<1) /* whether the TX frame was ACKed */
250 u32 flags; /* tx staus flags defined above */
251
252 int ack_signal; /* measured signal strength of the ACK frame */
253 int excessive_retries;
254 int retry_count;
255
256 int queue_length; /* information about TX queue */
257 int queue_number;
258};
259
260
261/**
262 * struct ieee80211_conf - configuration of the device
263 *
264 * This struct indicates how the driver shall configure the hardware.
265 *
266 * @radio_enabled: when zero, driver is required to switch off the radio.
267 */
268struct ieee80211_conf {
269 int channel; /* IEEE 802.11 channel number */
270 int freq; /* MHz */
271 int channel_val; /* hw specific value for the channel */
272
273 int phymode; /* MODE_IEEE80211A, .. */
274 struct ieee80211_channel *chan;
275 struct ieee80211_hw_mode *mode;
276 unsigned int regulatory_domain;
277 int radio_enabled;
278
279 int beacon_int;
280
281#define IEEE80211_CONF_SHORT_SLOT_TIME (1<<0) /* use IEEE 802.11g Short Slot
282 * Time */
283#define IEEE80211_CONF_SSID_HIDDEN (1<<1) /* do not broadcast the ssid */
284#define IEEE80211_CONF_RADIOTAP (1<<2) /* use radiotap if supported
285 check this bit at RX time */
286 u32 flags; /* configuration flags defined above */
287
288 u8 power_level; /* transmit power limit for current
289 * regulatory domain; in dBm */
290 u8 antenna_max; /* maximum antenna gain */
291 short tx_power_reduction; /* in 0.1 dBm */
292
293 /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
294 u8 antenna_sel_tx;
295 u8 antenna_sel_rx;
296
297 int antenna_def;
298 int antenna_mode;
299
300 /* Following five fields are used for IEEE 802.11H */
301 unsigned int radar_detect;
302 unsigned int spect_mgmt;
303 /* All following fields are currently unused. */
304 unsigned int quiet_duration; /* duration of quiet period */
305 unsigned int quiet_offset; /* how far into the beacon is the quiet
306 * period */
307 unsigned int quiet_period;
308 u8 radar_firpwr_threshold;
309 u8 radar_rssi_threshold;
310 u8 pulse_height_threshold;
311 u8 pulse_rssi_threshold;
312 u8 pulse_inband_threshold;
313};
314
315/**
316 * enum ieee80211_if_types - types of 802.11 network interfaces
317 *
318 * @IEEE80211_IF_TYPE_AP: interface in AP mode.
319 * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap
320 * daemon. Drivers should never see this type.
321 * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode.
322 * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode.
323 * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode.
324 * @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
325 * @IEEE80211_IF_TYPE_VLAN: not used.
326 */
327enum ieee80211_if_types {
328 IEEE80211_IF_TYPE_AP = 0x00000000,
329 IEEE80211_IF_TYPE_MGMT = 0x00000001,
330 IEEE80211_IF_TYPE_STA = 0x00000002,
331 IEEE80211_IF_TYPE_IBSS = 0x00000003,
332 IEEE80211_IF_TYPE_MNTR = 0x00000004,
333 IEEE80211_IF_TYPE_WDS = 0x5A580211,
334 IEEE80211_IF_TYPE_VLAN = 0x00080211,
335};
336
337/**
338 * struct ieee80211_if_init_conf - initial configuration of an interface
339 *
340 * @if_id: internal interface ID. This number has no particular meaning to
341 * drivers and the only allowed usage is to pass it to
342 * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions.
343 * This field is not valid for monitor interfaces
344 * (interfaces of %IEEE80211_IF_TYPE_MNTR type).
345 * @type: one of &enum ieee80211_if_types constants. Determines the type of
346 * added/removed interface.
347 * @mac_addr: pointer to MAC address of the interface. This pointer is valid
348 * until the interface is removed (i.e. it cannot be used after
349 * remove_interface() callback was called for this interface).
350 *
351 * This structure is used in add_interface() and remove_interface()
352 * callbacks of &struct ieee80211_hw.
353 */
354struct ieee80211_if_init_conf {
355 int if_id;
356 int type;
357 void *mac_addr;
358};
359
360/**
361 * struct ieee80211_if_conf - configuration of an interface
362 *
363 * @type: type of the interface. This is always the same as was specified in
364 * &struct ieee80211_if_init_conf. The type of an interface never changes
365 * during the life of the interface; this field is present only for
366 * convenience.
367 * @bssid: BSSID of the network we are associated to/creating.
368 * @ssid: used (together with @ssid_len) by drivers for hardware that
369 * generate beacons independently. The pointer is valid only during the
370 * config_interface() call, so copy the value somewhere if you need
371 * it.
372 * @ssid_len: length of the @ssid field.
373 * @generic_elem: used (together with @generic_elem_len) by drivers for
374 * hardware that generate beacons independently. The pointer is valid
375 * only during the config_interface() call, so copy the value somewhere
376 * if you need it.
377 * @generic_elem_len: length of the generic element.
378 * @beacon: beacon template. Valid only if @host_gen_beacon_template in
379 * &struct ieee80211_hw is set. The driver is responsible of freeing
380 * the sk_buff.
381 * @beacon_control: tx_control for the beacon template, this field is only
382 * valid when the @beacon field was set.
383 *
384 * This structure is passed to the config_interface() callback of
385 * &struct ieee80211_hw.
386 */
387struct ieee80211_if_conf {
388 int type;
389 u8 *bssid;
390 u8 *ssid;
391 size_t ssid_len;
392 u8 *generic_elem;
393 size_t generic_elem_len;
394 struct sk_buff *beacon;
395 struct ieee80211_tx_control *beacon_control;
396};
397
398typedef enum { ALG_NONE, ALG_WEP, ALG_TKIP, ALG_CCMP, ALG_NULL }
399ieee80211_key_alg;
400
401
402struct ieee80211_key_conf {
403
404 int hw_key_idx; /* filled + used by low-level driver */
405 ieee80211_key_alg alg;
406 int keylen;
407
408#define IEEE80211_KEY_FORCE_SW_ENCRYPT (1<<0) /* to be cleared by low-level
409 driver */
410#define IEEE80211_KEY_DEFAULT_TX_KEY (1<<1) /* This key is the new default TX
411 key (used only for broadcast
412 keys). */
413#define IEEE80211_KEY_DEFAULT_WEP_ONLY (1<<2) /* static WEP is the only
414 configured security policy;
415 this allows some low-level
416 drivers to determine when
417 hwaccel can be used */
418 u32 flags; /* key configuration flags defined above */
419
420 s8 keyidx; /* WEP key index */
421 u8 key[0];
422};
423
424#define IEEE80211_SEQ_COUNTER_RX 0
425#define IEEE80211_SEQ_COUNTER_TX 1
426
427typedef enum {
428 SET_KEY, DISABLE_KEY, REMOVE_ALL_KEYS,
429} set_key_cmd;
430
431/* This is driver-visible part of the per-hw state the stack keeps. */
432struct ieee80211_hw {
433 /* points to the cfg80211 wiphy for this piece. Note
434 * that you must fill in the perm_addr and dev fields
435 * of this structure, use the macros provided below. */
436 struct wiphy *wiphy;
437
438 /* assigned by mac80211, don't write */
439 struct ieee80211_conf conf;
440
441 /* Single thread workqueue available for driver use
442 * Allocated by mac80211 on registration */
443 struct workqueue_struct *workqueue;
444
445 /* Pointer to the private area that was
446 * allocated with this struct for you. */
447 void *priv;
448
449 /* The rest is information about your hardware */
450
451 /* TODO: frame_type 802.11/802.3, sw_encryption requirements */
452
453 /* Some wireless LAN chipsets generate beacons in the hardware/firmware
454 * and others rely on host generated beacons. This option is used to
455 * configure the upper layer IEEE 802.11 module to generate beacons.
456 * The low-level driver can use ieee80211_beacon_get() to fetch the
457 * next beacon frame. */
458#define IEEE80211_HW_HOST_GEN_BEACON (1<<0)
459
460 /* The device needs to be supplied with a beacon template only. */
461#define IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE (1<<1)
462
463 /* Some devices handle decryption internally and do not
464 * indicate whether the frame was encrypted (unencrypted frames
465 * will be dropped by the hardware, unless specifically allowed
466 * through) */
467#define IEEE80211_HW_DEVICE_HIDES_WEP (1<<2)
468
469 /* Whether RX frames passed to ieee80211_rx() include FCS in the end */
470#define IEEE80211_HW_RX_INCLUDES_FCS (1<<3)
471
472 /* Some wireless LAN chipsets buffer broadcast/multicast frames for
473 * power saving stations in the hardware/firmware and others rely on
474 * the host system for such buffering. This option is used to
475 * configure the IEEE 802.11 upper layer to buffer broadcast/multicast
476 * frames when there are power saving stations so that low-level driver
477 * can fetch them with ieee80211_get_buffered_bc(). */
478#define IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING (1<<4)
479
480#define IEEE80211_HW_WEP_INCLUDE_IV (1<<5)
481
482 /* will data nullfunc frames get proper TX status callback */
483#define IEEE80211_HW_DATA_NULLFUNC_ACK (1<<6)
484
485 /* Force software encryption for TKIP packets if WMM is enabled. */
486#define IEEE80211_HW_NO_TKIP_WMM_HWACCEL (1<<7)
487
488 /* Some devices handle Michael MIC internally and do not include MIC in
489 * the received packets passed up. device_strips_mic must be set
490 * for such devices. The 'encryption' frame control bit is expected to
491 * be still set in the IEEE 802.11 header with this option unlike with
492 * the device_hides_wep configuration option.
493 */
494#define IEEE80211_HW_DEVICE_STRIPS_MIC (1<<8)
495
496 /* Device is capable of performing full monitor mode even during
497 * normal operation. */
498#define IEEE80211_HW_MONITOR_DURING_OPER (1<<9)
499
500 /* Device does not need BSSID filter set to broadcast in order to
501 * receive all probe responses while scanning */
502#define IEEE80211_HW_NO_PROBE_FILTERING (1<<10)
503
504 /* Channels are already configured to the default regulatory domain
505 * specified in the device's EEPROM */
506#define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11)
507
508 /* calculate Michael MIC for an MSDU when doing hwcrypto */
509#define IEEE80211_HW_TKIP_INCLUDE_MMIC (1<<12)
510 /* Do TKIP phase1 key mixing in stack to support cards only do
511 * phase2 key mixing when doing hwcrypto */
512#define IEEE80211_HW_TKIP_REQ_PHASE1_KEY (1<<13)
513 /* Do TKIP phase1 and phase2 key mixing in stack and send the generated
514 * per-packet RC4 key with each TX frame when doing hwcrypto */
515#define IEEE80211_HW_TKIP_REQ_PHASE2_KEY (1<<14)
516
517 u32 flags; /* hardware flags defined above */
518
519 /* Set to the size of a needed device specific skb headroom for TX skbs. */
520 unsigned int extra_tx_headroom;
521
522 /* This is the time in us to change channels
523 */
524 int channel_change_time;
525 /* Maximum values for various statistics.
526 * Leave at 0 to indicate no support. Use negative numbers for dBm. */
527 s8 max_rssi;
528 s8 max_signal;
529 s8 max_noise;
530
531 /* Number of available hardware TX queues for data packets.
532 * WMM requires at least four queues. */
533 int queues;
534};
535
536static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
537{
538 set_wiphy_dev(hw->wiphy, dev);
539}
540
541static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
542{
543 memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
544}
545
546/* Configuration block used by the low-level driver to tell the 802.11 code
547 * about supported hardware features and to pass function pointers to callback
548 * functions. */
549struct ieee80211_ops {
550 /* Handler that 802.11 module calls for each transmitted frame.
551 * skb contains the buffer starting from the IEEE 802.11 header.
552 * The low-level driver should send the frame out based on
553 * configuration in the TX control data.
554 * Must be atomic. */
555 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
556 struct ieee80211_tx_control *control);
557
558 /* Handler for performing hardware reset. */
559 int (*reset)(struct ieee80211_hw *hw);
560
561 /* Handler that is called when any netdevice attached to the hardware
562 * device is set UP for the first time. This can be used, e.g., to
563 * enable interrupts and beacon sending. */
564 int (*open)(struct ieee80211_hw *hw);
565
566 /* Handler that is called when the last netdevice attached to the
567 * hardware device is set DOWN. This can be used, e.g., to disable
568 * interrupts and beacon sending. */
569 int (*stop)(struct ieee80211_hw *hw);
570
571 /* Handler for asking a driver if a new interface can be added (or,
572 * more exactly, set UP). If the handler returns zero, the interface
573 * is added. Driver should perform any initialization it needs prior
574 * to returning zero. By returning non-zero addition of the interface
575 * is inhibited. Unless monitor_during_oper is set, it is guaranteed
576 * that monitor interfaces and normal interfaces are mutually
577 * exclusive. The open() handler is called after add_interface()
578 * if this is the first device added. At least one of the open()
579 * open() and add_interface() callbacks has to be assigned. If
580 * add_interface() is NULL, one STA interface is permitted only. */
581 int (*add_interface)(struct ieee80211_hw *hw,
582 struct ieee80211_if_init_conf *conf);
583
584 /* Notify a driver that an interface is going down. The stop() handler
585 * is called prior to this if this is a last interface. */
586 void (*remove_interface)(struct ieee80211_hw *hw,
587 struct ieee80211_if_init_conf *conf);
588
589 /* Handler for configuration requests. IEEE 802.11 code calls this
590 * function to change hardware configuration, e.g., channel. */
591 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
592
593 /* Handler for configuration requests related to interfaces (e.g.
594 * BSSID). */
595 int (*config_interface)(struct ieee80211_hw *hw,
596 int if_id, struct ieee80211_if_conf *conf);
597
598 /* ieee80211 drivers do not have access to the &struct net_device
599 * that is (are) connected with their device. Hence (and because
600 * we need to combine the multicast lists and flags for multiple
601 * virtual interfaces), they cannot assign set_multicast_list.
602 * The parameters here replace dev->flags and dev->mc_count,
603 * dev->mc_list is replaced by calling ieee80211_get_mc_list_item.
604 * Must be atomic. */
605 void (*set_multicast_list)(struct ieee80211_hw *hw,
606 unsigned short flags, int mc_count);
607
608 /* Set TIM bit handler. If the hardware/firmware takes care of beacon
609 * generation, IEEE 802.11 code uses this function to tell the
610 * low-level to set (or clear if set==0) TIM bit for the given aid. If
611 * host system is used to generate beacons, this handler is not used
612 * and low-level driver should set it to NULL.
613 * Must be atomic. */
614 int (*set_tim)(struct ieee80211_hw *hw, int aid, int set);
615
616 /* Set encryption key. IEEE 802.11 module calls this function to set
617 * encryption keys. addr is ff:ff:ff:ff:ff:ff for default keys and
618 * station hwaddr for individual keys. aid of the station is given
619 * to help low-level driver in selecting which key->hw_key_idx to use
620 * for this key. TX control data will use the hw_key_idx selected by
621 * the low-level driver.
622 * Must be atomic. */
623 int (*set_key)(struct ieee80211_hw *hw, set_key_cmd cmd,
624 u8 *addr, struct ieee80211_key_conf *key, int aid);
625
626 /* Set TX key index for default/broadcast keys. This is needed in cases
627 * where wlan card is doing full WEP/TKIP encapsulation (wep_include_iv
628 * is not set), in other cases, this function pointer can be set to
629 * NULL since the IEEE 802. 11 module takes care of selecting the key
630 * index for each TX frame. */
631 int (*set_key_idx)(struct ieee80211_hw *hw, int idx);
632
633 /* Enable/disable IEEE 802.1X. This item requests wlan card to pass
634 * unencrypted EAPOL-Key frames even when encryption is configured.
635 * If the wlan card does not require such a configuration, this
636 * function pointer can be set to NULL. */
637 int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x);
638
639 /* Set port authorization state (IEEE 802.1X PAE) to be authorized
640 * (authorized=1) or unauthorized (authorized=0). This function can be
641 * used if the wlan hardware or low-level driver implements PAE.
642 * 80211.o module will anyway filter frames based on authorization
643 * state, so this function pointer can be NULL if low-level driver does
644 * not require event notification about port state changes.
645 * Currently unused. */
646 int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr,
647 int authorized);
648
649 /* Ask the hardware to service the scan request, no need to start
650 * the scan state machine in stack. */
651 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
652
653 /* return low-level statistics */
654 int (*get_stats)(struct ieee80211_hw *hw,
655 struct ieee80211_low_level_stats *stats);
656
657 /* For devices that generate their own beacons and probe response
658 * or association responses this updates the state of privacy_invoked
659 * returns 0 for success or an error number */
660 int (*set_privacy_invoked)(struct ieee80211_hw *hw,
661 int privacy_invoked);
662
663 /* For devices that have internal sequence counters, allow 802.11
664 * code to access the current value of a counter */
665 int (*get_sequence_counter)(struct ieee80211_hw *hw,
666 u8* addr, u8 keyidx, u8 txrx,
667 u32* iv32, u16* iv16);
668
669 /* Configuration of RTS threshold (if device needs it) */
670 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
671
672 /* Configuration of fragmentation threshold.
673 * Assign this if the device does fragmentation by itself,
674 * if this method is assigned then the stack will not do
675 * fragmentation. */
676 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
677
678 /* Configuration of retry limits (if device needs it) */
679 int (*set_retry_limit)(struct ieee80211_hw *hw,
680 u32 short_retry, u32 long_retr);
681
682 /* Number of STAs in STA table notification (NULL = disabled).
683 * Must be atomic. */
684 void (*sta_table_notification)(struct ieee80211_hw *hw,
685 int num_sta);
686
687 /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
688 * bursting) for a hardware TX queue.
689 * queue = IEEE80211_TX_QUEUE_*.
690 * Must be atomic. */
691 int (*conf_tx)(struct ieee80211_hw *hw, int queue,
692 const struct ieee80211_tx_queue_params *params);
693
694 /* Get statistics of the current TX queue status. This is used to get
695 * number of currently queued packets (queue length), maximum queue
696 * size (limit), and total number of packets sent using each TX queue
697 * (count).
698 * Currently unused. */
699 int (*get_tx_stats)(struct ieee80211_hw *hw,
700 struct ieee80211_tx_queue_stats *stats);
701
702 /* Get the current TSF timer value from firmware/hardware. Currently,
703 * this is only used for IBSS mode debugging and, as such, is not a
704 * required function.
705 * Must be atomic. */
706 u64 (*get_tsf)(struct ieee80211_hw *hw);
707
708 /* Reset the TSF timer and allow firmware/hardware to synchronize with
709 * other STAs in the IBSS. This is only used in IBSS mode. This
710 * function is optional if the firmware/hardware takes full care of
711 * TSF synchronization. */
712 void (*reset_tsf)(struct ieee80211_hw *hw);
713
714 /* Setup beacon data for IBSS beacons. Unlike access point (Master),
715 * IBSS uses a fixed beacon frame which is configured using this
716 * function. This handler is required only for IBSS mode. */
717 int (*beacon_update)(struct ieee80211_hw *hw,
718 struct sk_buff *skb,
719 struct ieee80211_tx_control *control);
720
721 /* Determine whether the last IBSS beacon was sent by us. This is
722 * needed only for IBSS mode and the result of this function is used to
723 * determine whether to reply to Probe Requests. */
724 int (*tx_last_beacon)(struct ieee80211_hw *hw);
725};
726
727/* Allocate a new hardware device. This must be called once for each
728 * hardware device. The returned pointer must be used to refer to this
729 * device when calling other functions. 802.11 code allocates a private data
730 * area for the low-level driver. The size of this area is given as
731 * priv_data_len.
732 */
733struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
734 const struct ieee80211_ops *ops);
735
736/* Register hardware device to the IEEE 802.11 code and kernel. Low-level
737 * drivers must call this function before using any other IEEE 802.11
738 * function except ieee80211_register_hwmode. */
739int ieee80211_register_hw(struct ieee80211_hw *hw);
740
741/* driver can use this and ieee80211_get_rx_led_name to get the
742 * name of the registered LEDs after ieee80211_register_hw
743 * was called.
744 * This is useful to set the default trigger on the LED class
745 * device that your driver should export for each LED the device
746 * has, that way the default behaviour will be as expected but
747 * the user can still change it/turn off the LED etc.
748 */
749#ifdef CONFIG_MAC80211_LEDS
750extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
751extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
752#endif
753static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
754{
755#ifdef CONFIG_MAC80211_LEDS
756 return __ieee80211_get_tx_led_name(hw);
757#else
758 return NULL;
759#endif
760}
761
762static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
763{
764#ifdef CONFIG_MAC80211_LEDS
765 return __ieee80211_get_rx_led_name(hw);
766#else
767 return NULL;
768#endif
769}
770
771/* Register a new hardware PHYMODE capability to the stack. */
772int ieee80211_register_hwmode(struct ieee80211_hw *hw,
773 struct ieee80211_hw_mode *mode);
774
775/* Unregister a hardware device. This function instructs 802.11 code to free
776 * allocated resources and unregister netdevices from the kernel. */
777void ieee80211_unregister_hw(struct ieee80211_hw *hw);
778
779/* Free everything that was allocated including private data of a driver. */
780void ieee80211_free_hw(struct ieee80211_hw *hw);
781
782/* Receive frame callback function. The low-level driver uses this function to
783 * send received frames to the IEEE 802.11 code. Receive buffer (skb) must
784 * start with IEEE 802.11 header. */
785void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
786 struct ieee80211_rx_status *status);
787void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
788 struct sk_buff *skb,
789 struct ieee80211_rx_status *status);
790
791/* Transmit status callback function. The low-level driver must call this
792 * function to report transmit status for all the TX frames that had
793 * req_tx_status set in the transmit control fields. In addition, this should
794 * be called at least for all unicast frames to provide information for TX rate
795 * control algorithm. In order to maintain all statistics, this function is
796 * recommended to be called after each frame, including multicast/broadcast, is
797 * sent. */
798void ieee80211_tx_status(struct ieee80211_hw *hw,
799 struct sk_buff *skb,
800 struct ieee80211_tx_status *status);
801void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
802 struct sk_buff *skb,
803 struct ieee80211_tx_status *status);
804
805/**
806 * ieee80211_beacon_get - beacon generation function
807 * @hw: pointer obtained from ieee80211_alloc_hw().
808 * @if_id: interface ID from &struct ieee80211_if_init_conf.
809 * @control: will be filled with information needed to send this beacon.
810 *
811 * If the beacon frames are generated by the host system (i.e., not in
812 * hardware/firmware), the low-level driver uses this function to receive
813 * the next beacon frame from the 802.11 code. The low-level is responsible
814 * for calling this function before beacon data is needed (e.g., based on
815 * hardware interrupt). Returned skb is used only once and low-level driver
816 * is responsible of freeing it.
817 */
818struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
819 int if_id,
820 struct ieee80211_tx_control *control);
821
822/**
823 * ieee80211_rts_get - RTS frame generation function
824 * @hw: pointer obtained from ieee80211_alloc_hw().
825 * @frame: pointer to the frame that is going to be protected by the RTS.
826 * @frame_len: the frame length (in octets).
827 * @frame_txctl: &struct ieee80211_tx_control of the frame.
828 * @rts: The buffer where to store the RTS frame.
829 *
830 * If the RTS frames are generated by the host system (i.e., not in
831 * hardware/firmware), the low-level driver uses this function to receive
832 * the next RTS frame from the 802.11 code. The low-level is responsible
833 * for calling this function before and RTS frame is needed.
834 */
835void ieee80211_rts_get(struct ieee80211_hw *hw,
836 const void *frame, size_t frame_len,
837 const struct ieee80211_tx_control *frame_txctl,
838 struct ieee80211_rts *rts);
839
840/**
841 * ieee80211_rts_duration - Get the duration field for an RTS frame
842 * @hw: pointer obtained from ieee80211_alloc_hw().
843 * @frame_len: the length of the frame that is going to be protected by the RTS.
844 * @frame_txctl: &struct ieee80211_tx_control of the frame.
845 *
846 * If the RTS is generated in firmware, but the host system must provide
847 * the duration field, the low-level driver uses this function to receive
848 * the duration field value in little-endian byteorder.
849 */
850__le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
851 size_t frame_len,
852 const struct ieee80211_tx_control *frame_txctl);
853
854/**
855 * ieee80211_ctstoself_get - CTS-to-self frame generation function
856 * @hw: pointer obtained from ieee80211_alloc_hw().
857 * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
858 * @frame_len: the frame length (in octets).
859 * @frame_txctl: &struct ieee80211_tx_control of the frame.
860 * @cts: The buffer where to store the CTS-to-self frame.
861 *
862 * If the CTS-to-self frames are generated by the host system (i.e., not in
863 * hardware/firmware), the low-level driver uses this function to receive
864 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
865 * for calling this function before and CTS-to-self frame is needed.
866 */
867void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
868 const void *frame, size_t frame_len,
869 const struct ieee80211_tx_control *frame_txctl,
870 struct ieee80211_cts *cts);
871
872/**
873 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
874 * @hw: pointer obtained from ieee80211_alloc_hw().
875 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
876 * @frame_txctl: &struct ieee80211_tx_control of the frame.
877 *
878 * If the CTS-to-self is generated in firmware, but the host system must provide
879 * the duration field, the low-level driver uses this function to receive
880 * the duration field value in little-endian byteorder.
881 */
882__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
883 size_t frame_len,
884 const struct ieee80211_tx_control *frame_txctl);
885
886/**
887 * ieee80211_generic_frame_duration - Calculate the duration field for a frame
888 * @hw: pointer obtained from ieee80211_alloc_hw().
889 * @frame_len: the length of the frame.
890 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
891 *
892 * Calculate the duration field of some generic frame, given its
893 * length and transmission rate (in 100kbps).
894 */
895__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
896 size_t frame_len,
897 int rate);
898
899/**
900 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
901 * @hw: pointer as obtained from ieee80211_alloc_hw().
902 * @if_id: interface ID from &struct ieee80211_if_init_conf.
903 * @control: will be filled with information needed to send returned frame.
904 *
905 * Function for accessing buffered broadcast and multicast frames. If
906 * hardware/firmware does not implement buffering of broadcast/multicast
907 * frames when power saving is used, 802.11 code buffers them in the host
908 * memory. The low-level driver uses this function to fetch next buffered
909 * frame. In most cases, this is used when generating beacon frame. This
910 * function returns a pointer to the next buffered skb or NULL if no more
911 * buffered frames are available.
912 *
913 * Note: buffered frames are returned only after DTIM beacon frame was
914 * generated with ieee80211_beacon_get() and the low-level driver must thus
915 * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
916 * NULL if the previous generated beacon was not DTIM, so the low-level driver
917 * does not need to check for DTIM beacons separately and should be able to
918 * use common code for all beacons.
919 */
920struct sk_buff *
921ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
922 struct ieee80211_tx_control *control);
923
924/* Low level drivers that have their own MLME and MAC indicate
925 * the aid for an associating station with this call */
926int ieee80211_set_aid_for_sta(struct ieee80211_hw *hw,
927 u8 *peer_address, u16 aid);
928
929
930/* Given an sk_buff with a raw 802.11 header at the data pointer this function
931 * returns the 802.11 header length in bytes (not including encryption
932 * headers). If the data in the sk_buff is too short to contain a valid 802.11
933 * header the function returns 0.
934 */
935int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
936
937/* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */
938int ieee80211_get_hdrlen(u16 fc);
939
940/**
941 * ieee80211_wake_queue - wake specific queue
942 * @hw: pointer as obtained from ieee80211_alloc_hw().
943 * @queue: queue number (counted from zero).
944 *
945 * Drivers should use this function instead of netif_wake_queue.
946 */
947void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
948
949/**
950 * ieee80211_stop_queue - stop specific queue
951 * @hw: pointer as obtained from ieee80211_alloc_hw().
952 * @queue: queue number (counted from zero).
953 *
954 * Drivers should use this function instead of netif_stop_queue.
955 */
956void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
957
958/**
959 * ieee80211_start_queues - start all queues
960 * @hw: pointer to as obtained from ieee80211_alloc_hw().
961 *
962 * Drivers should use this function instead of netif_start_queue.
963 */
964void ieee80211_start_queues(struct ieee80211_hw *hw);
965
966/**
967 * ieee80211_stop_queues - stop all queues
968 * @hw: pointer as obtained from ieee80211_alloc_hw().
969 *
970 * Drivers should use this function instead of netif_stop_queue.
971 */
972void ieee80211_stop_queues(struct ieee80211_hw *hw);
973
974/**
975 * ieee80211_wake_queues - wake all queues
976 * @hw: pointer as obtained from ieee80211_alloc_hw().
977 *
978 * Drivers should use this function instead of netif_wake_queue.
979 */
980void ieee80211_wake_queues(struct ieee80211_hw *hw);
981
982/**
983 * ieee80211_get_mc_list_item - iteration over items in multicast list
984 * @hw: pointer as obtained from ieee80211_alloc_hw().
985 * @prev: value returned by previous call to ieee80211_get_mc_list_item() or
986 * NULL to start a new iteration.
987 * @ptr: pointer to buffer of void * type for internal usage of
988 * ieee80211_get_mc_list_item().
989 *
990 * Iterates over items in multicast list of given device. To get the first
991 * item, pass NULL in @prev and in *@ptr. In subsequent calls, pass the
992 * value returned by previous call in @prev. Don't alter *@ptr during
993 * iteration. When there are no more items, NULL is returned.
994 */
995struct dev_mc_list *
996ieee80211_get_mc_list_item(struct ieee80211_hw *hw,
997 struct dev_mc_list *prev,
998 void **ptr);
999
1000/* called by driver to notify scan status completed */
1001void ieee80211_scan_completed(struct ieee80211_hw *hw);
1002
1003/* Function to indicate Radar Detection. The low level driver must call this
1004 * function to indicate the presence of radar in the current channel.
1005 * Additionally the radar type also could be sent */
1006int ieee80211_radar_status(struct ieee80211_hw *hw, int channel,
1007 int radar, int radar_type);
1008
1009/* return a pointer to the source address (SA) */
1010static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1011{
1012 u8 *raw = (u8 *) hdr;
1013 u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
1014
1015 switch (tofrom) {
1016 case 2:
1017 return hdr->addr3;
1018 case 3:
1019 return hdr->addr4;
1020 }
1021 return hdr->addr2;
1022}
1023
1024/* return a pointer to the destination address (DA) */
1025static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1026{
1027 u8 *raw = (u8 *) hdr;
1028 u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
1029
1030 if (to_ds)
1031 return hdr->addr3;
1032 return hdr->addr1;
1033}
1034
1035static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
1036{
1037 return (le16_to_cpu(hdr->frame_control) &
1038 IEEE80211_FCTL_MOREFRAGS) != 0;
1039}
1040
1041#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
1042#define MAC_ARG(x) ((u8*)(x))[0], ((u8*)(x))[1], ((u8*)(x))[2], \
1043 ((u8*)(x))[3], ((u8*)(x))[4], ((u8*)(x))[5]
1044
1045#endif /* MAC80211_H */
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 6114c4f54b0a..f56c8d695a82 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -100,6 +100,8 @@ typedef enum {
100 SCTP_CMD_T3_RTX_TIMERS_STOP, /* Stops T3-rtx pending timers */ 100 SCTP_CMD_T3_RTX_TIMERS_STOP, /* Stops T3-rtx pending timers */
101 SCTP_CMD_FORCE_PRIM_RETRAN, /* Forces retrans. over primary path. */ 101 SCTP_CMD_FORCE_PRIM_RETRAN, /* Forces retrans. over primary path. */
102 SCTP_CMD_SET_SK_ERR, /* Set sk_err */ 102 SCTP_CMD_SET_SK_ERR, /* Set sk_err */
103 SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */
104 SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */
103 SCTP_CMD_LAST 105 SCTP_CMD_LAST
104} sctp_verb_t; 106} sctp_verb_t;
105 107
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 28af68059521..dda72bf5b9b4 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -378,11 +378,15 @@ static inline int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int
378 378
379int sctp_v6_init(void); 379int sctp_v6_init(void);
380void sctp_v6_exit(void); 380void sctp_v6_exit(void);
381int sctp_v6_add_protocol(void);
382void sctp_v6_del_protocol(void);
381 383
382#else /* #ifdef defined(CONFIG_IPV6) */ 384#else /* #ifdef defined(CONFIG_IPV6) */
383 385
384static inline int sctp_v6_init(void) { return 0; } 386static inline int sctp_v6_init(void) { return 0; }
385static inline void sctp_v6_exit(void) { return; } 387static inline void sctp_v6_exit(void) { return; }
388static inline int sctp_v6_add_protocol(void) { return 0; }
389static inline void sctp_v6_del_protocol(void) { return; }
386 390
387#endif /* #if defined(CONFIG_IPV6) */ 391#endif /* #if defined(CONFIG_IPV6) */
388 392
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 7b4fff93ba7f..5e81984b8478 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1857,6 +1857,7 @@ int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *,
1857int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, 1857int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *,
1858 struct sctp_cookie*, 1858 struct sctp_cookie*,
1859 gfp_t gfp); 1859 gfp_t gfp);
1860int sctp_assoc_set_id(struct sctp_association *, gfp_t);
1860 1861
1861int sctp_cmp_addr_exact(const union sctp_addr *ss1, 1862int sctp_cmp_addr_exact(const union sctp_addr *ss1,
1862 const union sctp_addr *ss2); 1863 const union sctp_addr *ss2);
diff --git a/include/net/tcp.h b/include/net/tcp.h
index ef8f9d4dae85..e22b4f0305a3 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -736,7 +736,8 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk)
736 736
737static inline void tcp_sync_left_out(struct tcp_sock *tp) 737static inline void tcp_sync_left_out(struct tcp_sock *tp)
738{ 738{
739 BUG_ON(tp->sacked_out + tp->lost_out > tp->packets_out); 739 BUG_ON(tp->rx_opt.sack_ok &&
740 (tp->sacked_out + tp->lost_out > tp->packets_out));
740 tp->left_out = tp->sacked_out + tp->lost_out; 741 tp->left_out = tp->sacked_out + tp->lost_out;
741} 742}
742 743
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 66c2d3eec03c..39ef925d39dd 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -416,25 +416,6 @@ struct xfrm_audit
416 u32 secid; 416 u32 secid;
417}; 417};
418 418
419/* SAD metadata, add more later */
420struct xfrm_sadinfo
421{
422 u32 sadhcnt; /* current hash bkts */
423 u32 sadhmcnt; /* max allowed hash bkts */
424 u32 sadcnt; /* current running count */
425};
426
427struct xfrm_spdinfo
428{
429 u32 incnt;
430 u32 outcnt;
431 u32 fwdcnt;
432 u32 inscnt;
433 u32 outscnt;
434 u32 fwdscnt;
435 u32 spdhcnt;
436 u32 spdhmcnt;
437};
438#ifdef CONFIG_AUDITSYSCALL 419#ifdef CONFIG_AUDITSYSCALL
439extern void xfrm_audit_log(uid_t auid, u32 secid, int type, int result, 420extern void xfrm_audit_log(uid_t auid, u32 secid, int type, int result,
440 struct xfrm_policy *xp, struct xfrm_state *x); 421 struct xfrm_policy *xp, struct xfrm_state *x);
@@ -964,11 +945,29 @@ static inline int xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **s
964 return -ENOSYS; 945 return -ENOSYS;
965} 946}
966#endif 947#endif
948
949struct xfrmk_sadinfo {
950 u32 sadhcnt; /* current hash bkts */
951 u32 sadhmcnt; /* max allowed hash bkts */
952 u32 sadcnt; /* current running count */
953};
954
955struct xfrmk_spdinfo {
956 u32 incnt;
957 u32 outcnt;
958 u32 fwdcnt;
959 u32 inscnt;
960 u32 outscnt;
961 u32 fwdscnt;
962 u32 spdhcnt;
963 u32 spdhmcnt;
964};
965
967extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq); 966extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq);
968extern int xfrm_state_delete(struct xfrm_state *x); 967extern int xfrm_state_delete(struct xfrm_state *x);
969extern void xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info); 968extern void xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info);
970extern void xfrm_sad_getinfo(struct xfrm_sadinfo *si); 969extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si);
971extern void xfrm_spd_getinfo(struct xfrm_spdinfo *si); 970extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si);
972extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq); 971extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq);
973extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); 972extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
974extern void xfrm_replay_notify(struct xfrm_state *x, int event); 973extern void xfrm_replay_notify(struct xfrm_state *x, int event);
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 585d28e960dd..739fa4d0e539 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -39,8 +39,6 @@
39#if !defined( IB_MAD_H ) 39#if !defined( IB_MAD_H )
40#define IB_MAD_H 40#define IB_MAD_H
41 41
42#include <linux/pci.h>
43
44#include <rdma/ib_verbs.h> 42#include <rdma/ib_verbs.h>
45 43
46/* Management base version */ 44/* Management base version */
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index 4a44278ed768..8d1e4e8026fe 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -588,7 +588,17 @@ struct iscsi_reject {
588#define VALUE_MAXLEN 255 588#define VALUE_MAXLEN 255
589#define TARGET_NAME_MAXLEN VALUE_MAXLEN 589#define TARGET_NAME_MAXLEN VALUE_MAXLEN
590 590
591#define DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH 8192 591#define ISCSI_DEF_MAX_RECV_SEG_LEN 8192
592#define ISCSI_MIN_MAX_RECV_SEG_LEN 512
593#define ISCSI_MAX_MAX_RECV_SEG_LEN 16777215
594
595#define ISCSI_DEF_FIRST_BURST_LEN 65536
596#define ISCSI_MIN_FIRST_BURST_LEN 512
597#define ISCSI_MAX_FIRST_BURST_LEN 16777215
598
599#define ISCSI_DEF_MAX_BURST_LEN 262144
600#define ISCSI_MIN_MAX_BURST_LEN 512
601#define ISCSI_MAX_MAX_BURST_LEN 16777215
592 602
593/************************* RFC 3720 End *****************************/ 603/************************* RFC 3720 End *****************************/
594 604
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 5c0e9791441c..9f8f80ab0c8b 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -203,6 +203,7 @@ static inline int scsi_status_is_good(int status)
203 203
204/* 204/*
205 * DEVICE TYPES 205 * DEVICE TYPES
206 * Please keep them in 0x%02x format for $MODALIAS to work
206 */ 207 */
207 208
208#define TYPE_DISK 0x00 209#define TYPE_DISK 0x00
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index d6948d0e8cdb..a2e0c1032491 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -73,9 +73,6 @@ struct scsi_cmnd {
73 unsigned short use_sg; /* Number of pieces of scatter-gather */ 73 unsigned short use_sg; /* Number of pieces of scatter-gather */
74 unsigned short sglist_len; /* size of malloc'd scatter-gather list */ 74 unsigned short sglist_len; /* size of malloc'd scatter-gather list */
75 75
76 /* offset in cmd we are at (for multi-transfer tgt cmds) */
77 unsigned offset;
78
79 unsigned underflow; /* Return error if less than 76 unsigned underflow; /* Return error if less than
80 this amount is transferred */ 77 this amount is transferred */
81 78
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 3bbbfbe8cbfc..5a43a4cd96c6 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -5,14 +5,16 @@ struct scsi_cmnd;
5struct scsi_sense_hdr; 5struct scsi_sense_hdr;
6 6
7extern void scsi_print_command(struct scsi_cmnd *); 7extern void scsi_print_command(struct scsi_cmnd *);
8extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
9extern void __scsi_print_command(unsigned char *); 8extern void __scsi_print_command(unsigned char *);
10extern void scsi_print_sense(const char *, struct scsi_cmnd *); 9extern void scsi_show_extd_sense(unsigned char, unsigned char);
10extern void scsi_show_sense_hdr(struct scsi_sense_hdr *);
11extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
12extern void scsi_print_sense(char *, struct scsi_cmnd *);
11extern void __scsi_print_sense(const char *name, 13extern void __scsi_print_sense(const char *name,
12 const unsigned char *sense_buffer, 14 const unsigned char *sense_buffer,
13 int sense_len); 15 int sense_len);
14extern void scsi_print_driverbyte(int); 16extern void scsi_show_result(int);
15extern void scsi_print_hostbyte(int); 17extern void scsi_print_result(struct scsi_cmnd *);
16extern void scsi_print_status(unsigned char); 18extern void scsi_print_status(unsigned char);
17extern const char *scsi_sense_key_string(unsigned char); 19extern const char *scsi_sense_key_string(unsigned char);
18extern const char *scsi_extd_sense_format(unsigned char, unsigned char); 20extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 9dd37e2f5a84..2f3c5b8b1d6a 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -5,6 +5,7 @@
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/spinlock.h> 6#include <linux/spinlock.h>
7#include <linux/workqueue.h> 7#include <linux/workqueue.h>
8#include <linux/blkdev.h>
8#include <asm/atomic.h> 9#include <asm/atomic.h>
9 10
10struct request_queue; 11struct request_queue;
@@ -119,6 +120,7 @@ struct scsi_device {
119 unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ 120 unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
120 unsigned no_start_on_add:1; /* do not issue start on add */ 121 unsigned no_start_on_add:1; /* do not issue start on add */
121 unsigned allow_restart:1; /* issue START_UNIT in error handler */ 122 unsigned allow_restart:1; /* issue START_UNIT in error handler */
123 unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */
122 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ 124 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
123 unsigned select_no_atn:1; 125 unsigned select_no_atn:1;
124 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 126 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
@@ -154,8 +156,11 @@ struct scsi_device {
154#define sdev_printk(prefix, sdev, fmt, a...) \ 156#define sdev_printk(prefix, sdev, fmt, a...) \
155 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) 157 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)
156 158
157#define scmd_printk(prefix, scmd, fmt, a...) \ 159#define scmd_printk(prefix, scmd, fmt, a...) \
158 dev_printk(prefix, &(scmd)->device->sdev_gendev, fmt, ##a) 160 (scmd)->request->rq_disk ? \
161 sdev_printk(prefix, (scmd)->device, "[%s] " fmt, \
162 (scmd)->request->rq_disk->disk_name, ##a) : \
163 sdev_printk(prefix, (scmd)->device, fmt, ##a)
159 164
160enum scsi_target_state { 165enum scsi_target_state {
161 STARGET_RUNNING = 1, 166 STARGET_RUNNING = 1,
@@ -353,4 +358,9 @@ static inline int scsi_device_qas(struct scsi_device *sdev)
353 return 0; 358 return 0;
354 return sdev->inquiry[56] & 0x02; 359 return sdev->inquiry[56] & 0x02;
355} 360}
361
362#define MODULE_ALIAS_SCSI_DEVICE(type) \
363 MODULE_ALIAS("scsi:t-" __stringify(type) "*")
364#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
365
356#endif /* _SCSI_SCSI_DEVICE_H */ 366#endif /* _SCSI_SCSI_DEVICE_H */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 7f1f411d07af..68f461b7a835 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -129,6 +129,11 @@ struct scsi_host_template {
129 * the LLD. When the driver is finished processing the command 129 * the LLD. When the driver is finished processing the command
130 * the done callback is invoked. 130 * the done callback is invoked.
131 * 131 *
132 * This is called to inform the LLD to transfer
133 * cmd->request_bufflen bytes. The cmd->use_sg speciefies the
134 * number of scatterlist entried in the command and
135 * cmd->request_buffer contains the scatterlist.
136 *
132 * return values: see queuecommand 137 * return values: see queuecommand
133 * 138 *
134 * If the LLD accepts the cmd, it should set the result to an 139 * If the LLD accepts the cmd, it should set the result to an
@@ -139,20 +144,6 @@ struct scsi_host_template {
139 /* TODO: rename */ 144 /* TODO: rename */
140 int (* transfer_response)(struct scsi_cmnd *, 145 int (* transfer_response)(struct scsi_cmnd *,
141 void (*done)(struct scsi_cmnd *)); 146 void (*done)(struct scsi_cmnd *));
142 /*
143 * This is called to inform the LLD to transfer cmd->request_bufflen
144 * bytes of the cmd at cmd->offset in the cmd. The cmd->use_sg
145 * speciefies the number of scatterlist entried in the command
146 * and cmd->request_buffer contains the scatterlist.
147 *
148 * If the command cannot be processed in one transfer_data call
149 * becuase a scatterlist within the LLD's limits cannot be
150 * created then transfer_data will be called multiple times.
151 * It is initially called from process context, and later
152 * calls are from the interrup context.
153 */
154 int (* transfer_data)(struct scsi_cmnd *,
155 void (*done)(struct scsi_cmnd *));
156 147
157 /* Used as callback for the completion of task management request. */ 148 /* Used as callback for the completion of task management request. */
158 int (* tsk_mgmt_response)(u64 mid, int result); 149 int (* tsk_mgmt_response)(u64 mid, int result);
@@ -335,6 +326,19 @@ struct scsi_host_template {
335 int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int); 326 int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int);
336 327
337 /* 328 /*
329 * This is an optional routine that allows the transport to become
330 * involved when a scsi io timer fires. The return value tells the
331 * timer routine how to finish the io timeout handling:
332 * EH_HANDLED: I fixed the error, please complete the command
333 * EH_RESET_TIMER: I need more time, reset the timer and
334 * begin counting again
335 * EH_NOT_HANDLED Begin normal error recovery
336 *
337 * Status: OPTIONAL
338 */
339 enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *);
340
341 /*
338 * suspend support 342 * suspend support
339 */ 343 */
340 int (*resume)(struct scsi_device *); 344 int (*resume)(struct scsi_device *);
diff --git a/include/scsi/scsi_tgt_if.h b/include/scsi/scsi_tgt_if.h
index 07d6e77ae895..4cf9dff29a2f 100644
--- a/include/scsi/scsi_tgt_if.h
+++ b/include/scsi/scsi_tgt_if.h
@@ -45,11 +45,13 @@ struct tgt_event {
45 /* user-> kernel */ 45 /* user-> kernel */
46 struct { 46 struct {
47 int host_no; 47 int host_no;
48 uint32_t len;
49 int result; 48 int result;
49 aligned_u64 tag;
50 aligned_u64 uaddr; 50 aligned_u64 uaddr;
51 aligned_u64 sense_uaddr;
52 uint32_t len;
53 uint32_t sense_len;
51 uint8_t rw; 54 uint8_t rw;
52 aligned_u64 tag;
53 } cmd_rsp; 55 } cmd_rsp;
54 struct { 56 struct {
55 int host_no; 57 int host_no;
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 798f7c7ee426..1e797308640a 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -108,6 +108,8 @@ enum fc_port_state {
108#define FC_PORTSPEED_2GBIT 2 108#define FC_PORTSPEED_2GBIT 2
109#define FC_PORTSPEED_4GBIT 4 109#define FC_PORTSPEED_4GBIT 4
110#define FC_PORTSPEED_10GBIT 8 110#define FC_PORTSPEED_10GBIT 8
111#define FC_PORTSPEED_8GBIT 0x10
112#define FC_PORTSPEED_16GBIT 0x20
111#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ 113#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
112 114
113/* 115/*
diff --git a/include/scsi/sd.h b/include/scsi/sd.h
new file mode 100644
index 000000000000..5261488e1108
--- /dev/null
+++ b/include/scsi/sd.h
@@ -0,0 +1,72 @@
1#ifndef _SCSI_DISK_H
2#define _SCSI_DISK_H
3
4/*
5 * More than enough for everybody ;) The huge number of majors
6 * is a leftover from 16bit dev_t days, we don't really need that
7 * much numberspace.
8 */
9#define SD_MAJORS 16
10
11/*
12 * This is limited by the naming scheme enforced in sd_probe,
13 * add another character to it if you really need more disks.
14 */
15#define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26)
16
17/*
18 * Time out in seconds for disks and Magneto-opticals (which are slower).
19 */
20#define SD_TIMEOUT (30 * HZ)
21#define SD_MOD_TIMEOUT (75 * HZ)
22
23/*
24 * Number of allowed retries
25 */
26#define SD_MAX_RETRIES 5
27#define SD_PASSTHROUGH_RETRIES 1
28
29/*
30 * Size of the initial data buffer for mode and read capacity data
31 */
32#define SD_BUF_SIZE 512
33
34struct scsi_disk {
35 struct scsi_driver *driver; /* always &sd_template */
36 struct scsi_device *device;
37 struct class_device cdev;
38 struct gendisk *disk;
39 unsigned int openers; /* protected by BKL for now, yuck */
40 sector_t capacity; /* size in 512-byte sectors */
41 u32 index;
42 u8 media_present;
43 u8 write_prot;
44 unsigned WCE : 1; /* state of disk WCE bit */
45 unsigned RCD : 1; /* state of disk RCD bit, unused */
46 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
47};
48#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
49
50static int sd_revalidate_disk(struct gendisk *disk);
51static void sd_rw_intr(struct scsi_cmnd * SCpnt);
52static int sd_probe(struct device *);
53static int sd_remove(struct device *);
54static void sd_shutdown(struct device *dev);
55static int sd_suspend(struct device *dev, pm_message_t state);
56static int sd_resume(struct device *dev);
57static void sd_rescan(struct device *);
58static int sd_init_command(struct scsi_cmnd *);
59static int sd_issue_flush(struct device *, sector_t *);
60static void sd_prepare_flush(request_queue_t *, struct request *);
61static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
62static void scsi_disk_release(struct class_device *cdev);
63static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
64static void sd_print_result(struct scsi_disk *, int);
65
66#define sd_printk(prefix, sdsk, fmt, a...) \
67 (sdsk)->disk ? \
68 sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \
69 (sdsk)->disk->disk_name, ##a) : \
70 sdev_printk(prefix, (sdsk)->device, fmt, ##a)
71
72#endif /* _SCSI_DISK_H */
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 0133f4f9e9f0..615ce97c6cfd 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/msi.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/kernel_stat.h> 17#include <linux/kernel_stat.h>
@@ -185,6 +186,8 @@ int set_irq_msi(unsigned int irq, struct msi_desc *entry)
185 desc = irq_desc + irq; 186 desc = irq_desc + irq;
186 spin_lock_irqsave(&desc->lock, flags); 187 spin_lock_irqsave(&desc->lock, flags);
187 desc->msi_desc = entry; 188 desc->msi_desc = entry;
189 if (entry)
190 entry->irq = irq;
188 spin_unlock_irqrestore(&desc->lock, flags); 191 spin_unlock_irqrestore(&desc->lock, flags);
189 return 0; 192 return 0;
190} 193}
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index e0ffe4ab0917..559deca5ed15 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -24,18 +24,18 @@ static struct subsys_attribute _name##_attr = \
24 24
25#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 25#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
26/* current uevent sequence number */ 26/* current uevent sequence number */
27static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page) 27static ssize_t uevent_seqnum_show(struct kset *kset, char *page)
28{ 28{
29 return sprintf(page, "%llu\n", (unsigned long long)uevent_seqnum); 29 return sprintf(page, "%llu\n", (unsigned long long)uevent_seqnum);
30} 30}
31KERNEL_ATTR_RO(uevent_seqnum); 31KERNEL_ATTR_RO(uevent_seqnum);
32 32
33/* uevent helper program, used during early boo */ 33/* uevent helper program, used during early boo */
34static ssize_t uevent_helper_show(struct subsystem *subsys, char *page) 34static ssize_t uevent_helper_show(struct kset *kset, char *page)
35{ 35{
36 return sprintf(page, "%s\n", uevent_helper); 36 return sprintf(page, "%s\n", uevent_helper);
37} 37}
38static ssize_t uevent_helper_store(struct subsystem *subsys, const char *page, size_t count) 38static ssize_t uevent_helper_store(struct kset *kset, const char *page, size_t count)
39{ 39{
40 if (count+1 > UEVENT_HELPER_PATH_LEN) 40 if (count+1 > UEVENT_HELPER_PATH_LEN)
41 return -ENOENT; 41 return -ENOENT;
@@ -49,13 +49,13 @@ KERNEL_ATTR_RW(uevent_helper);
49#endif 49#endif
50 50
51#ifdef CONFIG_KEXEC 51#ifdef CONFIG_KEXEC
52static ssize_t kexec_loaded_show(struct subsystem *subsys, char *page) 52static ssize_t kexec_loaded_show(struct kset *kset, char *page)
53{ 53{
54 return sprintf(page, "%d\n", !!kexec_image); 54 return sprintf(page, "%d\n", !!kexec_image);
55} 55}
56KERNEL_ATTR_RO(kexec_loaded); 56KERNEL_ATTR_RO(kexec_loaded);
57 57
58static ssize_t kexec_crash_loaded_show(struct subsystem *subsys, char *page) 58static ssize_t kexec_crash_loaded_show(struct kset *kset, char *page)
59{ 59{
60 return sprintf(page, "%d\n", !!kexec_crash_image); 60 return sprintf(page, "%d\n", !!kexec_crash_image);
61} 61}
@@ -85,7 +85,7 @@ static int __init ksysfs_init(void)
85{ 85{
86 int error = subsystem_register(&kernel_subsys); 86 int error = subsystem_register(&kernel_subsys);
87 if (!error) 87 if (!error)
88 error = sysfs_create_group(&kernel_subsys.kset.kobj, 88 error = sysfs_create_group(&kernel_subsys.kobj,
89 &kernel_attr_group); 89 &kernel_attr_group);
90 90
91 return error; 91 return error;
diff --git a/kernel/module.c b/kernel/module.c
index 4dc4a257545c..1eb8ca565ba0 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -45,6 +45,8 @@
45#include <asm/cacheflush.h> 45#include <asm/cacheflush.h>
46#include <linux/license.h> 46#include <linux/license.h>
47 47
48extern int module_sysfs_initialized;
49
48#if 0 50#if 0
49#define DEBUGP printk 51#define DEBUGP printk
50#else 52#else
@@ -1117,8 +1119,8 @@ int mod_sysfs_init(struct module *mod)
1117{ 1119{
1118 int err; 1120 int err;
1119 1121
1120 if (!module_subsys.kset.subsys) { 1122 if (!module_sysfs_initialized) {
1121 printk(KERN_ERR "%s: module_subsys not initialized\n", 1123 printk(KERN_ERR "%s: module sysfs not initialized\n",
1122 mod->name); 1124 mod->name);
1123 err = -EINVAL; 1125 err = -EINVAL;
1124 goto out; 1126 goto out;
@@ -2385,7 +2387,7 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
2385 struct kobject *mkobj; 2387 struct kobject *mkobj;
2386 2388
2387 /* Lookup built-in module entry in /sys/modules */ 2389 /* Lookup built-in module entry in /sys/modules */
2388 mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name); 2390 mkobj = kset_find_obj(&module_subsys, drv->mod_name);
2389 if (mkobj) { 2391 if (mkobj) {
2390 mk = container_of(mkobj, struct module_kobject, kobj); 2392 mk = container_of(mkobj, struct module_kobject, kobj);
2391 /* remember our module structure */ 2393 /* remember our module structure */
diff --git a/kernel/params.c b/kernel/params.c
index 1fc4ac746cd8..312172320b4c 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -691,6 +691,7 @@ static struct kset_uevent_ops module_uevent_ops = {
691}; 691};
692 692
693decl_subsys(module, &module_ktype, &module_uevent_ops); 693decl_subsys(module, &module_ktype, &module_uevent_ops);
694int module_sysfs_initialized;
694 695
695static struct kobj_type module_ktype = { 696static struct kobj_type module_ktype = {
696 .sysfs_ops = &module_sysfs_ops, 697 .sysfs_ops = &module_sysfs_ops,
@@ -709,6 +710,7 @@ static int __init param_sysfs_init(void)
709 __FILE__, __LINE__, ret); 710 __FILE__, __LINE__, ret);
710 return ret; 711 return ret;
711 } 712 }
713 module_sysfs_initialized = 1;
712 714
713 param_sysfs_builtin(); 715 param_sysfs_builtin();
714 716
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 02e4fb69111a..8df51c23bba4 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -322,13 +322,13 @@ static const char * const pm_disk_modes[] = {
322 * supports it (as determined from pm_ops->pm_disk_mode). 322 * supports it (as determined from pm_ops->pm_disk_mode).
323 */ 323 */
324 324
325static ssize_t disk_show(struct subsystem * subsys, char * buf) 325static ssize_t disk_show(struct kset *kset, char *buf)
326{ 326{
327 return sprintf(buf, "%s\n", pm_disk_modes[pm_disk_mode]); 327 return sprintf(buf, "%s\n", pm_disk_modes[pm_disk_mode]);
328} 328}
329 329
330 330
331static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n) 331static ssize_t disk_store(struct kset *kset, const char *buf, size_t n)
332{ 332{
333 int error = 0; 333 int error = 0;
334 int i; 334 int i;
@@ -373,13 +373,13 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
373 373
374power_attr(disk); 374power_attr(disk);
375 375
376static ssize_t resume_show(struct subsystem * subsys, char *buf) 376static ssize_t resume_show(struct kset *kset, char *buf)
377{ 377{
378 return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device), 378 return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device),
379 MINOR(swsusp_resume_device)); 379 MINOR(swsusp_resume_device));
380} 380}
381 381
382static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n) 382static ssize_t resume_store(struct kset *kset, const char *buf, size_t n)
383{ 383{
384 unsigned int maj, min; 384 unsigned int maj, min;
385 dev_t res; 385 dev_t res;
@@ -405,12 +405,12 @@ static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n)
405 405
406power_attr(resume); 406power_attr(resume);
407 407
408static ssize_t image_size_show(struct subsystem * subsys, char *buf) 408static ssize_t image_size_show(struct kset *kset, char *buf)
409{ 409{
410 return sprintf(buf, "%lu\n", image_size); 410 return sprintf(buf, "%lu\n", image_size);
411} 411}
412 412
413static ssize_t image_size_store(struct subsystem * subsys, const char * buf, size_t n) 413static ssize_t image_size_store(struct kset *kset, const char *buf, size_t n)
414{ 414{
415 unsigned long size; 415 unsigned long size;
416 416
@@ -439,7 +439,7 @@ static struct attribute_group attr_group = {
439 439
440static int __init pm_disk_init(void) 440static int __init pm_disk_init(void)
441{ 441{
442 return sysfs_create_group(&power_subsys.kset.kobj,&attr_group); 442 return sysfs_create_group(&power_subsys.kobj, &attr_group);
443} 443}
444 444
445core_initcall(pm_disk_init); 445core_initcall(pm_disk_init);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 72419a3b1beb..b21c2a56f960 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -285,7 +285,7 @@ decl_subsys(power,NULL,NULL);
285 * proper enumerated value, and initiates a suspend transition. 285 * proper enumerated value, and initiates a suspend transition.
286 */ 286 */
287 287
288static ssize_t state_show(struct subsystem * subsys, char * buf) 288static ssize_t state_show(struct kset *kset, char *buf)
289{ 289{
290 int i; 290 int i;
291 char * s = buf; 291 char * s = buf;
@@ -298,7 +298,7 @@ static ssize_t state_show(struct subsystem * subsys, char * buf)
298 return (s - buf); 298 return (s - buf);
299} 299}
300 300
301static ssize_t state_store(struct subsystem * subsys, const char * buf, size_t n) 301static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
302{ 302{
303 suspend_state_t state = PM_SUSPEND_STANDBY; 303 suspend_state_t state = PM_SUSPEND_STANDBY;
304 const char * const *s; 304 const char * const *s;
@@ -325,13 +325,13 @@ power_attr(state);
325#ifdef CONFIG_PM_TRACE 325#ifdef CONFIG_PM_TRACE
326int pm_trace_enabled; 326int pm_trace_enabled;
327 327
328static ssize_t pm_trace_show(struct subsystem * subsys, char * buf) 328static ssize_t pm_trace_show(struct kset *kset, char *buf)
329{ 329{
330 return sprintf(buf, "%d\n", pm_trace_enabled); 330 return sprintf(buf, "%d\n", pm_trace_enabled);
331} 331}
332 332
333static ssize_t 333static ssize_t
334pm_trace_store(struct subsystem * subsys, const char * buf, size_t n) 334pm_trace_store(struct kset *kset, const char *buf, size_t n)
335{ 335{
336 int val; 336 int val;
337 337
@@ -365,7 +365,7 @@ static int __init pm_init(void)
365{ 365{
366 int error = subsystem_register(&power_subsys); 366 int error = subsystem_register(&power_subsys);
367 if (!error) 367 if (!error)
368 error = sysfs_create_group(&power_subsys.kset.kobj,&attr_group); 368 error = sysfs_create_group(&power_subsys.kobj,&attr_group);
369 return error; 369 return error;
370} 370}
371 371
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 1c6eef8df4ad..33bd94ceba32 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -37,7 +37,7 @@ static struct subsys_attribute _name##_attr = { \
37 .store = _name##_store, \ 37 .store = _name##_store, \
38} 38}
39 39
40extern struct subsystem power_subsys; 40extern struct kset power_subsys;
41 41
42/* Preferred image size in bytes (default 500 MB) */ 42/* Preferred image size in bytes (default 500 MB) */
43extern unsigned long image_size; 43extern unsigned long image_size;
diff --git a/lib/iomap.c b/lib/iomap.c
index 4d43f37c0154..a57d262a5ed9 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -35,20 +35,28 @@
35#define PIO_RESERVED 0x40000UL 35#define PIO_RESERVED 0x40000UL
36#endif 36#endif
37 37
38static void bad_io_access(unsigned long port, const char *access)
39{
40 static int count = 10;
41 if (count) {
42 count--;
43 printk(KERN_ERR "Bad IO access at port %lx (%s)\n", port, access);
44 WARN_ON(1);
45 }
46}
47
38/* 48/*
39 * Ugly macros are a way of life. 49 * Ugly macros are a way of life.
40 */ 50 */
41#define VERIFY_PIO(port) BUG_ON((port & ~PIO_MASK) != PIO_OFFSET)
42
43#define IO_COND(addr, is_pio, is_mmio) do { \ 51#define IO_COND(addr, is_pio, is_mmio) do { \
44 unsigned long port = (unsigned long __force)addr; \ 52 unsigned long port = (unsigned long __force)addr; \
45 if (port < PIO_RESERVED) { \ 53 if (port >= PIO_RESERVED) { \
46 VERIFY_PIO(port); \ 54 is_mmio; \
55 } else if (port > PIO_OFFSET) { \
47 port &= PIO_MASK; \ 56 port &= PIO_MASK; \
48 is_pio; \ 57 is_pio; \
49 } else { \ 58 } else \
50 is_mmio; \ 59 bad_io_access(port, #is_pio ); \
51 } \
52} while (0) 60} while (0)
53 61
54#ifndef pio_read16be 62#ifndef pio_read16be
@@ -64,22 +72,27 @@
64unsigned int fastcall ioread8(void __iomem *addr) 72unsigned int fastcall ioread8(void __iomem *addr)
65{ 73{
66 IO_COND(addr, return inb(port), return readb(addr)); 74 IO_COND(addr, return inb(port), return readb(addr));
75 return 0xff;
67} 76}
68unsigned int fastcall ioread16(void __iomem *addr) 77unsigned int fastcall ioread16(void __iomem *addr)
69{ 78{
70 IO_COND(addr, return inw(port), return readw(addr)); 79 IO_COND(addr, return inw(port), return readw(addr));
80 return 0xffff;
71} 81}
72unsigned int fastcall ioread16be(void __iomem *addr) 82unsigned int fastcall ioread16be(void __iomem *addr)
73{ 83{
74 IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr)); 84 IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr));
85 return 0xffff;
75} 86}
76unsigned int fastcall ioread32(void __iomem *addr) 87unsigned int fastcall ioread32(void __iomem *addr)
77{ 88{
78 IO_COND(addr, return inl(port), return readl(addr)); 89 IO_COND(addr, return inl(port), return readl(addr));
90 return 0xffffffff;
79} 91}
80unsigned int fastcall ioread32be(void __iomem *addr) 92unsigned int fastcall ioread32be(void __iomem *addr)
81{ 93{
82 IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr)); 94 IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr));
95 return 0xffffffff;
83} 96}
84EXPORT_SYMBOL(ioread8); 97EXPORT_SYMBOL(ioread8);
85EXPORT_SYMBOL(ioread16); 98EXPORT_SYMBOL(ioread16);
diff --git a/lib/kobject.c b/lib/kobject.c
index cecf2fbede3e..fc5f3f6e7329 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -582,22 +582,10 @@ void kset_init(struct kset * k)
582/** 582/**
583 * kset_add - add a kset object to the hierarchy. 583 * kset_add - add a kset object to the hierarchy.
584 * @k: kset. 584 * @k: kset.
585 *
586 * Simply, this adds the kset's embedded kobject to the
587 * hierarchy.
588 * We also try to make sure that the kset's embedded kobject
589 * has a parent before it is added. We only care if the embedded
590 * kobject is not part of a kset itself, since kobject_add()
591 * assigns a parent in that case.
592 * If that is the case, and the kset has a controlling subsystem,
593 * then we set the kset's parent to be said subsystem.
594 */ 585 */
595 586
596int kset_add(struct kset * k) 587int kset_add(struct kset * k)
597{ 588{
598 if (!k->kobj.parent && !k->kobj.kset && k->subsys)
599 k->kobj.parent = &k->subsys->kset.kobj;
600
601 return kobject_add(&k->kobj); 589 return kobject_add(&k->kobj);
602} 590}
603 591
@@ -656,53 +644,28 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name)
656 return ret; 644 return ret;
657} 645}
658 646
659 647void subsystem_init(struct kset *s)
660void subsystem_init(struct subsystem * s)
661{ 648{
662 kset_init(&s->kset); 649 kset_init(s);
663} 650}
664 651
665/** 652int subsystem_register(struct kset *s)
666 * subsystem_register - register a subsystem.
667 * @s: the subsystem we're registering.
668 *
669 * Once we register the subsystem, we want to make sure that
670 * the kset points back to this subsystem.
671 */
672
673int subsystem_register(struct subsystem * s)
674{ 653{
675 int error; 654 return kset_register(s);
676
677 if (!s)
678 return -EINVAL;
679
680 subsystem_init(s);
681 pr_debug("subsystem %s: registering\n",s->kset.kobj.name);
682
683 if (!(error = kset_add(&s->kset))) {
684 if (!s->kset.subsys)
685 s->kset.subsys = s;
686 }
687 return error;
688} 655}
689 656
690void subsystem_unregister(struct subsystem * s) 657void subsystem_unregister(struct kset *s)
691{ 658{
692 if (!s) 659 kset_unregister(s);
693 return;
694 pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name);
695 kset_unregister(&s->kset);
696} 660}
697 661
698
699/** 662/**
700 * subsystem_create_file - export sysfs attribute file. 663 * subsystem_create_file - export sysfs attribute file.
701 * @s: subsystem. 664 * @s: subsystem.
702 * @a: subsystem attribute descriptor. 665 * @a: subsystem attribute descriptor.
703 */ 666 */
704 667
705int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) 668int subsys_create_file(struct kset *s, struct subsys_attribute *a)
706{ 669{
707 int error = 0; 670 int error = 0;
708 671
@@ -710,28 +673,12 @@ int subsys_create_file(struct subsystem * s, struct subsys_attribute * a)
710 return -EINVAL; 673 return -EINVAL;
711 674
712 if (subsys_get(s)) { 675 if (subsys_get(s)) {
713 error = sysfs_create_file(&s->kset.kobj,&a->attr); 676 error = sysfs_create_file(&s->kobj, &a->attr);
714 subsys_put(s); 677 subsys_put(s);
715 } 678 }
716 return error; 679 return error;
717} 680}
718 681
719
720/**
721 * subsystem_remove_file - remove sysfs attribute file.
722 * @s: subsystem.
723 * @a: attribute desciptor.
724 */
725#if 0
726void subsys_remove_file(struct subsystem * s, struct subsys_attribute * a)
727{
728 if (subsys_get(s)) {
729 sysfs_remove_file(&s->kset.kobj,&a->attr);
730 subsys_put(s);
731 }
732}
733#endif /* 0 */
734
735EXPORT_SYMBOL(kobject_init); 682EXPORT_SYMBOL(kobject_init);
736EXPORT_SYMBOL(kobject_register); 683EXPORT_SYMBOL(kobject_register);
737EXPORT_SYMBOL(kobject_unregister); 684EXPORT_SYMBOL(kobject_unregister);
diff --git a/lib/parser.c b/lib/parser.c
index 7ad2a48abc5e..703c8c13b346 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -22,7 +22,7 @@
22 * match extremely simple token=arg style patterns. If the pattern is found, 22 * match extremely simple token=arg style patterns. If the pattern is found,
23 * the location(s) of the arguments will be returned in the @args array. 23 * the location(s) of the arguments will be returned in the @args array.
24 */ 24 */
25static int match_one(char *s, char *p, substring_t args[]) 25static int match_one(char *s, const char *p, substring_t args[])
26{ 26{
27 char *meta; 27 char *meta;
28 int argc = 0; 28 int argc = 0;
@@ -43,7 +43,7 @@ static int match_one(char *s, char *p, substring_t args[])
43 p = meta + 1; 43 p = meta + 1;
44 44
45 if (isdigit(*p)) 45 if (isdigit(*p))
46 len = simple_strtoul(p, &p, 10); 46 len = simple_strtoul(p, (char **) &p, 10);
47 else if (*p == '%') { 47 else if (*p == '%') {
48 if (*s++ != '%') 48 if (*s++ != '%')
49 return 0; 49 return 0;
@@ -102,7 +102,7 @@ static int match_one(char *s, char *p, substring_t args[])
102 */ 102 */
103int match_token(char *s, match_table_t table, substring_t args[]) 103int match_token(char *s, match_table_t table, substring_t args[])
104{ 104{
105 struct match_token *p; 105 const struct match_token *p;
106 106
107 for (p = table; !match_one(s, p->pattern, args) ; p++) 107 for (p = table; !match_one(s, p->pattern, args) ; p++)
108 ; 108 ;
@@ -190,7 +190,7 @@ int match_hex(substring_t *s, int *result)
190 * &substring_t @s to the c-style string @to. Caller guarantees that @to is 190 * &substring_t @s to the c-style string @to. Caller guarantees that @to is
191 * large enough to hold the characters of @s. 191 * large enough to hold the characters of @s.
192 */ 192 */
193void match_strcpy(char *to, substring_t *s) 193void match_strcpy(char *to, const substring_t *s)
194{ 194{
195 memcpy(to, s->from, s->to - s->from); 195 memcpy(to, s->from, s->to - s->from);
196 to[s->to - s->from] = '\0'; 196 to[s->to - s->from] = '\0';
@@ -204,7 +204,7 @@ void match_strcpy(char *to, substring_t *s)
204 * the &substring_t @s. The caller is responsible for freeing the returned 204 * the &substring_t @s. The caller is responsible for freeing the returned
205 * string with kfree(). 205 * string with kfree().
206 */ 206 */
207char *match_strdup(substring_t *s) 207char *match_strdup(const substring_t *s)
208{ 208{
209 char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL); 209 char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL);
210 if (p) 210 if (p)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index c0c7bb8e9f07..bd93c45778d4 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -117,8 +117,7 @@ static void __exit vlan_cleanup_devices(void)
117 struct net_device *dev, *nxt; 117 struct net_device *dev, *nxt;
118 118
119 rtnl_lock(); 119 rtnl_lock();
120 for (dev = dev_base; dev; dev = nxt) { 120 for_each_netdev_safe(dev, nxt) {
121 nxt = dev->next;
122 if (dev->priv_flags & IFF_802_1Q_VLAN) { 121 if (dev->priv_flags & IFF_802_1Q_VLAN) {
123 unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev, 122 unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
124 VLAN_DEV_INFO(dev)->vlan_id); 123 VLAN_DEV_INFO(dev)->vlan_id);
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 5e24f72602a1..d216a64421cd 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -237,13 +237,9 @@ int vlan_proc_rem_dev(struct net_device *vlandev)
237 * The following few functions build the content of /proc/net/vlan/config 237 * The following few functions build the content of /proc/net/vlan/config
238 */ 238 */
239 239
240/* starting at dev, find a VLAN device */ 240static inline int is_vlan_dev(struct net_device *dev)
241static struct net_device *vlan_skip(struct net_device *dev)
242{ 241{
243 while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN)) 242 return dev->priv_flags & IFF_802_1Q_VLAN;
244 dev = dev->next;
245
246 return dev;
247} 243}
248 244
249/* start read of /proc/net/vlan/config */ 245/* start read of /proc/net/vlan/config */
@@ -257,19 +253,35 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
257 if (*pos == 0) 253 if (*pos == 0)
258 return SEQ_START_TOKEN; 254 return SEQ_START_TOKEN;
259 255
260 for (dev = vlan_skip(dev_base); dev && i < *pos; 256 for_each_netdev(dev) {
261 dev = vlan_skip(dev->next), ++i); 257 if (!is_vlan_dev(dev))
258 continue;
259
260 if (i++ == *pos)
261 return dev;
262 }
262 263
263 return (i == *pos) ? dev : NULL; 264 return NULL;
264} 265}
265 266
266static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos) 267static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
267{ 268{
269 struct net_device *dev;
270
268 ++*pos; 271 ++*pos;
269 272
270 return vlan_skip((v == SEQ_START_TOKEN) 273 dev = (struct net_device *)v;
271 ? dev_base 274 if (v == SEQ_START_TOKEN)
272 : ((struct net_device *)v)->next); 275 dev = net_device_entry(&dev_base_head);
276
277 for_each_netdev_continue(dev) {
278 if (!is_vlan_dev(dev))
279 continue;
280
281 return dev;
282 }
283
284 return NULL;
273} 285}
274 286
275static void vlan_seq_stop(struct seq_file *seq, void *v) 287static void vlan_seq_stop(struct seq_file *seq, void *v)
diff --git a/net/Kconfig b/net/Kconfig
index 2fc8e77b1e62..5b2227813923 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -220,6 +220,7 @@ config FIB_RULES
220menu "Wireless" 220menu "Wireless"
221 221
222source "net/wireless/Kconfig" 222source "net/wireless/Kconfig"
223source "net/mac80211/Kconfig"
223source "net/ieee80211/Kconfig" 224source "net/ieee80211/Kconfig"
224 225
225endmenu 226endmenu
diff --git a/net/Makefile b/net/Makefile
index 6b74d4118c5b..9fdb60c2e4a1 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -45,6 +45,8 @@ obj-$(CONFIG_ECONET) += econet/
45obj-$(CONFIG_VLAN_8021Q) += 8021q/ 45obj-$(CONFIG_VLAN_8021Q) += 8021q/
46obj-$(CONFIG_IP_DCCP) += dccp/ 46obj-$(CONFIG_IP_DCCP) += dccp/
47obj-$(CONFIG_IP_SCTP) += sctp/ 47obj-$(CONFIG_IP_SCTP) += sctp/
48obj-y += wireless/
49obj-$(CONFIG_MAC80211) += mac80211/
48obj-$(CONFIG_IEEE80211) += ieee80211/ 50obj-$(CONFIG_IEEE80211) += ieee80211/
49obj-$(CONFIG_TIPC) += tipc/ 51obj-$(CONFIG_TIPC) += tipc/
50obj-$(CONFIG_NETLABEL) += netlabel/ 52obj-$(CONFIG_NETLABEL) += netlabel/
@@ -53,5 +55,3 @@ obj-$(CONFIG_IUCV) += iucv/
53ifeq ($(CONFIG_NET),y) 55ifeq ($(CONFIG_NET),y)
54obj-$(CONFIG_SYSCTL) += sysctl_net.o 56obj-$(CONFIG_SYSCTL) += sysctl_net.o
55endif 57endif
56
57obj-y += wireless/
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 690573bbf012..849deaf14108 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -475,11 +475,9 @@ void __exit br_cleanup_bridges(void)
475 struct net_device *dev, *nxt; 475 struct net_device *dev, *nxt;
476 476
477 rtnl_lock(); 477 rtnl_lock();
478 for (dev = dev_base; dev; dev = nxt) { 478 for_each_netdev_safe(dev, nxt)
479 nxt = dev->next;
480 if (dev->priv_flags & IFF_EBRIDGE) 479 if (dev->priv_flags & IFF_EBRIDGE)
481 del_br(dev->priv); 480 del_br(dev->priv);
482 }
483 rtnl_unlock(); 481 rtnl_unlock();
484 482
485} 483}
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index eda0fbfc923a..bb15e9e259b1 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -27,7 +27,9 @@ static int get_bridge_ifindices(int *indices, int num)
27 struct net_device *dev; 27 struct net_device *dev;
28 int i = 0; 28 int i = 0;
29 29
30 for (dev = dev_base; dev && i < num; dev = dev->next) { 30 for_each_netdev(dev) {
31 if (i >= num)
32 break;
31 if (dev->priv_flags & IFF_EBRIDGE) 33 if (dev->priv_flags & IFF_EBRIDGE)
32 indices[i++] = dev->ifindex; 34 indices[i++] = dev->ifindex;
33 } 35 }
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 9b2986b182ba..fa779874b9dd 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -142,14 +142,33 @@ static inline struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
142 return skb->nf_bridge; 142 return skb->nf_bridge;
143} 143}
144 144
145static inline void nf_bridge_save_header(struct sk_buff *skb) 145static inline void nf_bridge_push_encap_header(struct sk_buff *skb)
146{
147 unsigned int len = nf_bridge_encap_header_len(skb);
148
149 skb_push(skb, len);
150 skb->network_header -= len;
151}
152
153static inline void nf_bridge_pull_encap_header(struct sk_buff *skb)
146{ 154{
147 int header_size = ETH_HLEN; 155 unsigned int len = nf_bridge_encap_header_len(skb);
156
157 skb_pull(skb, len);
158 skb->network_header += len;
159}
148 160
149 if (skb->protocol == htons(ETH_P_8021Q)) 161static inline void nf_bridge_pull_encap_header_rcsum(struct sk_buff *skb)
150 header_size += VLAN_HLEN; 162{
151 else if (skb->protocol == htons(ETH_P_PPP_SES)) 163 unsigned int len = nf_bridge_encap_header_len(skb);
152 header_size += PPPOE_SES_HLEN; 164
165 skb_pull_rcsum(skb, len);
166 skb->network_header += len;
167}
168
169static inline void nf_bridge_save_header(struct sk_buff *skb)
170{
171 int header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);
153 172
154 skb_copy_from_linear_data_offset(skb, -header_size, 173 skb_copy_from_linear_data_offset(skb, -header_size,
155 skb->nf_bridge->data, header_size); 174 skb->nf_bridge->data, header_size);
@@ -162,12 +181,7 @@ static inline void nf_bridge_save_header(struct sk_buff *skb)
162int nf_bridge_copy_header(struct sk_buff *skb) 181int nf_bridge_copy_header(struct sk_buff *skb)
163{ 182{
164 int err; 183 int err;
165 int header_size = ETH_HLEN; 184 int header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);
166
167 if (skb->protocol == htons(ETH_P_8021Q))
168 header_size += VLAN_HLEN;
169 else if (skb->protocol == htons(ETH_P_PPP_SES))
170 header_size += PPPOE_SES_HLEN;
171 185
172 err = skb_cow(skb, header_size); 186 err = skb_cow(skb, header_size);
173 if (err) 187 if (err)
@@ -175,11 +189,7 @@ int nf_bridge_copy_header(struct sk_buff *skb)
175 189
176 skb_copy_to_linear_data_offset(skb, -header_size, 190 skb_copy_to_linear_data_offset(skb, -header_size,
177 skb->nf_bridge->data, header_size); 191 skb->nf_bridge->data, header_size);
178 192 __skb_push(skb, nf_bridge_encap_header_len(skb));
179 if (skb->protocol == htons(ETH_P_8021Q))
180 __skb_push(skb, VLAN_HLEN);
181 else if (skb->protocol == htons(ETH_P_PPP_SES))
182 __skb_push(skb, PPPOE_SES_HLEN);
183 return 0; 193 return 0;
184} 194}
185 195
@@ -200,13 +210,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
200 dst_hold(skb->dst); 210 dst_hold(skb->dst);
201 211
202 skb->dev = nf_bridge->physindev; 212 skb->dev = nf_bridge->physindev;
203 if (skb->protocol == htons(ETH_P_8021Q)) { 213 nf_bridge_push_encap_header(skb);
204 skb_push(skb, VLAN_HLEN);
205 skb->network_header -= VLAN_HLEN;
206 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
207 skb_push(skb, PPPOE_SES_HLEN);
208 skb->network_header -= PPPOE_SES_HLEN;
209 }
210 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, 214 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
211 br_handle_frame_finish, 1); 215 br_handle_frame_finish, 1);
212 216
@@ -284,13 +288,7 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
284 if (!skb->dev) 288 if (!skb->dev)
285 kfree_skb(skb); 289 kfree_skb(skb);
286 else { 290 else {
287 if (skb->protocol == htons(ETH_P_8021Q)) { 291 nf_bridge_pull_encap_header(skb);
288 skb_pull(skb, VLAN_HLEN);
289 skb->network_header += VLAN_HLEN;
290 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
291 skb_pull(skb, PPPOE_SES_HLEN);
292 skb->network_header += PPPOE_SES_HLEN;
293 }
294 skb->dst->output(skb); 292 skb->dst->output(skb);
295 } 293 }
296 return 0; 294 return 0;
@@ -356,15 +354,7 @@ bridged_dnat:
356 * bridged frame */ 354 * bridged frame */
357 nf_bridge->mask |= BRNF_BRIDGED_DNAT; 355 nf_bridge->mask |= BRNF_BRIDGED_DNAT;
358 skb->dev = nf_bridge->physindev; 356 skb->dev = nf_bridge->physindev;
359 if (skb->protocol == 357 nf_bridge_push_encap_header(skb);
360 htons(ETH_P_8021Q)) {
361 skb_push(skb, VLAN_HLEN);
362 skb->network_header -= VLAN_HLEN;
363 } else if(skb->protocol ==
364 htons(ETH_P_PPP_SES)) {
365 skb_push(skb, PPPOE_SES_HLEN);
366 skb->network_header -= PPPOE_SES_HLEN;
367 }
368 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, 358 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING,
369 skb, skb->dev, NULL, 359 skb, skb->dev, NULL,
370 br_nf_pre_routing_finish_bridge, 360 br_nf_pre_routing_finish_bridge,
@@ -380,13 +370,7 @@ bridged_dnat:
380 } 370 }
381 371
382 skb->dev = nf_bridge->physindev; 372 skb->dev = nf_bridge->physindev;
383 if (skb->protocol == htons(ETH_P_8021Q)) { 373 nf_bridge_push_encap_header(skb);
384 skb_push(skb, VLAN_HLEN);
385 skb->network_header -= VLAN_HLEN;
386 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
387 skb_push(skb, PPPOE_SES_HLEN);
388 skb->network_header -= PPPOE_SES_HLEN;
389 }
390 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, 374 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
391 br_handle_frame_finish, 1); 375 br_handle_frame_finish, 1);
392 376
@@ -536,14 +520,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
536#endif 520#endif
537 if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL) 521 if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL)
538 goto out; 522 goto out;
539 523 nf_bridge_pull_encap_header_rcsum(skb);
540 if (skb->protocol == htons(ETH_P_8021Q)) {
541 skb_pull_rcsum(skb, VLAN_HLEN);
542 skb->network_header += VLAN_HLEN;
543 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
544 skb_pull_rcsum(skb, PPPOE_SES_HLEN);
545 skb->network_header += PPPOE_SES_HLEN;
546 }
547 return br_nf_pre_routing_ipv6(hook, skb, in, out, okfn); 524 return br_nf_pre_routing_ipv6(hook, skb, in, out, okfn);
548 } 525 }
549#ifdef CONFIG_SYSCTL 526#ifdef CONFIG_SYSCTL
@@ -557,14 +534,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
557 534
558 if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL) 535 if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL)
559 goto out; 536 goto out;
560 537 nf_bridge_pull_encap_header_rcsum(skb);
561 if (skb->protocol == htons(ETH_P_8021Q)) {
562 skb_pull_rcsum(skb, VLAN_HLEN);
563 skb->network_header += VLAN_HLEN;
564 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
565 skb_pull_rcsum(skb, PPPOE_SES_HLEN);
566 skb->network_header += PPPOE_SES_HLEN;
567 }
568 538
569 if (!pskb_may_pull(skb, sizeof(struct iphdr))) 539 if (!pskb_may_pull(skb, sizeof(struct iphdr)))
570 goto inhdr_error; 540 goto inhdr_error;
@@ -642,13 +612,7 @@ static int br_nf_forward_finish(struct sk_buff *skb)
642 } else { 612 } else {
643 in = *((struct net_device **)(skb->cb)); 613 in = *((struct net_device **)(skb->cb));
644 } 614 }
645 if (skb->protocol == htons(ETH_P_8021Q)) { 615 nf_bridge_push_encap_header(skb);
646 skb_push(skb, VLAN_HLEN);
647 skb->network_header -= VLAN_HLEN;
648 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
649 skb_push(skb, PPPOE_SES_HLEN);
650 skb->network_header -= PPPOE_SES_HLEN;
651 }
652 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_FORWARD, skb, in, 616 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_FORWARD, skb, in,
653 skb->dev, br_forward_finish, 1); 617 skb->dev, br_forward_finish, 1);
654 return 0; 618 return 0;
@@ -682,13 +646,7 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff **pskb,
682 else 646 else
683 pf = PF_INET6; 647 pf = PF_INET6;
684 648
685 if (skb->protocol == htons(ETH_P_8021Q)) { 649 nf_bridge_pull_encap_header(*pskb);
686 skb_pull(*pskb, VLAN_HLEN);
687 (*pskb)->network_header += VLAN_HLEN;
688 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
689 skb_pull(*pskb, PPPOE_SES_HLEN);
690 (*pskb)->network_header += PPPOE_SES_HLEN;
691 }
692 650
693 nf_bridge = skb->nf_bridge; 651 nf_bridge = skb->nf_bridge;
694 if (skb->pkt_type == PACKET_OTHERHOST) { 652 if (skb->pkt_type == PACKET_OTHERHOST) {
@@ -722,15 +680,12 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb,
722 if (skb->protocol != htons(ETH_P_ARP)) { 680 if (skb->protocol != htons(ETH_P_ARP)) {
723 if (!IS_VLAN_ARP(skb)) 681 if (!IS_VLAN_ARP(skb))
724 return NF_ACCEPT; 682 return NF_ACCEPT;
725 skb_pull(*pskb, VLAN_HLEN); 683 nf_bridge_pull_encap_header(*pskb);
726 (*pskb)->network_header += VLAN_HLEN;
727 } 684 }
728 685
729 if (arp_hdr(skb)->ar_pln != 4) { 686 if (arp_hdr(skb)->ar_pln != 4) {
730 if (IS_VLAN_ARP(skb)) { 687 if (IS_VLAN_ARP(skb))
731 skb_push(*pskb, VLAN_HLEN); 688 nf_bridge_push_encap_header(*pskb);
732 (*pskb)->network_header -= VLAN_HLEN;
733 }
734 return NF_ACCEPT; 689 return NF_ACCEPT;
735 } 690 }
736 *d = (struct net_device *)in; 691 *d = (struct net_device *)in;
@@ -777,13 +732,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb,
777 skb->pkt_type = PACKET_OTHERHOST; 732 skb->pkt_type = PACKET_OTHERHOST;
778 nf_bridge->mask ^= BRNF_PKT_TYPE; 733 nf_bridge->mask ^= BRNF_PKT_TYPE;
779 } 734 }
780 if (skb->protocol == htons(ETH_P_8021Q)) { 735 nf_bridge_push_encap_header(skb);
781 skb_push(skb, VLAN_HLEN);
782 skb->network_header -= VLAN_HLEN;
783 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
784 skb_push(skb, PPPOE_SES_HLEN);
785 skb->network_header -= PPPOE_SES_HLEN;
786 }
787 736
788 NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, realindev, skb->dev, 737 NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, realindev, skb->dev,
789 br_forward_finish); 738 br_forward_finish);
@@ -848,14 +797,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,
848 nf_bridge->mask |= BRNF_PKT_TYPE; 797 nf_bridge->mask |= BRNF_PKT_TYPE;
849 } 798 }
850 799
851 if (skb->protocol == htons(ETH_P_8021Q)) { 800 nf_bridge_pull_encap_header(skb);
852 skb_pull(skb, VLAN_HLEN);
853 skb->network_header += VLAN_HLEN;
854 } else if (skb->protocol == htons(ETH_P_PPP_SES)) {
855 skb_pull(skb, PPPOE_SES_HLEN);
856 skb->network_header += PPPOE_SES_HLEN;
857 }
858
859 nf_bridge_save_header(skb); 801 nf_bridge_save_header(skb);
860 802
861#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 803#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 35facc0c11c2..0fcf6f073064 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -109,7 +109,8 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
109 struct net_device *dev; 109 struct net_device *dev;
110 int idx; 110 int idx;
111 111
112 for (dev = dev_base, idx = 0; dev; dev = dev->next) { 112 idx = 0;
113 for_each_netdev(dev) {
113 /* not a bridge port */ 114 /* not a bridge port */
114 if (dev->br_port == NULL || idx < cb->args[0]) 115 if (dev->br_port == NULL || idx < cb->args[0])
115 goto skip; 116 goto skip;
diff --git a/net/core/dev.c b/net/core/dev.c
index eb999003bbb7..f27d4ab181e6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -156,13 +156,13 @@ static spinlock_t net_dma_event_lock;
156#endif 156#endif
157 157
158/* 158/*
159 * The @dev_base list is protected by @dev_base_lock and the rtnl 159 * The @dev_base_head list is protected by @dev_base_lock and the rtnl
160 * semaphore. 160 * semaphore.
161 * 161 *
162 * Pure readers hold dev_base_lock for reading. 162 * Pure readers hold dev_base_lock for reading.
163 * 163 *
164 * Writers must hold the rtnl semaphore while they loop through the 164 * Writers must hold the rtnl semaphore while they loop through the
165 * dev_base list, and hold dev_base_lock for writing when they do the 165 * dev_base_head list, and hold dev_base_lock for writing when they do the
166 * actual updates. This allows pure readers to access the list even 166 * actual updates. This allows pure readers to access the list even
167 * while a writer is preparing to update it. 167 * while a writer is preparing to update it.
168 * 168 *
@@ -174,11 +174,10 @@ static spinlock_t net_dma_event_lock;
174 * unregister_netdevice(), which must be called with the rtnl 174 * unregister_netdevice(), which must be called with the rtnl
175 * semaphore held. 175 * semaphore held.
176 */ 176 */
177struct net_device *dev_base; 177LIST_HEAD(dev_base_head);
178static struct net_device **dev_tail = &dev_base;
179DEFINE_RWLOCK(dev_base_lock); 178DEFINE_RWLOCK(dev_base_lock);
180 179
181EXPORT_SYMBOL(dev_base); 180EXPORT_SYMBOL(dev_base_head);
182EXPORT_SYMBOL(dev_base_lock); 181EXPORT_SYMBOL(dev_base_lock);
183 182
184#define NETDEV_HASHBITS 8 183#define NETDEV_HASHBITS 8
@@ -567,26 +566,38 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)
567 566
568 ASSERT_RTNL(); 567 ASSERT_RTNL();
569 568
570 for (dev = dev_base; dev; dev = dev->next) 569 for_each_netdev(dev)
571 if (dev->type == type && 570 if (dev->type == type &&
572 !memcmp(dev->dev_addr, ha, dev->addr_len)) 571 !memcmp(dev->dev_addr, ha, dev->addr_len))
573 break; 572 return dev;
574 return dev; 573
574 return NULL;
575} 575}
576 576
577EXPORT_SYMBOL(dev_getbyhwaddr); 577EXPORT_SYMBOL(dev_getbyhwaddr);
578 578
579struct net_device *__dev_getfirstbyhwtype(unsigned short type)
580{
581 struct net_device *dev;
582
583 ASSERT_RTNL();
584 for_each_netdev(dev)
585 if (dev->type == type)
586 return dev;
587
588 return NULL;
589}
590
591EXPORT_SYMBOL(__dev_getfirstbyhwtype);
592
579struct net_device *dev_getfirstbyhwtype(unsigned short type) 593struct net_device *dev_getfirstbyhwtype(unsigned short type)
580{ 594{
581 struct net_device *dev; 595 struct net_device *dev;
582 596
583 rtnl_lock(); 597 rtnl_lock();
584 for (dev = dev_base; dev; dev = dev->next) { 598 dev = __dev_getfirstbyhwtype(type);
585 if (dev->type == type) { 599 if (dev)
586 dev_hold(dev); 600 dev_hold(dev);
587 break;
588 }
589 }
590 rtnl_unlock(); 601 rtnl_unlock();
591 return dev; 602 return dev;
592} 603}
@@ -606,17 +617,19 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype);
606 617
607struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mask) 618struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mask)
608{ 619{
609 struct net_device *dev; 620 struct net_device *dev, *ret;
610 621
622 ret = NULL;
611 read_lock(&dev_base_lock); 623 read_lock(&dev_base_lock);
612 for (dev = dev_base; dev != NULL; dev = dev->next) { 624 for_each_netdev(dev) {
613 if (((dev->flags ^ if_flags) & mask) == 0) { 625 if (((dev->flags ^ if_flags) & mask) == 0) {
614 dev_hold(dev); 626 dev_hold(dev);
627 ret = dev;
615 break; 628 break;
616 } 629 }
617 } 630 }
618 read_unlock(&dev_base_lock); 631 read_unlock(&dev_base_lock);
619 return dev; 632 return ret;
620} 633}
621 634
622/** 635/**
@@ -682,7 +695,7 @@ int dev_alloc_name(struct net_device *dev, const char *name)
682 if (!inuse) 695 if (!inuse)
683 return -ENOMEM; 696 return -ENOMEM;
684 697
685 for (d = dev_base; d; d = d->next) { 698 for_each_netdev(d) {
686 if (!sscanf(d->name, name, &i)) 699 if (!sscanf(d->name, name, &i))
687 continue; 700 continue;
688 if (i < 0 || i >= max_netdevices) 701 if (i < 0 || i >= max_netdevices)
@@ -964,7 +977,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
964 rtnl_lock(); 977 rtnl_lock();
965 err = raw_notifier_chain_register(&netdev_chain, nb); 978 err = raw_notifier_chain_register(&netdev_chain, nb);
966 if (!err) { 979 if (!err) {
967 for (dev = dev_base; dev; dev = dev->next) { 980 for_each_netdev(dev) {
968 nb->notifier_call(nb, NETDEV_REGISTER, dev); 981 nb->notifier_call(nb, NETDEV_REGISTER, dev);
969 982
970 if (dev->flags & IFF_UP) 983 if (dev->flags & IFF_UP)
@@ -2038,7 +2051,7 @@ static int dev_ifconf(char __user *arg)
2038 */ 2051 */
2039 2052
2040 total = 0; 2053 total = 0;
2041 for (dev = dev_base; dev; dev = dev->next) { 2054 for_each_netdev(dev) {
2042 for (i = 0; i < NPROTO; i++) { 2055 for (i = 0; i < NPROTO; i++) {
2043 if (gifconf_list[i]) { 2056 if (gifconf_list[i]) {
2044 int done; 2057 int done;
@@ -2070,26 +2083,28 @@ static int dev_ifconf(char __user *arg)
2070 * This is invoked by the /proc filesystem handler to display a device 2083 * This is invoked by the /proc filesystem handler to display a device
2071 * in detail. 2084 * in detail.
2072 */ 2085 */
2073static struct net_device *dev_get_idx(loff_t pos) 2086void *dev_seq_start(struct seq_file *seq, loff_t *pos)
2074{ 2087{
2088 loff_t off;
2075 struct net_device *dev; 2089 struct net_device *dev;
2076 loff_t i;
2077 2090
2078 for (i = 0, dev = dev_base; dev && i < pos; ++i, dev = dev->next); 2091 read_lock(&dev_base_lock);
2092 if (!*pos)
2093 return SEQ_START_TOKEN;
2079 2094
2080 return i == pos ? dev : NULL; 2095 off = 1;
2081} 2096 for_each_netdev(dev)
2097 if (off++ == *pos)
2098 return dev;
2082 2099
2083void *dev_seq_start(struct seq_file *seq, loff_t *pos) 2100 return NULL;
2084{
2085 read_lock(&dev_base_lock);
2086 return *pos ? dev_get_idx(*pos - 1) : SEQ_START_TOKEN;
2087} 2101}
2088 2102
2089void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2103void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2090{ 2104{
2091 ++*pos; 2105 ++*pos;
2092 return v == SEQ_START_TOKEN ? dev_base : ((struct net_device *)v)->next; 2106 return v == SEQ_START_TOKEN ?
2107 first_net_device() : next_net_device((struct net_device *)v);
2093} 2108}
2094 2109
2095void dev_seq_stop(struct seq_file *seq, void *v) 2110void dev_seq_stop(struct seq_file *seq, void *v)
@@ -3071,11 +3086,9 @@ int register_netdevice(struct net_device *dev)
3071 3086
3072 set_bit(__LINK_STATE_PRESENT, &dev->state); 3087 set_bit(__LINK_STATE_PRESENT, &dev->state);
3073 3088
3074 dev->next = NULL;
3075 dev_init_scheduler(dev); 3089 dev_init_scheduler(dev);
3076 write_lock_bh(&dev_base_lock); 3090 write_lock_bh(&dev_base_lock);
3077 *dev_tail = dev; 3091 list_add_tail(&dev->dev_list, &dev_base_head);
3078 dev_tail = &dev->next;
3079 hlist_add_head(&dev->name_hlist, head); 3092 hlist_add_head(&dev->name_hlist, head);
3080 hlist_add_head(&dev->index_hlist, dev_index_hash(dev->ifindex)); 3093 hlist_add_head(&dev->index_hlist, dev_index_hash(dev->ifindex));
3081 dev_hold(dev); 3094 dev_hold(dev);
@@ -3349,8 +3362,6 @@ void synchronize_net(void)
3349 3362
3350void unregister_netdevice(struct net_device *dev) 3363void unregister_netdevice(struct net_device *dev)
3351{ 3364{
3352 struct net_device *d, **dp;
3353
3354 BUG_ON(dev_boot_phase); 3365 BUG_ON(dev_boot_phase);
3355 ASSERT_RTNL(); 3366 ASSERT_RTNL();
3356 3367
@@ -3370,19 +3381,11 @@ void unregister_netdevice(struct net_device *dev)
3370 dev_close(dev); 3381 dev_close(dev);
3371 3382
3372 /* And unlink it from device chain. */ 3383 /* And unlink it from device chain. */
3373 for (dp = &dev_base; (d = *dp) != NULL; dp = &d->next) { 3384 write_lock_bh(&dev_base_lock);
3374 if (d == dev) { 3385 list_del(&dev->dev_list);
3375 write_lock_bh(&dev_base_lock); 3386 hlist_del(&dev->name_hlist);
3376 hlist_del(&dev->name_hlist); 3387 hlist_del(&dev->index_hlist);
3377 hlist_del(&dev->index_hlist); 3388 write_unlock_bh(&dev_base_lock);
3378 if (dev_tail == &dev->next)
3379 dev_tail = dp;
3380 *dp = d->next;
3381 write_unlock_bh(&dev_base_lock);
3382 break;
3383 }
3384 }
3385 BUG_ON(!d);
3386 3389
3387 dev->reg_state = NETREG_UNREGISTERING; 3390 dev->reg_state = NETREG_UNREGISTERING;
3388 3391
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
index 7d57bf77f3a3..5a54053386c8 100644
--- a/net/core/dev_mcast.c
+++ b/net/core/dev_mcast.c
@@ -223,7 +223,7 @@ static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
223 loff_t off = 0; 223 loff_t off = 0;
224 224
225 read_lock(&dev_base_lock); 225 read_lock(&dev_base_lock);
226 for (dev = dev_base; dev; dev = dev->next) { 226 for_each_netdev(dev) {
227 if (off++ == *pos) 227 if (off++ == *pos)
228 return dev; 228 return dev;
229 } 229 }
@@ -232,9 +232,8 @@ static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
232 232
233static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos) 233static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
234{ 234{
235 struct net_device *dev = v;
236 ++*pos; 235 ++*pos;
237 return dev->next; 236 return next_net_device((struct net_device *)v);
238} 237}
239 238
240static void dev_mc_seq_stop(struct seq_file *seq, void *v) 239static void dev_mc_seq_stop(struct seq_file *seq, void *v)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index cec111109155..8c971a2efe2a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -539,13 +539,16 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
539 int s_idx = cb->args[0]; 539 int s_idx = cb->args[0];
540 struct net_device *dev; 540 struct net_device *dev;
541 541
542 for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) { 542 idx = 0;
543 for_each_netdev(dev) {
543 if (idx < s_idx) 544 if (idx < s_idx)
544 continue; 545 goto cont;
545 if (rtnl_fill_ifinfo(skb, dev, NULL, 0, RTM_NEWLINK, 546 if (rtnl_fill_ifinfo(skb, dev, NULL, 0, RTM_NEWLINK,
546 NETLINK_CB(cb->skb).pid, 547 NETLINK_CB(cb->skb).pid,
547 cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0) 548 cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0)
548 break; 549 break;
550cont:
551 idx++;
549 } 552 }
550 cb->args[0] = idx; 553 cb->args[0] = idx;
551 554
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index a205eaa87f52..9fbe87c93802 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -721,7 +721,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
721 struct sock *sk = sock->sk; 721 struct sock *sk = sock->sk;
722 struct dn_scp *scp = DN_SK(sk); 722 struct dn_scp *scp = DN_SK(sk);
723 struct sockaddr_dn *saddr = (struct sockaddr_dn *)uaddr; 723 struct sockaddr_dn *saddr = (struct sockaddr_dn *)uaddr;
724 struct net_device *dev; 724 struct net_device *dev, *ldev;
725 int rv; 725 int rv;
726 726
727 if (addr_len != sizeof(struct sockaddr_dn)) 727 if (addr_len != sizeof(struct sockaddr_dn))
@@ -746,14 +746,17 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
746 if (!(saddr->sdn_flags & SDF_WILD)) { 746 if (!(saddr->sdn_flags & SDF_WILD)) {
747 if (dn_ntohs(saddr->sdn_nodeaddrl)) { 747 if (dn_ntohs(saddr->sdn_nodeaddrl)) {
748 read_lock(&dev_base_lock); 748 read_lock(&dev_base_lock);
749 for(dev = dev_base; dev; dev = dev->next) { 749 ldev = NULL;
750 for_each_netdev(dev) {
750 if (!dev->dn_ptr) 751 if (!dev->dn_ptr)
751 continue; 752 continue;
752 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) 753 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) {
754 ldev = dev;
753 break; 755 break;
756 }
754 } 757 }
755 read_unlock(&dev_base_lock); 758 read_unlock(&dev_base_lock);
756 if (dev == NULL) 759 if (ldev == NULL)
757 return -EADDRNOTAVAIL; 760 return -EADDRNOTAVAIL;
758 } 761 }
759 } 762 }
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 5c2a9951b638..764a56a13e38 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -799,9 +799,10 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
799 skip_ndevs = cb->args[0]; 799 skip_ndevs = cb->args[0];
800 skip_naddr = cb->args[1]; 800 skip_naddr = cb->args[1];
801 801
802 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 802 idx = 0;
803 for_each_netdev(dev) {
803 if (idx < skip_ndevs) 804 if (idx < skip_ndevs)
804 continue; 805 goto cont;
805 else if (idx > skip_ndevs) { 806 else if (idx > skip_ndevs) {
806 /* Only skip over addresses for first dev dumped 807 /* Only skip over addresses for first dev dumped
807 * in this iteration (idx == skip_ndevs) */ 808 * in this iteration (idx == skip_ndevs) */
@@ -809,18 +810,20 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
809 } 810 }
810 811
811 if ((dn_db = dev->dn_ptr) == NULL) 812 if ((dn_db = dev->dn_ptr) == NULL)
812 continue; 813 goto cont;
813 814
814 for (ifa = dn_db->ifa_list, dn_idx = 0; ifa; 815 for (ifa = dn_db->ifa_list, dn_idx = 0; ifa;
815 ifa = ifa->ifa_next, dn_idx++) { 816 ifa = ifa->ifa_next, dn_idx++) {
816 if (dn_idx < skip_naddr) 817 if (dn_idx < skip_naddr)
817 continue; 818 goto cont;
818 819
819 if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, 820 if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
820 cb->nlh->nlmsg_seq, RTM_NEWADDR, 821 cb->nlh->nlmsg_seq, RTM_NEWADDR,
821 NLM_F_MULTI) < 0) 822 NLM_F_MULTI) < 0)
822 goto done; 823 goto done;
823 } 824 }
825cont:
826 idx++;
824 } 827 }
825done: 828done:
826 cb->args[0] = idx; 829 cb->args[0] = idx;
@@ -1296,7 +1299,7 @@ void dn_dev_devices_off(void)
1296 struct net_device *dev; 1299 struct net_device *dev;
1297 1300
1298 rtnl_lock(); 1301 rtnl_lock();
1299 for(dev = dev_base; dev; dev = dev->next) 1302 for_each_netdev(dev)
1300 dn_dev_down(dev); 1303 dn_dev_down(dev);
1301 rtnl_unlock(); 1304 rtnl_unlock();
1302 1305
@@ -1307,7 +1310,7 @@ void dn_dev_devices_on(void)
1307 struct net_device *dev; 1310 struct net_device *dev;
1308 1311
1309 rtnl_lock(); 1312 rtnl_lock();
1310 for(dev = dev_base; dev; dev = dev->next) { 1313 for_each_netdev(dev) {
1311 if (dev->flags & IFF_UP) 1314 if (dev->flags & IFF_UP)
1312 dn_dev_up(dev); 1315 dn_dev_up(dev);
1313 } 1316 }
@@ -1325,62 +1328,56 @@ int unregister_dnaddr_notifier(struct notifier_block *nb)
1325} 1328}
1326 1329
1327#ifdef CONFIG_PROC_FS 1330#ifdef CONFIG_PROC_FS
1328static inline struct net_device *dn_dev_get_next(struct seq_file *seq, struct net_device *dev) 1331static inline int is_dn_dev(struct net_device *dev)
1329{ 1332{
1330 do { 1333 return dev->dn_ptr != NULL;
1331 dev = dev->next;
1332 } while(dev && !dev->dn_ptr);
1333
1334 return dev;
1335} 1334}
1336 1335
1337static struct net_device *dn_dev_get_idx(struct seq_file *seq, loff_t pos) 1336static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
1338{ 1337{
1338 int i;
1339 struct net_device *dev; 1339 struct net_device *dev;
1340 1340
1341 dev = dev_base; 1341 read_lock(&dev_base_lock);
1342 if (dev && !dev->dn_ptr)
1343 dev = dn_dev_get_next(seq, dev);
1344 if (pos) {
1345 while(dev && (dev = dn_dev_get_next(seq, dev)))
1346 --pos;
1347 }
1348 return dev;
1349}
1350 1342
1351static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos) 1343 if (*pos == 0)
1352{ 1344 return SEQ_START_TOKEN;
1353 if (*pos) { 1345
1354 struct net_device *dev; 1346 i = 1;
1355 read_lock(&dev_base_lock); 1347 for_each_netdev(dev) {
1356 dev = dn_dev_get_idx(seq, *pos - 1); 1348 if (!is_dn_dev(dev))
1357 if (dev == NULL) 1349 continue;
1358 read_unlock(&dev_base_lock); 1350
1359 return dev; 1351 if (i++ == *pos)
1352 return dev;
1360 } 1353 }
1361 return SEQ_START_TOKEN; 1354
1355 return NULL;
1362} 1356}
1363 1357
1364static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1358static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1365{ 1359{
1366 struct net_device *dev = v; 1360 struct net_device *dev;
1367 loff_t one = 1;
1368 1361
1369 if (v == SEQ_START_TOKEN) {
1370 dev = dn_dev_seq_start(seq, &one);
1371 } else {
1372 dev = dn_dev_get_next(seq, dev);
1373 if (dev == NULL)
1374 read_unlock(&dev_base_lock);
1375 }
1376 ++*pos; 1362 ++*pos;
1377 return dev; 1363
1364 dev = (struct net_device *)v;
1365 if (v == SEQ_START_TOKEN)
1366 dev = net_device_entry(&dev_base_head);
1367
1368 for_each_netdev_continue(dev) {
1369 if (!is_dn_dev(dev))
1370 continue;
1371
1372 return dev;
1373 }
1374
1375 return NULL;
1378} 1376}
1379 1377
1380static void dn_dev_seq_stop(struct seq_file *seq, void *v) 1378static void dn_dev_seq_stop(struct seq_file *seq, void *v)
1381{ 1379{
1382 if (v && v != SEQ_START_TOKEN) 1380 read_unlock(&dev_base_lock);
1383 read_unlock(&dev_base_lock);
1384} 1381}
1385 1382
1386static char *dn_type2asc(char type) 1383static char *dn_type2asc(char type)
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index 310a86268d2b..d2bc19d47950 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -602,7 +602,7 @@ static void dn_fib_del_ifaddr(struct dn_ifaddr *ifa)
602 602
603 /* Scan device list */ 603 /* Scan device list */
604 read_lock(&dev_base_lock); 604 read_lock(&dev_base_lock);
605 for(dev = dev_base; dev; dev = dev->next) { 605 for_each_netdev(dev) {
606 dn_db = dev->dn_ptr; 606 dn_db = dev->dn_ptr;
607 if (dn_db == NULL) 607 if (dn_db == NULL)
608 continue; 608 continue;
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 5d7337bcf0fe..a8bf106b7a61 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -886,7 +886,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
886 .iif = loopback_dev.ifindex, 886 .iif = loopback_dev.ifindex,
887 .oif = oldflp->oif }; 887 .oif = oldflp->oif };
888 struct dn_route *rt = NULL; 888 struct dn_route *rt = NULL;
889 struct net_device *dev_out = NULL; 889 struct net_device *dev_out = NULL, *dev;
890 struct neighbour *neigh = NULL; 890 struct neighbour *neigh = NULL;
891 unsigned hash; 891 unsigned hash;
892 unsigned flags = 0; 892 unsigned flags = 0;
@@ -925,15 +925,17 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
925 goto out; 925 goto out;
926 } 926 }
927 read_lock(&dev_base_lock); 927 read_lock(&dev_base_lock);
928 for(dev_out = dev_base; dev_out; dev_out = dev_out->next) { 928 for_each_netdev(dev) {
929 if (!dev_out->dn_ptr) 929 if (!dev->dn_ptr)
930 continue; 930 continue;
931 if (!dn_dev_islocal(dev_out, oldflp->fld_src)) 931 if (!dn_dev_islocal(dev, oldflp->fld_src))
932 continue; 932 continue;
933 if ((dev_out->flags & IFF_LOOPBACK) && 933 if ((dev->flags & IFF_LOOPBACK) &&
934 oldflp->fld_dst && 934 oldflp->fld_dst &&
935 !dn_dev_islocal(dev_out, oldflp->fld_dst)) 935 !dn_dev_islocal(dev, oldflp->fld_dst))
936 continue; 936 continue;
937
938 dev_out = dev;
937 break; 939 break;
938 } 940 }
939 read_unlock(&dev_base_lock); 941 read_unlock(&dev_base_lock);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 088888db8b3d..7f95e6e9beeb 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -910,7 +910,7 @@ no_in_dev:
910 */ 910 */
911 read_lock(&dev_base_lock); 911 read_lock(&dev_base_lock);
912 rcu_read_lock(); 912 rcu_read_lock();
913 for (dev = dev_base; dev; dev = dev->next) { 913 for_each_netdev(dev) {
914 if ((in_dev = __in_dev_get_rcu(dev)) == NULL) 914 if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
915 continue; 915 continue;
916 916
@@ -989,7 +989,7 @@ __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local,
989 989
990 read_lock(&dev_base_lock); 990 read_lock(&dev_base_lock);
991 rcu_read_lock(); 991 rcu_read_lock();
992 for (dev = dev_base; dev; dev = dev->next) { 992 for_each_netdev(dev) {
993 if ((in_dev = __in_dev_get_rcu(dev))) { 993 if ((in_dev = __in_dev_get_rcu(dev))) {
994 addr = confirm_addr_indev(in_dev, dst, local, scope); 994 addr = confirm_addr_indev(in_dev, dst, local, scope);
995 if (addr) 995 if (addr)
@@ -1182,23 +1182,26 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
1182 int s_ip_idx, s_idx = cb->args[0]; 1182 int s_ip_idx, s_idx = cb->args[0];
1183 1183
1184 s_ip_idx = ip_idx = cb->args[1]; 1184 s_ip_idx = ip_idx = cb->args[1];
1185 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 1185 idx = 0;
1186 for_each_netdev(dev) {
1186 if (idx < s_idx) 1187 if (idx < s_idx)
1187 continue; 1188 goto cont;
1188 if (idx > s_idx) 1189 if (idx > s_idx)
1189 s_ip_idx = 0; 1190 s_ip_idx = 0;
1190 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) 1191 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
1191 continue; 1192 goto cont;
1192 1193
1193 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa; 1194 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
1194 ifa = ifa->ifa_next, ip_idx++) { 1195 ifa = ifa->ifa_next, ip_idx++) {
1195 if (ip_idx < s_ip_idx) 1196 if (ip_idx < s_ip_idx)
1196 continue; 1197 goto cont;
1197 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, 1198 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
1198 cb->nlh->nlmsg_seq, 1199 cb->nlh->nlmsg_seq,
1199 RTM_NEWADDR, NLM_F_MULTI) <= 0) 1200 RTM_NEWADDR, NLM_F_MULTI) <= 0)
1200 goto done; 1201 goto done;
1201 } 1202 }
1203cont:
1204 idx++;
1202 } 1205 }
1203 1206
1204done: 1207done:
@@ -1243,7 +1246,7 @@ void inet_forward_change(void)
1243 ipv4_devconf_dflt.forwarding = on; 1246 ipv4_devconf_dflt.forwarding = on;
1244 1247
1245 read_lock(&dev_base_lock); 1248 read_lock(&dev_base_lock);
1246 for (dev = dev_base; dev; dev = dev->next) { 1249 for_each_netdev(dev) {
1247 struct in_device *in_dev; 1250 struct in_device *in_dev;
1248 rcu_read_lock(); 1251 rcu_read_lock();
1249 in_dev = __in_dev_get_rcu(dev); 1252 in_dev = __in_dev_get_rcu(dev);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 2506021c2935..f4dd47453108 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2288,9 +2288,8 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
2288 struct ip_mc_list *im = NULL; 2288 struct ip_mc_list *im = NULL;
2289 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq); 2289 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
2290 2290
2291 for (state->dev = dev_base, state->in_dev = NULL; 2291 state->in_dev = NULL;
2292 state->dev; 2292 for_each_netdev(state->dev) {
2293 state->dev = state->dev->next) {
2294 struct in_device *in_dev; 2293 struct in_device *in_dev;
2295 in_dev = in_dev_get(state->dev); 2294 in_dev = in_dev_get(state->dev);
2296 if (!in_dev) 2295 if (!in_dev)
@@ -2316,7 +2315,7 @@ static struct ip_mc_list *igmp_mc_get_next(struct seq_file *seq, struct ip_mc_li
2316 read_unlock(&state->in_dev->mc_list_lock); 2315 read_unlock(&state->in_dev->mc_list_lock);
2317 in_dev_put(state->in_dev); 2316 in_dev_put(state->in_dev);
2318 } 2317 }
2319 state->dev = state->dev->next; 2318 state->dev = next_net_device(state->dev);
2320 if (!state->dev) { 2319 if (!state->dev) {
2321 state->in_dev = NULL; 2320 state->in_dev = NULL;
2322 break; 2321 break;
@@ -2450,9 +2449,9 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
2450 struct ip_mc_list *im = NULL; 2449 struct ip_mc_list *im = NULL;
2451 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq); 2450 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
2452 2451
2453 for (state->dev = dev_base, state->idev = NULL, state->im = NULL; 2452 state->idev = NULL;
2454 state->dev; 2453 state->im = NULL;
2455 state->dev = state->dev->next) { 2454 for_each_netdev(state->dev) {
2456 struct in_device *idev; 2455 struct in_device *idev;
2457 idev = in_dev_get(state->dev); 2456 idev = in_dev_get(state->dev);
2458 if (unlikely(idev == NULL)) 2457 if (unlikely(idev == NULL))
@@ -2488,7 +2487,7 @@ static struct ip_sf_list *igmp_mcf_get_next(struct seq_file *seq, struct ip_sf_l
2488 read_unlock(&state->idev->mc_list_lock); 2487 read_unlock(&state->idev->mc_list_lock);
2489 in_dev_put(state->idev); 2488 in_dev_put(state->idev);
2490 } 2489 }
2491 state->dev = state->dev->next; 2490 state->dev = next_net_device(state->dev);
2492 if (!state->dev) { 2491 if (!state->dev) {
2493 state->idev = NULL; 2492 state->idev = NULL;
2494 goto out; 2493 goto out;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 597c800b2fdc..342ca8d89458 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -192,7 +192,7 @@ static int __init ic_open_devs(void)
192 if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0) 192 if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
193 printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name); 193 printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name);
194 194
195 for (dev = dev_base; dev; dev = dev->next) { 195 for_each_netdev(dev) {
196 if (dev == &loopback_dev) 196 if (dev == &loopback_dev)
197 continue; 197 continue;
198 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : 198 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
diff --git a/net/ipv4/netfilter/nf_nat_proto_gre.c b/net/ipv4/netfilter/nf_nat_proto_gre.c
index e5a34c17d927..c3908bc5a709 100644
--- a/net/ipv4/netfilter/nf_nat_proto_gre.c
+++ b/net/ipv4/netfilter/nf_nat_proto_gre.c
@@ -72,6 +72,11 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
72 __be16 *keyptr; 72 __be16 *keyptr;
73 unsigned int min, i, range_size; 73 unsigned int min, i, range_size;
74 74
75 /* If there is no master conntrack we are not PPTP,
76 do not change tuples */
77 if (!conntrack->master)
78 return 0;
79
75 if (maniptype == IP_NAT_MANIP_SRC) 80 if (maniptype == IP_NAT_MANIP_SRC)
76 keyptr = &tuple->src.u.gre.key; 81 keyptr = &tuple->src.u.gre.key;
77 else 82 else
@@ -122,18 +127,9 @@ gre_manip_pkt(struct sk_buff **pskb, unsigned int iphdroff,
122 if (maniptype != IP_NAT_MANIP_DST) 127 if (maniptype != IP_NAT_MANIP_DST)
123 return 1; 128 return 1;
124 switch (greh->version) { 129 switch (greh->version) {
125 case 0: 130 case GRE_VERSION_1701:
126 if (!greh->key) { 131 /* We do not currently NAT any GREv0 packets.
127 DEBUGP("can't nat GRE w/o key\n"); 132 * Try to behave like "nf_nat_proto_unknown" */
128 break;
129 }
130 if (greh->csum) {
131 /* FIXME: Never tested this code... */
132 nf_proto_csum_replace4(gre_csum(greh), *pskb,
133 *(gre_key(greh)),
134 tuple->dst.u.gre.key, 0);
135 }
136 *(gre_key(greh)) = tuple->dst.u.gre.key;
137 break; 133 break;
138 case GRE_VERSION_PPTP: 134 case GRE_VERSION_PPTP:
139 DEBUGP("call_id -> 0x%04x\n", ntohs(tuple->dst.u.gre.key)); 135 DEBUGP("call_id -> 0x%04x\n", ntohs(tuple->dst.u.gre.key));
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
index 2a283397a8b6..2534f718ab92 100644
--- a/net/ipv4/netfilter/nf_nat_rule.c
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -226,10 +226,6 @@ static int ipt_dnat_checkentry(const char *tablename,
226 printk("DNAT: multiple ranges no longer supported\n"); 226 printk("DNAT: multiple ranges no longer supported\n");
227 return 0; 227 return 0;
228 } 228 }
229 if (mr->range[0].flags & IP_NAT_RANGE_PROTO_RANDOM) {
230 printk("DNAT: port randomization not supported\n");
231 return 0;
232 }
233 return 1; 229 return 1;
234} 230}
235 231
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
index bfd88e4e0685..fac97cf51ae5 100644
--- a/net/ipv4/netfilter/nf_nat_sip.c
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -222,6 +222,29 @@ static unsigned int mangle_sdp(struct sk_buff **pskb,
222 return mangle_content_len(pskb, ctinfo, ct, dptr); 222 return mangle_content_len(pskb, ctinfo, ct, dptr);
223} 223}
224 224
225static void ip_nat_sdp_expect(struct nf_conn *ct,
226 struct nf_conntrack_expect *exp)
227{
228 struct nf_nat_range range;
229
230 /* This must be a fresh one. */
231 BUG_ON(ct->status & IPS_NAT_DONE_MASK);
232
233 /* Change src to where master sends to */
234 range.flags = IP_NAT_RANGE_MAP_IPS;
235 range.min_ip = range.max_ip
236 = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip;
237 /* hook doesn't matter, but it has to do source manip */
238 nf_nat_setup_info(ct, &range, NF_IP_POST_ROUTING);
239
240 /* For DST manip, map port here to where it's expected. */
241 range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
242 range.min = range.max = exp->saved_proto;
243 range.min_ip = range.max_ip = exp->saved_ip;
244 /* hook doesn't matter, but it has to do destination manip */
245 nf_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
246}
247
225/* So, this packet has hit the connection tracking matching code. 248/* So, this packet has hit the connection tracking matching code.
226 Mangle it, and change the expectation to match the new version. */ 249 Mangle it, and change the expectation to match the new version. */
227static unsigned int ip_nat_sdp(struct sk_buff **pskb, 250static unsigned int ip_nat_sdp(struct sk_buff **pskb,
@@ -239,13 +262,14 @@ static unsigned int ip_nat_sdp(struct sk_buff **pskb,
239 /* Connection will come from reply */ 262 /* Connection will come from reply */
240 newip = ct->tuplehash[!dir].tuple.dst.u3.ip; 263 newip = ct->tuplehash[!dir].tuple.dst.u3.ip;
241 264
265 exp->saved_ip = exp->tuple.dst.u3.ip;
242 exp->tuple.dst.u3.ip = newip; 266 exp->tuple.dst.u3.ip = newip;
243 exp->saved_proto.udp.port = exp->tuple.dst.u.udp.port; 267 exp->saved_proto.udp.port = exp->tuple.dst.u.udp.port;
244 exp->dir = !dir; 268 exp->dir = !dir;
245 269
246 /* When you see the packet, we need to NAT it the same as the 270 /* When you see the packet, we need to NAT it the same as the
247 this one. */ 271 this one. */
248 exp->expectfn = nf_nat_follow_master; 272 exp->expectfn = ip_nat_sdp_expect;
249 273
250 /* Try to get same port: if not, try to change it. */ 274 /* Try to get same port: if not, try to change it. */
251 for (port = ntohs(exp->saved_proto.udp.port); port != 0; port++) { 275 for (port = ntohs(exp->saved_proto.udp.port); port != 0; port++) {
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index d6e488668171..8b124eafbb90 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1760,8 +1760,7 @@ int tcp_disconnect(struct sock *sk, int flags)
1760 tcp_clear_retrans(tp); 1760 tcp_clear_retrans(tp);
1761 inet_csk_delack_init(sk); 1761 inet_csk_delack_init(sk);
1762 tcp_init_send_head(sk); 1762 tcp_init_send_head(sk);
1763 tp->rx_opt.saw_tstamp = 0; 1763 memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
1764 tcp_sack_reset(&tp->rx_opt);
1765 __sk_dst_reset(sk); 1764 __sk_dst_reset(sk);
1766 1765
1767 BUG_TRAP(!inet->num || icsk->icsk_bind_hash); 1766 BUG_TRAP(!inet->num || icsk->icsk_bind_hash);
diff --git a/net/ipv4/tcp_highspeed.c b/net/ipv4/tcp_highspeed.c
index a291097fcc0a..43d624e5043c 100644
--- a/net/ipv4/tcp_highspeed.c
+++ b/net/ipv4/tcp_highspeed.c
@@ -97,10 +97,6 @@ struct hstcp {
97 u32 ai; 97 u32 ai;
98}; 98};
99 99
100static int max_ssthresh = 100;
101module_param(max_ssthresh, int, 0644);
102MODULE_PARM_DESC(max_ssthresh, "limited slow start threshold (RFC3742)");
103
104static void hstcp_init(struct sock *sk) 100static void hstcp_init(struct sock *sk)
105{ 101{
106 struct tcp_sock *tp = tcp_sk(sk); 102 struct tcp_sock *tp = tcp_sk(sk);
@@ -122,23 +118,9 @@ static void hstcp_cong_avoid(struct sock *sk, u32 adk, u32 rtt,
122 if (!tcp_is_cwnd_limited(sk, in_flight)) 118 if (!tcp_is_cwnd_limited(sk, in_flight))
123 return; 119 return;
124 120
125 if (tp->snd_cwnd <= tp->snd_ssthresh) { 121 if (tp->snd_cwnd <= tp->snd_ssthresh)
126 /* RFC3742: limited slow start 122 tcp_slow_start(tp);
127 * the window is increased by 1/K MSS for each arriving ACK, 123 else {
128 * for K = int(cwnd/(0.5 max_ssthresh))
129 */
130 if (max_ssthresh > 0 && tp->snd_cwnd > max_ssthresh) {
131 u32 k = max(tp->snd_cwnd / (max_ssthresh >> 1), 1U);
132 if (++tp->snd_cwnd_cnt >= k) {
133 if (tp->snd_cwnd < tp->snd_cwnd_clamp)
134 tp->snd_cwnd++;
135 tp->snd_cwnd_cnt = 0;
136 }
137 } else {
138 if (tp->snd_cwnd < tp->snd_cwnd_clamp)
139 tp->snd_cwnd++;
140 }
141 } else {
142 /* Update AIMD parameters. 124 /* Update AIMD parameters.
143 * 125 *
144 * We want to guarantee that: 126 * We want to guarantee that:
diff --git a/net/ipv4/tcp_yeah.h b/net/ipv4/tcp_yeah.h
deleted file mode 100644
index ed3b7198f23c..000000000000
--- a/net/ipv4/tcp_yeah.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#include <linux/mm.h>
2#include <linux/module.h>
3#include <linux/skbuff.h>
4#include <linux/inet_diag.h>
5#include <asm/div64.h>
6
7#include <net/tcp.h>
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 3452433cbc96..d02685c6bc69 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -449,7 +449,7 @@ static void addrconf_forward_change(void)
449 struct inet6_dev *idev; 449 struct inet6_dev *idev;
450 450
451 read_lock(&dev_base_lock); 451 read_lock(&dev_base_lock);
452 for (dev=dev_base; dev; dev=dev->next) { 452 for_each_netdev(dev) {
453 rcu_read_lock(); 453 rcu_read_lock();
454 idev = __in6_dev_get(dev); 454 idev = __in6_dev_get(dev);
455 if (idev) { 455 if (idev) {
@@ -911,7 +911,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
911 read_lock(&dev_base_lock); 911 read_lock(&dev_base_lock);
912 rcu_read_lock(); 912 rcu_read_lock();
913 913
914 for (dev = dev_base; dev; dev=dev->next) { 914 for_each_netdev(dev) {
915 struct inet6_dev *idev; 915 struct inet6_dev *idev;
916 struct inet6_ifaddr *ifa; 916 struct inet6_ifaddr *ifa;
917 917
@@ -2064,7 +2064,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2064 return; 2064 return;
2065 } 2065 }
2066 2066
2067 for (dev = dev_base; dev != NULL; dev = dev->next) { 2067 for_each_netdev(dev) {
2068 struct in_device * in_dev = __in_dev_get_rtnl(dev); 2068 struct in_device * in_dev = __in_dev_get_rtnl(dev);
2069 if (in_dev && (dev->flags & IFF_UP)) { 2069 if (in_dev && (dev->flags & IFF_UP)) {
2070 struct in_ifaddr * ifa; 2070 struct in_ifaddr * ifa;
@@ -2225,7 +2225,7 @@ static void ip6_tnl_add_linklocal(struct inet6_dev *idev)
2225 return; 2225 return;
2226 } 2226 }
2227 /* then try to inherit it from any device */ 2227 /* then try to inherit it from any device */
2228 for (link_dev = dev_base; link_dev; link_dev = link_dev->next) { 2228 for_each_netdev(link_dev) {
2229 if (!ipv6_inherit_linklocal(idev, link_dev)) 2229 if (!ipv6_inherit_linklocal(idev, link_dev))
2230 return; 2230 return;
2231 } 2231 }
@@ -3257,14 +3257,15 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3257 s_idx = cb->args[0]; 3257 s_idx = cb->args[0];
3258 s_ip_idx = ip_idx = cb->args[1]; 3258 s_ip_idx = ip_idx = cb->args[1];
3259 3259
3260 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 3260 idx = 0;
3261 for_each_netdev(dev) {
3261 if (idx < s_idx) 3262 if (idx < s_idx)
3262 continue; 3263 goto cont;
3263 if (idx > s_idx) 3264 if (idx > s_idx)
3264 s_ip_idx = 0; 3265 s_ip_idx = 0;
3265 ip_idx = 0; 3266 ip_idx = 0;
3266 if ((idev = in6_dev_get(dev)) == NULL) 3267 if ((idev = in6_dev_get(dev)) == NULL)
3267 continue; 3268 goto cont;
3268 read_lock_bh(&idev->lock); 3269 read_lock_bh(&idev->lock);
3269 switch (type) { 3270 switch (type) {
3270 case UNICAST_ADDR: 3271 case UNICAST_ADDR:
@@ -3311,6 +3312,8 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3311 } 3312 }
3312 read_unlock_bh(&idev->lock); 3313 read_unlock_bh(&idev->lock);
3313 in6_dev_put(idev); 3314 in6_dev_put(idev);
3315cont:
3316 idx++;
3314 } 3317 }
3315done: 3318done:
3316 if (err <= 0) { 3319 if (err <= 0) {
@@ -3575,16 +3578,19 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
3575 struct inet6_dev *idev; 3578 struct inet6_dev *idev;
3576 3579
3577 read_lock(&dev_base_lock); 3580 read_lock(&dev_base_lock);
3578 for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) { 3581 idx = 0;
3582 for_each_netdev(dev) {
3579 if (idx < s_idx) 3583 if (idx < s_idx)
3580 continue; 3584 goto cont;
3581 if ((idev = in6_dev_get(dev)) == NULL) 3585 if ((idev = in6_dev_get(dev)) == NULL)
3582 continue; 3586 goto cont;
3583 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid, 3587 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
3584 cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI); 3588 cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI);
3585 in6_dev_put(idev); 3589 in6_dev_put(idev);
3586 if (err <= 0) 3590 if (err <= 0)
3587 break; 3591 break;
3592cont:
3593 idx++;
3588 } 3594 }
3589 read_unlock(&dev_base_lock); 3595 read_unlock(&dev_base_lock);
3590 cb->args[0] = idx; 3596 cb->args[0] = idx;
@@ -4247,7 +4253,7 @@ void __exit addrconf_cleanup(void)
4247 * clean dev list. 4253 * clean dev list.
4248 */ 4254 */
4249 4255
4250 for (dev=dev_base; dev; dev=dev->next) { 4256 for_each_netdev(dev) {
4251 if ((idev = __in6_dev_get(dev)) == NULL) 4257 if ((idev = __in6_dev_get(dev)) == NULL)
4252 continue; 4258 continue;
4253 addrconf_ifdown(dev, 1); 4259 addrconf_ifdown(dev, 1);
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 09117d63256f..9b81264eb78f 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -423,14 +423,18 @@ static int ipv6_chk_acast_dev(struct net_device *dev, struct in6_addr *addr)
423 */ 423 */
424int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr) 424int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr)
425{ 425{
426 int found = 0;
427
426 if (dev) 428 if (dev)
427 return ipv6_chk_acast_dev(dev, addr); 429 return ipv6_chk_acast_dev(dev, addr);
428 read_lock(&dev_base_lock); 430 read_lock(&dev_base_lock);
429 for (dev=dev_base; dev; dev=dev->next) 431 for_each_netdev(dev)
430 if (ipv6_chk_acast_dev(dev, addr)) 432 if (ipv6_chk_acast_dev(dev, addr)) {
433 found = 1;
431 break; 434 break;
435 }
432 read_unlock(&dev_base_lock); 436 read_unlock(&dev_base_lock);
433 return dev != 0; 437 return found;
434} 438}
435 439
436 440
@@ -447,9 +451,8 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
447 struct ifacaddr6 *im = NULL; 451 struct ifacaddr6 *im = NULL;
448 struct ac6_iter_state *state = ac6_seq_private(seq); 452 struct ac6_iter_state *state = ac6_seq_private(seq);
449 453
450 for (state->dev = dev_base, state->idev = NULL; 454 state->idev = NULL;
451 state->dev; 455 for_each_netdev(state->dev) {
452 state->dev = state->dev->next) {
453 struct inet6_dev *idev; 456 struct inet6_dev *idev;
454 idev = in6_dev_get(state->dev); 457 idev = in6_dev_get(state->dev);
455 if (!idev) 458 if (!idev)
@@ -476,7 +479,7 @@ static struct ifacaddr6 *ac6_get_next(struct seq_file *seq, struct ifacaddr6 *im
476 read_unlock_bh(&state->idev->lock); 479 read_unlock_bh(&state->idev->lock);
477 in6_dev_put(state->idev); 480 in6_dev_put(state->idev);
478 } 481 }
479 state->dev = state->dev->next; 482 state->dev = next_net_device(state->dev);
480 if (!state->dev) { 483 if (!state->dev) {
481 state->idev = NULL; 484 state->idev = NULL;
482 break; 485 break;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 6c2758951d60..3e308fb41b49 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -2331,9 +2331,8 @@ static inline struct ifmcaddr6 *igmp6_mc_get_first(struct seq_file *seq)
2331 struct ifmcaddr6 *im = NULL; 2331 struct ifmcaddr6 *im = NULL;
2332 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq); 2332 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
2333 2333
2334 for (state->dev = dev_base, state->idev = NULL; 2334 state->idev = NULL;
2335 state->dev; 2335 for_each_netdev(state->dev) {
2336 state->dev = state->dev->next) {
2337 struct inet6_dev *idev; 2336 struct inet6_dev *idev;
2338 idev = in6_dev_get(state->dev); 2337 idev = in6_dev_get(state->dev);
2339 if (!idev) 2338 if (!idev)
@@ -2360,7 +2359,7 @@ static struct ifmcaddr6 *igmp6_mc_get_next(struct seq_file *seq, struct ifmcaddr
2360 read_unlock_bh(&state->idev->lock); 2359 read_unlock_bh(&state->idev->lock);
2361 in6_dev_put(state->idev); 2360 in6_dev_put(state->idev);
2362 } 2361 }
2363 state->dev = state->dev->next; 2362 state->dev = next_net_device(state->dev);
2364 if (!state->dev) { 2363 if (!state->dev) {
2365 state->idev = NULL; 2364 state->idev = NULL;
2366 break; 2365 break;
@@ -2475,9 +2474,9 @@ static inline struct ip6_sf_list *igmp6_mcf_get_first(struct seq_file *seq)
2475 struct ifmcaddr6 *im = NULL; 2474 struct ifmcaddr6 *im = NULL;
2476 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq); 2475 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
2477 2476
2478 for (state->dev = dev_base, state->idev = NULL, state->im = NULL; 2477 state->idev = NULL;
2479 state->dev; 2478 state->im = NULL;
2480 state->dev = state->dev->next) { 2479 for_each_netdev(state->dev) {
2481 struct inet6_dev *idev; 2480 struct inet6_dev *idev;
2482 idev = in6_dev_get(state->dev); 2481 idev = in6_dev_get(state->dev);
2483 if (unlikely(idev == NULL)) 2482 if (unlikely(idev == NULL))
@@ -2513,7 +2512,7 @@ static struct ip6_sf_list *igmp6_mcf_get_next(struct seq_file *seq, struct ip6_s
2513 read_unlock_bh(&state->idev->lock); 2512 read_unlock_bh(&state->idev->lock);
2514 in6_dev_put(state->idev); 2513 in6_dev_put(state->idev);
2515 } 2514 }
2516 state->dev = state->dev->next; 2515 state->dev = next_net_device(state->dev);
2517 if (!state->dev) { 2516 if (!state->dev) {
2518 state->idev = NULL; 2517 state->idev = NULL;
2519 goto out; 2518 goto out;
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index e84c924a81ee..d9e9ddb8eac5 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -45,7 +45,8 @@ static struct proto iucv_proto = {
45static void iucv_callback_rx(struct iucv_path *, struct iucv_message *); 45static void iucv_callback_rx(struct iucv_path *, struct iucv_message *);
46static void iucv_callback_txdone(struct iucv_path *, struct iucv_message *); 46static void iucv_callback_txdone(struct iucv_path *, struct iucv_message *);
47static void iucv_callback_connack(struct iucv_path *, u8 ipuser[16]); 47static void iucv_callback_connack(struct iucv_path *, u8 ipuser[16]);
48static int iucv_callback_connreq(struct iucv_path *, u8 ipvmid[8], u8 ipuser[16]); 48static int iucv_callback_connreq(struct iucv_path *, u8 ipvmid[8],
49 u8 ipuser[16]);
49static void iucv_callback_connrej(struct iucv_path *, u8 ipuser[16]); 50static void iucv_callback_connrej(struct iucv_path *, u8 ipuser[16]);
50 51
51static struct iucv_sock_list iucv_sk_list = { 52static struct iucv_sock_list iucv_sk_list = {
@@ -147,11 +148,12 @@ static void iucv_sock_close(struct sock *sk)
147 unsigned char user_data[16]; 148 unsigned char user_data[16];
148 struct iucv_sock *iucv = iucv_sk(sk); 149 struct iucv_sock *iucv = iucv_sk(sk);
149 int err; 150 int err;
151 unsigned long timeo;
150 152
151 iucv_sock_clear_timer(sk); 153 iucv_sock_clear_timer(sk);
152 lock_sock(sk); 154 lock_sock(sk);
153 155
154 switch(sk->sk_state) { 156 switch (sk->sk_state) {
155 case IUCV_LISTEN: 157 case IUCV_LISTEN:
156 iucv_sock_cleanup_listen(sk); 158 iucv_sock_cleanup_listen(sk);
157 break; 159 break;
@@ -159,6 +161,21 @@ static void iucv_sock_close(struct sock *sk)
159 case IUCV_CONNECTED: 161 case IUCV_CONNECTED:
160 case IUCV_DISCONN: 162 case IUCV_DISCONN:
161 err = 0; 163 err = 0;
164
165 sk->sk_state = IUCV_CLOSING;
166 sk->sk_state_change(sk);
167
168 if (!skb_queue_empty(&iucv->send_skb_q)) {
169 if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
170 timeo = sk->sk_lingertime;
171 else
172 timeo = IUCV_DISCONN_TIMEOUT;
173 err = iucv_sock_wait_state(sk, IUCV_CLOSED, 0, timeo);
174 }
175
176 sk->sk_state = IUCV_CLOSED;
177 sk->sk_state_change(sk);
178
162 if (iucv->path) { 179 if (iucv->path) {
163 low_nmcpy(user_data, iucv->src_name); 180 low_nmcpy(user_data, iucv->src_name);
164 high_nmcpy(user_data, iucv->dst_name); 181 high_nmcpy(user_data, iucv->dst_name);
@@ -168,12 +185,11 @@ static void iucv_sock_close(struct sock *sk)
168 iucv->path = NULL; 185 iucv->path = NULL;
169 } 186 }
170 187
171 sk->sk_state = IUCV_CLOSED;
172 sk->sk_state_change(sk);
173 sk->sk_err = ECONNRESET; 188 sk->sk_err = ECONNRESET;
174 sk->sk_state_change(sk); 189 sk->sk_state_change(sk);
175 190
176 skb_queue_purge(&iucv->send_skb_q); 191 skb_queue_purge(&iucv->send_skb_q);
192 skb_queue_purge(&iucv->backlog_skb_q);
177 193
178 sock_set_flag(sk, SOCK_ZAPPED); 194 sock_set_flag(sk, SOCK_ZAPPED);
179 break; 195 break;
@@ -204,6 +220,7 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio)
204 sock_init_data(sock, sk); 220 sock_init_data(sock, sk);
205 INIT_LIST_HEAD(&iucv_sk(sk)->accept_q); 221 INIT_LIST_HEAD(&iucv_sk(sk)->accept_q);
206 skb_queue_head_init(&iucv_sk(sk)->send_skb_q); 222 skb_queue_head_init(&iucv_sk(sk)->send_skb_q);
223 skb_queue_head_init(&iucv_sk(sk)->backlog_skb_q);
207 iucv_sk(sk)->send_tag = 0; 224 iucv_sk(sk)->send_tag = 0;
208 225
209 sk->sk_destruct = iucv_sock_destruct; 226 sk->sk_destruct = iucv_sock_destruct;
@@ -276,7 +293,7 @@ struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock)
276 struct iucv_sock *isk, *n; 293 struct iucv_sock *isk, *n;
277 struct sock *sk; 294 struct sock *sk;
278 295
279 list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q){ 296 list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q) {
280 sk = (struct sock *) isk; 297 sk = (struct sock *) isk;
281 lock_sock(sk); 298 lock_sock(sk);
282 299
@@ -510,7 +527,7 @@ static int iucv_sock_accept(struct socket *sock, struct socket *newsock,
510 long timeo; 527 long timeo;
511 int err = 0; 528 int err = 0;
512 529
513 lock_sock(sk); 530 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
514 531
515 if (sk->sk_state != IUCV_LISTEN) { 532 if (sk->sk_state != IUCV_LISTEN) {
516 err = -EBADFD; 533 err = -EBADFD;
@@ -521,7 +538,7 @@ static int iucv_sock_accept(struct socket *sock, struct socket *newsock,
521 538
522 /* Wait for an incoming connection */ 539 /* Wait for an incoming connection */
523 add_wait_queue_exclusive(sk->sk_sleep, &wait); 540 add_wait_queue_exclusive(sk->sk_sleep, &wait);
524 while (!(nsk = iucv_accept_dequeue(sk, newsock))){ 541 while (!(nsk = iucv_accept_dequeue(sk, newsock))) {
525 set_current_state(TASK_INTERRUPTIBLE); 542 set_current_state(TASK_INTERRUPTIBLE);
526 if (!timeo) { 543 if (!timeo) {
527 err = -EAGAIN; 544 err = -EAGAIN;
@@ -530,7 +547,7 @@ static int iucv_sock_accept(struct socket *sock, struct socket *newsock,
530 547
531 release_sock(sk); 548 release_sock(sk);
532 timeo = schedule_timeout(timeo); 549 timeo = schedule_timeout(timeo);
533 lock_sock(sk); 550 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
534 551
535 if (sk->sk_state != IUCV_LISTEN) { 552 if (sk->sk_state != IUCV_LISTEN) {
536 err = -EBADFD; 553 err = -EBADFD;
@@ -602,13 +619,13 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
602 goto out; 619 goto out;
603 } 620 }
604 621
605 if (sk->sk_state == IUCV_CONNECTED){ 622 if (sk->sk_state == IUCV_CONNECTED) {
606 if(!(skb = sock_alloc_send_skb(sk, len, 623 if (!(skb = sock_alloc_send_skb(sk, len,
607 msg->msg_flags & MSG_DONTWAIT, 624 msg->msg_flags & MSG_DONTWAIT,
608 &err))) 625 &err)))
609 return err; 626 goto out;
610 627
611 if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)){ 628 if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
612 err = -EFAULT; 629 err = -EFAULT;
613 goto fail; 630 goto fail;
614 } 631 }
@@ -647,10 +664,16 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
647{ 664{
648 int noblock = flags & MSG_DONTWAIT; 665 int noblock = flags & MSG_DONTWAIT;
649 struct sock *sk = sock->sk; 666 struct sock *sk = sock->sk;
667 struct iucv_sock *iucv = iucv_sk(sk);
650 int target, copied = 0; 668 int target, copied = 0;
651 struct sk_buff *skb; 669 struct sk_buff *skb, *rskb, *cskb;
652 int err = 0; 670 int err = 0;
653 671
672 if ((sk->sk_state == IUCV_DISCONN || sk->sk_state == IUCV_SEVERED) &&
673 skb_queue_empty(&iucv->backlog_skb_q) &&
674 skb_queue_empty(&sk->sk_receive_queue))
675 return 0;
676
654 if (flags & (MSG_OOB)) 677 if (flags & (MSG_OOB))
655 return -EOPNOTSUPP; 678 return -EOPNOTSUPP;
656 679
@@ -665,10 +688,12 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
665 688
666 copied = min_t(unsigned int, skb->len, len); 689 copied = min_t(unsigned int, skb->len, len);
667 690
668 if (memcpy_toiovec(msg->msg_iov, skb->data, copied)) { 691 cskb = skb;
692 if (memcpy_toiovec(msg->msg_iov, cskb->data, copied)) {
669 skb_queue_head(&sk->sk_receive_queue, skb); 693 skb_queue_head(&sk->sk_receive_queue, skb);
670 if (copied == 0) 694 if (copied == 0)
671 return -EFAULT; 695 return -EFAULT;
696 goto done;
672 } 697 }
673 698
674 len -= copied; 699 len -= copied;
@@ -683,6 +708,18 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
683 } 708 }
684 709
685 kfree_skb(skb); 710 kfree_skb(skb);
711
712 /* Queue backlog skbs */
713 rskb = skb_dequeue(&iucv_sk(sk)->backlog_skb_q);
714 while (rskb) {
715 if (sock_queue_rcv_skb(sk, rskb)) {
716 skb_queue_head(&iucv_sk(sk)->backlog_skb_q,
717 rskb);
718 break;
719 } else {
720 rskb = skb_dequeue(&iucv_sk(sk)->backlog_skb_q);
721 }
722 }
686 } else 723 } else
687 skb_queue_head(&sk->sk_receive_queue, skb); 724 skb_queue_head(&sk->sk_receive_queue, skb);
688 725
@@ -695,7 +732,7 @@ static inline unsigned int iucv_accept_poll(struct sock *parent)
695 struct iucv_sock *isk, *n; 732 struct iucv_sock *isk, *n;
696 struct sock *sk; 733 struct sock *sk;
697 734
698 list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q){ 735 list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q) {
699 sk = (struct sock *) isk; 736 sk = (struct sock *) isk;
700 737
701 if (sk->sk_state == IUCV_CONNECTED) 738 if (sk->sk_state == IUCV_CONNECTED)
@@ -726,12 +763,15 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
726 mask |= POLLHUP; 763 mask |= POLLHUP;
727 764
728 if (!skb_queue_empty(&sk->sk_receive_queue) || 765 if (!skb_queue_empty(&sk->sk_receive_queue) ||
729 (sk->sk_shutdown & RCV_SHUTDOWN)) 766 (sk->sk_shutdown & RCV_SHUTDOWN))
730 mask |= POLLIN | POLLRDNORM; 767 mask |= POLLIN | POLLRDNORM;
731 768
732 if (sk->sk_state == IUCV_CLOSED) 769 if (sk->sk_state == IUCV_CLOSED)
733 mask |= POLLHUP; 770 mask |= POLLHUP;
734 771
772 if (sk->sk_state == IUCV_DISCONN || sk->sk_state == IUCV_SEVERED)
773 mask |= POLLIN;
774
735 if (sock_writeable(sk)) 775 if (sock_writeable(sk))
736 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 776 mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
737 else 777 else
@@ -754,7 +794,7 @@ static int iucv_sock_shutdown(struct socket *sock, int how)
754 return -EINVAL; 794 return -EINVAL;
755 795
756 lock_sock(sk); 796 lock_sock(sk);
757 switch(sk->sk_state) { 797 switch (sk->sk_state) {
758 case IUCV_CLOSED: 798 case IUCV_CLOSED:
759 err = -ENOTCONN; 799 err = -ENOTCONN;
760 goto fail; 800 goto fail;
@@ -770,7 +810,7 @@ static int iucv_sock_shutdown(struct socket *sock, int how)
770 err = iucv_message_send(iucv->path, &txmsg, IUCV_IPRMDATA, 0, 810 err = iucv_message_send(iucv->path, &txmsg, IUCV_IPRMDATA, 0,
771 (void *) prmmsg, 8); 811 (void *) prmmsg, 8);
772 if (err) { 812 if (err) {
773 switch(err) { 813 switch (err) {
774 case 1: 814 case 1:
775 err = -ENOTCONN; 815 err = -ENOTCONN;
776 break; 816 break;
@@ -817,13 +857,6 @@ static int iucv_sock_release(struct socket *sock)
817 iucv_sk(sk)->path = NULL; 857 iucv_sk(sk)->path = NULL;
818 } 858 }
819 859
820 if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime){
821 lock_sock(sk);
822 err = iucv_sock_wait_state(sk, IUCV_CLOSED, 0,
823 sk->sk_lingertime);
824 release_sock(sk);
825 }
826
827 sock_orphan(sk); 860 sock_orphan(sk);
828 iucv_sock_kill(sk); 861 iucv_sock_kill(sk);
829 return err; 862 return err;
@@ -880,7 +913,7 @@ static int iucv_callback_connreq(struct iucv_path *path,
880 913
881 /* Create the new socket */ 914 /* Create the new socket */
882 nsk = iucv_sock_alloc(NULL, SOCK_STREAM, GFP_ATOMIC); 915 nsk = iucv_sock_alloc(NULL, SOCK_STREAM, GFP_ATOMIC);
883 if (!nsk){ 916 if (!nsk) {
884 err = iucv_path_sever(path, user_data); 917 err = iucv_path_sever(path, user_data);
885 goto fail; 918 goto fail;
886 } 919 }
@@ -903,7 +936,7 @@ static int iucv_callback_connreq(struct iucv_path *path,
903 936
904 path->msglim = IUCV_QUEUELEN_DEFAULT; 937 path->msglim = IUCV_QUEUELEN_DEFAULT;
905 err = iucv_path_accept(path, &af_iucv_handler, nuser_data, nsk); 938 err = iucv_path_accept(path, &af_iucv_handler, nuser_data, nsk);
906 if (err){ 939 if (err) {
907 err = iucv_path_sever(path, user_data); 940 err = iucv_path_sever(path, user_data);
908 goto fail; 941 goto fail;
909 } 942 }
@@ -927,18 +960,53 @@ static void iucv_callback_connack(struct iucv_path *path, u8 ipuser[16])
927 sk->sk_state_change(sk); 960 sk->sk_state_change(sk);
928} 961}
929 962
963static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len,
964 struct sk_buff_head *fragmented_skb_q)
965{
966 int dataleft, size, copied = 0;
967 struct sk_buff *nskb;
968
969 dataleft = len;
970 while (dataleft) {
971 if (dataleft >= sk->sk_rcvbuf / 4)
972 size = sk->sk_rcvbuf / 4;
973 else
974 size = dataleft;
975
976 nskb = alloc_skb(size, GFP_ATOMIC | GFP_DMA);
977 if (!nskb)
978 return -ENOMEM;
979
980 memcpy(nskb->data, skb->data + copied, size);
981 copied += size;
982 dataleft -= size;
983
984 skb_reset_transport_header(nskb);
985 skb_reset_network_header(nskb);
986 nskb->len = size;
987
988 skb_queue_tail(fragmented_skb_q, nskb);
989 }
990
991 return 0;
992}
993
930static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg) 994static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
931{ 995{
932 struct sock *sk = path->private; 996 struct sock *sk = path->private;
933 struct sk_buff *skb; 997 struct iucv_sock *iucv = iucv_sk(sk);
998 struct sk_buff *skb, *fskb;
999 struct sk_buff_head fragmented_skb_q;
934 int rc; 1000 int rc;
935 1001
1002 skb_queue_head_init(&fragmented_skb_q);
1003
936 if (sk->sk_shutdown & RCV_SHUTDOWN) 1004 if (sk->sk_shutdown & RCV_SHUTDOWN)
937 return; 1005 return;
938 1006
939 skb = alloc_skb(msg->length, GFP_ATOMIC | GFP_DMA); 1007 skb = alloc_skb(msg->length, GFP_ATOMIC | GFP_DMA);
940 if (!skb) { 1008 if (!skb) {
941 iucv_message_reject(path, msg); 1009 iucv_path_sever(path, NULL);
942 return; 1010 return;
943 } 1011 }
944 1012
@@ -952,14 +1020,39 @@ static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
952 kfree_skb(skb); 1020 kfree_skb(skb);
953 return; 1021 return;
954 } 1022 }
1023 if (skb->truesize >= sk->sk_rcvbuf / 4) {
1024 rc = iucv_fragment_skb(sk, skb, msg->length,
1025 &fragmented_skb_q);
1026 kfree_skb(skb);
1027 skb = NULL;
1028 if (rc) {
1029 iucv_path_sever(path, NULL);
1030 return;
1031 }
1032 } else {
1033 skb_reset_transport_header(skb);
1034 skb_reset_network_header(skb);
1035 skb->len = msg->length;
1036 }
1037 }
1038 /* Queue the fragmented skb */
1039 fskb = skb_dequeue(&fragmented_skb_q);
1040 while (fskb) {
1041 if (!skb_queue_empty(&iucv->backlog_skb_q))
1042 skb_queue_tail(&iucv->backlog_skb_q, fskb);
1043 else if (sock_queue_rcv_skb(sk, fskb))
1044 skb_queue_tail(&iucv_sk(sk)->backlog_skb_q, fskb);
1045 fskb = skb_dequeue(&fragmented_skb_q);
1046 }
955 1047
956 skb_reset_transport_header(skb); 1048 /* Queue the original skb if it exists (was not fragmented) */
957 skb_reset_network_header(skb); 1049 if (skb) {
958 skb->len = msg->length; 1050 if (!skb_queue_empty(&iucv->backlog_skb_q))
1051 skb_queue_tail(&iucv_sk(sk)->backlog_skb_q, skb);
1052 else if (sock_queue_rcv_skb(sk, skb))
1053 skb_queue_tail(&iucv_sk(sk)->backlog_skb_q, skb);
959 } 1054 }
960 1055
961 if (sock_queue_rcv_skb(sk, skb))
962 kfree_skb(skb);
963} 1056}
964 1057
965static void iucv_callback_txdone(struct iucv_path *path, 1058static void iucv_callback_txdone(struct iucv_path *path,
@@ -971,17 +1064,27 @@ static void iucv_callback_txdone(struct iucv_path *path,
971 struct sk_buff *list_skb = list->next; 1064 struct sk_buff *list_skb = list->next;
972 unsigned long flags; 1065 unsigned long flags;
973 1066
974 spin_lock_irqsave(&list->lock, flags); 1067 if (list_skb) {
1068 spin_lock_irqsave(&list->lock, flags);
1069
1070 do {
1071 this = list_skb;
1072 list_skb = list_skb->next;
1073 } while (memcmp(&msg->tag, this->cb, 4) && list_skb);
1074
1075 spin_unlock_irqrestore(&list->lock, flags);
975 1076
976 do { 1077 skb_unlink(this, &iucv_sk(sk)->send_skb_q);
977 this = list_skb; 1078 kfree_skb(this);
978 list_skb = list_skb->next; 1079 }
979 } while (memcmp(&msg->tag, this->cb, 4));
980 1080
981 spin_unlock_irqrestore(&list->lock, flags); 1081 if (sk->sk_state == IUCV_CLOSING) {
1082 if (skb_queue_empty(&iucv_sk(sk)->send_skb_q)) {
1083 sk->sk_state = IUCV_CLOSED;
1084 sk->sk_state_change(sk);
1085 }
1086 }
982 1087
983 skb_unlink(this, &iucv_sk(sk)->send_skb_q);
984 kfree_skb(this);
985} 1088}
986 1089
987static void iucv_callback_connrej(struct iucv_path *path, u8 ipuser[16]) 1090static void iucv_callback_connrej(struct iucv_path *path, u8 ipuser[16])
@@ -1022,7 +1125,7 @@ static struct net_proto_family iucv_sock_family_ops = {
1022 .create = iucv_sock_create, 1125 .create = iucv_sock_create,
1023}; 1126};
1024 1127
1025static int afiucv_init(void) 1128static int __init afiucv_init(void)
1026{ 1129{
1027 int err; 1130 int err;
1028 1131
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index 903bdb6eaaa1..fb3faf72e850 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -32,7 +32,6 @@
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
35
36#include <linux/spinlock.h> 35#include <linux/spinlock.h>
37#include <linux/kernel.h> 36#include <linux/kernel.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
@@ -69,7 +68,7 @@
69#define IUCV_IPNORPY 0x10 68#define IUCV_IPNORPY 0x10
70#define IUCV_IPALL 0x80 69#define IUCV_IPALL 0x80
71 70
72static int iucv_bus_match (struct device *dev, struct device_driver *drv) 71static int iucv_bus_match(struct device *dev, struct device_driver *drv)
73{ 72{
74 return 0; 73 return 0;
75} 74}
@@ -78,8 +77,11 @@ struct bus_type iucv_bus = {
78 .name = "iucv", 77 .name = "iucv",
79 .match = iucv_bus_match, 78 .match = iucv_bus_match,
80}; 79};
80EXPORT_SYMBOL(iucv_bus);
81 81
82struct device *iucv_root; 82struct device *iucv_root;
83EXPORT_SYMBOL(iucv_root);
84
83static int iucv_available; 85static int iucv_available;
84 86
85/* General IUCV interrupt structure */ 87/* General IUCV interrupt structure */
@@ -405,7 +407,7 @@ static void iucv_declare_cpu(void *data)
405 rc = iucv_call_b2f0(IUCV_DECLARE_BUFFER, parm); 407 rc = iucv_call_b2f0(IUCV_DECLARE_BUFFER, parm);
406 if (rc) { 408 if (rc) {
407 char *err = "Unknown"; 409 char *err = "Unknown";
408 switch(rc) { 410 switch (rc) {
409 case 0x03: 411 case 0x03:
410 err = "Directory error"; 412 err = "Directory error";
411 break; 413 break;
@@ -588,7 +590,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
588 return NOTIFY_OK; 590 return NOTIFY_OK;
589} 591}
590 592
591static struct notifier_block iucv_cpu_notifier = { 593static struct notifier_block __cpuinitdata iucv_cpu_notifier = {
592 .notifier_call = iucv_cpu_notify, 594 .notifier_call = iucv_cpu_notify,
593}; 595};
594 596
@@ -691,6 +693,7 @@ out_mutex:
691 mutex_unlock(&iucv_register_mutex); 693 mutex_unlock(&iucv_register_mutex);
692 return rc; 694 return rc;
693} 695}
696EXPORT_SYMBOL(iucv_register);
694 697
695/** 698/**
696 * iucv_unregister 699 * iucv_unregister
@@ -723,6 +726,7 @@ void iucv_unregister(struct iucv_handler *handler, int smp)
723 iucv_setmask_mp(); 726 iucv_setmask_mp();
724 mutex_unlock(&iucv_register_mutex); 727 mutex_unlock(&iucv_register_mutex);
725} 728}
729EXPORT_SYMBOL(iucv_unregister);
726 730
727/** 731/**
728 * iucv_path_accept 732 * iucv_path_accept
@@ -761,6 +765,7 @@ int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
761 local_bh_enable(); 765 local_bh_enable();
762 return rc; 766 return rc;
763} 767}
768EXPORT_SYMBOL(iucv_path_accept);
764 769
765/** 770/**
766 * iucv_path_connect 771 * iucv_path_connect
@@ -824,6 +829,7 @@ int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
824 spin_unlock_bh(&iucv_table_lock); 829 spin_unlock_bh(&iucv_table_lock);
825 return rc; 830 return rc;
826} 831}
832EXPORT_SYMBOL(iucv_path_connect);
827 833
828/** 834/**
829 * iucv_path_quiesce: 835 * iucv_path_quiesce:
@@ -850,6 +856,7 @@ int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16])
850 local_bh_enable(); 856 local_bh_enable();
851 return rc; 857 return rc;
852} 858}
859EXPORT_SYMBOL(iucv_path_quiesce);
853 860
854/** 861/**
855 * iucv_path_resume: 862 * iucv_path_resume:
@@ -890,7 +897,6 @@ int iucv_path_sever(struct iucv_path *path, u8 userdata[16])
890{ 897{
891 int rc; 898 int rc;
892 899
893
894 preempt_disable(); 900 preempt_disable();
895 if (iucv_active_cpu != smp_processor_id()) 901 if (iucv_active_cpu != smp_processor_id())
896 spin_lock_bh(&iucv_table_lock); 902 spin_lock_bh(&iucv_table_lock);
@@ -904,6 +910,7 @@ int iucv_path_sever(struct iucv_path *path, u8 userdata[16])
904 preempt_enable(); 910 preempt_enable();
905 return rc; 911 return rc;
906} 912}
913EXPORT_SYMBOL(iucv_path_sever);
907 914
908/** 915/**
909 * iucv_message_purge 916 * iucv_message_purge
@@ -936,6 +943,7 @@ int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
936 local_bh_enable(); 943 local_bh_enable();
937 return rc; 944 return rc;
938} 945}
946EXPORT_SYMBOL(iucv_message_purge);
939 947
940/** 948/**
941 * iucv_message_receive 949 * iucv_message_receive
@@ -1006,6 +1014,7 @@ int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1006 local_bh_enable(); 1014 local_bh_enable();
1007 return rc; 1015 return rc;
1008} 1016}
1017EXPORT_SYMBOL(iucv_message_receive);
1009 1018
1010/** 1019/**
1011 * iucv_message_reject 1020 * iucv_message_reject
@@ -1034,6 +1043,7 @@ int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg)
1034 local_bh_enable(); 1043 local_bh_enable();
1035 return rc; 1044 return rc;
1036} 1045}
1046EXPORT_SYMBOL(iucv_message_reject);
1037 1047
1038/** 1048/**
1039 * iucv_message_reply 1049 * iucv_message_reply
@@ -1077,6 +1087,7 @@ int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
1077 local_bh_enable(); 1087 local_bh_enable();
1078 return rc; 1088 return rc;
1079} 1089}
1090EXPORT_SYMBOL(iucv_message_reply);
1080 1091
1081/** 1092/**
1082 * iucv_message_send 1093 * iucv_message_send
@@ -1125,6 +1136,7 @@ int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1125 local_bh_enable(); 1136 local_bh_enable();
1126 return rc; 1137 return rc;
1127} 1138}
1139EXPORT_SYMBOL(iucv_message_send);
1128 1140
1129/** 1141/**
1130 * iucv_message_send2way 1142 * iucv_message_send2way
@@ -1181,6 +1193,7 @@ int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
1181 local_bh_enable(); 1193 local_bh_enable();
1182 return rc; 1194 return rc;
1183} 1195}
1196EXPORT_SYMBOL(iucv_message_send2way);
1184 1197
1185/** 1198/**
1186 * iucv_path_pending 1199 * iucv_path_pending
@@ -1572,7 +1585,7 @@ static void iucv_external_interrupt(u16 code)
1572 * 1585 *
1573 * Allocates and initializes various data structures. 1586 * Allocates and initializes various data structures.
1574 */ 1587 */
1575static int iucv_init(void) 1588static int __init iucv_init(void)
1576{ 1589{
1577 int rc; 1590 int rc;
1578 1591
@@ -1583,7 +1596,7 @@ static int iucv_init(void)
1583 rc = iucv_query_maxconn(); 1596 rc = iucv_query_maxconn();
1584 if (rc) 1597 if (rc)
1585 goto out; 1598 goto out;
1586 rc = register_external_interrupt (0x4000, iucv_external_interrupt); 1599 rc = register_external_interrupt(0x4000, iucv_external_interrupt);
1587 if (rc) 1600 if (rc)
1588 goto out; 1601 goto out;
1589 rc = bus_register(&iucv_bus); 1602 rc = bus_register(&iucv_bus);
@@ -1594,7 +1607,7 @@ static int iucv_init(void)
1594 rc = PTR_ERR(iucv_root); 1607 rc = PTR_ERR(iucv_root);
1595 goto out_bus; 1608 goto out_bus;
1596 } 1609 }
1597 /* Note: GFP_DMA used used to get memory below 2G */ 1610 /* Note: GFP_DMA used to get memory below 2G */
1598 iucv_irq_data = percpu_alloc(sizeof(struct iucv_irq_data), 1611 iucv_irq_data = percpu_alloc(sizeof(struct iucv_irq_data),
1599 GFP_KERNEL|GFP_DMA); 1612 GFP_KERNEL|GFP_DMA);
1600 if (!iucv_irq_data) { 1613 if (!iucv_irq_data) {
@@ -1632,7 +1645,7 @@ out:
1632 * 1645 *
1633 * Frees everything allocated from iucv_init. 1646 * Frees everything allocated from iucv_init.
1634 */ 1647 */
1635static void iucv_exit(void) 1648static void __exit iucv_exit(void)
1636{ 1649{
1637 struct iucv_irq_list *p, *n; 1650 struct iucv_irq_list *p, *n;
1638 1651
@@ -1653,24 +1666,6 @@ static void iucv_exit(void)
1653subsys_initcall(iucv_init); 1666subsys_initcall(iucv_init);
1654module_exit(iucv_exit); 1667module_exit(iucv_exit);
1655 1668
1656/**
1657 * Export all public stuff
1658 */
1659EXPORT_SYMBOL (iucv_bus);
1660EXPORT_SYMBOL (iucv_root);
1661EXPORT_SYMBOL (iucv_register);
1662EXPORT_SYMBOL (iucv_unregister);
1663EXPORT_SYMBOL (iucv_path_accept);
1664EXPORT_SYMBOL (iucv_path_connect);
1665EXPORT_SYMBOL (iucv_path_quiesce);
1666EXPORT_SYMBOL (iucv_path_sever);
1667EXPORT_SYMBOL (iucv_message_purge);
1668EXPORT_SYMBOL (iucv_message_receive);
1669EXPORT_SYMBOL (iucv_message_reject);
1670EXPORT_SYMBOL (iucv_message_reply);
1671EXPORT_SYMBOL (iucv_message_send);
1672EXPORT_SYMBOL (iucv_message_send2way);
1673
1674MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)"); 1669MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
1675MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver"); 1670MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
1676MODULE_LICENSE("GPL"); 1671MODULE_LICENSE("GPL");
diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c
index d12413cff5bd..d4b13a031fd5 100644
--- a/net/llc/llc_core.c
+++ b/net/llc/llc_core.c
@@ -160,8 +160,14 @@ static struct packet_type llc_tr_packet_type = {
160 160
161static int __init llc_init(void) 161static int __init llc_init(void)
162{ 162{
163 if (dev_base->next) 163 struct net_device *dev;
164 memcpy(llc_station_mac_sa, dev_base->next->dev_addr, ETH_ALEN); 164
165 dev = first_net_device();
166 if (dev != NULL)
167 dev = next_net_device(dev);
168
169 if (dev != NULL)
170 memcpy(llc_station_mac_sa, dev->dev_addr, ETH_ALEN);
165 else 171 else
166 memset(llc_station_mac_sa, 0, ETH_ALEN); 172 memset(llc_station_mac_sa, 0, ETH_ALEN);
167 dev_add_pack(&llc_packet_type); 173 dev_add_pack(&llc_packet_type);
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
new file mode 100644
index 000000000000..6fffb3845ab6
--- /dev/null
+++ b/net/mac80211/Kconfig
@@ -0,0 +1,78 @@
1config MAC80211
2 tristate "Generic IEEE 802.11 Networking Stack (mac80211)"
3 depends on EXPERIMENTAL
4 select CRYPTO
5 select CRYPTO_ECB
6 select CRYPTO_ARC4
7 select CRYPTO_AES
8 select CRC32
9 select WIRELESS_EXT
10 select CFG80211
11 select NET_SCH_FIFO
12 ---help---
13 This option enables the hardware independent IEEE 802.11
14 networking stack.
15
16config MAC80211_LEDS
17 bool "Enable LED triggers"
18 depends on MAC80211 && LEDS_TRIGGERS
19 ---help---
20 This option enables a few LED triggers for different
21 packet receive/transmit events.
22
23config MAC80211_DEBUGFS
24 bool "Export mac80211 internals in DebugFS"
25 depends on MAC80211 && DEBUG_FS
26 ---help---
27 Select this to see extensive information about
28 the internal state of mac80211 in debugfs.
29
30 Say N unless you know you need this.
31
32config MAC80211_DEBUG
33 bool "Enable debugging output"
34 depends on MAC80211
35 ---help---
36 This option will enable debug tracing output for the
37 ieee80211 network stack.
38
39 If you are not trying to debug or develop the ieee80211
40 subsystem, you most likely want to say N here.
41
42config MAC80211_VERBOSE_DEBUG
43 bool "Verbose debugging output"
44 depends on MAC80211_DEBUG
45
46config MAC80211_LOWTX_FRAME_DUMP
47 bool "Debug frame dumping"
48 depends on MAC80211_DEBUG
49 ---help---
50 Selecting this option will cause the stack to
51 print a message for each frame that is handed
52 to the lowlevel driver for transmission. This
53 message includes all MAC addresses and the
54 frame control field.
55
56 If unsure, say N and insert the debugging code
57 you require into the driver you are debugging.
58
59config TKIP_DEBUG
60 bool "TKIP debugging"
61 depends on MAC80211_DEBUG
62
63config MAC80211_DEBUG_COUNTERS
64 bool "Extra statistics for TX/RX debugging"
65 depends on MAC80211_DEBUG
66
67config MAC80211_IBSS_DEBUG
68 bool "Support for IBSS testing"
69 depends on MAC80211_DEBUG
70 ---help---
71 Say Y here if you intend to debug the IBSS code.
72
73config MAC80211_VERBOSE_PS_DEBUG
74 bool "Verbose powersave mode debugging"
75 depends on MAC80211_DEBUG
76 ---help---
77 Say Y here to print out verbose powersave
78 mode debug messages.
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
new file mode 100644
index 000000000000..e9738dad2d7c
--- /dev/null
+++ b/net/mac80211/Makefile
@@ -0,0 +1,20 @@
1obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o
2
3mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
4mac80211-objs-$(CONFIG_MAC80211_DEBUGFS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o
5
6mac80211-objs := \
7 ieee80211.o \
8 ieee80211_ioctl.o \
9 sta_info.o \
10 wep.o \
11 wpa.o \
12 ieee80211_sta.o \
13 ieee80211_iface.o \
14 ieee80211_rate.o \
15 michael.o \
16 tkip.o \
17 aes_ccm.o \
18 wme.o \
19 ieee80211_cfg.o \
20 $(mac80211-objs-y)
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c
new file mode 100644
index 000000000000..e55569bee7d0
--- /dev/null
+++ b/net/mac80211/aes_ccm.c
@@ -0,0 +1,155 @@
1/*
2 * Copyright 2003-2004, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/types.h>
11#include <linux/crypto.h>
12#include <linux/err.h>
13#include <asm/scatterlist.h>
14
15#include <net/mac80211.h>
16#include "ieee80211_key.h"
17#include "aes_ccm.h"
18
19
20static void ieee80211_aes_encrypt(struct crypto_cipher *tfm,
21 const u8 pt[16], u8 ct[16])
22{
23 crypto_cipher_encrypt_one(tfm, ct, pt);
24}
25
26
27static inline void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
28 u8 *b, u8 *s_0, u8 *a)
29{
30 int i;
31
32 ieee80211_aes_encrypt(tfm, b_0, b);
33
34 /* Extra Authenticate-only data (always two AES blocks) */
35 for (i = 0; i < AES_BLOCK_LEN; i++)
36 aad[i] ^= b[i];
37 ieee80211_aes_encrypt(tfm, aad, b);
38
39 aad += AES_BLOCK_LEN;
40
41 for (i = 0; i < AES_BLOCK_LEN; i++)
42 aad[i] ^= b[i];
43 ieee80211_aes_encrypt(tfm, aad, a);
44
45 /* Mask out bits from auth-only-b_0 */
46 b_0[0] &= 0x07;
47
48 /* S_0 is used to encrypt T (= MIC) */
49 b_0[14] = 0;
50 b_0[15] = 0;
51 ieee80211_aes_encrypt(tfm, b_0, s_0);
52}
53
54
55void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
56 u8 *b_0, u8 *aad, u8 *data, size_t data_len,
57 u8 *cdata, u8 *mic)
58{
59 int i, j, last_len, num_blocks;
60 u8 *pos, *cpos, *b, *s_0, *e;
61
62 b = scratch;
63 s_0 = scratch + AES_BLOCK_LEN;
64 e = scratch + 2 * AES_BLOCK_LEN;
65
66 num_blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
67 last_len = data_len % AES_BLOCK_LEN;
68 aes_ccm_prepare(tfm, b_0, aad, b, s_0, b);
69
70 /* Process payload blocks */
71 pos = data;
72 cpos = cdata;
73 for (j = 1; j <= num_blocks; j++) {
74 int blen = (j == num_blocks && last_len) ?
75 last_len : AES_BLOCK_LEN;
76
77 /* Authentication followed by encryption */
78 for (i = 0; i < blen; i++)
79 b[i] ^= pos[i];
80 ieee80211_aes_encrypt(tfm, b, b);
81
82 b_0[14] = (j >> 8) & 0xff;
83 b_0[15] = j & 0xff;
84 ieee80211_aes_encrypt(tfm, b_0, e);
85 for (i = 0; i < blen; i++)
86 *cpos++ = *pos++ ^ e[i];
87 }
88
89 for (i = 0; i < CCMP_MIC_LEN; i++)
90 mic[i] = b[i] ^ s_0[i];
91}
92
93
94int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
95 u8 *b_0, u8 *aad, u8 *cdata, size_t data_len,
96 u8 *mic, u8 *data)
97{
98 int i, j, last_len, num_blocks;
99 u8 *pos, *cpos, *b, *s_0, *a;
100
101 b = scratch;
102 s_0 = scratch + AES_BLOCK_LEN;
103 a = scratch + 2 * AES_BLOCK_LEN;
104
105 num_blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
106 last_len = data_len % AES_BLOCK_LEN;
107 aes_ccm_prepare(tfm, b_0, aad, b, s_0, a);
108
109 /* Process payload blocks */
110 cpos = cdata;
111 pos = data;
112 for (j = 1; j <= num_blocks; j++) {
113 int blen = (j == num_blocks && last_len) ?
114 last_len : AES_BLOCK_LEN;
115
116 /* Decryption followed by authentication */
117 b_0[14] = (j >> 8) & 0xff;
118 b_0[15] = j & 0xff;
119 ieee80211_aes_encrypt(tfm, b_0, b);
120 for (i = 0; i < blen; i++) {
121 *pos = *cpos++ ^ b[i];
122 a[i] ^= *pos++;
123 }
124
125 ieee80211_aes_encrypt(tfm, a, a);
126 }
127
128 for (i = 0; i < CCMP_MIC_LEN; i++) {
129 if ((mic[i] ^ s_0[i]) != a[i])
130 return -1;
131 }
132
133 return 0;
134}
135
136
137struct crypto_cipher * ieee80211_aes_key_setup_encrypt(const u8 key[])
138{
139 struct crypto_cipher *tfm;
140
141 tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
142 if (IS_ERR(tfm))
143 return NULL;
144
145 crypto_cipher_setkey(tfm, key, ALG_CCMP_KEY_LEN);
146
147 return tfm;
148}
149
150
151void ieee80211_aes_key_free(struct crypto_cipher *tfm)
152{
153 if (tfm)
154 crypto_free_cipher(tfm);
155}
diff --git a/net/mac80211/aes_ccm.h b/net/mac80211/aes_ccm.h
new file mode 100644
index 000000000000..885f19030b29
--- /dev/null
+++ b/net/mac80211/aes_ccm.h
@@ -0,0 +1,26 @@
1/*
2 * Copyright 2003-2004, Instant802 Networks, Inc.
3 * Copyright 2006, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef AES_CCM_H
11#define AES_CCM_H
12
13#include <linux/crypto.h>
14
15#define AES_BLOCK_LEN 16
16
17struct crypto_cipher * ieee80211_aes_key_setup_encrypt(const u8 key[]);
18void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
19 u8 *b_0, u8 *aad, u8 *data, size_t data_len,
20 u8 *cdata, u8 *mic);
21int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
22 u8 *b_0, u8 *aad, u8 *cdata, size_t data_len,
23 u8 *mic, u8 *data);
24void ieee80211_aes_key_free(struct crypto_cipher *tfm);
25
26#endif /* AES_CCM_H */
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
new file mode 100644
index 000000000000..bb6c0feb2d48
--- /dev/null
+++ b/net/mac80211/debugfs.c
@@ -0,0 +1,433 @@
1/*
2 * mac80211 debugfs for wireless PHYs
3 *
4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * GPLv2
7 *
8 */
9
10#include <linux/debugfs.h>
11#include <linux/rtnetlink.h>
12#include "ieee80211_i.h"
13#include "ieee80211_rate.h"
14#include "debugfs.h"
15
16int mac80211_open_file_generic(struct inode *inode, struct file *file)
17{
18 file->private_data = inode->i_private;
19 return 0;
20}
21
22static const char *ieee80211_mode_str(int mode)
23{
24 switch (mode) {
25 case MODE_IEEE80211A:
26 return "IEEE 802.11a";
27 case MODE_IEEE80211B:
28 return "IEEE 802.11b";
29 case MODE_IEEE80211G:
30 return "IEEE 802.11g";
31 case MODE_ATHEROS_TURBO:
32 return "Atheros Turbo (5 GHz)";
33 default:
34 return "UNKNOWN";
35 }
36}
37
38static ssize_t modes_read(struct file *file, char __user *userbuf,
39 size_t count, loff_t *ppos)
40{
41 struct ieee80211_local *local = file->private_data;
42 struct ieee80211_hw_mode *mode;
43 char buf[150], *p = buf;
44
45 /* FIXME: locking! */
46 list_for_each_entry(mode, &local->modes_list, list) {
47 p += scnprintf(p, sizeof(buf)+buf-p,
48 "%s\n", ieee80211_mode_str(mode->mode));
49 }
50
51 return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf);
52}
53
54static const struct file_operations modes_ops = {
55 .read = modes_read,
56 .open = mac80211_open_file_generic,
57};
58
59#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
60static ssize_t name## _read(struct file *file, char __user *userbuf, \
61 size_t count, loff_t *ppos) \
62{ \
63 struct ieee80211_local *local = file->private_data; \
64 char buf[buflen]; \
65 int res; \
66 \
67 res = scnprintf(buf, buflen, fmt "\n", ##value); \
68 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
69} \
70 \
71static const struct file_operations name## _ops = { \
72 .read = name## _read, \
73 .open = mac80211_open_file_generic, \
74};
75
76#define DEBUGFS_ADD(name) \
77 local->debugfs.name = debugfs_create_file(#name, 0444, phyd, \
78 local, &name## _ops);
79
80#define DEBUGFS_DEL(name) \
81 debugfs_remove(local->debugfs.name); \
82 local->debugfs.name = NULL;
83
84
85DEBUGFS_READONLY_FILE(channel, 20, "%d",
86 local->hw.conf.channel);
87DEBUGFS_READONLY_FILE(frequency, 20, "%d",
88 local->hw.conf.freq);
89DEBUGFS_READONLY_FILE(radar_detect, 20, "%d",
90 local->hw.conf.radar_detect);
91DEBUGFS_READONLY_FILE(antenna_sel_tx, 20, "%d",
92 local->hw.conf.antenna_sel_tx);
93DEBUGFS_READONLY_FILE(antenna_sel_rx, 20, "%d",
94 local->hw.conf.antenna_sel_rx);
95DEBUGFS_READONLY_FILE(bridge_packets, 20, "%d",
96 local->bridge_packets);
97DEBUGFS_READONLY_FILE(key_tx_rx_threshold, 20, "%d",
98 local->key_tx_rx_threshold);
99DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
100 local->rts_threshold);
101DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d",
102 local->fragmentation_threshold);
103DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d",
104 local->short_retry_limit);
105DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d",
106 local->long_retry_limit);
107DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d",
108 local->total_ps_buffered);
109DEBUGFS_READONLY_FILE(mode, 20, "%s",
110 ieee80211_mode_str(local->hw.conf.phymode));
111DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x",
112 local->wep_iv & 0xffffff);
113DEBUGFS_READONLY_FILE(tx_power_reduction, 20, "%d.%d dBm",
114 local->hw.conf.tx_power_reduction / 10,
115 local->hw.conf.tx_power_reduction & 10);
116DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s",
117 local->rate_ctrl ? local->rate_ctrl->ops->name : "<unset>");
118
119/* statistics stuff */
120
121static inline int rtnl_lock_local(struct ieee80211_local *local)
122{
123 rtnl_lock();
124 if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) {
125 rtnl_unlock();
126 return -ENODEV;
127 }
128 return 0;
129}
130
131#define DEBUGFS_STATS_FILE(name, buflen, fmt, value...) \
132 DEBUGFS_READONLY_FILE(stats_ ##name, buflen, fmt, ##value)
133
134static ssize_t format_devstat_counter(struct ieee80211_local *local,
135 char __user *userbuf,
136 size_t count, loff_t *ppos,
137 int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf,
138 int buflen))
139{
140 struct ieee80211_low_level_stats stats;
141 char buf[20];
142 int res;
143
144 if (!local->ops->get_stats)
145 return -EOPNOTSUPP;
146
147 res = rtnl_lock_local(local);
148 if (res)
149 return res;
150
151 res = local->ops->get_stats(local_to_hw(local), &stats);
152 rtnl_unlock();
153 if (!res)
154 res = printvalue(&stats, buf, sizeof(buf));
155 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
156}
157
158#define DEBUGFS_DEVSTATS_FILE(name) \
159static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\
160 char *buf, int buflen) \
161{ \
162 return scnprintf(buf, buflen, "%u\n", stats->name); \
163} \
164static ssize_t stats_ ##name## _read(struct file *file, \
165 char __user *userbuf, \
166 size_t count, loff_t *ppos) \
167{ \
168 return format_devstat_counter(file->private_data, \
169 userbuf, \
170 count, \
171 ppos, \
172 print_devstats_##name); \
173} \
174 \
175static const struct file_operations stats_ ##name## _ops = { \
176 .read = stats_ ##name## _read, \
177 .open = mac80211_open_file_generic, \
178};
179
180#define DEBUGFS_STATS_ADD(name) \
181 local->debugfs.stats.name = debugfs_create_file(#name, 0444, statsd,\
182 local, &stats_ ##name## _ops);
183
184#define DEBUGFS_STATS_DEL(name) \
185 debugfs_remove(local->debugfs.stats.name); \
186 local->debugfs.stats.name = NULL;
187
188DEBUGFS_STATS_FILE(transmitted_fragment_count, 20, "%u",
189 local->dot11TransmittedFragmentCount);
190DEBUGFS_STATS_FILE(multicast_transmitted_frame_count, 20, "%u",
191 local->dot11MulticastTransmittedFrameCount);
192DEBUGFS_STATS_FILE(failed_count, 20, "%u",
193 local->dot11FailedCount);
194DEBUGFS_STATS_FILE(retry_count, 20, "%u",
195 local->dot11RetryCount);
196DEBUGFS_STATS_FILE(multiple_retry_count, 20, "%u",
197 local->dot11MultipleRetryCount);
198DEBUGFS_STATS_FILE(frame_duplicate_count, 20, "%u",
199 local->dot11FrameDuplicateCount);
200DEBUGFS_STATS_FILE(received_fragment_count, 20, "%u",
201 local->dot11ReceivedFragmentCount);
202DEBUGFS_STATS_FILE(multicast_received_frame_count, 20, "%u",
203 local->dot11MulticastReceivedFrameCount);
204DEBUGFS_STATS_FILE(transmitted_frame_count, 20, "%u",
205 local->dot11TransmittedFrameCount);
206DEBUGFS_STATS_FILE(wep_undecryptable_count, 20, "%u",
207 local->dot11WEPUndecryptableCount);
208#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
209DEBUGFS_STATS_FILE(tx_handlers_drop, 20, "%u",
210 local->tx_handlers_drop);
211DEBUGFS_STATS_FILE(tx_handlers_queued, 20, "%u",
212 local->tx_handlers_queued);
213DEBUGFS_STATS_FILE(tx_handlers_drop_unencrypted, 20, "%u",
214 local->tx_handlers_drop_unencrypted);
215DEBUGFS_STATS_FILE(tx_handlers_drop_fragment, 20, "%u",
216 local->tx_handlers_drop_fragment);
217DEBUGFS_STATS_FILE(tx_handlers_drop_wep, 20, "%u",
218 local->tx_handlers_drop_wep);
219DEBUGFS_STATS_FILE(tx_handlers_drop_not_assoc, 20, "%u",
220 local->tx_handlers_drop_not_assoc);
221DEBUGFS_STATS_FILE(tx_handlers_drop_unauth_port, 20, "%u",
222 local->tx_handlers_drop_unauth_port);
223DEBUGFS_STATS_FILE(rx_handlers_drop, 20, "%u",
224 local->rx_handlers_drop);
225DEBUGFS_STATS_FILE(rx_handlers_queued, 20, "%u",
226 local->rx_handlers_queued);
227DEBUGFS_STATS_FILE(rx_handlers_drop_nullfunc, 20, "%u",
228 local->rx_handlers_drop_nullfunc);
229DEBUGFS_STATS_FILE(rx_handlers_drop_defrag, 20, "%u",
230 local->rx_handlers_drop_defrag);
231DEBUGFS_STATS_FILE(rx_handlers_drop_short, 20, "%u",
232 local->rx_handlers_drop_short);
233DEBUGFS_STATS_FILE(rx_handlers_drop_passive_scan, 20, "%u",
234 local->rx_handlers_drop_passive_scan);
235DEBUGFS_STATS_FILE(tx_expand_skb_head, 20, "%u",
236 local->tx_expand_skb_head);
237DEBUGFS_STATS_FILE(tx_expand_skb_head_cloned, 20, "%u",
238 local->tx_expand_skb_head_cloned);
239DEBUGFS_STATS_FILE(rx_expand_skb_head, 20, "%u",
240 local->rx_expand_skb_head);
241DEBUGFS_STATS_FILE(rx_expand_skb_head2, 20, "%u",
242 local->rx_expand_skb_head2);
243DEBUGFS_STATS_FILE(rx_handlers_fragments, 20, "%u",
244 local->rx_handlers_fragments);
245DEBUGFS_STATS_FILE(tx_status_drop, 20, "%u",
246 local->tx_status_drop);
247
248static ssize_t stats_wme_rx_queue_read(struct file *file,
249 char __user *userbuf,
250 size_t count, loff_t *ppos)
251{
252 struct ieee80211_local *local = file->private_data;
253 char buf[NUM_RX_DATA_QUEUES*15], *p = buf;
254 int i;
255
256 for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
257 p += scnprintf(p, sizeof(buf)+buf-p,
258 "%u\n", local->wme_rx_queue[i]);
259
260 return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf);
261}
262
263static const struct file_operations stats_wme_rx_queue_ops = {
264 .read = stats_wme_rx_queue_read,
265 .open = mac80211_open_file_generic,
266};
267
268static ssize_t stats_wme_tx_queue_read(struct file *file,
269 char __user *userbuf,
270 size_t count, loff_t *ppos)
271{
272 struct ieee80211_local *local = file->private_data;
273 char buf[NUM_TX_DATA_QUEUES*15], *p = buf;
274 int i;
275
276 for (i = 0; i < NUM_TX_DATA_QUEUES; i++)
277 p += scnprintf(p, sizeof(buf)+buf-p,
278 "%u\n", local->wme_tx_queue[i]);
279
280 return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf);
281}
282
283static const struct file_operations stats_wme_tx_queue_ops = {
284 .read = stats_wme_tx_queue_read,
285 .open = mac80211_open_file_generic,
286};
287#endif
288
289DEBUGFS_DEVSTATS_FILE(dot11ACKFailureCount);
290DEBUGFS_DEVSTATS_FILE(dot11RTSFailureCount);
291DEBUGFS_DEVSTATS_FILE(dot11FCSErrorCount);
292DEBUGFS_DEVSTATS_FILE(dot11RTSSuccessCount);
293
294
295void debugfs_hw_add(struct ieee80211_local *local)
296{
297 struct dentry *phyd = local->hw.wiphy->debugfsdir;
298 struct dentry *statsd;
299
300 if (!phyd)
301 return;
302
303 local->debugfs.stations = debugfs_create_dir("stations", phyd);
304 local->debugfs.keys = debugfs_create_dir("keys", phyd);
305
306 DEBUGFS_ADD(channel);
307 DEBUGFS_ADD(frequency);
308 DEBUGFS_ADD(radar_detect);
309 DEBUGFS_ADD(antenna_sel_tx);
310 DEBUGFS_ADD(antenna_sel_rx);
311 DEBUGFS_ADD(bridge_packets);
312 DEBUGFS_ADD(key_tx_rx_threshold);
313 DEBUGFS_ADD(rts_threshold);
314 DEBUGFS_ADD(fragmentation_threshold);
315 DEBUGFS_ADD(short_retry_limit);
316 DEBUGFS_ADD(long_retry_limit);
317 DEBUGFS_ADD(total_ps_buffered);
318 DEBUGFS_ADD(mode);
319 DEBUGFS_ADD(wep_iv);
320 DEBUGFS_ADD(tx_power_reduction);
321 DEBUGFS_ADD(modes);
322
323 statsd = debugfs_create_dir("statistics", phyd);
324 local->debugfs.statistics = statsd;
325
326 /* if the dir failed, don't put all the other things into the root! */
327 if (!statsd)
328 return;
329
330 DEBUGFS_STATS_ADD(transmitted_fragment_count);
331 DEBUGFS_STATS_ADD(multicast_transmitted_frame_count);
332 DEBUGFS_STATS_ADD(failed_count);
333 DEBUGFS_STATS_ADD(retry_count);
334 DEBUGFS_STATS_ADD(multiple_retry_count);
335 DEBUGFS_STATS_ADD(frame_duplicate_count);
336 DEBUGFS_STATS_ADD(received_fragment_count);
337 DEBUGFS_STATS_ADD(multicast_received_frame_count);
338 DEBUGFS_STATS_ADD(transmitted_frame_count);
339 DEBUGFS_STATS_ADD(wep_undecryptable_count);
340#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
341 DEBUGFS_STATS_ADD(tx_handlers_drop);
342 DEBUGFS_STATS_ADD(tx_handlers_queued);
343 DEBUGFS_STATS_ADD(tx_handlers_drop_unencrypted);
344 DEBUGFS_STATS_ADD(tx_handlers_drop_fragment);
345 DEBUGFS_STATS_ADD(tx_handlers_drop_wep);
346 DEBUGFS_STATS_ADD(tx_handlers_drop_not_assoc);
347 DEBUGFS_STATS_ADD(tx_handlers_drop_unauth_port);
348 DEBUGFS_STATS_ADD(rx_handlers_drop);
349 DEBUGFS_STATS_ADD(rx_handlers_queued);
350 DEBUGFS_STATS_ADD(rx_handlers_drop_nullfunc);
351 DEBUGFS_STATS_ADD(rx_handlers_drop_defrag);
352 DEBUGFS_STATS_ADD(rx_handlers_drop_short);
353 DEBUGFS_STATS_ADD(rx_handlers_drop_passive_scan);
354 DEBUGFS_STATS_ADD(tx_expand_skb_head);
355 DEBUGFS_STATS_ADD(tx_expand_skb_head_cloned);
356 DEBUGFS_STATS_ADD(rx_expand_skb_head);
357 DEBUGFS_STATS_ADD(rx_expand_skb_head2);
358 DEBUGFS_STATS_ADD(rx_handlers_fragments);
359 DEBUGFS_STATS_ADD(tx_status_drop);
360 DEBUGFS_STATS_ADD(wme_tx_queue);
361 DEBUGFS_STATS_ADD(wme_rx_queue);
362#endif
363 DEBUGFS_STATS_ADD(dot11ACKFailureCount);
364 DEBUGFS_STATS_ADD(dot11RTSFailureCount);
365 DEBUGFS_STATS_ADD(dot11FCSErrorCount);
366 DEBUGFS_STATS_ADD(dot11RTSSuccessCount);
367}
368
369void debugfs_hw_del(struct ieee80211_local *local)
370{
371 DEBUGFS_DEL(channel);
372 DEBUGFS_DEL(frequency);
373 DEBUGFS_DEL(radar_detect);
374 DEBUGFS_DEL(antenna_sel_tx);
375 DEBUGFS_DEL(antenna_sel_rx);
376 DEBUGFS_DEL(bridge_packets);
377 DEBUGFS_DEL(key_tx_rx_threshold);
378 DEBUGFS_DEL(rts_threshold);
379 DEBUGFS_DEL(fragmentation_threshold);
380 DEBUGFS_DEL(short_retry_limit);
381 DEBUGFS_DEL(long_retry_limit);
382 DEBUGFS_DEL(total_ps_buffered);
383 DEBUGFS_DEL(mode);
384 DEBUGFS_DEL(wep_iv);
385 DEBUGFS_DEL(tx_power_reduction);
386 DEBUGFS_DEL(modes);
387
388 DEBUGFS_STATS_DEL(transmitted_fragment_count);
389 DEBUGFS_STATS_DEL(multicast_transmitted_frame_count);
390 DEBUGFS_STATS_DEL(failed_count);
391 DEBUGFS_STATS_DEL(retry_count);
392 DEBUGFS_STATS_DEL(multiple_retry_count);
393 DEBUGFS_STATS_DEL(frame_duplicate_count);
394 DEBUGFS_STATS_DEL(received_fragment_count);
395 DEBUGFS_STATS_DEL(multicast_received_frame_count);
396 DEBUGFS_STATS_DEL(transmitted_frame_count);
397 DEBUGFS_STATS_DEL(wep_undecryptable_count);
398 DEBUGFS_STATS_DEL(num_scans);
399#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
400 DEBUGFS_STATS_DEL(tx_handlers_drop);
401 DEBUGFS_STATS_DEL(tx_handlers_queued);
402 DEBUGFS_STATS_DEL(tx_handlers_drop_unencrypted);
403 DEBUGFS_STATS_DEL(tx_handlers_drop_fragment);
404 DEBUGFS_STATS_DEL(tx_handlers_drop_wep);
405 DEBUGFS_STATS_DEL(tx_handlers_drop_not_assoc);
406 DEBUGFS_STATS_DEL(tx_handlers_drop_unauth_port);
407 DEBUGFS_STATS_DEL(rx_handlers_drop);
408 DEBUGFS_STATS_DEL(rx_handlers_queued);
409 DEBUGFS_STATS_DEL(rx_handlers_drop_nullfunc);
410 DEBUGFS_STATS_DEL(rx_handlers_drop_defrag);
411 DEBUGFS_STATS_DEL(rx_handlers_drop_short);
412 DEBUGFS_STATS_DEL(rx_handlers_drop_passive_scan);
413 DEBUGFS_STATS_DEL(tx_expand_skb_head);
414 DEBUGFS_STATS_DEL(tx_expand_skb_head_cloned);
415 DEBUGFS_STATS_DEL(rx_expand_skb_head);
416 DEBUGFS_STATS_DEL(rx_expand_skb_head2);
417 DEBUGFS_STATS_DEL(rx_handlers_fragments);
418 DEBUGFS_STATS_DEL(tx_status_drop);
419 DEBUGFS_STATS_DEL(wme_tx_queue);
420 DEBUGFS_STATS_DEL(wme_rx_queue);
421#endif
422 DEBUGFS_STATS_DEL(dot11ACKFailureCount);
423 DEBUGFS_STATS_DEL(dot11RTSFailureCount);
424 DEBUGFS_STATS_DEL(dot11FCSErrorCount);
425 DEBUGFS_STATS_DEL(dot11RTSSuccessCount);
426
427 debugfs_remove(local->debugfs.statistics);
428 local->debugfs.statistics = NULL;
429 debugfs_remove(local->debugfs.stations);
430 local->debugfs.stations = NULL;
431 debugfs_remove(local->debugfs.keys);
432 local->debugfs.keys = NULL;
433}
diff --git a/net/mac80211/debugfs.h b/net/mac80211/debugfs.h
new file mode 100644
index 000000000000..dd2541935c27
--- /dev/null
+++ b/net/mac80211/debugfs.h
@@ -0,0 +1,16 @@
1#ifndef __MAC80211_DEBUGFS_H
2#define __MAC80211_DEBUGFS_H
3
4#ifdef CONFIG_MAC80211_DEBUGFS
5extern void debugfs_hw_add(struct ieee80211_local *local);
6extern void debugfs_hw_del(struct ieee80211_local *local);
7extern int mac80211_open_file_generic(struct inode *inode, struct file *file);
8#else
9static inline void debugfs_hw_add(struct ieee80211_local *local)
10{
11 return;
12}
13static inline void debugfs_hw_del(struct ieee80211_local *local) {}
14#endif
15
16#endif /* __MAC80211_DEBUGFS_H */
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
new file mode 100644
index 000000000000..7d56dc9e7326
--- /dev/null
+++ b/net/mac80211/debugfs_key.c
@@ -0,0 +1,252 @@
1/*
2 * Copyright 2003-2005 Devicescape Software, Inc.
3 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kobject.h>
12#include "ieee80211_i.h"
13#include "ieee80211_key.h"
14#include "debugfs.h"
15#include "debugfs_key.h"
16
17#define KEY_READ(name, buflen, format_string) \
18static ssize_t key_##name##_read(struct file *file, \
19 char __user *userbuf, \
20 size_t count, loff_t *ppos) \
21{ \
22 char buf[buflen]; \
23 struct ieee80211_key *key = file->private_data; \
24 int res = scnprintf(buf, buflen, format_string, key->name); \
25 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
26}
27#define KEY_READ_D(name) KEY_READ(name, 20, "%d\n")
28
29#define KEY_OPS(name) \
30static const struct file_operations key_ ##name## _ops = { \
31 .read = key_##name##_read, \
32 .open = mac80211_open_file_generic, \
33}
34
35#define KEY_FILE(name, format) \
36 KEY_READ_##format(name) \
37 KEY_OPS(name)
38
39KEY_FILE(keylen, D);
40KEY_FILE(force_sw_encrypt, D);
41KEY_FILE(keyidx, D);
42KEY_FILE(hw_key_idx, D);
43KEY_FILE(tx_rx_count, D);
44
45static ssize_t key_algorithm_read(struct file *file,
46 char __user *userbuf,
47 size_t count, loff_t *ppos)
48{
49 char *alg;
50 struct ieee80211_key *key = file->private_data;
51
52 switch (key->alg) {
53 case ALG_WEP:
54 alg = "WEP\n";
55 break;
56 case ALG_TKIP:
57 alg = "TKIP\n";
58 break;
59 case ALG_CCMP:
60 alg = "CCMP\n";
61 break;
62 default:
63 return 0;
64 }
65 return simple_read_from_buffer(userbuf, count, ppos, alg, strlen(alg));
66}
67KEY_OPS(algorithm);
68
69static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
70 size_t count, loff_t *ppos)
71{
72 const u8 *tpn;
73 char buf[20];
74 int len;
75 struct ieee80211_key *key = file->private_data;
76
77 switch (key->alg) {
78 case ALG_WEP:
79 len = scnprintf(buf, sizeof(buf), "\n");
80 case ALG_TKIP:
81 len = scnprintf(buf, sizeof(buf), "%08x %04x\n",
82 key->u.tkip.iv32,
83 key->u.tkip.iv16);
84 case ALG_CCMP:
85 tpn = key->u.ccmp.tx_pn;
86 len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
87 tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]);
88 default:
89 return 0;
90 }
91 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
92}
93KEY_OPS(tx_spec);
94
95static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
96 size_t count, loff_t *ppos)
97{
98 struct ieee80211_key *key = file->private_data;
99 char buf[14*NUM_RX_DATA_QUEUES+1], *p = buf;
100 int i, len;
101 const u8 *rpn;
102
103 switch (key->alg) {
104 case ALG_WEP:
105 len = scnprintf(buf, sizeof(buf), "\n");
106 case ALG_TKIP:
107 for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
108 p += scnprintf(p, sizeof(buf)+buf-p,
109 "%08x %04x\n",
110 key->u.tkip.iv32_rx[i],
111 key->u.tkip.iv16_rx[i]);
112 len = p - buf;
113 case ALG_CCMP:
114 for (i = 0; i < NUM_RX_DATA_QUEUES; i++) {
115 rpn = key->u.ccmp.rx_pn[i];
116 p += scnprintf(p, sizeof(buf)+buf-p,
117 "%02x%02x%02x%02x%02x%02x\n",
118 rpn[0], rpn[1], rpn[2],
119 rpn[3], rpn[4], rpn[5]);
120 }
121 len = p - buf;
122 default:
123 return 0;
124 }
125 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
126}
127KEY_OPS(rx_spec);
128
129static ssize_t key_replays_read(struct file *file, char __user *userbuf,
130 size_t count, loff_t *ppos)
131{
132 struct ieee80211_key *key = file->private_data;
133 char buf[20];
134 int len;
135
136 if (key->alg != ALG_CCMP)
137 return 0;
138 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
139 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
140}
141KEY_OPS(replays);
142
143static ssize_t key_key_read(struct file *file, char __user *userbuf,
144 size_t count, loff_t *ppos)
145{
146 struct ieee80211_key *key = file->private_data;
147 int i, res, bufsize = 2*key->keylen+2;
148 char *buf = kmalloc(bufsize, GFP_KERNEL);
149 char *p = buf;
150
151 for (i = 0; i < key->keylen; i++)
152 p += scnprintf(p, bufsize+buf-p, "%02x", key->key[i]);
153 p += scnprintf(p, bufsize+buf-p, "\n");
154 res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
155 kfree(buf);
156 return res;
157}
158KEY_OPS(key);
159
160#define DEBUGFS_ADD(name) \
161 key->debugfs.name = debugfs_create_file(#name, 0400,\
162 key->debugfs.dir, key, &key_##name##_ops);
163
164void ieee80211_debugfs_key_add(struct ieee80211_local *local,
165 struct ieee80211_key *key)
166{
167 char buf[20];
168
169 if (!local->debugfs.keys)
170 return;
171
172 sprintf(buf, "%d", key->keyidx);
173 key->debugfs.dir = debugfs_create_dir(buf,
174 local->debugfs.keys);
175
176 if (!key->debugfs.dir)
177 return;
178
179 DEBUGFS_ADD(keylen);
180 DEBUGFS_ADD(force_sw_encrypt);
181 DEBUGFS_ADD(keyidx);
182 DEBUGFS_ADD(hw_key_idx);
183 DEBUGFS_ADD(tx_rx_count);
184 DEBUGFS_ADD(algorithm);
185 DEBUGFS_ADD(tx_spec);
186 DEBUGFS_ADD(rx_spec);
187 DEBUGFS_ADD(replays);
188 DEBUGFS_ADD(key);
189};
190
191#define DEBUGFS_DEL(name) \
192 debugfs_remove(key->debugfs.name); key->debugfs.name = NULL;
193
194void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
195{
196 if (!key)
197 return;
198
199 DEBUGFS_DEL(keylen);
200 DEBUGFS_DEL(force_sw_encrypt);
201 DEBUGFS_DEL(keyidx);
202 DEBUGFS_DEL(hw_key_idx);
203 DEBUGFS_DEL(tx_rx_count);
204 DEBUGFS_DEL(algorithm);
205 DEBUGFS_DEL(tx_spec);
206 DEBUGFS_DEL(rx_spec);
207 DEBUGFS_DEL(replays);
208 DEBUGFS_DEL(key);
209
210 debugfs_remove(key->debugfs.stalink);
211 key->debugfs.stalink = NULL;
212 debugfs_remove(key->debugfs.dir);
213 key->debugfs.dir = NULL;
214}
215void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
216{
217 char buf[50];
218
219 if (!sdata->debugfsdir)
220 return;
221
222 sprintf(buf, "../keys/%d", sdata->default_key->keyidx);
223 sdata->debugfs.default_key =
224 debugfs_create_symlink("default_key", sdata->debugfsdir, buf);
225}
226void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata)
227{
228 if (!sdata)
229 return;
230
231 debugfs_remove(sdata->debugfs.default_key);
232 sdata->debugfs.default_key = NULL;
233}
234void ieee80211_debugfs_key_sta_link(struct ieee80211_key *key,
235 struct sta_info *sta)
236{
237 char buf[50];
238
239 if (!key->debugfs.dir)
240 return;
241
242 sprintf(buf, "../sta/" MAC_FMT, MAC_ARG(sta->addr));
243 key->debugfs.stalink =
244 debugfs_create_symlink("station", key->debugfs.dir, buf);
245}
246
247void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
248 struct sta_info *sta)
249{
250 debugfs_remove(key->debugfs.stalink);
251 key->debugfs.stalink = NULL;
252}
diff --git a/net/mac80211/debugfs_key.h b/net/mac80211/debugfs_key.h
new file mode 100644
index 000000000000..aecfce395da6
--- /dev/null
+++ b/net/mac80211/debugfs_key.h
@@ -0,0 +1,34 @@
1#ifndef __MAC80211_DEBUGFS_KEY_H
2#define __MAC80211_DEBUGFS_KEY_H
3
4#ifdef CONFIG_MAC80211_DEBUGFS
5void ieee80211_debugfs_key_add(struct ieee80211_local *local,
6 struct ieee80211_key *key);
7void ieee80211_debugfs_key_remove(struct ieee80211_key *key);
8void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata);
9void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata);
10void ieee80211_debugfs_key_sta_link(struct ieee80211_key *key,
11 struct sta_info *sta);
12void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
13 struct sta_info *sta);
14#else
15static inline void ieee80211_debugfs_key_add(struct ieee80211_local *local,
16 struct ieee80211_key *key)
17{}
18static inline void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
19{}
20static inline void ieee80211_debugfs_key_add_default(
21 struct ieee80211_sub_if_data *sdata)
22{}
23static inline void ieee80211_debugfs_key_remove_default(
24 struct ieee80211_sub_if_data *sdata)
25{}
26static inline void ieee80211_debugfs_key_sta_link(
27 struct ieee80211_key *key, struct sta_info *sta)
28{}
29static inline void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
30 struct sta_info *sta)
31{}
32#endif
33
34#endif /* __MAC80211_DEBUGFS_KEY_H */
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
new file mode 100644
index 000000000000..9e3964638bad
--- /dev/null
+++ b/net/mac80211/debugfs_netdev.c
@@ -0,0 +1,440 @@
1/*
2 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
3 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/kernel.h>
11#include <linux/device.h>
12#include <linux/if.h>
13#include <linux/interrupt.h>
14#include <linux/netdevice.h>
15#include <linux/rtnetlink.h>
16#include <linux/notifier.h>
17#include <net/mac80211.h>
18#include <net/cfg80211.h>
19#include "ieee80211_i.h"
20#include "ieee80211_rate.h"
21#include "debugfs.h"
22#include "debugfs_netdev.h"
23
24static ssize_t ieee80211_if_read(
25 struct ieee80211_sub_if_data *sdata,
26 char __user *userbuf,
27 size_t count, loff_t *ppos,
28 ssize_t (*format)(const struct ieee80211_sub_if_data *, char *, int))
29{
30 char buf[70];
31 ssize_t ret = -EINVAL;
32
33 read_lock(&dev_base_lock);
34 if (sdata->dev->reg_state == NETREG_REGISTERED) {
35 ret = (*format)(sdata, buf, sizeof(buf));
36 ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret);
37 }
38 read_unlock(&dev_base_lock);
39 return ret;
40}
41
42#define IEEE80211_IF_FMT(name, field, format_string) \
43static ssize_t ieee80211_if_fmt_##name( \
44 const struct ieee80211_sub_if_data *sdata, char *buf, \
45 int buflen) \
46{ \
47 return scnprintf(buf, buflen, format_string, sdata->field); \
48}
49#define IEEE80211_IF_FMT_DEC(name, field) \
50 IEEE80211_IF_FMT(name, field, "%d\n")
51#define IEEE80211_IF_FMT_HEX(name, field) \
52 IEEE80211_IF_FMT(name, field, "%#x\n")
53#define IEEE80211_IF_FMT_SIZE(name, field) \
54 IEEE80211_IF_FMT(name, field, "%zd\n")
55
56#define IEEE80211_IF_FMT_ATOMIC(name, field) \
57static ssize_t ieee80211_if_fmt_##name( \
58 const struct ieee80211_sub_if_data *sdata, \
59 char *buf, int buflen) \
60{ \
61 return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\
62}
63
64#define IEEE80211_IF_FMT_MAC(name, field) \
65static ssize_t ieee80211_if_fmt_##name( \
66 const struct ieee80211_sub_if_data *sdata, char *buf, \
67 int buflen) \
68{ \
69 return scnprintf(buf, buflen, MAC_FMT "\n", MAC_ARG(sdata->field));\
70}
71
72#define __IEEE80211_IF_FILE(name) \
73static ssize_t ieee80211_if_read_##name(struct file *file, \
74 char __user *userbuf, \
75 size_t count, loff_t *ppos) \
76{ \
77 return ieee80211_if_read(file->private_data, \
78 userbuf, count, ppos, \
79 ieee80211_if_fmt_##name); \
80} \
81static const struct file_operations name##_ops = { \
82 .read = ieee80211_if_read_##name, \
83 .open = mac80211_open_file_generic, \
84}
85
86#define IEEE80211_IF_FILE(name, field, format) \
87 IEEE80211_IF_FMT_##format(name, field) \
88 __IEEE80211_IF_FILE(name)
89
90/* common attributes */
91IEEE80211_IF_FILE(channel_use, channel_use, DEC);
92IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
93IEEE80211_IF_FILE(eapol, eapol, DEC);
94IEEE80211_IF_FILE(ieee8021_x, ieee802_1x, DEC);
95
96/* STA/IBSS attributes */
97IEEE80211_IF_FILE(state, u.sta.state, DEC);
98IEEE80211_IF_FILE(bssid, u.sta.bssid, MAC);
99IEEE80211_IF_FILE(prev_bssid, u.sta.prev_bssid, MAC);
100IEEE80211_IF_FILE(ssid_len, u.sta.ssid_len, SIZE);
101IEEE80211_IF_FILE(aid, u.sta.aid, DEC);
102IEEE80211_IF_FILE(ap_capab, u.sta.ap_capab, HEX);
103IEEE80211_IF_FILE(capab, u.sta.capab, HEX);
104IEEE80211_IF_FILE(extra_ie_len, u.sta.extra_ie_len, SIZE);
105IEEE80211_IF_FILE(auth_tries, u.sta.auth_tries, DEC);
106IEEE80211_IF_FILE(assoc_tries, u.sta.assoc_tries, DEC);
107IEEE80211_IF_FILE(auth_algs, u.sta.auth_algs, HEX);
108IEEE80211_IF_FILE(auth_alg, u.sta.auth_alg, DEC);
109IEEE80211_IF_FILE(auth_transaction, u.sta.auth_transaction, DEC);
110
111static ssize_t ieee80211_if_fmt_flags(
112 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
113{
114 return scnprintf(buf, buflen, "%s%s%s%s%s%s%s\n",
115 sdata->u.sta.ssid_set ? "SSID\n" : "",
116 sdata->u.sta.bssid_set ? "BSSID\n" : "",
117 sdata->u.sta.prev_bssid_set ? "prev BSSID\n" : "",
118 sdata->u.sta.authenticated ? "AUTH\n" : "",
119 sdata->u.sta.associated ? "ASSOC\n" : "",
120 sdata->u.sta.probereq_poll ? "PROBEREQ POLL\n" : "",
121 sdata->u.sta.use_protection ? "CTS prot\n" : "");
122}
123__IEEE80211_IF_FILE(flags);
124
125/* AP attributes */
126IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
127IEEE80211_IF_FILE(dtim_period, u.ap.dtim_period, DEC);
128IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC);
129IEEE80211_IF_FILE(num_beacons, u.ap.num_beacons, DEC);
130IEEE80211_IF_FILE(force_unicast_rateidx, u.ap.force_unicast_rateidx, DEC);
131IEEE80211_IF_FILE(max_ratectrl_rateidx, u.ap.max_ratectrl_rateidx, DEC);
132
133static ssize_t ieee80211_if_fmt_num_buffered_multicast(
134 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
135{
136 return scnprintf(buf, buflen, "%u\n",
137 skb_queue_len(&sdata->u.ap.ps_bc_buf));
138}
139__IEEE80211_IF_FILE(num_buffered_multicast);
140
141static ssize_t ieee80211_if_fmt_beacon_head_len(
142 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
143{
144 if (sdata->u.ap.beacon_head)
145 return scnprintf(buf, buflen, "%d\n",
146 sdata->u.ap.beacon_head_len);
147 return scnprintf(buf, buflen, "\n");
148}
149__IEEE80211_IF_FILE(beacon_head_len);
150
151static ssize_t ieee80211_if_fmt_beacon_tail_len(
152 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
153{
154 if (sdata->u.ap.beacon_tail)
155 return scnprintf(buf, buflen, "%d\n",
156 sdata->u.ap.beacon_tail_len);
157 return scnprintf(buf, buflen, "\n");
158}
159__IEEE80211_IF_FILE(beacon_tail_len);
160
161/* WDS attributes */
162IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC);
163
164/* VLAN attributes */
165IEEE80211_IF_FILE(vlan_id, u.vlan.id, DEC);
166
167/* MONITOR attributes */
168static ssize_t ieee80211_if_fmt_mode(
169 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
170{
171 struct ieee80211_local *local = sdata->local;
172
173 return scnprintf(buf, buflen, "%s\n",
174 ((local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) ||
175 local->open_count == local->monitors) ?
176 "hard" : "soft");
177}
178__IEEE80211_IF_FILE(mode);
179
180
181#define DEBUGFS_ADD(name, type)\
182 sdata->debugfs.type.name = debugfs_create_file(#name, 0444,\
183 sdata->debugfsdir, sdata, &name##_ops);
184
185static void add_sta_files(struct ieee80211_sub_if_data *sdata)
186{
187 DEBUGFS_ADD(channel_use, sta);
188 DEBUGFS_ADD(drop_unencrypted, sta);
189 DEBUGFS_ADD(eapol, sta);
190 DEBUGFS_ADD(ieee8021_x, sta);
191 DEBUGFS_ADD(state, sta);
192 DEBUGFS_ADD(bssid, sta);
193 DEBUGFS_ADD(prev_bssid, sta);
194 DEBUGFS_ADD(ssid_len, sta);
195 DEBUGFS_ADD(aid, sta);
196 DEBUGFS_ADD(ap_capab, sta);
197 DEBUGFS_ADD(capab, sta);
198 DEBUGFS_ADD(extra_ie_len, sta);
199 DEBUGFS_ADD(auth_tries, sta);
200 DEBUGFS_ADD(assoc_tries, sta);
201 DEBUGFS_ADD(auth_algs, sta);
202 DEBUGFS_ADD(auth_alg, sta);
203 DEBUGFS_ADD(auth_transaction, sta);
204 DEBUGFS_ADD(flags, sta);
205}
206
207static void add_ap_files(struct ieee80211_sub_if_data *sdata)
208{
209 DEBUGFS_ADD(channel_use, ap);
210 DEBUGFS_ADD(drop_unencrypted, ap);
211 DEBUGFS_ADD(eapol, ap);
212 DEBUGFS_ADD(ieee8021_x, ap);
213 DEBUGFS_ADD(num_sta_ps, ap);
214 DEBUGFS_ADD(dtim_period, ap);
215 DEBUGFS_ADD(dtim_count, ap);
216 DEBUGFS_ADD(num_beacons, ap);
217 DEBUGFS_ADD(force_unicast_rateidx, ap);
218 DEBUGFS_ADD(max_ratectrl_rateidx, ap);
219 DEBUGFS_ADD(num_buffered_multicast, ap);
220 DEBUGFS_ADD(beacon_head_len, ap);
221 DEBUGFS_ADD(beacon_tail_len, ap);
222}
223
224static void add_wds_files(struct ieee80211_sub_if_data *sdata)
225{
226 DEBUGFS_ADD(channel_use, wds);
227 DEBUGFS_ADD(drop_unencrypted, wds);
228 DEBUGFS_ADD(eapol, wds);
229 DEBUGFS_ADD(ieee8021_x, wds);
230 DEBUGFS_ADD(peer, wds);
231}
232
233static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
234{
235 DEBUGFS_ADD(channel_use, vlan);
236 DEBUGFS_ADD(drop_unencrypted, vlan);
237 DEBUGFS_ADD(eapol, vlan);
238 DEBUGFS_ADD(ieee8021_x, vlan);
239 DEBUGFS_ADD(vlan_id, vlan);
240}
241
242static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
243{
244 DEBUGFS_ADD(mode, monitor);
245}
246
247static void add_files(struct ieee80211_sub_if_data *sdata)
248{
249 if (!sdata->debugfsdir)
250 return;
251
252 switch (sdata->type) {
253 case IEEE80211_IF_TYPE_STA:
254 case IEEE80211_IF_TYPE_IBSS:
255 add_sta_files(sdata);
256 break;
257 case IEEE80211_IF_TYPE_AP:
258 add_ap_files(sdata);
259 break;
260 case IEEE80211_IF_TYPE_WDS:
261 add_wds_files(sdata);
262 break;
263 case IEEE80211_IF_TYPE_MNTR:
264 add_monitor_files(sdata);
265 break;
266 case IEEE80211_IF_TYPE_VLAN:
267 add_vlan_files(sdata);
268 break;
269 default:
270 break;
271 }
272}
273
274#define DEBUGFS_DEL(name, type)\
275 debugfs_remove(sdata->debugfs.type.name);\
276 sdata->debugfs.type.name = NULL;
277
278static void del_sta_files(struct ieee80211_sub_if_data *sdata)
279{
280 DEBUGFS_DEL(channel_use, sta);
281 DEBUGFS_DEL(drop_unencrypted, sta);
282 DEBUGFS_DEL(eapol, sta);
283 DEBUGFS_DEL(ieee8021_x, sta);
284 DEBUGFS_DEL(state, sta);
285 DEBUGFS_DEL(bssid, sta);
286 DEBUGFS_DEL(prev_bssid, sta);
287 DEBUGFS_DEL(ssid_len, sta);
288 DEBUGFS_DEL(aid, sta);
289 DEBUGFS_DEL(ap_capab, sta);
290 DEBUGFS_DEL(capab, sta);
291 DEBUGFS_DEL(extra_ie_len, sta);
292 DEBUGFS_DEL(auth_tries, sta);
293 DEBUGFS_DEL(assoc_tries, sta);
294 DEBUGFS_DEL(auth_algs, sta);
295 DEBUGFS_DEL(auth_alg, sta);
296 DEBUGFS_DEL(auth_transaction, sta);
297 DEBUGFS_DEL(flags, sta);
298}
299
300static void del_ap_files(struct ieee80211_sub_if_data *sdata)
301{
302 DEBUGFS_DEL(channel_use, ap);
303 DEBUGFS_DEL(drop_unencrypted, ap);
304 DEBUGFS_DEL(eapol, ap);
305 DEBUGFS_DEL(ieee8021_x, ap);
306 DEBUGFS_DEL(num_sta_ps, ap);
307 DEBUGFS_DEL(dtim_period, ap);
308 DEBUGFS_DEL(dtim_count, ap);
309 DEBUGFS_DEL(num_beacons, ap);
310 DEBUGFS_DEL(force_unicast_rateidx, ap);
311 DEBUGFS_DEL(max_ratectrl_rateidx, ap);
312 DEBUGFS_DEL(num_buffered_multicast, ap);
313 DEBUGFS_DEL(beacon_head_len, ap);
314 DEBUGFS_DEL(beacon_tail_len, ap);
315}
316
317static void del_wds_files(struct ieee80211_sub_if_data *sdata)
318{
319 DEBUGFS_DEL(channel_use, wds);
320 DEBUGFS_DEL(drop_unencrypted, wds);
321 DEBUGFS_DEL(eapol, wds);
322 DEBUGFS_DEL(ieee8021_x, wds);
323 DEBUGFS_DEL(peer, wds);
324}
325
326static void del_vlan_files(struct ieee80211_sub_if_data *sdata)
327{
328 DEBUGFS_DEL(channel_use, vlan);
329 DEBUGFS_DEL(drop_unencrypted, vlan);
330 DEBUGFS_DEL(eapol, vlan);
331 DEBUGFS_DEL(ieee8021_x, vlan);
332 DEBUGFS_DEL(vlan_id, vlan);
333}
334
335static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
336{
337 DEBUGFS_DEL(mode, monitor);
338}
339
340static void del_files(struct ieee80211_sub_if_data *sdata, int type)
341{
342 if (!sdata->debugfsdir)
343 return;
344
345 switch (type) {
346 case IEEE80211_IF_TYPE_STA:
347 case IEEE80211_IF_TYPE_IBSS:
348 del_sta_files(sdata);
349 break;
350 case IEEE80211_IF_TYPE_AP:
351 del_ap_files(sdata);
352 break;
353 case IEEE80211_IF_TYPE_WDS:
354 del_wds_files(sdata);
355 break;
356 case IEEE80211_IF_TYPE_MNTR:
357 del_monitor_files(sdata);
358 break;
359 case IEEE80211_IF_TYPE_VLAN:
360 del_vlan_files(sdata);
361 break;
362 default:
363 break;
364 }
365}
366
367static int notif_registered;
368
369void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
370{
371 char buf[10+IFNAMSIZ];
372
373 if (!notif_registered)
374 return;
375
376 sprintf(buf, "netdev:%s", sdata->dev->name);
377 sdata->debugfsdir = debugfs_create_dir(buf,
378 sdata->local->hw.wiphy->debugfsdir);
379}
380
381void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
382{
383 del_files(sdata, sdata->type);
384 debugfs_remove(sdata->debugfsdir);
385 sdata->debugfsdir = NULL;
386}
387
388void ieee80211_debugfs_change_if_type(struct ieee80211_sub_if_data *sdata,
389 int oldtype)
390{
391 del_files(sdata, oldtype);
392 add_files(sdata);
393}
394
395static int netdev_notify(struct notifier_block * nb,
396 unsigned long state,
397 void *ndev)
398{
399 struct net_device *dev = ndev;
400 char buf[10+IFNAMSIZ];
401
402 if (state != NETDEV_CHANGENAME)
403 return 0;
404
405 if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy)
406 return 0;
407
408 if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
409 return 0;
410
411 /* TODO
412 sprintf(buf, "netdev:%s", dev->name);
413 debugfs_rename(IEEE80211_DEV_TO_SUB_IF(dev)->debugfsdir, buf);
414 */
415
416 return 0;
417}
418
419static struct notifier_block mac80211_debugfs_netdev_notifier = {
420 .notifier_call = netdev_notify,
421};
422
423void ieee80211_debugfs_netdev_init(void)
424{
425 int err;
426
427 err = register_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
428 if (err) {
429 printk(KERN_ERR
430 "mac80211: failed to install netdev notifier,"
431 " disabling per-netdev debugfs!\n");
432 } else
433 notif_registered = 1;
434}
435
436void ieee80211_debugfs_netdev_exit(void)
437{
438 unregister_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
439 notif_registered = 0;
440}
diff --git a/net/mac80211/debugfs_netdev.h b/net/mac80211/debugfs_netdev.h
new file mode 100644
index 000000000000..a690071fde8a
--- /dev/null
+++ b/net/mac80211/debugfs_netdev.h
@@ -0,0 +1,30 @@
1/* routines exported for debugfs handling */
2
3#ifndef __IEEE80211_DEBUGFS_NETDEV_H
4#define __IEEE80211_DEBUGFS_NETDEV_H
5
6#ifdef CONFIG_MAC80211_DEBUGFS
7void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata);
8void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata);
9void ieee80211_debugfs_change_if_type(struct ieee80211_sub_if_data *sdata,
10 int oldtype);
11void ieee80211_debugfs_netdev_init(void);
12void ieee80211_debugfs_netdev_exit(void);
13#else
14static inline void ieee80211_debugfs_add_netdev(
15 struct ieee80211_sub_if_data *sdata)
16{}
17static inline void ieee80211_debugfs_remove_netdev(
18 struct ieee80211_sub_if_data *sdata)
19{}
20static inline void ieee80211_debugfs_change_if_type(
21 struct ieee80211_sub_if_data *sdata, int oldtype)
22{}
23static inline void ieee80211_debugfs_netdev_init(void)
24{}
25
26static inline void ieee80211_debugfs_netdev_exit(void)
27{}
28#endif
29
30#endif /* __IEEE80211_DEBUGFS_NETDEV_H */
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
new file mode 100644
index 000000000000..d41e696f3980
--- /dev/null
+++ b/net/mac80211/debugfs_sta.c
@@ -0,0 +1,246 @@
1/*
2 * Copyright 2003-2005 Devicescape Software, Inc.
3 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/debugfs.h>
12#include <linux/ieee80211.h>
13#include "ieee80211_i.h"
14#include "debugfs.h"
15#include "debugfs_sta.h"
16#include "sta_info.h"
17
18/* sta attributtes */
19
20#define STA_READ(name, buflen, field, format_string) \
21static ssize_t sta_ ##name## _read(struct file *file, \
22 char __user *userbuf, \
23 size_t count, loff_t *ppos) \
24{ \
25 int res; \
26 struct sta_info *sta = file->private_data; \
27 char buf[buflen]; \
28 res = scnprintf(buf, buflen, format_string, sta->field); \
29 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
30}
31#define STA_READ_D(name, field) STA_READ(name, 20, field, "%d\n")
32#define STA_READ_U(name, field) STA_READ(name, 20, field, "%u\n")
33#define STA_READ_LU(name, field) STA_READ(name, 20, field, "%lu\n")
34#define STA_READ_S(name, field) STA_READ(name, 20, field, "%s\n")
35
36#define STA_READ_RATE(name, field) \
37static ssize_t sta_##name##_read(struct file *file, \
38 char __user *userbuf, \
39 size_t count, loff_t *ppos) \
40{ \
41 struct sta_info *sta = file->private_data; \
42 struct ieee80211_local *local = wdev_priv(sta->dev->ieee80211_ptr);\
43 struct ieee80211_hw_mode *mode = local->oper_hw_mode; \
44 char buf[20]; \
45 int res = scnprintf(buf, sizeof(buf), "%d\n", \
46 (sta->field >= 0 && \
47 sta->field < mode->num_rates) ? \
48 mode->rates[sta->field].rate : -1); \
49 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
50}
51
52#define STA_OPS(name) \
53static const struct file_operations sta_ ##name## _ops = { \
54 .read = sta_##name##_read, \
55 .open = mac80211_open_file_generic, \
56}
57
58#define STA_FILE(name, field, format) \
59 STA_READ_##format(name, field) \
60 STA_OPS(name)
61
62STA_FILE(aid, aid, D);
63STA_FILE(key_idx_compression, key_idx_compression, D);
64STA_FILE(dev, dev->name, S);
65STA_FILE(vlan_id, vlan_id, D);
66STA_FILE(rx_packets, rx_packets, LU);
67STA_FILE(tx_packets, tx_packets, LU);
68STA_FILE(rx_bytes, rx_bytes, LU);
69STA_FILE(tx_bytes, tx_bytes, LU);
70STA_FILE(rx_duplicates, num_duplicates, LU);
71STA_FILE(rx_fragments, rx_fragments, LU);
72STA_FILE(rx_dropped, rx_dropped, LU);
73STA_FILE(tx_fragments, tx_fragments, LU);
74STA_FILE(tx_filtered, tx_filtered_count, LU);
75STA_FILE(txrate, txrate, RATE);
76STA_FILE(last_txrate, last_txrate, RATE);
77STA_FILE(tx_retry_failed, tx_retry_failed, LU);
78STA_FILE(tx_retry_count, tx_retry_count, LU);
79STA_FILE(last_rssi, last_rssi, D);
80STA_FILE(last_signal, last_signal, D);
81STA_FILE(last_noise, last_noise, D);
82STA_FILE(channel_use, channel_use, D);
83STA_FILE(wep_weak_iv_count, wep_weak_iv_count, D);
84
85static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
86 size_t count, loff_t *ppos)
87{
88 char buf[100];
89 struct sta_info *sta = file->private_data;
90 int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
91 sta->flags & WLAN_STA_AUTH ? "AUTH\n" : "",
92 sta->flags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
93 sta->flags & WLAN_STA_PS ? "PS\n" : "",
94 sta->flags & WLAN_STA_TIM ? "TIM\n" : "",
95 sta->flags & WLAN_STA_PERM ? "PERM\n" : "",
96 sta->flags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
97 sta->flags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
98 sta->flags & WLAN_STA_WME ? "WME\n" : "",
99 sta->flags & WLAN_STA_WDS ? "WDS\n" : "");
100 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
101}
102STA_OPS(flags);
103
104static ssize_t sta_num_ps_buf_frames_read(struct file *file,
105 char __user *userbuf,
106 size_t count, loff_t *ppos)
107{
108 char buf[20];
109 struct sta_info *sta = file->private_data;
110 int res = scnprintf(buf, sizeof(buf), "%u\n",
111 skb_queue_len(&sta->ps_tx_buf));
112 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
113}
114STA_OPS(num_ps_buf_frames);
115
116static ssize_t sta_last_ack_rssi_read(struct file *file, char __user *userbuf,
117 size_t count, loff_t *ppos)
118{
119 char buf[100];
120 struct sta_info *sta = file->private_data;
121 int res = scnprintf(buf, sizeof(buf), "%d %d %d\n",
122 sta->last_ack_rssi[0],
123 sta->last_ack_rssi[1],
124 sta->last_ack_rssi[2]);
125 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
126}
127STA_OPS(last_ack_rssi);
128
129static ssize_t sta_last_ack_ms_read(struct file *file, char __user *userbuf,
130 size_t count, loff_t *ppos)
131{
132 char buf[20];
133 struct sta_info *sta = file->private_data;
134 int res = scnprintf(buf, sizeof(buf), "%d\n",
135 sta->last_ack ?
136 jiffies_to_msecs(jiffies - sta->last_ack) : -1);
137 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
138}
139STA_OPS(last_ack_ms);
140
141static ssize_t sta_inactive_ms_read(struct file *file, char __user *userbuf,
142 size_t count, loff_t *ppos)
143{
144 char buf[20];
145 struct sta_info *sta = file->private_data;
146 int res = scnprintf(buf, sizeof(buf), "%d\n",
147 jiffies_to_msecs(jiffies - sta->last_rx));
148 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
149}
150STA_OPS(inactive_ms);
151
152static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf,
153 size_t count, loff_t *ppos)
154{
155 char buf[15*NUM_RX_DATA_QUEUES], *p = buf;
156 int i;
157 struct sta_info *sta = file->private_data;
158 for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
159 p += scnprintf(p, sizeof(buf)+buf-p, "%x ",
160 sta->last_seq_ctrl[i]);
161 p += scnprintf(p, sizeof(buf)+buf-p, "\n");
162 return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
163}
164STA_OPS(last_seq_ctrl);
165
166#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
167static ssize_t sta_wme_rx_queue_read(struct file *file, char __user *userbuf,
168 size_t count, loff_t *ppos)
169{
170 char buf[15*NUM_RX_DATA_QUEUES], *p = buf;
171 int i;
172 struct sta_info *sta = file->private_data;
173 for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
174 p += scnprintf(p, sizeof(buf)+buf-p, "%u ",
175 sta->wme_rx_queue[i]);
176 p += scnprintf(p, sizeof(buf)+buf-p, "\n");
177 return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
178}
179STA_OPS(wme_rx_queue);
180
181static ssize_t sta_wme_tx_queue_read(struct file *file, char __user *userbuf,
182 size_t count, loff_t *ppos)
183{
184 char buf[15*NUM_TX_DATA_QUEUES], *p = buf;
185 int i;
186 struct sta_info *sta = file->private_data;
187 for (i = 0; i < NUM_TX_DATA_QUEUES; i++)
188 p += scnprintf(p, sizeof(buf)+buf-p, "%u ",
189 sta->wme_tx_queue[i]);
190 p += scnprintf(p, sizeof(buf)+buf-p, "\n");
191 return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
192}
193STA_OPS(wme_tx_queue);
194#endif
195
196#define DEBUGFS_ADD(name) \
197 sta->debugfs.name = debugfs_create_file(#name, 0444, \
198 sta->debugfs.dir, sta, &sta_ ##name## _ops);
199
200#define DEBUGFS_DEL(name) \
201 debugfs_remove(sta->debugfs.name);\
202 sta->debugfs.name = NULL;
203
204
205void ieee80211_sta_debugfs_add(struct sta_info *sta)
206{
207 char buf[3*6];
208 struct dentry *stations_dir = sta->local->debugfs.stations;
209
210 if (!stations_dir)
211 return;
212
213 sprintf(buf, MAC_FMT, MAC_ARG(sta->addr));
214
215 sta->debugfs.dir = debugfs_create_dir(buf, stations_dir);
216 if (!sta->debugfs.dir)
217 return;
218
219 DEBUGFS_ADD(flags);
220 DEBUGFS_ADD(num_ps_buf_frames);
221 DEBUGFS_ADD(last_ack_rssi);
222 DEBUGFS_ADD(last_ack_ms);
223 DEBUGFS_ADD(inactive_ms);
224 DEBUGFS_ADD(last_seq_ctrl);
225#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
226 DEBUGFS_ADD(wme_rx_queue);
227 DEBUGFS_ADD(wme_tx_queue);
228#endif
229}
230
231void ieee80211_sta_debugfs_remove(struct sta_info *sta)
232{
233 DEBUGFS_DEL(flags);
234 DEBUGFS_DEL(num_ps_buf_frames);
235 DEBUGFS_DEL(last_ack_rssi);
236 DEBUGFS_DEL(last_ack_ms);
237 DEBUGFS_DEL(inactive_ms);
238 DEBUGFS_DEL(last_seq_ctrl);
239#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
240 DEBUGFS_DEL(wme_rx_queue);
241 DEBUGFS_DEL(wme_tx_queue);
242#endif
243
244 debugfs_remove(sta->debugfs.dir);
245 sta->debugfs.dir = NULL;
246}
diff --git a/net/mac80211/debugfs_sta.h b/net/mac80211/debugfs_sta.h
new file mode 100644
index 000000000000..574a1cd54b96
--- /dev/null
+++ b/net/mac80211/debugfs_sta.h
@@ -0,0 +1,12 @@
1#ifndef __MAC80211_DEBUGFS_STA_H
2#define __MAC80211_DEBUGFS_STA_H
3
4#ifdef CONFIG_MAC80211_DEBUGFS
5void ieee80211_sta_debugfs_add(struct sta_info *sta);
6void ieee80211_sta_debugfs_remove(struct sta_info *sta);
7#else
8static inline void ieee80211_sta_debugfs_add(struct sta_info *sta) {}
9static inline void ieee80211_sta_debugfs_remove(struct sta_info *sta) {}
10#endif
11
12#endif /* __MAC80211_DEBUGFS_STA_H */
diff --git a/net/mac80211/hostapd_ioctl.h b/net/mac80211/hostapd_ioctl.h
new file mode 100644
index 000000000000..34fa128e9872
--- /dev/null
+++ b/net/mac80211/hostapd_ioctl.h
@@ -0,0 +1,108 @@
1/*
2 * Host AP (software wireless LAN access point) user space daemon for
3 * Host AP kernel driver
4 * Copyright 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
5 * Copyright 2002-2004, Instant802 Networks, Inc.
6 * Copyright 2005, Devicescape 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
13#ifndef HOSTAPD_IOCTL_H
14#define HOSTAPD_IOCTL_H
15
16#ifdef __KERNEL__
17#include <linux/types.h>
18#endif /* __KERNEL__ */
19
20#define PRISM2_IOCTL_PRISM2_PARAM (SIOCIWFIRSTPRIV + 0)
21#define PRISM2_IOCTL_GET_PRISM2_PARAM (SIOCIWFIRSTPRIV + 1)
22#define PRISM2_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 3)
23
24/* PRISM2_IOCTL_PRISM2_PARAM ioctl() subtypes:
25 * This table is no longer added to, the whole sub-ioctl
26 * mess shall be deleted completely. */
27enum {
28 PRISM2_PARAM_IEEE_802_1X = 23,
29 PRISM2_PARAM_ANTSEL_TX = 24,
30 PRISM2_PARAM_ANTSEL_RX = 25,
31
32 /* Instant802 additions */
33 PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES = 1001,
34 PRISM2_PARAM_DROP_UNENCRYPTED = 1002,
35 PRISM2_PARAM_PREAMBLE = 1003,
36 PRISM2_PARAM_SHORT_SLOT_TIME = 1006,
37 PRISM2_PARAM_NEXT_MODE = 1008,
38 PRISM2_PARAM_CLEAR_KEYS = 1009,
39 PRISM2_PARAM_RADIO_ENABLED = 1010,
40 PRISM2_PARAM_ANTENNA_MODE = 1013,
41 PRISM2_PARAM_STAT_TIME = 1016,
42 PRISM2_PARAM_STA_ANTENNA_SEL = 1017,
43 PRISM2_PARAM_FORCE_UNICAST_RATE = 1018,
44 PRISM2_PARAM_RATE_CTRL_NUM_UP = 1019,
45 PRISM2_PARAM_RATE_CTRL_NUM_DOWN = 1020,
46 PRISM2_PARAM_MAX_RATECTRL_RATE = 1021,
47 PRISM2_PARAM_TX_POWER_REDUCTION = 1022,
48 PRISM2_PARAM_KEY_TX_RX_THRESHOLD = 1024,
49 PRISM2_PARAM_DEFAULT_WEP_ONLY = 1026,
50 PRISM2_PARAM_WIFI_WME_NOACK_TEST = 1033,
51 PRISM2_PARAM_SCAN_FLAGS = 1035,
52 PRISM2_PARAM_HW_MODES = 1036,
53 PRISM2_PARAM_CREATE_IBSS = 1037,
54 PRISM2_PARAM_WMM_ENABLED = 1038,
55 PRISM2_PARAM_MIXED_CELL = 1039,
56 PRISM2_PARAM_RADAR_DETECT = 1043,
57 PRISM2_PARAM_SPECTRUM_MGMT = 1044,
58};
59
60enum {
61 IEEE80211_KEY_MGMT_NONE = 0,
62 IEEE80211_KEY_MGMT_IEEE8021X = 1,
63 IEEE80211_KEY_MGMT_WPA_PSK = 2,
64 IEEE80211_KEY_MGMT_WPA_EAP = 3,
65};
66
67
68/* Data structures used for get_hw_features ioctl */
69struct hostapd_ioctl_hw_modes_hdr {
70 int mode;
71 int num_channels;
72 int num_rates;
73};
74
75struct ieee80211_channel_data {
76 short chan; /* channel number (IEEE 802.11) */
77 short freq; /* frequency in MHz */
78 int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */
79};
80
81struct ieee80211_rate_data {
82 int rate; /* rate in 100 kbps */
83 int flags; /* IEEE80211_RATE_ flags */
84};
85
86
87/* ADD_IF, REMOVE_IF, and UPDATE_IF 'type' argument */
88enum {
89 HOSTAP_IF_WDS = 1, HOSTAP_IF_VLAN = 2, HOSTAP_IF_BSS = 3,
90 HOSTAP_IF_STA = 4
91};
92
93struct hostapd_if_wds {
94 u8 remote_addr[ETH_ALEN];
95};
96
97struct hostapd_if_vlan {
98 u8 id;
99};
100
101struct hostapd_if_bss {
102 u8 bssid[ETH_ALEN];
103};
104
105struct hostapd_if_sta {
106};
107
108#endif /* HOSTAPD_IOCTL_H */
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
new file mode 100644
index 000000000000..6e36df67f8d5
--- /dev/null
+++ b/net/mac80211/ieee80211.c
@@ -0,0 +1,4984 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <net/mac80211.h>
12#include <net/ieee80211_radiotap.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/netdevice.h>
16#include <linux/types.h>
17#include <linux/slab.h>
18#include <linux/skbuff.h>
19#include <linux/etherdevice.h>
20#include <linux/if_arp.h>
21#include <linux/wireless.h>
22#include <linux/rtnetlink.h>
23#include <net/iw_handler.h>
24#include <linux/compiler.h>
25#include <linux/bitmap.h>
26#include <net/cfg80211.h>
27
28#include "ieee80211_common.h"
29#include "ieee80211_i.h"
30#include "ieee80211_rate.h"
31#include "wep.h"
32#include "wpa.h"
33#include "tkip.h"
34#include "wme.h"
35#include "aes_ccm.h"
36#include "ieee80211_led.h"
37#include "ieee80211_cfg.h"
38#include "debugfs.h"
39#include "debugfs_netdev.h"
40#include "debugfs_key.h"
41
42/* privid for wiphys to determine whether they belong to us or not */
43void *mac80211_wiphy_privid = &mac80211_wiphy_privid;
44
45/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
46/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
47static const unsigned char rfc1042_header[] =
48 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
49
50/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
51static const unsigned char bridge_tunnel_header[] =
52 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
53
54/* No encapsulation header if EtherType < 0x600 (=length) */
55static const unsigned char eapol_header[] =
56 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e };
57
58
59static inline void ieee80211_include_sequence(struct ieee80211_sub_if_data *sdata,
60 struct ieee80211_hdr *hdr)
61{
62 /* Set the sequence number for this frame. */
63 hdr->seq_ctrl = cpu_to_le16(sdata->sequence);
64
65 /* Increase the sequence number. */
66 sdata->sequence = (sdata->sequence + 0x10) & IEEE80211_SCTL_SEQ;
67}
68
69struct ieee80211_key_conf *
70ieee80211_key_data2conf(struct ieee80211_local *local,
71 const struct ieee80211_key *data)
72{
73 struct ieee80211_key_conf *conf;
74
75 conf = kmalloc(sizeof(*conf) + data->keylen, GFP_ATOMIC);
76 if (!conf)
77 return NULL;
78
79 conf->hw_key_idx = data->hw_key_idx;
80 conf->alg = data->alg;
81 conf->keylen = data->keylen;
82 conf->flags = 0;
83 if (data->force_sw_encrypt)
84 conf->flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT;
85 conf->keyidx = data->keyidx;
86 if (data->default_tx_key)
87 conf->flags |= IEEE80211_KEY_DEFAULT_TX_KEY;
88 if (local->default_wep_only)
89 conf->flags |= IEEE80211_KEY_DEFAULT_WEP_ONLY;
90 memcpy(conf->key, data->key, data->keylen);
91
92 return conf;
93}
94
95struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
96 int idx, size_t key_len, gfp_t flags)
97{
98 struct ieee80211_key *key;
99
100 key = kzalloc(sizeof(struct ieee80211_key) + key_len, flags);
101 if (!key)
102 return NULL;
103 kref_init(&key->kref);
104 return key;
105}
106
107static void ieee80211_key_release(struct kref *kref)
108{
109 struct ieee80211_key *key;
110
111 key = container_of(kref, struct ieee80211_key, kref);
112 if (key->alg == ALG_CCMP)
113 ieee80211_aes_key_free(key->u.ccmp.tfm);
114 ieee80211_debugfs_key_remove(key);
115 kfree(key);
116}
117
118void ieee80211_key_free(struct ieee80211_key *key)
119{
120 if (key)
121 kref_put(&key->kref, ieee80211_key_release);
122}
123
124static int rate_list_match(const int *rate_list, int rate)
125{
126 int i;
127
128 if (!rate_list)
129 return 0;
130
131 for (i = 0; rate_list[i] >= 0; i++)
132 if (rate_list[i] == rate)
133 return 1;
134
135 return 0;
136}
137
138
139void ieee80211_prepare_rates(struct ieee80211_local *local,
140 struct ieee80211_hw_mode *mode)
141{
142 int i;
143
144 for (i = 0; i < mode->num_rates; i++) {
145 struct ieee80211_rate *rate = &mode->rates[i];
146
147 rate->flags &= ~(IEEE80211_RATE_SUPPORTED |
148 IEEE80211_RATE_BASIC);
149
150 if (local->supp_rates[mode->mode]) {
151 if (!rate_list_match(local->supp_rates[mode->mode],
152 rate->rate))
153 continue;
154 }
155
156 rate->flags |= IEEE80211_RATE_SUPPORTED;
157
158 /* Use configured basic rate set if it is available. If not,
159 * use defaults that are sane for most cases. */
160 if (local->basic_rates[mode->mode]) {
161 if (rate_list_match(local->basic_rates[mode->mode],
162 rate->rate))
163 rate->flags |= IEEE80211_RATE_BASIC;
164 } else switch (mode->mode) {
165 case MODE_IEEE80211A:
166 if (rate->rate == 60 || rate->rate == 120 ||
167 rate->rate == 240)
168 rate->flags |= IEEE80211_RATE_BASIC;
169 break;
170 case MODE_IEEE80211B:
171 if (rate->rate == 10 || rate->rate == 20)
172 rate->flags |= IEEE80211_RATE_BASIC;
173 break;
174 case MODE_ATHEROS_TURBO:
175 if (rate->rate == 120 || rate->rate == 240 ||
176 rate->rate == 480)
177 rate->flags |= IEEE80211_RATE_BASIC;
178 break;
179 case MODE_IEEE80211G:
180 if (rate->rate == 10 || rate->rate == 20 ||
181 rate->rate == 55 || rate->rate == 110)
182 rate->flags |= IEEE80211_RATE_BASIC;
183 break;
184 }
185
186 /* Set ERP and MANDATORY flags based on phymode */
187 switch (mode->mode) {
188 case MODE_IEEE80211A:
189 if (rate->rate == 60 || rate->rate == 120 ||
190 rate->rate == 240)
191 rate->flags |= IEEE80211_RATE_MANDATORY;
192 break;
193 case MODE_IEEE80211B:
194 if (rate->rate == 10)
195 rate->flags |= IEEE80211_RATE_MANDATORY;
196 break;
197 case MODE_ATHEROS_TURBO:
198 break;
199 case MODE_IEEE80211G:
200 if (rate->rate == 10 || rate->rate == 20 ||
201 rate->rate == 55 || rate->rate == 110 ||
202 rate->rate == 60 || rate->rate == 120 ||
203 rate->rate == 240)
204 rate->flags |= IEEE80211_RATE_MANDATORY;
205 break;
206 }
207 if (ieee80211_is_erp_rate(mode->mode, rate->rate))
208 rate->flags |= IEEE80211_RATE_ERP;
209 }
210}
211
212
213static void ieee80211_key_threshold_notify(struct net_device *dev,
214 struct ieee80211_key *key,
215 struct sta_info *sta)
216{
217 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
218 struct sk_buff *skb;
219 struct ieee80211_msg_key_notification *msg;
220
221 /* if no one will get it anyway, don't even allocate it.
222 * unlikely because this is only relevant for APs
223 * where the device must be open... */
224 if (unlikely(!local->apdev))
225 return;
226
227 skb = dev_alloc_skb(sizeof(struct ieee80211_frame_info) +
228 sizeof(struct ieee80211_msg_key_notification));
229 if (!skb)
230 return;
231
232 skb_reserve(skb, sizeof(struct ieee80211_frame_info));
233 msg = (struct ieee80211_msg_key_notification *)
234 skb_put(skb, sizeof(struct ieee80211_msg_key_notification));
235 msg->tx_rx_count = key->tx_rx_count;
236 memcpy(msg->ifname, dev->name, IFNAMSIZ);
237 if (sta)
238 memcpy(msg->addr, sta->addr, ETH_ALEN);
239 else
240 memset(msg->addr, 0xff, ETH_ALEN);
241
242 key->tx_rx_count = 0;
243
244 ieee80211_rx_mgmt(local, skb, NULL,
245 ieee80211_msg_key_threshold_notification);
246}
247
248
249static u8 * ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
250{
251 u16 fc;
252
253 if (len < 24)
254 return NULL;
255
256 fc = le16_to_cpu(hdr->frame_control);
257
258 switch (fc & IEEE80211_FCTL_FTYPE) {
259 case IEEE80211_FTYPE_DATA:
260 switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
261 case IEEE80211_FCTL_TODS:
262 return hdr->addr1;
263 case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
264 return NULL;
265 case IEEE80211_FCTL_FROMDS:
266 return hdr->addr2;
267 case 0:
268 return hdr->addr3;
269 }
270 break;
271 case IEEE80211_FTYPE_MGMT:
272 return hdr->addr3;
273 case IEEE80211_FTYPE_CTL:
274 if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
275 return hdr->addr1;
276 else
277 return NULL;
278 }
279
280 return NULL;
281}
282
283int ieee80211_get_hdrlen(u16 fc)
284{
285 int hdrlen = 24;
286
287 switch (fc & IEEE80211_FCTL_FTYPE) {
288 case IEEE80211_FTYPE_DATA:
289 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
290 hdrlen = 30; /* Addr4 */
291 /*
292 * The QoS Control field is two bytes and its presence is
293 * indicated by the IEEE80211_STYPE_QOS_DATA bit. Add 2 to
294 * hdrlen if that bit is set.
295 * This works by masking out the bit and shifting it to
296 * bit position 1 so the result has the value 0 or 2.
297 */
298 hdrlen += (fc & IEEE80211_STYPE_QOS_DATA)
299 >> (ilog2(IEEE80211_STYPE_QOS_DATA)-1);
300 break;
301 case IEEE80211_FTYPE_CTL:
302 /*
303 * ACK and CTS are 10 bytes, all others 16. To see how
304 * to get this condition consider
305 * subtype mask: 0b0000000011110000 (0x00F0)
306 * ACK subtype: 0b0000000011010000 (0x00D0)
307 * CTS subtype: 0b0000000011000000 (0x00C0)
308 * bits that matter: ^^^ (0x00E0)
309 * value of those: 0b0000000011000000 (0x00C0)
310 */
311 if ((fc & 0xE0) == 0xC0)
312 hdrlen = 10;
313 else
314 hdrlen = 16;
315 break;
316 }
317
318 return hdrlen;
319}
320EXPORT_SYMBOL(ieee80211_get_hdrlen);
321
322int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb)
323{
324 const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data;
325 int hdrlen;
326
327 if (unlikely(skb->len < 10))
328 return 0;
329 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));
330 if (unlikely(hdrlen > skb->len))
331 return 0;
332 return hdrlen;
333}
334EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb);
335
336static int ieee80211_get_radiotap_len(struct sk_buff *skb)
337{
338 struct ieee80211_radiotap_header *hdr =
339 (struct ieee80211_radiotap_header *) skb->data;
340
341 return le16_to_cpu(hdr->it_len);
342}
343
344#ifdef CONFIG_MAC80211_LOWTX_FRAME_DUMP
345static void ieee80211_dump_frame(const char *ifname, const char *title,
346 const struct sk_buff *skb)
347{
348 const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
349 u16 fc;
350 int hdrlen;
351
352 printk(KERN_DEBUG "%s: %s (len=%d)", ifname, title, skb->len);
353 if (skb->len < 4) {
354 printk("\n");
355 return;
356 }
357
358 fc = le16_to_cpu(hdr->frame_control);
359 hdrlen = ieee80211_get_hdrlen(fc);
360 if (hdrlen > skb->len)
361 hdrlen = skb->len;
362 if (hdrlen >= 4)
363 printk(" FC=0x%04x DUR=0x%04x",
364 fc, le16_to_cpu(hdr->duration_id));
365 if (hdrlen >= 10)
366 printk(" A1=" MAC_FMT, MAC_ARG(hdr->addr1));
367 if (hdrlen >= 16)
368 printk(" A2=" MAC_FMT, MAC_ARG(hdr->addr2));
369 if (hdrlen >= 24)
370 printk(" A3=" MAC_FMT, MAC_ARG(hdr->addr3));
371 if (hdrlen >= 30)
372 printk(" A4=" MAC_FMT, MAC_ARG(hdr->addr4));
373 printk("\n");
374}
375#else /* CONFIG_MAC80211_LOWTX_FRAME_DUMP */
376static inline void ieee80211_dump_frame(const char *ifname, const char *title,
377 struct sk_buff *skb)
378{
379}
380#endif /* CONFIG_MAC80211_LOWTX_FRAME_DUMP */
381
382
383static int ieee80211_is_eapol(const struct sk_buff *skb)
384{
385 const struct ieee80211_hdr *hdr;
386 u16 fc;
387 int hdrlen;
388
389 if (unlikely(skb->len < 10))
390 return 0;
391
392 hdr = (const struct ieee80211_hdr *) skb->data;
393 fc = le16_to_cpu(hdr->frame_control);
394
395 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
396 return 0;
397
398 hdrlen = ieee80211_get_hdrlen(fc);
399
400 if (unlikely(skb->len >= hdrlen + sizeof(eapol_header) &&
401 memcmp(skb->data + hdrlen, eapol_header,
402 sizeof(eapol_header)) == 0))
403 return 1;
404
405 return 0;
406}
407
408
409static ieee80211_txrx_result
410ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx)
411{
412 struct rate_control_extra extra;
413
414 memset(&extra, 0, sizeof(extra));
415 extra.mode = tx->u.tx.mode;
416 extra.mgmt_data = tx->sdata &&
417 tx->sdata->type == IEEE80211_IF_TYPE_MGMT;
418 extra.ethertype = tx->ethertype;
419
420 tx->u.tx.rate = rate_control_get_rate(tx->local, tx->dev, tx->skb,
421 &extra);
422 if (unlikely(extra.probe != NULL)) {
423 tx->u.tx.control->flags |= IEEE80211_TXCTL_RATE_CTRL_PROBE;
424 tx->u.tx.probe_last_frag = 1;
425 tx->u.tx.control->alt_retry_rate = tx->u.tx.rate->val;
426 tx->u.tx.rate = extra.probe;
427 } else {
428 tx->u.tx.control->alt_retry_rate = -1;
429 }
430 if (!tx->u.tx.rate)
431 return TXRX_DROP;
432 if (tx->u.tx.mode->mode == MODE_IEEE80211G &&
433 tx->local->cts_protect_erp_frames && tx->fragmented &&
434 extra.nonerp) {
435 tx->u.tx.last_frag_rate = tx->u.tx.rate;
436 tx->u.tx.probe_last_frag = extra.probe ? 1 : 0;
437
438 tx->u.tx.rate = extra.nonerp;
439 tx->u.tx.control->rate = extra.nonerp;
440 tx->u.tx.control->flags &= ~IEEE80211_TXCTL_RATE_CTRL_PROBE;
441 } else {
442 tx->u.tx.last_frag_rate = tx->u.tx.rate;
443 tx->u.tx.control->rate = tx->u.tx.rate;
444 }
445 tx->u.tx.control->tx_rate = tx->u.tx.rate->val;
446 if ((tx->u.tx.rate->flags & IEEE80211_RATE_PREAMBLE2) &&
447 tx->local->short_preamble &&
448 (!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) {
449 tx->u.tx.short_preamble = 1;
450 tx->u.tx.control->tx_rate = tx->u.tx.rate->val2;
451 }
452
453 return TXRX_CONTINUE;
454}
455
456
457static ieee80211_txrx_result
458ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx)
459{
460 if (tx->sta)
461 tx->u.tx.control->key_idx = tx->sta->key_idx_compression;
462 else
463 tx->u.tx.control->key_idx = HW_KEY_IDX_INVALID;
464
465 if (unlikely(tx->u.tx.control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT))
466 tx->key = NULL;
467 else if (tx->sta && tx->sta->key)
468 tx->key = tx->sta->key;
469 else if (tx->sdata->default_key)
470 tx->key = tx->sdata->default_key;
471 else if (tx->sdata->drop_unencrypted &&
472 !(tx->sdata->eapol && ieee80211_is_eapol(tx->skb))) {
473 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
474 return TXRX_DROP;
475 } else
476 tx->key = NULL;
477
478 if (tx->key) {
479 tx->key->tx_rx_count++;
480 if (unlikely(tx->local->key_tx_rx_threshold &&
481 tx->key->tx_rx_count >
482 tx->local->key_tx_rx_threshold)) {
483 ieee80211_key_threshold_notify(tx->dev, tx->key,
484 tx->sta);
485 }
486 }
487
488 return TXRX_CONTINUE;
489}
490
491
492static ieee80211_txrx_result
493ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx)
494{
495 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
496 size_t hdrlen, per_fragm, num_fragm, payload_len, left;
497 struct sk_buff **frags, *first, *frag;
498 int i;
499 u16 seq;
500 u8 *pos;
501 int frag_threshold = tx->local->fragmentation_threshold;
502
503 if (!tx->fragmented)
504 return TXRX_CONTINUE;
505
506 first = tx->skb;
507
508 hdrlen = ieee80211_get_hdrlen(tx->fc);
509 payload_len = first->len - hdrlen;
510 per_fragm = frag_threshold - hdrlen - FCS_LEN;
511 num_fragm = (payload_len + per_fragm - 1) / per_fragm;
512
513 frags = kzalloc(num_fragm * sizeof(struct sk_buff *), GFP_ATOMIC);
514 if (!frags)
515 goto fail;
516
517 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS);
518 seq = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ;
519 pos = first->data + hdrlen + per_fragm;
520 left = payload_len - per_fragm;
521 for (i = 0; i < num_fragm - 1; i++) {
522 struct ieee80211_hdr *fhdr;
523 size_t copylen;
524
525 if (left <= 0)
526 goto fail;
527
528 /* reserve enough extra head and tail room for possible
529 * encryption */
530 frag = frags[i] =
531 dev_alloc_skb(tx->local->hw.extra_tx_headroom +
532 frag_threshold +
533 IEEE80211_ENCRYPT_HEADROOM +
534 IEEE80211_ENCRYPT_TAILROOM);
535 if (!frag)
536 goto fail;
537 /* Make sure that all fragments use the same priority so
538 * that they end up using the same TX queue */
539 frag->priority = first->priority;
540 skb_reserve(frag, tx->local->hw.extra_tx_headroom +
541 IEEE80211_ENCRYPT_HEADROOM);
542 fhdr = (struct ieee80211_hdr *) skb_put(frag, hdrlen);
543 memcpy(fhdr, first->data, hdrlen);
544 if (i == num_fragm - 2)
545 fhdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREFRAGS);
546 fhdr->seq_ctrl = cpu_to_le16(seq | ((i + 1) & IEEE80211_SCTL_FRAG));
547 copylen = left > per_fragm ? per_fragm : left;
548 memcpy(skb_put(frag, copylen), pos, copylen);
549
550 pos += copylen;
551 left -= copylen;
552 }
553 skb_trim(first, hdrlen + per_fragm);
554
555 tx->u.tx.num_extra_frag = num_fragm - 1;
556 tx->u.tx.extra_frag = frags;
557
558 return TXRX_CONTINUE;
559
560 fail:
561 printk(KERN_DEBUG "%s: failed to fragment frame\n", tx->dev->name);
562 if (frags) {
563 for (i = 0; i < num_fragm - 1; i++)
564 if (frags[i])
565 dev_kfree_skb(frags[i]);
566 kfree(frags);
567 }
568 I802_DEBUG_INC(tx->local->tx_handlers_drop_fragment);
569 return TXRX_DROP;
570}
571
572
573static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb)
574{
575 if (tx->key->force_sw_encrypt) {
576 if (ieee80211_wep_encrypt(tx->local, skb, tx->key))
577 return -1;
578 } else {
579 tx->u.tx.control->key_idx = tx->key->hw_key_idx;
580 if (tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) {
581 if (ieee80211_wep_add_iv(tx->local, skb, tx->key) ==
582 NULL)
583 return -1;
584 }
585 }
586 return 0;
587}
588
589
590void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx)
591{
592 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
593
594 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
595 if (tx->u.tx.extra_frag) {
596 struct ieee80211_hdr *fhdr;
597 int i;
598 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
599 fhdr = (struct ieee80211_hdr *)
600 tx->u.tx.extra_frag[i]->data;
601 fhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
602 }
603 }
604}
605
606
607static ieee80211_txrx_result
608ieee80211_tx_h_wep_encrypt(struct ieee80211_txrx_data *tx)
609{
610 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
611 u16 fc;
612
613 fc = le16_to_cpu(hdr->frame_control);
614
615 if (!tx->key || tx->key->alg != ALG_WEP ||
616 ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
617 ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
618 (fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)))
619 return TXRX_CONTINUE;
620
621 tx->u.tx.control->iv_len = WEP_IV_LEN;
622 tx->u.tx.control->icv_len = WEP_ICV_LEN;
623 ieee80211_tx_set_iswep(tx);
624
625 if (wep_encrypt_skb(tx, tx->skb) < 0) {
626 I802_DEBUG_INC(tx->local->tx_handlers_drop_wep);
627 return TXRX_DROP;
628 }
629
630 if (tx->u.tx.extra_frag) {
631 int i;
632 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
633 if (wep_encrypt_skb(tx, tx->u.tx.extra_frag[i]) < 0) {
634 I802_DEBUG_INC(tx->local->
635 tx_handlers_drop_wep);
636 return TXRX_DROP;
637 }
638 }
639 }
640
641 return TXRX_CONTINUE;
642}
643
644
645static int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
646 int rate, int erp, int short_preamble)
647{
648 int dur;
649
650 /* calculate duration (in microseconds, rounded up to next higher
651 * integer if it includes a fractional microsecond) to send frame of
652 * len bytes (does not include FCS) at the given rate. Duration will
653 * also include SIFS.
654 *
655 * rate is in 100 kbps, so divident is multiplied by 10 in the
656 * DIV_ROUND_UP() operations.
657 */
658
659 if (local->hw.conf.phymode == MODE_IEEE80211A || erp ||
660 local->hw.conf.phymode == MODE_ATHEROS_TURBO) {
661 /*
662 * OFDM:
663 *
664 * N_DBPS = DATARATE x 4
665 * N_SYM = Ceiling((16+8xLENGTH+6) / N_DBPS)
666 * (16 = SIGNAL time, 6 = tail bits)
667 * TXTIME = T_PREAMBLE + T_SIGNAL + T_SYM x N_SYM + Signal Ext
668 *
669 * T_SYM = 4 usec
670 * 802.11a - 17.5.2: aSIFSTime = 16 usec
671 * 802.11g - 19.8.4: aSIFSTime = 10 usec +
672 * signal ext = 6 usec
673 */
674 /* FIX: Atheros Turbo may have different (shorter) duration? */
675 dur = 16; /* SIFS + signal ext */
676 dur += 16; /* 17.3.2.3: T_PREAMBLE = 16 usec */
677 dur += 4; /* 17.3.2.3: T_SIGNAL = 4 usec */
678 dur += 4 * DIV_ROUND_UP((16 + 8 * (len + 4) + 6) * 10,
679 4 * rate); /* T_SYM x N_SYM */
680 } else {
681 /*
682 * 802.11b or 802.11g with 802.11b compatibility:
683 * 18.3.4: TXTIME = PreambleLength + PLCPHeaderTime +
684 * Ceiling(((LENGTH+PBCC)x8)/DATARATE). PBCC=0.
685 *
686 * 802.11 (DS): 15.3.3, 802.11b: 18.3.4
687 * aSIFSTime = 10 usec
688 * aPreambleLength = 144 usec or 72 usec with short preamble
689 * aPLCPHeaderLength = 48 usec or 24 usec with short preamble
690 */
691 dur = 10; /* aSIFSTime = 10 usec */
692 dur += short_preamble ? (72 + 24) : (144 + 48);
693
694 dur += DIV_ROUND_UP(8 * (len + 4) * 10, rate);
695 }
696
697 return dur;
698}
699
700
701/* Exported duration function for driver use */
702__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
703 size_t frame_len, int rate)
704{
705 struct ieee80211_local *local = hw_to_local(hw);
706 u16 dur;
707 int erp;
708
709 erp = ieee80211_is_erp_rate(hw->conf.phymode, rate);
710 dur = ieee80211_frame_duration(local, frame_len, rate,
711 erp, local->short_preamble);
712
713 return cpu_to_le16(dur);
714}
715EXPORT_SYMBOL(ieee80211_generic_frame_duration);
716
717
718static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr,
719 int next_frag_len)
720{
721 int rate, mrate, erp, dur, i;
722 struct ieee80211_rate *txrate = tx->u.tx.rate;
723 struct ieee80211_local *local = tx->local;
724 struct ieee80211_hw_mode *mode = tx->u.tx.mode;
725
726 erp = txrate->flags & IEEE80211_RATE_ERP;
727
728 /*
729 * data and mgmt (except PS Poll):
730 * - during CFP: 32768
731 * - during contention period:
732 * if addr1 is group address: 0
733 * if more fragments = 0 and addr1 is individual address: time to
734 * transmit one ACK plus SIFS
735 * if more fragments = 1 and addr1 is individual address: time to
736 * transmit next fragment plus 2 x ACK plus 3 x SIFS
737 *
738 * IEEE 802.11, 9.6:
739 * - control response frame (CTS or ACK) shall be transmitted using the
740 * same rate as the immediately previous frame in the frame exchange
741 * sequence, if this rate belongs to the PHY mandatory rates, or else
742 * at the highest possible rate belonging to the PHY rates in the
743 * BSSBasicRateSet
744 */
745
746 if ((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) {
747 /* TODO: These control frames are not currently sent by
748 * 80211.o, but should they be implemented, this function
749 * needs to be updated to support duration field calculation.
750 *
751 * RTS: time needed to transmit pending data/mgmt frame plus
752 * one CTS frame plus one ACK frame plus 3 x SIFS
753 * CTS: duration of immediately previous RTS minus time
754 * required to transmit CTS and its SIFS
755 * ACK: 0 if immediately previous directed data/mgmt had
756 * more=0, with more=1 duration in ACK frame is duration
757 * from previous frame minus time needed to transmit ACK
758 * and its SIFS
759 * PS Poll: BIT(15) | BIT(14) | aid
760 */
761 return 0;
762 }
763
764 /* data/mgmt */
765 if (0 /* FIX: data/mgmt during CFP */)
766 return 32768;
767
768 if (group_addr) /* Group address as the destination - no ACK */
769 return 0;
770
771 /* Individual destination address:
772 * IEEE 802.11, Ch. 9.6 (after IEEE 802.11g changes)
773 * CTS and ACK frames shall be transmitted using the highest rate in
774 * basic rate set that is less than or equal to the rate of the
775 * immediately previous frame and that is using the same modulation
776 * (CCK or OFDM). If no basic rate set matches with these requirements,
777 * the highest mandatory rate of the PHY that is less than or equal to
778 * the rate of the previous frame is used.
779 * Mandatory rates for IEEE 802.11g PHY: 1, 2, 5.5, 11, 6, 12, 24 Mbps
780 */
781 rate = -1;
782 mrate = 10; /* use 1 Mbps if everything fails */
783 for (i = 0; i < mode->num_rates; i++) {
784 struct ieee80211_rate *r = &mode->rates[i];
785 if (r->rate > txrate->rate)
786 break;
787
788 if (IEEE80211_RATE_MODULATION(txrate->flags) !=
789 IEEE80211_RATE_MODULATION(r->flags))
790 continue;
791
792 if (r->flags & IEEE80211_RATE_BASIC)
793 rate = r->rate;
794 else if (r->flags & IEEE80211_RATE_MANDATORY)
795 mrate = r->rate;
796 }
797 if (rate == -1) {
798 /* No matching basic rate found; use highest suitable mandatory
799 * PHY rate */
800 rate = mrate;
801 }
802
803 /* Time needed to transmit ACK
804 * (10 bytes + 4-byte FCS = 112 bits) plus SIFS; rounded up
805 * to closest integer */
806
807 dur = ieee80211_frame_duration(local, 10, rate, erp,
808 local->short_preamble);
809
810 if (next_frag_len) {
811 /* Frame is fragmented: duration increases with time needed to
812 * transmit next fragment plus ACK and 2 x SIFS. */
813 dur *= 2; /* ACK + SIFS */
814 /* next fragment */
815 dur += ieee80211_frame_duration(local, next_frag_len,
816 txrate->rate, erp,
817 local->short_preamble);
818 }
819
820 return dur;
821}
822
823
824static ieee80211_txrx_result
825ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
826{
827 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
828 u16 dur;
829 struct ieee80211_tx_control *control = tx->u.tx.control;
830 struct ieee80211_hw_mode *mode = tx->u.tx.mode;
831
832 if (!is_multicast_ether_addr(hdr->addr1)) {
833 if (tx->skb->len + FCS_LEN > tx->local->rts_threshold &&
834 tx->local->rts_threshold < IEEE80211_MAX_RTS_THRESHOLD) {
835 control->flags |= IEEE80211_TXCTL_USE_RTS_CTS;
836 control->retry_limit =
837 tx->local->long_retry_limit;
838 } else {
839 control->retry_limit =
840 tx->local->short_retry_limit;
841 }
842 } else {
843 control->retry_limit = 1;
844 }
845
846 if (tx->fragmented) {
847 /* Do not use multiple retry rates when sending fragmented
848 * frames.
849 * TODO: The last fragment could still use multiple retry
850 * rates. */
851 control->alt_retry_rate = -1;
852 }
853
854 /* Use CTS protection for unicast frames sent using extended rates if
855 * there are associated non-ERP stations and RTS/CTS is not configured
856 * for the frame. */
857 if (mode->mode == MODE_IEEE80211G &&
858 (tx->u.tx.rate->flags & IEEE80211_RATE_ERP) &&
859 tx->u.tx.unicast &&
860 tx->local->cts_protect_erp_frames &&
861 !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS))
862 control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT;
863
864 /* Setup duration field for the first fragment of the frame. Duration
865 * for remaining fragments will be updated when they are being sent
866 * to low-level driver in ieee80211_tx(). */
867 dur = ieee80211_duration(tx, is_multicast_ether_addr(hdr->addr1),
868 tx->fragmented ? tx->u.tx.extra_frag[0]->len :
869 0);
870 hdr->duration_id = cpu_to_le16(dur);
871
872 if ((control->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
873 (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) {
874 struct ieee80211_rate *rate;
875
876 /* Do not use multiple retry rates when using RTS/CTS */
877 control->alt_retry_rate = -1;
878
879 /* Use min(data rate, max base rate) as CTS/RTS rate */
880 rate = tx->u.tx.rate;
881 while (rate > mode->rates &&
882 !(rate->flags & IEEE80211_RATE_BASIC))
883 rate--;
884
885 control->rts_cts_rate = rate->val;
886 control->rts_rate = rate;
887 }
888
889 if (tx->sta) {
890 tx->sta->tx_packets++;
891 tx->sta->tx_fragments++;
892 tx->sta->tx_bytes += tx->skb->len;
893 if (tx->u.tx.extra_frag) {
894 int i;
895 tx->sta->tx_fragments += tx->u.tx.num_extra_frag;
896 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
897 tx->sta->tx_bytes +=
898 tx->u.tx.extra_frag[i]->len;
899 }
900 }
901 }
902
903 return TXRX_CONTINUE;
904}
905
906
907static ieee80211_txrx_result
908ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx)
909{
910#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
911 struct sk_buff *skb = tx->skb;
912 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
913#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
914 u32 sta_flags;
915
916 if (unlikely(tx->local->sta_scanning != 0) &&
917 ((tx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
918 (tx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PROBE_REQ))
919 return TXRX_DROP;
920
921 if (tx->u.tx.ps_buffered)
922 return TXRX_CONTINUE;
923
924 sta_flags = tx->sta ? tx->sta->flags : 0;
925
926 if (likely(tx->u.tx.unicast)) {
927 if (unlikely(!(sta_flags & WLAN_STA_ASSOC) &&
928 tx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
929 (tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)) {
930#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
931 printk(KERN_DEBUG "%s: dropped data frame to not "
932 "associated station " MAC_FMT "\n",
933 tx->dev->name, MAC_ARG(hdr->addr1));
934#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
935 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc);
936 return TXRX_DROP;
937 }
938 } else {
939 if (unlikely((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
940 tx->local->num_sta == 0 &&
941 !tx->local->allow_broadcast_always &&
942 tx->sdata->type != IEEE80211_IF_TYPE_IBSS)) {
943 /*
944 * No associated STAs - no need to send multicast
945 * frames.
946 */
947 return TXRX_DROP;
948 }
949 return TXRX_CONTINUE;
950 }
951
952 if (unlikely(!tx->u.tx.mgmt_interface && tx->sdata->ieee802_1x &&
953 !(sta_flags & WLAN_STA_AUTHORIZED))) {
954#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
955 printk(KERN_DEBUG "%s: dropped frame to " MAC_FMT
956 " (unauthorized port)\n", tx->dev->name,
957 MAC_ARG(hdr->addr1));
958#endif
959 I802_DEBUG_INC(tx->local->tx_handlers_drop_unauth_port);
960 return TXRX_DROP;
961 }
962
963 return TXRX_CONTINUE;
964}
965
966static ieee80211_txrx_result
967ieee80211_tx_h_sequence(struct ieee80211_txrx_data *tx)
968{
969 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
970
971 if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24)
972 ieee80211_include_sequence(tx->sdata, hdr);
973
974 return TXRX_CONTINUE;
975}
976
977/* This function is called whenever the AP is about to exceed the maximum limit
978 * of buffered frames for power saving STAs. This situation should not really
979 * happen often during normal operation, so dropping the oldest buffered packet
980 * from each queue should be OK to make some room for new frames. */
981static void purge_old_ps_buffers(struct ieee80211_local *local)
982{
983 int total = 0, purged = 0;
984 struct sk_buff *skb;
985 struct ieee80211_sub_if_data *sdata;
986 struct sta_info *sta;
987
988 read_lock(&local->sub_if_lock);
989 list_for_each_entry(sdata, &local->sub_if_list, list) {
990 struct ieee80211_if_ap *ap;
991 if (sdata->dev == local->mdev ||
992 sdata->type != IEEE80211_IF_TYPE_AP)
993 continue;
994 ap = &sdata->u.ap;
995 skb = skb_dequeue(&ap->ps_bc_buf);
996 if (skb) {
997 purged++;
998 dev_kfree_skb(skb);
999 }
1000 total += skb_queue_len(&ap->ps_bc_buf);
1001 }
1002 read_unlock(&local->sub_if_lock);
1003
1004 spin_lock_bh(&local->sta_lock);
1005 list_for_each_entry(sta, &local->sta_list, list) {
1006 skb = skb_dequeue(&sta->ps_tx_buf);
1007 if (skb) {
1008 purged++;
1009 dev_kfree_skb(skb);
1010 }
1011 total += skb_queue_len(&sta->ps_tx_buf);
1012 }
1013 spin_unlock_bh(&local->sta_lock);
1014
1015 local->total_ps_buffered = total;
1016 printk(KERN_DEBUG "%s: PS buffers full - purged %d frames\n",
1017 local->mdev->name, purged);
1018}
1019
1020
1021static inline ieee80211_txrx_result
1022ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx)
1023{
1024 /* broadcast/multicast frame */
1025 /* If any of the associated stations is in power save mode,
1026 * the frame is buffered to be sent after DTIM beacon frame */
1027 if ((tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) &&
1028 tx->sdata->type != IEEE80211_IF_TYPE_WDS &&
1029 tx->sdata->bss && atomic_read(&tx->sdata->bss->num_sta_ps) &&
1030 !(tx->fc & IEEE80211_FCTL_ORDER)) {
1031 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
1032 purge_old_ps_buffers(tx->local);
1033 if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >=
1034 AP_MAX_BC_BUFFER) {
1035 if (net_ratelimit()) {
1036 printk(KERN_DEBUG "%s: BC TX buffer full - "
1037 "dropping the oldest frame\n",
1038 tx->dev->name);
1039 }
1040 dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf));
1041 } else
1042 tx->local->total_ps_buffered++;
1043 skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb);
1044 return TXRX_QUEUED;
1045 }
1046
1047 return TXRX_CONTINUE;
1048}
1049
1050
1051static inline ieee80211_txrx_result
1052ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx)
1053{
1054 struct sta_info *sta = tx->sta;
1055
1056 if (unlikely(!sta ||
1057 ((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT &&
1058 (tx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP)))
1059 return TXRX_CONTINUE;
1060
1061 if (unlikely((sta->flags & WLAN_STA_PS) && !sta->pspoll)) {
1062 struct ieee80211_tx_packet_data *pkt_data;
1063#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1064 printk(KERN_DEBUG "STA " MAC_FMT " aid %d: PS buffer (entries "
1065 "before %d)\n",
1066 MAC_ARG(sta->addr), sta->aid,
1067 skb_queue_len(&sta->ps_tx_buf));
1068#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1069 sta->flags |= WLAN_STA_TIM;
1070 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
1071 purge_old_ps_buffers(tx->local);
1072 if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) {
1073 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf);
1074 if (net_ratelimit()) {
1075 printk(KERN_DEBUG "%s: STA " MAC_FMT " TX "
1076 "buffer full - dropping oldest frame\n",
1077 tx->dev->name, MAC_ARG(sta->addr));
1078 }
1079 dev_kfree_skb(old);
1080 } else
1081 tx->local->total_ps_buffered++;
1082 /* Queue frame to be sent after STA sends an PS Poll frame */
1083 if (skb_queue_empty(&sta->ps_tx_buf)) {
1084 if (tx->local->ops->set_tim)
1085 tx->local->ops->set_tim(local_to_hw(tx->local),
1086 sta->aid, 1);
1087 if (tx->sdata->bss)
1088 bss_tim_set(tx->local, tx->sdata->bss, sta->aid);
1089 }
1090 pkt_data = (struct ieee80211_tx_packet_data *)tx->skb->cb;
1091 pkt_data->jiffies = jiffies;
1092 skb_queue_tail(&sta->ps_tx_buf, tx->skb);
1093 return TXRX_QUEUED;
1094 }
1095#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1096 else if (unlikely(sta->flags & WLAN_STA_PS)) {
1097 printk(KERN_DEBUG "%s: STA " MAC_FMT " in PS mode, but pspoll "
1098 "set -> send frame\n", tx->dev->name,
1099 MAC_ARG(sta->addr));
1100 }
1101#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1102 sta->pspoll = 0;
1103
1104 return TXRX_CONTINUE;
1105}
1106
1107
1108static ieee80211_txrx_result
1109ieee80211_tx_h_ps_buf(struct ieee80211_txrx_data *tx)
1110{
1111 if (unlikely(tx->u.tx.ps_buffered))
1112 return TXRX_CONTINUE;
1113
1114 if (tx->u.tx.unicast)
1115 return ieee80211_tx_h_unicast_ps_buf(tx);
1116 else
1117 return ieee80211_tx_h_multicast_ps_buf(tx);
1118}
1119
1120
1121static void inline
1122__ieee80211_tx_prepare(struct ieee80211_txrx_data *tx,
1123 struct sk_buff *skb,
1124 struct net_device *dev,
1125 struct ieee80211_tx_control *control)
1126{
1127 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1128 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1129 int hdrlen;
1130
1131 memset(tx, 0, sizeof(*tx));
1132 tx->skb = skb;
1133 tx->dev = dev; /* use original interface */
1134 tx->local = local;
1135 tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1136 tx->sta = sta_info_get(local, hdr->addr1);
1137 tx->fc = le16_to_cpu(hdr->frame_control);
1138 control->power_level = local->hw.conf.power_level;
1139 tx->u.tx.control = control;
1140 tx->u.tx.unicast = !is_multicast_ether_addr(hdr->addr1);
1141 if (is_multicast_ether_addr(hdr->addr1))
1142 control->flags |= IEEE80211_TXCTL_NO_ACK;
1143 else
1144 control->flags &= ~IEEE80211_TXCTL_NO_ACK;
1145 tx->fragmented = local->fragmentation_threshold <
1146 IEEE80211_MAX_FRAG_THRESHOLD && tx->u.tx.unicast &&
1147 skb->len + FCS_LEN > local->fragmentation_threshold &&
1148 (!local->ops->set_frag_threshold);
1149 if (!tx->sta)
1150 control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK;
1151 else if (tx->sta->clear_dst_mask) {
1152 control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK;
1153 tx->sta->clear_dst_mask = 0;
1154 }
1155 control->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
1156 if (local->sta_antenna_sel != STA_ANTENNA_SEL_AUTO && tx->sta)
1157 control->antenna_sel_tx = tx->sta->antenna_sel_tx;
1158 hdrlen = ieee80211_get_hdrlen(tx->fc);
1159 if (skb->len > hdrlen + sizeof(rfc1042_header) + 2) {
1160 u8 *pos = &skb->data[hdrlen + sizeof(rfc1042_header)];
1161 tx->ethertype = (pos[0] << 8) | pos[1];
1162 }
1163 control->flags |= IEEE80211_TXCTL_FIRST_FRAGMENT;
1164
1165}
1166
1167static int inline is_ieee80211_device(struct net_device *dev,
1168 struct net_device *master)
1169{
1170 return (wdev_priv(dev->ieee80211_ptr) ==
1171 wdev_priv(master->ieee80211_ptr));
1172}
1173
1174/* Device in tx->dev has a reference added; use dev_put(tx->dev) when
1175 * finished with it. */
1176static int inline ieee80211_tx_prepare(struct ieee80211_txrx_data *tx,
1177 struct sk_buff *skb,
1178 struct net_device *mdev,
1179 struct ieee80211_tx_control *control)
1180{
1181 struct ieee80211_tx_packet_data *pkt_data;
1182 struct net_device *dev;
1183
1184 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
1185 dev = dev_get_by_index(pkt_data->ifindex);
1186 if (unlikely(dev && !is_ieee80211_device(dev, mdev))) {
1187 dev_put(dev);
1188 dev = NULL;
1189 }
1190 if (unlikely(!dev))
1191 return -ENODEV;
1192 __ieee80211_tx_prepare(tx, skb, dev, control);
1193 return 0;
1194}
1195
1196static inline int __ieee80211_queue_stopped(const struct ieee80211_local *local,
1197 int queue)
1198{
1199 return test_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]);
1200}
1201
1202static inline int __ieee80211_queue_pending(const struct ieee80211_local *local,
1203 int queue)
1204{
1205 return test_bit(IEEE80211_LINK_STATE_PENDING, &local->state[queue]);
1206}
1207
1208#define IEEE80211_TX_OK 0
1209#define IEEE80211_TX_AGAIN 1
1210#define IEEE80211_TX_FRAG_AGAIN 2
1211
1212static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb,
1213 struct ieee80211_txrx_data *tx)
1214{
1215 struct ieee80211_tx_control *control = tx->u.tx.control;
1216 int ret, i;
1217
1218 if (!ieee80211_qdisc_installed(local->mdev) &&
1219 __ieee80211_queue_stopped(local, 0)) {
1220 netif_stop_queue(local->mdev);
1221 return IEEE80211_TX_AGAIN;
1222 }
1223 if (skb) {
1224 ieee80211_dump_frame(local->mdev->name, "TX to low-level driver", skb);
1225 ret = local->ops->tx(local_to_hw(local), skb, control);
1226 if (ret)
1227 return IEEE80211_TX_AGAIN;
1228 local->mdev->trans_start = jiffies;
1229 ieee80211_led_tx(local, 1);
1230 }
1231 if (tx->u.tx.extra_frag) {
1232 control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS |
1233 IEEE80211_TXCTL_USE_CTS_PROTECT |
1234 IEEE80211_TXCTL_CLEAR_DST_MASK |
1235 IEEE80211_TXCTL_FIRST_FRAGMENT);
1236 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
1237 if (!tx->u.tx.extra_frag[i])
1238 continue;
1239 if (__ieee80211_queue_stopped(local, control->queue))
1240 return IEEE80211_TX_FRAG_AGAIN;
1241 if (i == tx->u.tx.num_extra_frag) {
1242 control->tx_rate = tx->u.tx.last_frag_hwrate;
1243 control->rate = tx->u.tx.last_frag_rate;
1244 if (tx->u.tx.probe_last_frag)
1245 control->flags |=
1246 IEEE80211_TXCTL_RATE_CTRL_PROBE;
1247 else
1248 control->flags &=
1249 ~IEEE80211_TXCTL_RATE_CTRL_PROBE;
1250 }
1251
1252 ieee80211_dump_frame(local->mdev->name,
1253 "TX to low-level driver",
1254 tx->u.tx.extra_frag[i]);
1255 ret = local->ops->tx(local_to_hw(local),
1256 tx->u.tx.extra_frag[i],
1257 control);
1258 if (ret)
1259 return IEEE80211_TX_FRAG_AGAIN;
1260 local->mdev->trans_start = jiffies;
1261 ieee80211_led_tx(local, 1);
1262 tx->u.tx.extra_frag[i] = NULL;
1263 }
1264 kfree(tx->u.tx.extra_frag);
1265 tx->u.tx.extra_frag = NULL;
1266 }
1267 return IEEE80211_TX_OK;
1268}
1269
1270static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
1271 struct ieee80211_tx_control *control, int mgmt)
1272{
1273 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1274 struct sta_info *sta;
1275 ieee80211_tx_handler *handler;
1276 struct ieee80211_txrx_data tx;
1277 ieee80211_txrx_result res = TXRX_DROP;
1278 int ret, i;
1279
1280 WARN_ON(__ieee80211_queue_pending(local, control->queue));
1281
1282 if (unlikely(skb->len < 10)) {
1283 dev_kfree_skb(skb);
1284 return 0;
1285 }
1286
1287 __ieee80211_tx_prepare(&tx, skb, dev, control);
1288 sta = tx.sta;
1289 tx.u.tx.mgmt_interface = mgmt;
1290 tx.u.tx.mode = local->hw.conf.mode;
1291
1292 for (handler = local->tx_handlers; *handler != NULL; handler++) {
1293 res = (*handler)(&tx);
1294 if (res != TXRX_CONTINUE)
1295 break;
1296 }
1297
1298 skb = tx.skb; /* handlers are allowed to change skb */
1299
1300 if (sta)
1301 sta_info_put(sta);
1302
1303 if (unlikely(res == TXRX_DROP)) {
1304 I802_DEBUG_INC(local->tx_handlers_drop);
1305 goto drop;
1306 }
1307
1308 if (unlikely(res == TXRX_QUEUED)) {
1309 I802_DEBUG_INC(local->tx_handlers_queued);
1310 return 0;
1311 }
1312
1313 if (tx.u.tx.extra_frag) {
1314 for (i = 0; i < tx.u.tx.num_extra_frag; i++) {
1315 int next_len, dur;
1316 struct ieee80211_hdr *hdr =
1317 (struct ieee80211_hdr *)
1318 tx.u.tx.extra_frag[i]->data;
1319
1320 if (i + 1 < tx.u.tx.num_extra_frag) {
1321 next_len = tx.u.tx.extra_frag[i + 1]->len;
1322 } else {
1323 next_len = 0;
1324 tx.u.tx.rate = tx.u.tx.last_frag_rate;
1325 tx.u.tx.last_frag_hwrate = tx.u.tx.rate->val;
1326 }
1327 dur = ieee80211_duration(&tx, 0, next_len);
1328 hdr->duration_id = cpu_to_le16(dur);
1329 }
1330 }
1331
1332retry:
1333 ret = __ieee80211_tx(local, skb, &tx);
1334 if (ret) {
1335 struct ieee80211_tx_stored_packet *store =
1336 &local->pending_packet[control->queue];
1337
1338 if (ret == IEEE80211_TX_FRAG_AGAIN)
1339 skb = NULL;
1340 set_bit(IEEE80211_LINK_STATE_PENDING,
1341 &local->state[control->queue]);
1342 smp_mb();
1343 /* When the driver gets out of buffers during sending of
1344 * fragments and calls ieee80211_stop_queue, there is
1345 * a small window between IEEE80211_LINK_STATE_XOFF and
1346 * IEEE80211_LINK_STATE_PENDING flags are set. If a buffer
1347 * gets available in that window (i.e. driver calls
1348 * ieee80211_wake_queue), we would end up with ieee80211_tx
1349 * called with IEEE80211_LINK_STATE_PENDING. Prevent this by
1350 * continuing transmitting here when that situation is
1351 * possible to have happened. */
1352 if (!__ieee80211_queue_stopped(local, control->queue)) {
1353 clear_bit(IEEE80211_LINK_STATE_PENDING,
1354 &local->state[control->queue]);
1355 goto retry;
1356 }
1357 memcpy(&store->control, control,
1358 sizeof(struct ieee80211_tx_control));
1359 store->skb = skb;
1360 store->extra_frag = tx.u.tx.extra_frag;
1361 store->num_extra_frag = tx.u.tx.num_extra_frag;
1362 store->last_frag_hwrate = tx.u.tx.last_frag_hwrate;
1363 store->last_frag_rate = tx.u.tx.last_frag_rate;
1364 store->last_frag_rate_ctrl_probe = tx.u.tx.probe_last_frag;
1365 }
1366 return 0;
1367
1368 drop:
1369 if (skb)
1370 dev_kfree_skb(skb);
1371 for (i = 0; i < tx.u.tx.num_extra_frag; i++)
1372 if (tx.u.tx.extra_frag[i])
1373 dev_kfree_skb(tx.u.tx.extra_frag[i]);
1374 kfree(tx.u.tx.extra_frag);
1375 return 0;
1376}
1377
1378static void ieee80211_tx_pending(unsigned long data)
1379{
1380 struct ieee80211_local *local = (struct ieee80211_local *)data;
1381 struct net_device *dev = local->mdev;
1382 struct ieee80211_tx_stored_packet *store;
1383 struct ieee80211_txrx_data tx;
1384 int i, ret, reschedule = 0;
1385
1386 netif_tx_lock_bh(dev);
1387 for (i = 0; i < local->hw.queues; i++) {
1388 if (__ieee80211_queue_stopped(local, i))
1389 continue;
1390 if (!__ieee80211_queue_pending(local, i)) {
1391 reschedule = 1;
1392 continue;
1393 }
1394 store = &local->pending_packet[i];
1395 tx.u.tx.control = &store->control;
1396 tx.u.tx.extra_frag = store->extra_frag;
1397 tx.u.tx.num_extra_frag = store->num_extra_frag;
1398 tx.u.tx.last_frag_hwrate = store->last_frag_hwrate;
1399 tx.u.tx.last_frag_rate = store->last_frag_rate;
1400 tx.u.tx.probe_last_frag = store->last_frag_rate_ctrl_probe;
1401 ret = __ieee80211_tx(local, store->skb, &tx);
1402 if (ret) {
1403 if (ret == IEEE80211_TX_FRAG_AGAIN)
1404 store->skb = NULL;
1405 } else {
1406 clear_bit(IEEE80211_LINK_STATE_PENDING,
1407 &local->state[i]);
1408 reschedule = 1;
1409 }
1410 }
1411 netif_tx_unlock_bh(dev);
1412 if (reschedule) {
1413 if (!ieee80211_qdisc_installed(dev)) {
1414 if (!__ieee80211_queue_stopped(local, 0))
1415 netif_wake_queue(dev);
1416 } else
1417 netif_schedule(dev);
1418 }
1419}
1420
1421static void ieee80211_clear_tx_pending(struct ieee80211_local *local)
1422{
1423 int i, j;
1424 struct ieee80211_tx_stored_packet *store;
1425
1426 for (i = 0; i < local->hw.queues; i++) {
1427 if (!__ieee80211_queue_pending(local, i))
1428 continue;
1429 store = &local->pending_packet[i];
1430 kfree_skb(store->skb);
1431 for (j = 0; j < store->num_extra_frag; j++)
1432 kfree_skb(store->extra_frag[j]);
1433 kfree(store->extra_frag);
1434 clear_bit(IEEE80211_LINK_STATE_PENDING, &local->state[i]);
1435 }
1436}
1437
1438static int ieee80211_master_start_xmit(struct sk_buff *skb,
1439 struct net_device *dev)
1440{
1441 struct ieee80211_tx_control control;
1442 struct ieee80211_tx_packet_data *pkt_data;
1443 struct net_device *odev = NULL;
1444 struct ieee80211_sub_if_data *osdata;
1445 int headroom;
1446 int ret;
1447
1448 /*
1449 * copy control out of the skb so other people can use skb->cb
1450 */
1451 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
1452 memset(&control, 0, sizeof(struct ieee80211_tx_control));
1453
1454 if (pkt_data->ifindex)
1455 odev = dev_get_by_index(pkt_data->ifindex);
1456 if (unlikely(odev && !is_ieee80211_device(odev, dev))) {
1457 dev_put(odev);
1458 odev = NULL;
1459 }
1460 if (unlikely(!odev)) {
1461#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1462 printk(KERN_DEBUG "%s: Discarded packet with nonexistent "
1463 "originating device\n", dev->name);
1464#endif
1465 dev_kfree_skb(skb);
1466 return 0;
1467 }
1468 osdata = IEEE80211_DEV_TO_SUB_IF(odev);
1469
1470 headroom = osdata->local->hw.extra_tx_headroom +
1471 IEEE80211_ENCRYPT_HEADROOM;
1472 if (skb_headroom(skb) < headroom) {
1473 if (pskb_expand_head(skb, headroom, 0, GFP_ATOMIC)) {
1474 dev_kfree_skb(skb);
1475 return 0;
1476 }
1477 }
1478
1479 control.ifindex = odev->ifindex;
1480 control.type = osdata->type;
1481 if (pkt_data->req_tx_status)
1482 control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS;
1483 if (pkt_data->do_not_encrypt)
1484 control.flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
1485 if (pkt_data->requeue)
1486 control.flags |= IEEE80211_TXCTL_REQUEUE;
1487 control.queue = pkt_data->queue;
1488
1489 ret = ieee80211_tx(odev, skb, &control,
1490 control.type == IEEE80211_IF_TYPE_MGMT);
1491 dev_put(odev);
1492
1493 return ret;
1494}
1495
1496
1497/**
1498 * ieee80211_subif_start_xmit - netif start_xmit function for Ethernet-type
1499 * subinterfaces (wlan#, WDS, and VLAN interfaces)
1500 * @skb: packet to be sent
1501 * @dev: incoming interface
1502 *
1503 * Returns: 0 on success (and frees skb in this case) or 1 on failure (skb will
1504 * not be freed, and caller is responsible for either retrying later or freeing
1505 * skb).
1506 *
1507 * This function takes in an Ethernet header and encapsulates it with suitable
1508 * IEEE 802.11 header based on which interface the packet is coming in. The
1509 * encapsulated packet will then be passed to master interface, wlan#.11, for
1510 * transmission (through low-level driver).
1511 */
1512static int ieee80211_subif_start_xmit(struct sk_buff *skb,
1513 struct net_device *dev)
1514{
1515 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1516 struct ieee80211_tx_packet_data *pkt_data;
1517 struct ieee80211_sub_if_data *sdata;
1518 int ret = 1, head_need;
1519 u16 ethertype, hdrlen, fc;
1520 struct ieee80211_hdr hdr;
1521 const u8 *encaps_data;
1522 int encaps_len, skip_header_bytes;
1523 int nh_pos, h_pos, no_encrypt = 0;
1524 struct sta_info *sta;
1525
1526 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1527 if (unlikely(skb->len < ETH_HLEN)) {
1528 printk(KERN_DEBUG "%s: short skb (len=%d)\n",
1529 dev->name, skb->len);
1530 ret = 0;
1531 goto fail;
1532 }
1533
1534 nh_pos = skb_network_header(skb) - skb->data;
1535 h_pos = skb_transport_header(skb) - skb->data;
1536
1537 /* convert Ethernet header to proper 802.11 header (based on
1538 * operation mode) */
1539 ethertype = (skb->data[12] << 8) | skb->data[13];
1540 /* TODO: handling for 802.1x authorized/unauthorized port */
1541 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
1542
1543 if (likely(sdata->type == IEEE80211_IF_TYPE_AP ||
1544 sdata->type == IEEE80211_IF_TYPE_VLAN)) {
1545 fc |= IEEE80211_FCTL_FROMDS;
1546 /* DA BSSID SA */
1547 memcpy(hdr.addr1, skb->data, ETH_ALEN);
1548 memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
1549 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
1550 hdrlen = 24;
1551 } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
1552 fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS;
1553 /* RA TA DA SA */
1554 memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN);
1555 memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
1556 memcpy(hdr.addr3, skb->data, ETH_ALEN);
1557 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN);
1558 hdrlen = 30;
1559 } else if (sdata->type == IEEE80211_IF_TYPE_STA) {
1560 fc |= IEEE80211_FCTL_TODS;
1561 /* BSSID SA DA */
1562 memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN);
1563 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
1564 memcpy(hdr.addr3, skb->data, ETH_ALEN);
1565 hdrlen = 24;
1566 } else if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
1567 /* DA SA BSSID */
1568 memcpy(hdr.addr1, skb->data, ETH_ALEN);
1569 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
1570 memcpy(hdr.addr3, sdata->u.sta.bssid, ETH_ALEN);
1571 hdrlen = 24;
1572 } else {
1573 ret = 0;
1574 goto fail;
1575 }
1576
1577 /* receiver is QoS enabled, use a QoS type frame */
1578 sta = sta_info_get(local, hdr.addr1);
1579 if (sta) {
1580 if (sta->flags & WLAN_STA_WME) {
1581 fc |= IEEE80211_STYPE_QOS_DATA;
1582 hdrlen += 2;
1583 }
1584 sta_info_put(sta);
1585 }
1586
1587 hdr.frame_control = cpu_to_le16(fc);
1588 hdr.duration_id = 0;
1589 hdr.seq_ctrl = 0;
1590
1591 skip_header_bytes = ETH_HLEN;
1592 if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) {
1593 encaps_data = bridge_tunnel_header;
1594 encaps_len = sizeof(bridge_tunnel_header);
1595 skip_header_bytes -= 2;
1596 } else if (ethertype >= 0x600) {
1597 encaps_data = rfc1042_header;
1598 encaps_len = sizeof(rfc1042_header);
1599 skip_header_bytes -= 2;
1600 } else {
1601 encaps_data = NULL;
1602 encaps_len = 0;
1603 }
1604
1605 skb_pull(skb, skip_header_bytes);
1606 nh_pos -= skip_header_bytes;
1607 h_pos -= skip_header_bytes;
1608
1609 /* TODO: implement support for fragments so that there is no need to
1610 * reallocate and copy payload; it might be enough to support one
1611 * extra fragment that would be copied in the beginning of the frame
1612 * data.. anyway, it would be nice to include this into skb structure
1613 * somehow
1614 *
1615 * There are few options for this:
1616 * use skb->cb as an extra space for 802.11 header
1617 * allocate new buffer if not enough headroom
1618 * make sure that there is enough headroom in every skb by increasing
1619 * build in headroom in __dev_alloc_skb() (linux/skbuff.h) and
1620 * alloc_skb() (net/core/skbuff.c)
1621 */
1622 head_need = hdrlen + encaps_len + local->hw.extra_tx_headroom;
1623 head_need -= skb_headroom(skb);
1624
1625 /* We are going to modify skb data, so make a copy of it if happens to
1626 * be cloned. This could happen, e.g., with Linux bridge code passing
1627 * us broadcast frames. */
1628
1629 if (head_need > 0 || skb_cloned(skb)) {
1630#if 0
1631 printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes "
1632 "of headroom\n", dev->name, head_need);
1633#endif
1634
1635 if (skb_cloned(skb))
1636 I802_DEBUG_INC(local->tx_expand_skb_head_cloned);
1637 else
1638 I802_DEBUG_INC(local->tx_expand_skb_head);
1639 /* Since we have to reallocate the buffer, make sure that there
1640 * is enough room for possible WEP IV/ICV and TKIP (8 bytes
1641 * before payload and 12 after). */
1642 if (pskb_expand_head(skb, (head_need > 0 ? head_need + 8 : 8),
1643 12, GFP_ATOMIC)) {
1644 printk(KERN_DEBUG "%s: failed to reallocate TX buffer"
1645 "\n", dev->name);
1646 goto fail;
1647 }
1648 }
1649
1650 if (encaps_data) {
1651 memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len);
1652 nh_pos += encaps_len;
1653 h_pos += encaps_len;
1654 }
1655 memcpy(skb_push(skb, hdrlen), &hdr, hdrlen);
1656 nh_pos += hdrlen;
1657 h_pos += hdrlen;
1658
1659 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
1660 memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data));
1661 pkt_data->ifindex = sdata->dev->ifindex;
1662 pkt_data->mgmt_iface = (sdata->type == IEEE80211_IF_TYPE_MGMT);
1663 pkt_data->do_not_encrypt = no_encrypt;
1664
1665 skb->dev = local->mdev;
1666 sdata->stats.tx_packets++;
1667 sdata->stats.tx_bytes += skb->len;
1668
1669 /* Update skb pointers to various headers since this modified frame
1670 * is going to go through Linux networking code that may potentially
1671 * need things like pointer to IP header. */
1672 skb_set_mac_header(skb, 0);
1673 skb_set_network_header(skb, nh_pos);
1674 skb_set_transport_header(skb, h_pos);
1675
1676 dev->trans_start = jiffies;
1677 dev_queue_xmit(skb);
1678
1679 return 0;
1680
1681 fail:
1682 if (!ret)
1683 dev_kfree_skb(skb);
1684
1685 return ret;
1686}
1687
1688
1689/*
1690 * This is the transmit routine for the 802.11 type interfaces
1691 * called by upper layers of the linux networking
1692 * stack when it has a frame to transmit
1693 */
1694static int
1695ieee80211_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
1696{
1697 struct ieee80211_sub_if_data *sdata;
1698 struct ieee80211_tx_packet_data *pkt_data;
1699 struct ieee80211_hdr *hdr;
1700 u16 fc;
1701
1702 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1703
1704 if (skb->len < 10) {
1705 dev_kfree_skb(skb);
1706 return 0;
1707 }
1708
1709 if (skb_headroom(skb) < sdata->local->hw.extra_tx_headroom) {
1710 if (pskb_expand_head(skb,
1711 sdata->local->hw.extra_tx_headroom, 0, GFP_ATOMIC)) {
1712 dev_kfree_skb(skb);
1713 return 0;
1714 }
1715 }
1716
1717 hdr = (struct ieee80211_hdr *) skb->data;
1718 fc = le16_to_cpu(hdr->frame_control);
1719
1720 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
1721 memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data));
1722 pkt_data->ifindex = sdata->dev->ifindex;
1723 pkt_data->mgmt_iface = (sdata->type == IEEE80211_IF_TYPE_MGMT);
1724
1725 skb->priority = 20; /* use hardcoded priority for mgmt TX queue */
1726 skb->dev = sdata->local->mdev;
1727
1728 /*
1729 * We're using the protocol field of the the frame control header
1730 * to request TX callback for hostapd. BIT(1) is checked.
1731 */
1732 if ((fc & BIT(1)) == BIT(1)) {
1733 pkt_data->req_tx_status = 1;
1734 fc &= ~BIT(1);
1735 hdr->frame_control = cpu_to_le16(fc);
1736 }
1737
1738 pkt_data->do_not_encrypt = !(fc & IEEE80211_FCTL_PROTECTED);
1739
1740 sdata->stats.tx_packets++;
1741 sdata->stats.tx_bytes += skb->len;
1742
1743 dev_queue_xmit(skb);
1744
1745 return 0;
1746}
1747
1748
1749static void ieee80211_beacon_add_tim(struct ieee80211_local *local,
1750 struct ieee80211_if_ap *bss,
1751 struct sk_buff *skb)
1752{
1753 u8 *pos, *tim;
1754 int aid0 = 0;
1755 int i, have_bits = 0, n1, n2;
1756
1757 /* Generate bitmap for TIM only if there are any STAs in power save
1758 * mode. */
1759 spin_lock_bh(&local->sta_lock);
1760 if (atomic_read(&bss->num_sta_ps) > 0)
1761 /* in the hope that this is faster than
1762 * checking byte-for-byte */
1763 have_bits = !bitmap_empty((unsigned long*)bss->tim,
1764 IEEE80211_MAX_AID+1);
1765
1766 if (bss->dtim_count == 0)
1767 bss->dtim_count = bss->dtim_period - 1;
1768 else
1769 bss->dtim_count--;
1770
1771 tim = pos = (u8 *) skb_put(skb, 6);
1772 *pos++ = WLAN_EID_TIM;
1773 *pos++ = 4;
1774 *pos++ = bss->dtim_count;
1775 *pos++ = bss->dtim_period;
1776
1777 if (bss->dtim_count == 0 && !skb_queue_empty(&bss->ps_bc_buf))
1778 aid0 = 1;
1779
1780 if (have_bits) {
1781 /* Find largest even number N1 so that bits numbered 1 through
1782 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits
1783 * (N2 + 1) x 8 through 2007 are 0. */
1784 n1 = 0;
1785 for (i = 0; i < IEEE80211_MAX_TIM_LEN; i++) {
1786 if (bss->tim[i]) {
1787 n1 = i & 0xfe;
1788 break;
1789 }
1790 }
1791 n2 = n1;
1792 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) {
1793 if (bss->tim[i]) {
1794 n2 = i;
1795 break;
1796 }
1797 }
1798
1799 /* Bitmap control */
1800 *pos++ = n1 | aid0;
1801 /* Part Virt Bitmap */
1802 memcpy(pos, bss->tim + n1, n2 - n1 + 1);
1803
1804 tim[1] = n2 - n1 + 4;
1805 skb_put(skb, n2 - n1);
1806 } else {
1807 *pos++ = aid0; /* Bitmap control */
1808 *pos++ = 0; /* Part Virt Bitmap */
1809 }
1810 spin_unlock_bh(&local->sta_lock);
1811}
1812
1813
1814struct sk_buff * ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id,
1815 struct ieee80211_tx_control *control)
1816{
1817 struct ieee80211_local *local = hw_to_local(hw);
1818 struct sk_buff *skb;
1819 struct net_device *bdev;
1820 struct ieee80211_sub_if_data *sdata = NULL;
1821 struct ieee80211_if_ap *ap = NULL;
1822 struct ieee80211_rate *rate;
1823 struct rate_control_extra extra;
1824 u8 *b_head, *b_tail;
1825 int bh_len, bt_len;
1826
1827 bdev = dev_get_by_index(if_id);
1828 if (bdev) {
1829 sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
1830 ap = &sdata->u.ap;
1831 dev_put(bdev);
1832 }
1833
1834 if (!ap || sdata->type != IEEE80211_IF_TYPE_AP ||
1835 !ap->beacon_head) {
1836#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1837 if (net_ratelimit())
1838 printk(KERN_DEBUG "no beacon data avail for idx=%d "
1839 "(%s)\n", if_id, bdev ? bdev->name : "N/A");
1840#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
1841 return NULL;
1842 }
1843
1844 /* Assume we are generating the normal beacon locally */
1845 b_head = ap->beacon_head;
1846 b_tail = ap->beacon_tail;
1847 bh_len = ap->beacon_head_len;
1848 bt_len = ap->beacon_tail_len;
1849
1850 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
1851 bh_len + bt_len + 256 /* maximum TIM len */);
1852 if (!skb)
1853 return NULL;
1854
1855 skb_reserve(skb, local->hw.extra_tx_headroom);
1856 memcpy(skb_put(skb, bh_len), b_head, bh_len);
1857
1858 ieee80211_include_sequence(sdata, (struct ieee80211_hdr *)skb->data);
1859
1860 ieee80211_beacon_add_tim(local, ap, skb);
1861
1862 if (b_tail) {
1863 memcpy(skb_put(skb, bt_len), b_tail, bt_len);
1864 }
1865
1866 if (control) {
1867 memset(&extra, 0, sizeof(extra));
1868 extra.mode = local->oper_hw_mode;
1869
1870 rate = rate_control_get_rate(local, local->mdev, skb, &extra);
1871 if (!rate) {
1872 if (net_ratelimit()) {
1873 printk(KERN_DEBUG "%s: ieee80211_beacon_get: no rate "
1874 "found\n", local->mdev->name);
1875 }
1876 dev_kfree_skb(skb);
1877 return NULL;
1878 }
1879
1880 control->tx_rate = (local->short_preamble &&
1881 (rate->flags & IEEE80211_RATE_PREAMBLE2)) ?
1882 rate->val2 : rate->val;
1883 control->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
1884 control->power_level = local->hw.conf.power_level;
1885 control->flags |= IEEE80211_TXCTL_NO_ACK;
1886 control->retry_limit = 1;
1887 control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK;
1888 }
1889
1890 ap->num_beacons++;
1891 return skb;
1892}
1893EXPORT_SYMBOL(ieee80211_beacon_get);
1894
1895__le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
1896 size_t frame_len,
1897 const struct ieee80211_tx_control *frame_txctl)
1898{
1899 struct ieee80211_local *local = hw_to_local(hw);
1900 struct ieee80211_rate *rate;
1901 int short_preamble = local->short_preamble;
1902 int erp;
1903 u16 dur;
1904
1905 rate = frame_txctl->rts_rate;
1906 erp = !!(rate->flags & IEEE80211_RATE_ERP);
1907
1908 /* CTS duration */
1909 dur = ieee80211_frame_duration(local, 10, rate->rate,
1910 erp, short_preamble);
1911 /* Data frame duration */
1912 dur += ieee80211_frame_duration(local, frame_len, rate->rate,
1913 erp, short_preamble);
1914 /* ACK duration */
1915 dur += ieee80211_frame_duration(local, 10, rate->rate,
1916 erp, short_preamble);
1917
1918 return cpu_to_le16(dur);
1919}
1920EXPORT_SYMBOL(ieee80211_rts_duration);
1921
1922
1923__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
1924 size_t frame_len,
1925 const struct ieee80211_tx_control *frame_txctl)
1926{
1927 struct ieee80211_local *local = hw_to_local(hw);
1928 struct ieee80211_rate *rate;
1929 int short_preamble = local->short_preamble;
1930 int erp;
1931 u16 dur;
1932
1933 rate = frame_txctl->rts_rate;
1934 erp = !!(rate->flags & IEEE80211_RATE_ERP);
1935
1936 /* Data frame duration */
1937 dur = ieee80211_frame_duration(local, frame_len, rate->rate,
1938 erp, short_preamble);
1939 if (!(frame_txctl->flags & IEEE80211_TXCTL_NO_ACK)) {
1940 /* ACK duration */
1941 dur += ieee80211_frame_duration(local, 10, rate->rate,
1942 erp, short_preamble);
1943 }
1944
1945 return cpu_to_le16(dur);
1946}
1947EXPORT_SYMBOL(ieee80211_ctstoself_duration);
1948
1949void ieee80211_rts_get(struct ieee80211_hw *hw,
1950 const void *frame, size_t frame_len,
1951 const struct ieee80211_tx_control *frame_txctl,
1952 struct ieee80211_rts *rts)
1953{
1954 const struct ieee80211_hdr *hdr = frame;
1955 u16 fctl;
1956
1957 fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS;
1958 rts->frame_control = cpu_to_le16(fctl);
1959 rts->duration = ieee80211_rts_duration(hw, frame_len, frame_txctl);
1960 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra));
1961 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta));
1962}
1963EXPORT_SYMBOL(ieee80211_rts_get);
1964
1965void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
1966 const void *frame, size_t frame_len,
1967 const struct ieee80211_tx_control *frame_txctl,
1968 struct ieee80211_cts *cts)
1969{
1970 const struct ieee80211_hdr *hdr = frame;
1971 u16 fctl;
1972
1973 fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS;
1974 cts->frame_control = cpu_to_le16(fctl);
1975 cts->duration = ieee80211_ctstoself_duration(hw, frame_len, frame_txctl);
1976 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra));
1977}
1978EXPORT_SYMBOL(ieee80211_ctstoself_get);
1979
1980struct sk_buff *
1981ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
1982 struct ieee80211_tx_control *control)
1983{
1984 struct ieee80211_local *local = hw_to_local(hw);
1985 struct sk_buff *skb;
1986 struct sta_info *sta;
1987 ieee80211_tx_handler *handler;
1988 struct ieee80211_txrx_data tx;
1989 ieee80211_txrx_result res = TXRX_DROP;
1990 struct net_device *bdev;
1991 struct ieee80211_sub_if_data *sdata;
1992 struct ieee80211_if_ap *bss = NULL;
1993
1994 bdev = dev_get_by_index(if_id);
1995 if (bdev) {
1996 sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
1997 bss = &sdata->u.ap;
1998 dev_put(bdev);
1999 }
2000 if (!bss || sdata->type != IEEE80211_IF_TYPE_AP || !bss->beacon_head)
2001 return NULL;
2002
2003 if (bss->dtim_count != 0)
2004 return NULL; /* send buffered bc/mc only after DTIM beacon */
2005 memset(control, 0, sizeof(*control));
2006 while (1) {
2007 skb = skb_dequeue(&bss->ps_bc_buf);
2008 if (!skb)
2009 return NULL;
2010 local->total_ps_buffered--;
2011
2012 if (!skb_queue_empty(&bss->ps_bc_buf) && skb->len >= 2) {
2013 struct ieee80211_hdr *hdr =
2014 (struct ieee80211_hdr *) skb->data;
2015 /* more buffered multicast/broadcast frames ==> set
2016 * MoreData flag in IEEE 802.11 header to inform PS
2017 * STAs */
2018 hdr->frame_control |=
2019 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
2020 }
2021
2022 if (ieee80211_tx_prepare(&tx, skb, local->mdev, control) == 0)
2023 break;
2024 dev_kfree_skb_any(skb);
2025 }
2026 sta = tx.sta;
2027 tx.u.tx.ps_buffered = 1;
2028
2029 for (handler = local->tx_handlers; *handler != NULL; handler++) {
2030 res = (*handler)(&tx);
2031 if (res == TXRX_DROP || res == TXRX_QUEUED)
2032 break;
2033 }
2034 dev_put(tx.dev);
2035 skb = tx.skb; /* handlers are allowed to change skb */
2036
2037 if (res == TXRX_DROP) {
2038 I802_DEBUG_INC(local->tx_handlers_drop);
2039 dev_kfree_skb(skb);
2040 skb = NULL;
2041 } else if (res == TXRX_QUEUED) {
2042 I802_DEBUG_INC(local->tx_handlers_queued);
2043 skb = NULL;
2044 }
2045
2046 if (sta)
2047 sta_info_put(sta);
2048
2049 return skb;
2050}
2051EXPORT_SYMBOL(ieee80211_get_buffered_bc);
2052
2053static int __ieee80211_if_config(struct net_device *dev,
2054 struct sk_buff *beacon,
2055 struct ieee80211_tx_control *control)
2056{
2057 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2058 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2059 struct ieee80211_if_conf conf;
2060 static u8 scan_bssid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2061
2062 if (!local->ops->config_interface || !netif_running(dev))
2063 return 0;
2064
2065 memset(&conf, 0, sizeof(conf));
2066 conf.type = sdata->type;
2067 if (sdata->type == IEEE80211_IF_TYPE_STA ||
2068 sdata->type == IEEE80211_IF_TYPE_IBSS) {
2069 if (local->sta_scanning &&
2070 local->scan_dev == dev)
2071 conf.bssid = scan_bssid;
2072 else
2073 conf.bssid = sdata->u.sta.bssid;
2074 conf.ssid = sdata->u.sta.ssid;
2075 conf.ssid_len = sdata->u.sta.ssid_len;
2076 conf.generic_elem = sdata->u.sta.extra_ie;
2077 conf.generic_elem_len = sdata->u.sta.extra_ie_len;
2078 } else if (sdata->type == IEEE80211_IF_TYPE_AP) {
2079 conf.ssid = sdata->u.ap.ssid;
2080 conf.ssid_len = sdata->u.ap.ssid_len;
2081 conf.generic_elem = sdata->u.ap.generic_elem;
2082 conf.generic_elem_len = sdata->u.ap.generic_elem_len;
2083 conf.beacon = beacon;
2084 conf.beacon_control = control;
2085 }
2086 return local->ops->config_interface(local_to_hw(local),
2087 dev->ifindex, &conf);
2088}
2089
2090int ieee80211_if_config(struct net_device *dev)
2091{
2092 return __ieee80211_if_config(dev, NULL, NULL);
2093}
2094
2095int ieee80211_if_config_beacon(struct net_device *dev)
2096{
2097 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2098 struct ieee80211_tx_control control;
2099 struct sk_buff *skb;
2100
2101 if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
2102 return 0;
2103 skb = ieee80211_beacon_get(local_to_hw(local), dev->ifindex, &control);
2104 if (!skb)
2105 return -ENOMEM;
2106 return __ieee80211_if_config(dev, skb, &control);
2107}
2108
2109int ieee80211_hw_config(struct ieee80211_local *local)
2110{
2111 struct ieee80211_hw_mode *mode;
2112 struct ieee80211_channel *chan;
2113 int ret = 0;
2114
2115 if (local->sta_scanning) {
2116 chan = local->scan_channel;
2117 mode = local->scan_hw_mode;
2118 } else {
2119 chan = local->oper_channel;
2120 mode = local->oper_hw_mode;
2121 }
2122
2123 local->hw.conf.channel = chan->chan;
2124 local->hw.conf.channel_val = chan->val;
2125 local->hw.conf.power_level = chan->power_level;
2126 local->hw.conf.freq = chan->freq;
2127 local->hw.conf.phymode = mode->mode;
2128 local->hw.conf.antenna_max = chan->antenna_max;
2129 local->hw.conf.chan = chan;
2130 local->hw.conf.mode = mode;
2131
2132#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
2133 printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d "
2134 "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq,
2135 local->hw.conf.phymode);
2136#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
2137
2138 if (local->ops->config)
2139 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
2140
2141 return ret;
2142}
2143
2144
2145static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
2146{
2147 /* FIX: what would be proper limits for MTU?
2148 * This interface uses 802.3 frames. */
2149 if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6) {
2150 printk(KERN_WARNING "%s: invalid MTU %d\n",
2151 dev->name, new_mtu);
2152 return -EINVAL;
2153 }
2154
2155#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
2156 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
2157#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
2158 dev->mtu = new_mtu;
2159 return 0;
2160}
2161
2162
2163static int ieee80211_change_mtu_apdev(struct net_device *dev, int new_mtu)
2164{
2165 /* FIX: what would be proper limits for MTU?
2166 * This interface uses 802.11 frames. */
2167 if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN) {
2168 printk(KERN_WARNING "%s: invalid MTU %d\n",
2169 dev->name, new_mtu);
2170 return -EINVAL;
2171 }
2172
2173#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
2174 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
2175#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
2176 dev->mtu = new_mtu;
2177 return 0;
2178}
2179
2180enum netif_tx_lock_class {
2181 TX_LOCK_NORMAL,
2182 TX_LOCK_MASTER,
2183};
2184
2185static inline void netif_tx_lock_nested(struct net_device *dev, int subclass)
2186{
2187 spin_lock_nested(&dev->_xmit_lock, subclass);
2188 dev->xmit_lock_owner = smp_processor_id();
2189}
2190
2191static void ieee80211_set_multicast_list(struct net_device *dev)
2192{
2193 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2194 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2195 unsigned short flags;
2196
2197 netif_tx_lock_nested(local->mdev, TX_LOCK_MASTER);
2198 if (((dev->flags & IFF_ALLMULTI) != 0) ^ (sdata->allmulti != 0)) {
2199 if (sdata->allmulti) {
2200 sdata->allmulti = 0;
2201 local->iff_allmultis--;
2202 } else {
2203 sdata->allmulti = 1;
2204 local->iff_allmultis++;
2205 }
2206 }
2207 if (((dev->flags & IFF_PROMISC) != 0) ^ (sdata->promisc != 0)) {
2208 if (sdata->promisc) {
2209 sdata->promisc = 0;
2210 local->iff_promiscs--;
2211 } else {
2212 sdata->promisc = 1;
2213 local->iff_promiscs++;
2214 }
2215 }
2216 if (dev->mc_count != sdata->mc_count) {
2217 local->mc_count = local->mc_count - sdata->mc_count +
2218 dev->mc_count;
2219 sdata->mc_count = dev->mc_count;
2220 }
2221 if (local->ops->set_multicast_list) {
2222 flags = local->mdev->flags;
2223 if (local->iff_allmultis)
2224 flags |= IFF_ALLMULTI;
2225 if (local->iff_promiscs)
2226 flags |= IFF_PROMISC;
2227 read_lock(&local->sub_if_lock);
2228 local->ops->set_multicast_list(local_to_hw(local), flags,
2229 local->mc_count);
2230 read_unlock(&local->sub_if_lock);
2231 }
2232 netif_tx_unlock(local->mdev);
2233}
2234
2235struct dev_mc_list *ieee80211_get_mc_list_item(struct ieee80211_hw *hw,
2236 struct dev_mc_list *prev,
2237 void **ptr)
2238{
2239 struct ieee80211_local *local = hw_to_local(hw);
2240 struct ieee80211_sub_if_data *sdata = *ptr;
2241 struct dev_mc_list *mc;
2242
2243 if (!prev) {
2244 WARN_ON(sdata);
2245 sdata = NULL;
2246 }
2247 if (!prev || !prev->next) {
2248 if (sdata)
2249 sdata = list_entry(sdata->list.next,
2250 struct ieee80211_sub_if_data, list);
2251 else
2252 sdata = list_entry(local->sub_if_list.next,
2253 struct ieee80211_sub_if_data, list);
2254 if (&sdata->list != &local->sub_if_list)
2255 mc = sdata->dev->mc_list;
2256 else
2257 mc = NULL;
2258 } else
2259 mc = prev->next;
2260
2261 *ptr = sdata;
2262 return mc;
2263}
2264EXPORT_SYMBOL(ieee80211_get_mc_list_item);
2265
2266static struct net_device_stats *ieee80211_get_stats(struct net_device *dev)
2267{
2268 struct ieee80211_sub_if_data *sdata;
2269 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2270 return &(sdata->stats);
2271}
2272
2273static void ieee80211_if_shutdown(struct net_device *dev)
2274{
2275 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2276 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2277
2278 ASSERT_RTNL();
2279 switch (sdata->type) {
2280 case IEEE80211_IF_TYPE_STA:
2281 case IEEE80211_IF_TYPE_IBSS:
2282 sdata->u.sta.state = IEEE80211_DISABLED;
2283 del_timer_sync(&sdata->u.sta.timer);
2284 skb_queue_purge(&sdata->u.sta.skb_queue);
2285 if (!local->ops->hw_scan &&
2286 local->scan_dev == sdata->dev) {
2287 local->sta_scanning = 0;
2288 cancel_delayed_work(&local->scan_work);
2289 }
2290 flush_workqueue(local->hw.workqueue);
2291 break;
2292 }
2293}
2294
2295static inline int identical_mac_addr_allowed(int type1, int type2)
2296{
2297 return (type1 == IEEE80211_IF_TYPE_MNTR ||
2298 type2 == IEEE80211_IF_TYPE_MNTR ||
2299 (type1 == IEEE80211_IF_TYPE_AP &&
2300 type2 == IEEE80211_IF_TYPE_WDS) ||
2301 (type1 == IEEE80211_IF_TYPE_WDS &&
2302 (type2 == IEEE80211_IF_TYPE_WDS ||
2303 type2 == IEEE80211_IF_TYPE_AP)) ||
2304 (type1 == IEEE80211_IF_TYPE_AP &&
2305 type2 == IEEE80211_IF_TYPE_VLAN) ||
2306 (type1 == IEEE80211_IF_TYPE_VLAN &&
2307 (type2 == IEEE80211_IF_TYPE_AP ||
2308 type2 == IEEE80211_IF_TYPE_VLAN)));
2309}
2310
2311static int ieee80211_master_open(struct net_device *dev)
2312{
2313 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2314 struct ieee80211_sub_if_data *sdata;
2315 int res = -EOPNOTSUPP;
2316
2317 read_lock(&local->sub_if_lock);
2318 list_for_each_entry(sdata, &local->sub_if_list, list) {
2319 if (sdata->dev != dev && netif_running(sdata->dev)) {
2320 res = 0;
2321 break;
2322 }
2323 }
2324 read_unlock(&local->sub_if_lock);
2325 return res;
2326}
2327
2328static int ieee80211_master_stop(struct net_device *dev)
2329{
2330 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2331 struct ieee80211_sub_if_data *sdata;
2332
2333 read_lock(&local->sub_if_lock);
2334 list_for_each_entry(sdata, &local->sub_if_list, list)
2335 if (sdata->dev != dev && netif_running(sdata->dev))
2336 dev_close(sdata->dev);
2337 read_unlock(&local->sub_if_lock);
2338
2339 return 0;
2340}
2341
2342static int ieee80211_mgmt_open(struct net_device *dev)
2343{
2344 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2345
2346 if (!netif_running(local->mdev))
2347 return -EOPNOTSUPP;
2348 return 0;
2349}
2350
2351static int ieee80211_mgmt_stop(struct net_device *dev)
2352{
2353 return 0;
2354}
2355
2356/* Check if running monitor interfaces should go to a "soft monitor" mode
2357 * and switch them if necessary. */
2358static inline void ieee80211_start_soft_monitor(struct ieee80211_local *local)
2359{
2360 struct ieee80211_if_init_conf conf;
2361
2362 if (local->open_count && local->open_count == local->monitors &&
2363 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) &&
2364 local->ops->remove_interface) {
2365 conf.if_id = -1;
2366 conf.type = IEEE80211_IF_TYPE_MNTR;
2367 conf.mac_addr = NULL;
2368 local->ops->remove_interface(local_to_hw(local), &conf);
2369 }
2370}
2371
2372/* Check if running monitor interfaces should go to a "hard monitor" mode
2373 * and switch them if necessary. */
2374static void ieee80211_start_hard_monitor(struct ieee80211_local *local)
2375{
2376 struct ieee80211_if_init_conf conf;
2377
2378 if (local->open_count && local->open_count == local->monitors &&
2379 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) &&
2380 local->ops->add_interface) {
2381 conf.if_id = -1;
2382 conf.type = IEEE80211_IF_TYPE_MNTR;
2383 conf.mac_addr = NULL;
2384 local->ops->add_interface(local_to_hw(local), &conf);
2385 }
2386}
2387
2388static int ieee80211_open(struct net_device *dev)
2389{
2390 struct ieee80211_sub_if_data *sdata, *nsdata;
2391 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2392 struct ieee80211_if_init_conf conf;
2393 int res;
2394
2395 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2396 read_lock(&local->sub_if_lock);
2397 list_for_each_entry(nsdata, &local->sub_if_list, list) {
2398 struct net_device *ndev = nsdata->dev;
2399
2400 if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
2401 compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0 &&
2402 !identical_mac_addr_allowed(sdata->type, nsdata->type)) {
2403 read_unlock(&local->sub_if_lock);
2404 return -ENOTUNIQ;
2405 }
2406 }
2407 read_unlock(&local->sub_if_lock);
2408
2409 if (sdata->type == IEEE80211_IF_TYPE_WDS &&
2410 is_zero_ether_addr(sdata->u.wds.remote_addr))
2411 return -ENOLINK;
2412
2413 if (sdata->type == IEEE80211_IF_TYPE_MNTR && local->open_count &&
2414 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) {
2415 /* run the interface in a "soft monitor" mode */
2416 local->monitors++;
2417 local->open_count++;
2418 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
2419 return 0;
2420 }
2421 ieee80211_start_soft_monitor(local);
2422
2423 if (local->ops->add_interface) {
2424 conf.if_id = dev->ifindex;
2425 conf.type = sdata->type;
2426 conf.mac_addr = dev->dev_addr;
2427 res = local->ops->add_interface(local_to_hw(local), &conf);
2428 if (res) {
2429 if (sdata->type == IEEE80211_IF_TYPE_MNTR)
2430 ieee80211_start_hard_monitor(local);
2431 return res;
2432 }
2433 } else {
2434 if (sdata->type != IEEE80211_IF_TYPE_STA)
2435 return -EOPNOTSUPP;
2436 if (local->open_count > 0)
2437 return -ENOBUFS;
2438 }
2439
2440 if (local->open_count == 0) {
2441 res = 0;
2442 tasklet_enable(&local->tx_pending_tasklet);
2443 tasklet_enable(&local->tasklet);
2444 if (local->ops->open)
2445 res = local->ops->open(local_to_hw(local));
2446 if (res == 0) {
2447 res = dev_open(local->mdev);
2448 if (res) {
2449 if (local->ops->stop)
2450 local->ops->stop(local_to_hw(local));
2451 } else {
2452 res = ieee80211_hw_config(local);
2453 if (res && local->ops->stop)
2454 local->ops->stop(local_to_hw(local));
2455 else if (!res && local->apdev)
2456 dev_open(local->apdev);
2457 }
2458 }
2459 if (res) {
2460 if (local->ops->remove_interface)
2461 local->ops->remove_interface(local_to_hw(local),
2462 &conf);
2463 return res;
2464 }
2465 }
2466 local->open_count++;
2467
2468 if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
2469 local->monitors++;
2470 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
2471 } else
2472 ieee80211_if_config(dev);
2473
2474 if (sdata->type == IEEE80211_IF_TYPE_STA &&
2475 !local->user_space_mlme)
2476 netif_carrier_off(dev);
2477
2478 netif_start_queue(dev);
2479 return 0;
2480}
2481
2482
2483static int ieee80211_stop(struct net_device *dev)
2484{
2485 struct ieee80211_sub_if_data *sdata;
2486 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2487
2488 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2489
2490 if (sdata->type == IEEE80211_IF_TYPE_MNTR &&
2491 local->open_count > 1 &&
2492 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) {
2493 /* remove "soft monitor" interface */
2494 local->open_count--;
2495 local->monitors--;
2496 if (!local->monitors)
2497 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
2498 return 0;
2499 }
2500
2501 netif_stop_queue(dev);
2502 ieee80211_if_shutdown(dev);
2503
2504 if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
2505 local->monitors--;
2506 if (!local->monitors)
2507 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
2508 }
2509
2510 local->open_count--;
2511 if (local->open_count == 0) {
2512 if (netif_running(local->mdev))
2513 dev_close(local->mdev);
2514 if (local->apdev)
2515 dev_close(local->apdev);
2516 if (local->ops->stop)
2517 local->ops->stop(local_to_hw(local));
2518 tasklet_disable(&local->tx_pending_tasklet);
2519 tasklet_disable(&local->tasklet);
2520 }
2521 if (local->ops->remove_interface) {
2522 struct ieee80211_if_init_conf conf;
2523
2524 conf.if_id = dev->ifindex;
2525 conf.type = sdata->type;
2526 conf.mac_addr = dev->dev_addr;
2527 local->ops->remove_interface(local_to_hw(local), &conf);
2528 }
2529
2530 ieee80211_start_hard_monitor(local);
2531
2532 return 0;
2533}
2534
2535
2536static int header_parse_80211(struct sk_buff *skb, unsigned char *haddr)
2537{
2538 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
2539 return ETH_ALEN;
2540}
2541
2542static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
2543{
2544 return compare_ether_addr(raddr, addr) == 0 ||
2545 is_broadcast_ether_addr(raddr);
2546}
2547
2548
2549static ieee80211_txrx_result
2550ieee80211_rx_h_data(struct ieee80211_txrx_data *rx)
2551{
2552 struct net_device *dev = rx->dev;
2553 struct ieee80211_local *local = rx->local;
2554 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
2555 u16 fc, hdrlen, ethertype;
2556 u8 *payload;
2557 u8 dst[ETH_ALEN];
2558 u8 src[ETH_ALEN];
2559 struct sk_buff *skb = rx->skb, *skb2;
2560 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2561
2562 fc = rx->fc;
2563 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA))
2564 return TXRX_CONTINUE;
2565
2566 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
2567 return TXRX_DROP;
2568
2569 hdrlen = ieee80211_get_hdrlen(fc);
2570
2571 /* convert IEEE 802.11 header + possible LLC headers into Ethernet
2572 * header
2573 * IEEE 802.11 address fields:
2574 * ToDS FromDS Addr1 Addr2 Addr3 Addr4
2575 * 0 0 DA SA BSSID n/a
2576 * 0 1 DA BSSID SA n/a
2577 * 1 0 BSSID SA DA n/a
2578 * 1 1 RA TA DA SA
2579 */
2580
2581 switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
2582 case IEEE80211_FCTL_TODS:
2583 /* BSSID SA DA */
2584 memcpy(dst, hdr->addr3, ETH_ALEN);
2585 memcpy(src, hdr->addr2, ETH_ALEN);
2586
2587 if (unlikely(sdata->type != IEEE80211_IF_TYPE_AP &&
2588 sdata->type != IEEE80211_IF_TYPE_VLAN)) {
2589 printk(KERN_DEBUG "%s: dropped ToDS frame (BSSID="
2590 MAC_FMT " SA=" MAC_FMT " DA=" MAC_FMT ")\n",
2591 dev->name, MAC_ARG(hdr->addr1),
2592 MAC_ARG(hdr->addr2), MAC_ARG(hdr->addr3));
2593 return TXRX_DROP;
2594 }
2595 break;
2596 case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
2597 /* RA TA DA SA */
2598 memcpy(dst, hdr->addr3, ETH_ALEN);
2599 memcpy(src, hdr->addr4, ETH_ALEN);
2600
2601 if (unlikely(sdata->type != IEEE80211_IF_TYPE_WDS)) {
2602 printk(KERN_DEBUG "%s: dropped FromDS&ToDS frame (RA="
2603 MAC_FMT " TA=" MAC_FMT " DA=" MAC_FMT " SA="
2604 MAC_FMT ")\n",
2605 rx->dev->name, MAC_ARG(hdr->addr1),
2606 MAC_ARG(hdr->addr2), MAC_ARG(hdr->addr3),
2607 MAC_ARG(hdr->addr4));
2608 return TXRX_DROP;
2609 }
2610 break;
2611 case IEEE80211_FCTL_FROMDS:
2612 /* DA BSSID SA */
2613 memcpy(dst, hdr->addr1, ETH_ALEN);
2614 memcpy(src, hdr->addr3, ETH_ALEN);
2615
2616 if (sdata->type != IEEE80211_IF_TYPE_STA) {
2617 return TXRX_DROP;
2618 }
2619 break;
2620 case 0:
2621 /* DA SA BSSID */
2622 memcpy(dst, hdr->addr1, ETH_ALEN);
2623 memcpy(src, hdr->addr2, ETH_ALEN);
2624
2625 if (sdata->type != IEEE80211_IF_TYPE_IBSS) {
2626 if (net_ratelimit()) {
2627 printk(KERN_DEBUG "%s: dropped IBSS frame (DA="
2628 MAC_FMT " SA=" MAC_FMT " BSSID=" MAC_FMT
2629 ")\n",
2630 dev->name, MAC_ARG(hdr->addr1),
2631 MAC_ARG(hdr->addr2),
2632 MAC_ARG(hdr->addr3));
2633 }
2634 return TXRX_DROP;
2635 }
2636 break;
2637 }
2638
2639 payload = skb->data + hdrlen;
2640
2641 if (unlikely(skb->len - hdrlen < 8)) {
2642 if (net_ratelimit()) {
2643 printk(KERN_DEBUG "%s: RX too short data frame "
2644 "payload\n", dev->name);
2645 }
2646 return TXRX_DROP;
2647 }
2648
2649 ethertype = (payload[6] << 8) | payload[7];
2650
2651 if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
2652 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
2653 compare_ether_addr(payload, bridge_tunnel_header) == 0)) {
2654 /* remove RFC1042 or Bridge-Tunnel encapsulation and
2655 * replace EtherType */
2656 skb_pull(skb, hdrlen + 6);
2657 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
2658 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
2659 } else {
2660 struct ethhdr *ehdr;
2661 __be16 len;
2662 skb_pull(skb, hdrlen);
2663 len = htons(skb->len);
2664 ehdr = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr));
2665 memcpy(ehdr->h_dest, dst, ETH_ALEN);
2666 memcpy(ehdr->h_source, src, ETH_ALEN);
2667 ehdr->h_proto = len;
2668 }
2669 skb->dev = dev;
2670
2671 skb2 = NULL;
2672
2673 sdata->stats.rx_packets++;
2674 sdata->stats.rx_bytes += skb->len;
2675
2676 if (local->bridge_packets && (sdata->type == IEEE80211_IF_TYPE_AP
2677 || sdata->type == IEEE80211_IF_TYPE_VLAN) && rx->u.rx.ra_match) {
2678 if (is_multicast_ether_addr(skb->data)) {
2679 /* send multicast frames both to higher layers in
2680 * local net stack and back to the wireless media */
2681 skb2 = skb_copy(skb, GFP_ATOMIC);
2682 if (!skb2)
2683 printk(KERN_DEBUG "%s: failed to clone "
2684 "multicast frame\n", dev->name);
2685 } else {
2686 struct sta_info *dsta;
2687 dsta = sta_info_get(local, skb->data);
2688 if (dsta && !dsta->dev) {
2689 printk(KERN_DEBUG "Station with null dev "
2690 "structure!\n");
2691 } else if (dsta && dsta->dev == dev) {
2692 /* Destination station is associated to this
2693 * AP, so send the frame directly to it and
2694 * do not pass the frame to local net stack.
2695 */
2696 skb2 = skb;
2697 skb = NULL;
2698 }
2699 if (dsta)
2700 sta_info_put(dsta);
2701 }
2702 }
2703
2704 if (skb) {
2705 /* deliver to local stack */
2706 skb->protocol = eth_type_trans(skb, dev);
2707 memset(skb->cb, 0, sizeof(skb->cb));
2708 netif_rx(skb);
2709 }
2710
2711 if (skb2) {
2712 /* send to wireless media */
2713 skb2->protocol = __constant_htons(ETH_P_802_3);
2714 skb_set_network_header(skb2, 0);
2715 skb_set_mac_header(skb2, 0);
2716 dev_queue_xmit(skb2);
2717 }
2718
2719 return TXRX_QUEUED;
2720}
2721
2722
2723static struct ieee80211_rate *
2724ieee80211_get_rate(struct ieee80211_local *local, int phymode, int hw_rate)
2725{
2726 struct ieee80211_hw_mode *mode;
2727 int r;
2728
2729 list_for_each_entry(mode, &local->modes_list, list) {
2730 if (mode->mode != phymode)
2731 continue;
2732 for (r = 0; r < mode->num_rates; r++) {
2733 struct ieee80211_rate *rate = &mode->rates[r];
2734 if (rate->val == hw_rate ||
2735 (rate->flags & IEEE80211_RATE_PREAMBLE2 &&
2736 rate->val2 == hw_rate))
2737 return rate;
2738 }
2739 }
2740
2741 return NULL;
2742}
2743
2744static void
2745ieee80211_fill_frame_info(struct ieee80211_local *local,
2746 struct ieee80211_frame_info *fi,
2747 struct ieee80211_rx_status *status)
2748{
2749 if (status) {
2750 struct timespec ts;
2751 struct ieee80211_rate *rate;
2752
2753 jiffies_to_timespec(jiffies, &ts);
2754 fi->hosttime = cpu_to_be64((u64) ts.tv_sec * 1000000 +
2755 ts.tv_nsec / 1000);
2756 fi->mactime = cpu_to_be64(status->mactime);
2757 switch (status->phymode) {
2758 case MODE_IEEE80211A:
2759 fi->phytype = htonl(ieee80211_phytype_ofdm_dot11_a);
2760 break;
2761 case MODE_IEEE80211B:
2762 fi->phytype = htonl(ieee80211_phytype_dsss_dot11_b);
2763 break;
2764 case MODE_IEEE80211G:
2765 fi->phytype = htonl(ieee80211_phytype_pbcc_dot11_g);
2766 break;
2767 case MODE_ATHEROS_TURBO:
2768 fi->phytype =
2769 htonl(ieee80211_phytype_dsss_dot11_turbo);
2770 break;
2771 default:
2772 fi->phytype = htonl(0xAAAAAAAA);
2773 break;
2774 }
2775 fi->channel = htonl(status->channel);
2776 rate = ieee80211_get_rate(local, status->phymode,
2777 status->rate);
2778 if (rate) {
2779 fi->datarate = htonl(rate->rate);
2780 if (rate->flags & IEEE80211_RATE_PREAMBLE2) {
2781 if (status->rate == rate->val)
2782 fi->preamble = htonl(2); /* long */
2783 else if (status->rate == rate->val2)
2784 fi->preamble = htonl(1); /* short */
2785 } else
2786 fi->preamble = htonl(0);
2787 } else {
2788 fi->datarate = htonl(0);
2789 fi->preamble = htonl(0);
2790 }
2791
2792 fi->antenna = htonl(status->antenna);
2793 fi->priority = htonl(0xffffffff); /* no clue */
2794 fi->ssi_type = htonl(ieee80211_ssi_raw);
2795 fi->ssi_signal = htonl(status->ssi);
2796 fi->ssi_noise = 0x00000000;
2797 fi->encoding = 0;
2798 } else {
2799 /* clear everything because we really don't know.
2800 * the msg_type field isn't present on monitor frames
2801 * so we don't know whether it will be present or not,
2802 * but it's ok to not clear it since it'll be assigned
2803 * anyway */
2804 memset(fi, 0, sizeof(*fi) - sizeof(fi->msg_type));
2805
2806 fi->ssi_type = htonl(ieee80211_ssi_none);
2807 }
2808 fi->version = htonl(IEEE80211_FI_VERSION);
2809 fi->length = cpu_to_be32(sizeof(*fi) - sizeof(fi->msg_type));
2810}
2811
2812/* this routine is actually not just for this, but also
2813 * for pushing fake 'management' frames into userspace.
2814 * it shall be replaced by a netlink-based system. */
2815void
2816ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
2817 struct ieee80211_rx_status *status, u32 msg_type)
2818{
2819 struct ieee80211_frame_info *fi;
2820 const size_t hlen = sizeof(struct ieee80211_frame_info);
2821 struct ieee80211_sub_if_data *sdata;
2822
2823 skb->dev = local->apdev;
2824
2825 sdata = IEEE80211_DEV_TO_SUB_IF(local->apdev);
2826
2827 if (skb_headroom(skb) < hlen) {
2828 I802_DEBUG_INC(local->rx_expand_skb_head);
2829 if (pskb_expand_head(skb, hlen, 0, GFP_ATOMIC)) {
2830 dev_kfree_skb(skb);
2831 return;
2832 }
2833 }
2834
2835 fi = (struct ieee80211_frame_info *) skb_push(skb, hlen);
2836
2837 ieee80211_fill_frame_info(local, fi, status);
2838 fi->msg_type = htonl(msg_type);
2839
2840 sdata->stats.rx_packets++;
2841 sdata->stats.rx_bytes += skb->len;
2842
2843 skb_set_mac_header(skb, 0);
2844 skb->ip_summed = CHECKSUM_UNNECESSARY;
2845 skb->pkt_type = PACKET_OTHERHOST;
2846 skb->protocol = htons(ETH_P_802_2);
2847 memset(skb->cb, 0, sizeof(skb->cb));
2848 netif_rx(skb);
2849}
2850
2851static void
2852ieee80211_rx_monitor(struct net_device *dev, struct sk_buff *skb,
2853 struct ieee80211_rx_status *status)
2854{
2855 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2856 struct ieee80211_sub_if_data *sdata;
2857 struct ieee80211_rate *rate;
2858 struct ieee80211_rtap_hdr {
2859 struct ieee80211_radiotap_header hdr;
2860 u8 flags;
2861 u8 rate;
2862 __le16 chan_freq;
2863 __le16 chan_flags;
2864 u8 antsignal;
2865 } __attribute__ ((packed)) *rthdr;
2866
2867 skb->dev = dev;
2868
2869 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2870
2871 if (status->flag & RX_FLAG_RADIOTAP)
2872 goto out;
2873
2874 if (skb_headroom(skb) < sizeof(*rthdr)) {
2875 I802_DEBUG_INC(local->rx_expand_skb_head);
2876 if (pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) {
2877 dev_kfree_skb(skb);
2878 return;
2879 }
2880 }
2881
2882 rthdr = (struct ieee80211_rtap_hdr *) skb_push(skb, sizeof(*rthdr));
2883 memset(rthdr, 0, sizeof(*rthdr));
2884 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
2885 rthdr->hdr.it_present =
2886 cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
2887 (1 << IEEE80211_RADIOTAP_RATE) |
2888 (1 << IEEE80211_RADIOTAP_CHANNEL) |
2889 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL));
2890 rthdr->flags = local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS ?
2891 IEEE80211_RADIOTAP_F_FCS : 0;
2892 rate = ieee80211_get_rate(local, status->phymode, status->rate);
2893 if (rate)
2894 rthdr->rate = rate->rate / 5;
2895 rthdr->chan_freq = cpu_to_le16(status->freq);
2896 rthdr->chan_flags =
2897 status->phymode == MODE_IEEE80211A ?
2898 cpu_to_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ) :
2899 cpu_to_le16(IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ);
2900 rthdr->antsignal = status->ssi;
2901
2902 out:
2903 sdata->stats.rx_packets++;
2904 sdata->stats.rx_bytes += skb->len;
2905
2906 skb_set_mac_header(skb, 0);
2907 skb->ip_summed = CHECKSUM_UNNECESSARY;
2908 skb->pkt_type = PACKET_OTHERHOST;
2909 skb->protocol = htons(ETH_P_802_2);
2910 memset(skb->cb, 0, sizeof(skb->cb));
2911 netif_rx(skb);
2912}
2913
2914int ieee80211_radar_status(struct ieee80211_hw *hw, int channel,
2915 int radar, int radar_type)
2916{
2917 struct sk_buff *skb;
2918 struct ieee80211_radar_info *msg;
2919 struct ieee80211_local *local = hw_to_local(hw);
2920
2921 if (!local->apdev)
2922 return 0;
2923
2924 skb = dev_alloc_skb(sizeof(struct ieee80211_frame_info) +
2925 sizeof(struct ieee80211_radar_info));
2926
2927 if (!skb)
2928 return -ENOMEM;
2929 skb_reserve(skb, sizeof(struct ieee80211_frame_info));
2930
2931 msg = (struct ieee80211_radar_info *)
2932 skb_put(skb, sizeof(struct ieee80211_radar_info));
2933 msg->channel = channel;
2934 msg->radar = radar;
2935 msg->radar_type = radar_type;
2936
2937 ieee80211_rx_mgmt(local, skb, NULL, ieee80211_msg_radar);
2938 return 0;
2939}
2940EXPORT_SYMBOL(ieee80211_radar_status);
2941
2942int ieee80211_set_aid_for_sta(struct ieee80211_hw *hw, u8 *peer_address,
2943 u16 aid)
2944{
2945 struct sk_buff *skb;
2946 struct ieee80211_msg_set_aid_for_sta *msg;
2947 struct ieee80211_local *local = hw_to_local(hw);
2948
2949 /* unlikely because if this event only happens for APs,
2950 * which require an open ap device. */
2951 if (unlikely(!local->apdev))
2952 return 0;
2953
2954 skb = dev_alloc_skb(sizeof(struct ieee80211_frame_info) +
2955 sizeof(struct ieee80211_msg_set_aid_for_sta));
2956
2957 if (!skb)
2958 return -ENOMEM;
2959 skb_reserve(skb, sizeof(struct ieee80211_frame_info));
2960
2961 msg = (struct ieee80211_msg_set_aid_for_sta *)
2962 skb_put(skb, sizeof(struct ieee80211_msg_set_aid_for_sta));
2963 memcpy(msg->sta_address, peer_address, ETH_ALEN);
2964 msg->aid = aid;
2965
2966 ieee80211_rx_mgmt(local, skb, NULL, ieee80211_msg_set_aid_for_sta);
2967 return 0;
2968}
2969EXPORT_SYMBOL(ieee80211_set_aid_for_sta);
2970
2971static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta)
2972{
2973 struct ieee80211_sub_if_data *sdata;
2974 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
2975
2976 if (sdata->bss)
2977 atomic_inc(&sdata->bss->num_sta_ps);
2978 sta->flags |= WLAN_STA_PS;
2979 sta->pspoll = 0;
2980#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
2981 printk(KERN_DEBUG "%s: STA " MAC_FMT " aid %d enters power "
2982 "save mode\n", dev->name, MAC_ARG(sta->addr), sta->aid);
2983#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
2984}
2985
2986
2987static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta)
2988{
2989 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2990 struct sk_buff *skb;
2991 int sent = 0;
2992 struct ieee80211_sub_if_data *sdata;
2993 struct ieee80211_tx_packet_data *pkt_data;
2994
2995 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
2996 if (sdata->bss)
2997 atomic_dec(&sdata->bss->num_sta_ps);
2998 sta->flags &= ~(WLAN_STA_PS | WLAN_STA_TIM);
2999 sta->pspoll = 0;
3000 if (!skb_queue_empty(&sta->ps_tx_buf)) {
3001 if (local->ops->set_tim)
3002 local->ops->set_tim(local_to_hw(local), sta->aid, 0);
3003 if (sdata->bss)
3004 bss_tim_clear(local, sdata->bss, sta->aid);
3005 }
3006#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
3007 printk(KERN_DEBUG "%s: STA " MAC_FMT " aid %d exits power "
3008 "save mode\n", dev->name, MAC_ARG(sta->addr), sta->aid);
3009#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
3010 /* Send all buffered frames to the station */
3011 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
3012 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
3013 sent++;
3014 pkt_data->requeue = 1;
3015 dev_queue_xmit(skb);
3016 }
3017 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
3018 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
3019 local->total_ps_buffered--;
3020 sent++;
3021#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
3022 printk(KERN_DEBUG "%s: STA " MAC_FMT " aid %d send PS frame "
3023 "since STA not sleeping anymore\n", dev->name,
3024 MAC_ARG(sta->addr), sta->aid);
3025#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
3026 pkt_data->requeue = 1;
3027 dev_queue_xmit(skb);
3028 }
3029
3030 return sent;
3031}
3032
3033
3034static ieee80211_txrx_result
3035ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
3036{
3037 struct sk_buff *skb;
3038 int no_pending_pkts;
3039
3040 if (likely(!rx->sta ||
3041 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL ||
3042 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL ||
3043 !rx->u.rx.ra_match))
3044 return TXRX_CONTINUE;
3045
3046 skb = skb_dequeue(&rx->sta->tx_filtered);
3047 if (!skb) {
3048 skb = skb_dequeue(&rx->sta->ps_tx_buf);
3049 if (skb)
3050 rx->local->total_ps_buffered--;
3051 }
3052 no_pending_pkts = skb_queue_empty(&rx->sta->tx_filtered) &&
3053 skb_queue_empty(&rx->sta->ps_tx_buf);
3054
3055 if (skb) {
3056 struct ieee80211_hdr *hdr =
3057 (struct ieee80211_hdr *) skb->data;
3058
3059 /* tell TX path to send one frame even though the STA may
3060 * still remain is PS mode after this frame exchange */
3061 rx->sta->pspoll = 1;
3062
3063#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
3064 printk(KERN_DEBUG "STA " MAC_FMT " aid %d: PS Poll (entries "
3065 "after %d)\n",
3066 MAC_ARG(rx->sta->addr), rx->sta->aid,
3067 skb_queue_len(&rx->sta->ps_tx_buf));
3068#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
3069
3070 /* Use MoreData flag to indicate whether there are more
3071 * buffered frames for this STA */
3072 if (no_pending_pkts) {
3073 hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREDATA);
3074 rx->sta->flags &= ~WLAN_STA_TIM;
3075 } else
3076 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
3077
3078 dev_queue_xmit(skb);
3079
3080 if (no_pending_pkts) {
3081 if (rx->local->ops->set_tim)
3082 rx->local->ops->set_tim(local_to_hw(rx->local),
3083 rx->sta->aid, 0);
3084 if (rx->sdata->bss)
3085 bss_tim_clear(rx->local, rx->sdata->bss, rx->sta->aid);
3086 }
3087#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
3088 } else if (!rx->u.rx.sent_ps_buffered) {
3089 printk(KERN_DEBUG "%s: STA " MAC_FMT " sent PS Poll even "
3090 "though there is no buffered frames for it\n",
3091 rx->dev->name, MAC_ARG(rx->sta->addr));
3092#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
3093
3094 }
3095
3096 /* Free PS Poll skb here instead of returning TXRX_DROP that would
3097 * count as an dropped frame. */
3098 dev_kfree_skb(rx->skb);
3099
3100 return TXRX_QUEUED;
3101}
3102
3103
3104static inline struct ieee80211_fragment_entry *
3105ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
3106 unsigned int frag, unsigned int seq, int rx_queue,
3107 struct sk_buff **skb)
3108{
3109 struct ieee80211_fragment_entry *entry;
3110 int idx;
3111
3112 idx = sdata->fragment_next;
3113 entry = &sdata->fragments[sdata->fragment_next++];
3114 if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX)
3115 sdata->fragment_next = 0;
3116
3117 if (!skb_queue_empty(&entry->skb_list)) {
3118#ifdef CONFIG_MAC80211_DEBUG
3119 struct ieee80211_hdr *hdr =
3120 (struct ieee80211_hdr *) entry->skb_list.next->data;
3121 printk(KERN_DEBUG "%s: RX reassembly removed oldest "
3122 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d "
3123 "addr1=" MAC_FMT " addr2=" MAC_FMT "\n",
3124 sdata->dev->name, idx,
3125 jiffies - entry->first_frag_time, entry->seq,
3126 entry->last_frag, MAC_ARG(hdr->addr1),
3127 MAC_ARG(hdr->addr2));
3128#endif /* CONFIG_MAC80211_DEBUG */
3129 __skb_queue_purge(&entry->skb_list);
3130 }
3131
3132 __skb_queue_tail(&entry->skb_list, *skb); /* no need for locking */
3133 *skb = NULL;
3134 entry->first_frag_time = jiffies;
3135 entry->seq = seq;
3136 entry->rx_queue = rx_queue;
3137 entry->last_frag = frag;
3138 entry->ccmp = 0;
3139 entry->extra_len = 0;
3140
3141 return entry;
3142}
3143
3144
3145static inline struct ieee80211_fragment_entry *
3146ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
3147 u16 fc, unsigned int frag, unsigned int seq,
3148 int rx_queue, struct ieee80211_hdr *hdr)
3149{
3150 struct ieee80211_fragment_entry *entry;
3151 int i, idx;
3152
3153 idx = sdata->fragment_next;
3154 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) {
3155 struct ieee80211_hdr *f_hdr;
3156 u16 f_fc;
3157
3158 idx--;
3159 if (idx < 0)
3160 idx = IEEE80211_FRAGMENT_MAX - 1;
3161
3162 entry = &sdata->fragments[idx];
3163 if (skb_queue_empty(&entry->skb_list) || entry->seq != seq ||
3164 entry->rx_queue != rx_queue ||
3165 entry->last_frag + 1 != frag)
3166 continue;
3167
3168 f_hdr = (struct ieee80211_hdr *) entry->skb_list.next->data;
3169 f_fc = le16_to_cpu(f_hdr->frame_control);
3170
3171 if ((fc & IEEE80211_FCTL_FTYPE) != (f_fc & IEEE80211_FCTL_FTYPE) ||
3172 compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 ||
3173 compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0)
3174 continue;
3175
3176 if (entry->first_frag_time + 2 * HZ < jiffies) {
3177 __skb_queue_purge(&entry->skb_list);
3178 continue;
3179 }
3180 return entry;
3181 }
3182
3183 return NULL;
3184}
3185
3186
3187static ieee80211_txrx_result
3188ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
3189{
3190 struct ieee80211_hdr *hdr;
3191 u16 sc;
3192 unsigned int frag, seq;
3193 struct ieee80211_fragment_entry *entry;
3194 struct sk_buff *skb;
3195
3196 hdr = (struct ieee80211_hdr *) rx->skb->data;
3197 sc = le16_to_cpu(hdr->seq_ctrl);
3198 frag = sc & IEEE80211_SCTL_FRAG;
3199
3200 if (likely((!(rx->fc & IEEE80211_FCTL_MOREFRAGS) && frag == 0) ||
3201 (rx->skb)->len < 24 ||
3202 is_multicast_ether_addr(hdr->addr1))) {
3203 /* not fragmented */
3204 goto out;
3205 }
3206 I802_DEBUG_INC(rx->local->rx_handlers_fragments);
3207
3208 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
3209
3210 if (frag == 0) {
3211 /* This is the first fragment of a new frame. */
3212 entry = ieee80211_reassemble_add(rx->sdata, frag, seq,
3213 rx->u.rx.queue, &(rx->skb));
3214 if (rx->key && rx->key->alg == ALG_CCMP &&
3215 (rx->fc & IEEE80211_FCTL_PROTECTED)) {
3216 /* Store CCMP PN so that we can verify that the next
3217 * fragment has a sequential PN value. */
3218 entry->ccmp = 1;
3219 memcpy(entry->last_pn,
3220 rx->key->u.ccmp.rx_pn[rx->u.rx.queue],
3221 CCMP_PN_LEN);
3222 }
3223 return TXRX_QUEUED;
3224 }
3225
3226 /* This is a fragment for a frame that should already be pending in
3227 * fragment cache. Add this fragment to the end of the pending entry.
3228 */
3229 entry = ieee80211_reassemble_find(rx->sdata, rx->fc, frag, seq,
3230 rx->u.rx.queue, hdr);
3231 if (!entry) {
3232 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
3233 return TXRX_DROP;
3234 }
3235
3236 /* Verify that MPDUs within one MSDU have sequential PN values.
3237 * (IEEE 802.11i, 8.3.3.4.5) */
3238 if (entry->ccmp) {
3239 int i;
3240 u8 pn[CCMP_PN_LEN], *rpn;
3241 if (!rx->key || rx->key->alg != ALG_CCMP)
3242 return TXRX_DROP;
3243 memcpy(pn, entry->last_pn, CCMP_PN_LEN);
3244 for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
3245 pn[i]++;
3246 if (pn[i])
3247 break;
3248 }
3249 rpn = rx->key->u.ccmp.rx_pn[rx->u.rx.queue];
3250 if (memcmp(pn, rpn, CCMP_PN_LEN) != 0) {
3251 printk(KERN_DEBUG "%s: defrag: CCMP PN not sequential"
3252 " A2=" MAC_FMT " PN=%02x%02x%02x%02x%02x%02x "
3253 "(expected %02x%02x%02x%02x%02x%02x)\n",
3254 rx->dev->name, MAC_ARG(hdr->addr2),
3255 rpn[0], rpn[1], rpn[2], rpn[3], rpn[4], rpn[5],
3256 pn[0], pn[1], pn[2], pn[3], pn[4], pn[5]);
3257 return TXRX_DROP;
3258 }
3259 memcpy(entry->last_pn, pn, CCMP_PN_LEN);
3260 }
3261
3262 skb_pull(rx->skb, ieee80211_get_hdrlen(rx->fc));
3263 __skb_queue_tail(&entry->skb_list, rx->skb);
3264 entry->last_frag = frag;
3265 entry->extra_len += rx->skb->len;
3266 if (rx->fc & IEEE80211_FCTL_MOREFRAGS) {
3267 rx->skb = NULL;
3268 return TXRX_QUEUED;
3269 }
3270
3271 rx->skb = __skb_dequeue(&entry->skb_list);
3272 if (skb_tailroom(rx->skb) < entry->extra_len) {
3273 I802_DEBUG_INC(rx->local->rx_expand_skb_head2);
3274 if (unlikely(pskb_expand_head(rx->skb, 0, entry->extra_len,
3275 GFP_ATOMIC))) {
3276 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
3277 __skb_queue_purge(&entry->skb_list);
3278 return TXRX_DROP;
3279 }
3280 }
3281 while ((skb = __skb_dequeue(&entry->skb_list)))
3282 memcpy(skb_put(rx->skb, skb->len), skb->data, skb->len);
3283
3284 /* Complete frame has been reassembled - process it now */
3285 rx->fragmented = 1;
3286
3287 out:
3288 if (rx->sta)
3289 rx->sta->rx_packets++;
3290 if (is_multicast_ether_addr(hdr->addr1))
3291 rx->local->dot11MulticastReceivedFrameCount++;
3292 else
3293 ieee80211_led_rx(rx->local);
3294 return TXRX_CONTINUE;
3295}
3296
3297
3298static ieee80211_txrx_result
3299ieee80211_rx_h_monitor(struct ieee80211_txrx_data *rx)
3300{
3301 if (rx->sdata->type == IEEE80211_IF_TYPE_MNTR) {
3302 ieee80211_rx_monitor(rx->dev, rx->skb, rx->u.rx.status);
3303 return TXRX_QUEUED;
3304 }
3305
3306 if (rx->u.rx.status->flag & RX_FLAG_RADIOTAP)
3307 skb_pull(rx->skb, ieee80211_get_radiotap_len(rx->skb));
3308
3309 return TXRX_CONTINUE;
3310}
3311
3312
3313static ieee80211_txrx_result
3314ieee80211_rx_h_check(struct ieee80211_txrx_data *rx)
3315{
3316 struct ieee80211_hdr *hdr;
3317 int always_sta_key;
3318 hdr = (struct ieee80211_hdr *) rx->skb->data;
3319
3320 /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
3321 if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
3322 if (unlikely(rx->fc & IEEE80211_FCTL_RETRY &&
3323 rx->sta->last_seq_ctrl[rx->u.rx.queue] ==
3324 hdr->seq_ctrl)) {
3325 if (rx->u.rx.ra_match) {
3326 rx->local->dot11FrameDuplicateCount++;
3327 rx->sta->num_duplicates++;
3328 }
3329 return TXRX_DROP;
3330 } else
3331 rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl;
3332 }
3333
3334 if ((rx->local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) &&
3335 rx->skb->len > FCS_LEN)
3336 skb_trim(rx->skb, rx->skb->len - FCS_LEN);
3337
3338 if (unlikely(rx->skb->len < 16)) {
3339 I802_DEBUG_INC(rx->local->rx_handlers_drop_short);
3340 return TXRX_DROP;
3341 }
3342
3343 if (!rx->u.rx.ra_match)
3344 rx->skb->pkt_type = PACKET_OTHERHOST;
3345 else if (compare_ether_addr(rx->dev->dev_addr, hdr->addr1) == 0)
3346 rx->skb->pkt_type = PACKET_HOST;
3347 else if (is_multicast_ether_addr(hdr->addr1)) {
3348 if (is_broadcast_ether_addr(hdr->addr1))
3349 rx->skb->pkt_type = PACKET_BROADCAST;
3350 else
3351 rx->skb->pkt_type = PACKET_MULTICAST;
3352 } else
3353 rx->skb->pkt_type = PACKET_OTHERHOST;
3354
3355 /* Drop disallowed frame classes based on STA auth/assoc state;
3356 * IEEE 802.11, Chap 5.5.
3357 *
3358 * 80211.o does filtering only based on association state, i.e., it
3359 * drops Class 3 frames from not associated stations. hostapd sends
3360 * deauth/disassoc frames when needed. In addition, hostapd is
3361 * responsible for filtering on both auth and assoc states.
3362 */
3363 if (unlikely(((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA ||
3364 ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL &&
3365 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)) &&
3366 rx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
3367 (!rx->sta || !(rx->sta->flags & WLAN_STA_ASSOC)))) {
3368 if ((!(rx->fc & IEEE80211_FCTL_FROMDS) &&
3369 !(rx->fc & IEEE80211_FCTL_TODS) &&
3370 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
3371 || !rx->u.rx.ra_match) {
3372 /* Drop IBSS frames and frames for other hosts
3373 * silently. */
3374 return TXRX_DROP;
3375 }
3376
3377 if (!rx->local->apdev)
3378 return TXRX_DROP;
3379
3380 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
3381 ieee80211_msg_sta_not_assoc);
3382 return TXRX_QUEUED;
3383 }
3384
3385 if (rx->sdata->type == IEEE80211_IF_TYPE_STA)
3386 always_sta_key = 0;
3387 else
3388 always_sta_key = 1;
3389
3390 if (rx->sta && rx->sta->key && always_sta_key) {
3391 rx->key = rx->sta->key;
3392 } else {
3393 if (rx->sta && rx->sta->key)
3394 rx->key = rx->sta->key;
3395 else
3396 rx->key = rx->sdata->default_key;
3397
3398 if ((rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) &&
3399 rx->fc & IEEE80211_FCTL_PROTECTED) {
3400 int keyidx = ieee80211_wep_get_keyidx(rx->skb);
3401
3402 if (keyidx >= 0 && keyidx < NUM_DEFAULT_KEYS &&
3403 (!rx->sta || !rx->sta->key || keyidx > 0))
3404 rx->key = rx->sdata->keys[keyidx];
3405
3406 if (!rx->key) {
3407 if (!rx->u.rx.ra_match)
3408 return TXRX_DROP;
3409 printk(KERN_DEBUG "%s: RX WEP frame with "
3410 "unknown keyidx %d (A1=" MAC_FMT " A2="
3411 MAC_FMT " A3=" MAC_FMT ")\n",
3412 rx->dev->name, keyidx,
3413 MAC_ARG(hdr->addr1),
3414 MAC_ARG(hdr->addr2),
3415 MAC_ARG(hdr->addr3));
3416 if (!rx->local->apdev)
3417 return TXRX_DROP;
3418 ieee80211_rx_mgmt(
3419 rx->local, rx->skb, rx->u.rx.status,
3420 ieee80211_msg_wep_frame_unknown_key);
3421 return TXRX_QUEUED;
3422 }
3423 }
3424 }
3425
3426 if (rx->fc & IEEE80211_FCTL_PROTECTED && rx->key && rx->u.rx.ra_match) {
3427 rx->key->tx_rx_count++;
3428 if (unlikely(rx->local->key_tx_rx_threshold &&
3429 rx->key->tx_rx_count >
3430 rx->local->key_tx_rx_threshold)) {
3431 ieee80211_key_threshold_notify(rx->dev, rx->key,
3432 rx->sta);
3433 }
3434 }
3435
3436 return TXRX_CONTINUE;
3437}
3438
3439
3440static ieee80211_txrx_result
3441ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx)
3442{
3443 struct sta_info *sta = rx->sta;
3444 struct net_device *dev = rx->dev;
3445 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
3446
3447 if (!sta)
3448 return TXRX_CONTINUE;
3449
3450 /* Update last_rx only for IBSS packets which are for the current
3451 * BSSID to avoid keeping the current IBSS network alive in cases where
3452 * other STAs are using different BSSID. */
3453 if (rx->sdata->type == IEEE80211_IF_TYPE_IBSS) {
3454 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
3455 if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0)
3456 sta->last_rx = jiffies;
3457 } else
3458 if (!is_multicast_ether_addr(hdr->addr1) ||
3459 rx->sdata->type == IEEE80211_IF_TYPE_STA) {
3460 /* Update last_rx only for unicast frames in order to prevent
3461 * the Probe Request frames (the only broadcast frames from a
3462 * STA in infrastructure mode) from keeping a connection alive.
3463 */
3464 sta->last_rx = jiffies;
3465 }
3466
3467 if (!rx->u.rx.ra_match)
3468 return TXRX_CONTINUE;
3469
3470 sta->rx_fragments++;
3471 sta->rx_bytes += rx->skb->len;
3472 sta->last_rssi = (sta->last_rssi * 15 +
3473 rx->u.rx.status->ssi) / 16;
3474 sta->last_signal = (sta->last_signal * 15 +
3475 rx->u.rx.status->signal) / 16;
3476 sta->last_noise = (sta->last_noise * 15 +
3477 rx->u.rx.status->noise) / 16;
3478
3479 if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
3480 /* Change STA power saving mode only in the end of a frame
3481 * exchange sequence */
3482 if ((sta->flags & WLAN_STA_PS) && !(rx->fc & IEEE80211_FCTL_PM))
3483 rx->u.rx.sent_ps_buffered += ap_sta_ps_end(dev, sta);
3484 else if (!(sta->flags & WLAN_STA_PS) &&
3485 (rx->fc & IEEE80211_FCTL_PM))
3486 ap_sta_ps_start(dev, sta);
3487 }
3488
3489 /* Drop data::nullfunc frames silently, since they are used only to
3490 * control station power saving mode. */
3491 if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
3492 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_NULLFUNC) {
3493 I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc);
3494 /* Update counter and free packet here to avoid counting this
3495 * as a dropped packed. */
3496 sta->rx_packets++;
3497 dev_kfree_skb(rx->skb);
3498 return TXRX_QUEUED;
3499 }
3500
3501 return TXRX_CONTINUE;
3502} /* ieee80211_rx_h_sta_process */
3503
3504
3505static ieee80211_txrx_result
3506ieee80211_rx_h_wep_weak_iv_detection(struct ieee80211_txrx_data *rx)
3507{
3508 if (!rx->sta || !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
3509 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
3510 !rx->key || rx->key->alg != ALG_WEP || !rx->u.rx.ra_match)
3511 return TXRX_CONTINUE;
3512
3513 /* Check for weak IVs, if hwaccel did not remove IV from the frame */
3514 if ((rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) ||
3515 rx->key->force_sw_encrypt) {
3516 u8 *iv = ieee80211_wep_is_weak_iv(rx->skb, rx->key);
3517 if (iv) {
3518 rx->sta->wep_weak_iv_count++;
3519 }
3520 }
3521
3522 return TXRX_CONTINUE;
3523}
3524
3525
3526static ieee80211_txrx_result
3527ieee80211_rx_h_wep_decrypt(struct ieee80211_txrx_data *rx)
3528{
3529 /* If the device handles decryption totally, skip this test */
3530 if (rx->local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP)
3531 return TXRX_CONTINUE;
3532
3533 if ((rx->key && rx->key->alg != ALG_WEP) ||
3534 !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
3535 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
3536 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
3537 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)))
3538 return TXRX_CONTINUE;
3539
3540 if (!rx->key) {
3541 printk(KERN_DEBUG "%s: RX WEP frame, but no key set\n",
3542 rx->dev->name);
3543 return TXRX_DROP;
3544 }
3545
3546 if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED) ||
3547 rx->key->force_sw_encrypt) {
3548 if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) {
3549 printk(KERN_DEBUG "%s: RX WEP frame, decrypt "
3550 "failed\n", rx->dev->name);
3551 return TXRX_DROP;
3552 }
3553 } else if (rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) {
3554 ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key);
3555 /* remove ICV */
3556 skb_trim(rx->skb, rx->skb->len - 4);
3557 }
3558
3559 return TXRX_CONTINUE;
3560}
3561
3562
3563static ieee80211_txrx_result
3564ieee80211_rx_h_802_1x_pae(struct ieee80211_txrx_data *rx)
3565{
3566 if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb) &&
3567 rx->sdata->type != IEEE80211_IF_TYPE_STA && rx->u.rx.ra_match) {
3568 /* Pass both encrypted and unencrypted EAPOL frames to user
3569 * space for processing. */
3570 if (!rx->local->apdev)
3571 return TXRX_DROP;
3572 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
3573 ieee80211_msg_normal);
3574 return TXRX_QUEUED;
3575 }
3576
3577 if (unlikely(rx->sdata->ieee802_1x &&
3578 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
3579 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
3580 (!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED)) &&
3581 !ieee80211_is_eapol(rx->skb))) {
3582#ifdef CONFIG_MAC80211_DEBUG
3583 struct ieee80211_hdr *hdr =
3584 (struct ieee80211_hdr *) rx->skb->data;
3585 printk(KERN_DEBUG "%s: dropped frame from " MAC_FMT
3586 " (unauthorized port)\n", rx->dev->name,
3587 MAC_ARG(hdr->addr2));
3588#endif /* CONFIG_MAC80211_DEBUG */
3589 return TXRX_DROP;
3590 }
3591
3592 return TXRX_CONTINUE;
3593}
3594
3595
3596static ieee80211_txrx_result
3597ieee80211_rx_h_drop_unencrypted(struct ieee80211_txrx_data *rx)
3598{
3599 /* If the device handles decryption totally, skip this test */
3600 if (rx->local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP)
3601 return TXRX_CONTINUE;
3602
3603 /* Drop unencrypted frames if key is set. */
3604 if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) &&
3605 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
3606 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
3607 (rx->key || rx->sdata->drop_unencrypted) &&
3608 (rx->sdata->eapol == 0 ||
3609 !ieee80211_is_eapol(rx->skb)))) {
3610 printk(KERN_DEBUG "%s: RX non-WEP frame, but expected "
3611 "encryption\n", rx->dev->name);
3612 return TXRX_DROP;
3613 }
3614 return TXRX_CONTINUE;
3615}
3616
3617
3618static ieee80211_txrx_result
3619ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx)
3620{
3621 struct ieee80211_sub_if_data *sdata;
3622
3623 if (!rx->u.rx.ra_match)
3624 return TXRX_DROP;
3625
3626 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
3627 if ((sdata->type == IEEE80211_IF_TYPE_STA ||
3628 sdata->type == IEEE80211_IF_TYPE_IBSS) &&
3629 !rx->local->user_space_mlme) {
3630 ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status);
3631 } else {
3632 /* Management frames are sent to hostapd for processing */
3633 if (!rx->local->apdev)
3634 return TXRX_DROP;
3635 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
3636 ieee80211_msg_normal);
3637 }
3638 return TXRX_QUEUED;
3639}
3640
3641
3642static ieee80211_txrx_result
3643ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx)
3644{
3645 struct ieee80211_local *local = rx->local;
3646 struct sk_buff *skb = rx->skb;
3647
3648 if (unlikely(local->sta_scanning != 0)) {
3649 ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status);
3650 return TXRX_QUEUED;
3651 }
3652
3653 if (unlikely(rx->u.rx.in_scan)) {
3654 /* scanning finished during invoking of handlers */
3655 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan);
3656 return TXRX_DROP;
3657 }
3658
3659 return TXRX_CONTINUE;
3660}
3661
3662
3663static void ieee80211_rx_michael_mic_report(struct net_device *dev,
3664 struct ieee80211_hdr *hdr,
3665 struct sta_info *sta,
3666 struct ieee80211_txrx_data *rx)
3667{
3668 int keyidx, hdrlen;
3669
3670 hdrlen = ieee80211_get_hdrlen_from_skb(rx->skb);
3671 if (rx->skb->len >= hdrlen + 4)
3672 keyidx = rx->skb->data[hdrlen + 3] >> 6;
3673 else
3674 keyidx = -1;
3675
3676 /* TODO: verify that this is not triggered by fragmented
3677 * frames (hw does not verify MIC for them). */
3678 printk(KERN_DEBUG "%s: TKIP hwaccel reported Michael MIC "
3679 "failure from " MAC_FMT " to " MAC_FMT " keyidx=%d\n",
3680 dev->name, MAC_ARG(hdr->addr2), MAC_ARG(hdr->addr1), keyidx);
3681
3682 if (!sta) {
3683 /* Some hardware versions seem to generate incorrect
3684 * Michael MIC reports; ignore them to avoid triggering
3685 * countermeasures. */
3686 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
3687 "error for unknown address " MAC_FMT "\n",
3688 dev->name, MAC_ARG(hdr->addr2));
3689 goto ignore;
3690 }
3691
3692 if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) {
3693 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
3694 "error for a frame with no ISWEP flag (src "
3695 MAC_FMT ")\n", dev->name, MAC_ARG(hdr->addr2));
3696 goto ignore;
3697 }
3698
3699 if ((rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) &&
3700 rx->sdata->type == IEEE80211_IF_TYPE_AP) {
3701 keyidx = ieee80211_wep_get_keyidx(rx->skb);
3702 /* AP with Pairwise keys support should never receive Michael
3703 * MIC errors for non-zero keyidx because these are reserved
3704 * for group keys and only the AP is sending real multicast
3705 * frames in BSS. */
3706 if (keyidx) {
3707 printk(KERN_DEBUG "%s: ignored Michael MIC error for "
3708 "a frame with non-zero keyidx (%d) (src " MAC_FMT
3709 ")\n", dev->name, keyidx, MAC_ARG(hdr->addr2));
3710 goto ignore;
3711 }
3712 }
3713
3714 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
3715 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
3716 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) {
3717 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
3718 "error for a frame that cannot be encrypted "
3719 "(fc=0x%04x) (src " MAC_FMT ")\n",
3720 dev->name, rx->fc, MAC_ARG(hdr->addr2));
3721 goto ignore;
3722 }
3723
3724 do {
3725 union iwreq_data wrqu;
3726 char *buf = kmalloc(128, GFP_ATOMIC);
3727 if (!buf)
3728 break;
3729
3730 /* TODO: needed parameters: count, key type, TSC */
3731 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
3732 "keyid=%d %scast addr=" MAC_FMT ")",
3733 keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
3734 MAC_ARG(hdr->addr2));
3735 memset(&wrqu, 0, sizeof(wrqu));
3736 wrqu.data.length = strlen(buf);
3737 wireless_send_event(rx->dev, IWEVCUSTOM, &wrqu, buf);
3738 kfree(buf);
3739 } while (0);
3740
3741 /* TODO: consider verifying the MIC error report with software
3742 * implementation if we get too many spurious reports from the
3743 * hardware. */
3744 if (!rx->local->apdev)
3745 goto ignore;
3746 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
3747 ieee80211_msg_michael_mic_failure);
3748 return;
3749
3750 ignore:
3751 dev_kfree_skb(rx->skb);
3752 rx->skb = NULL;
3753}
3754
3755static inline ieee80211_txrx_result __ieee80211_invoke_rx_handlers(
3756 struct ieee80211_local *local,
3757 ieee80211_rx_handler *handlers,
3758 struct ieee80211_txrx_data *rx,
3759 struct sta_info *sta)
3760{
3761 ieee80211_rx_handler *handler;
3762 ieee80211_txrx_result res = TXRX_DROP;
3763
3764 for (handler = handlers; *handler != NULL; handler++) {
3765 res = (*handler)(rx);
3766 if (res != TXRX_CONTINUE) {
3767 if (res == TXRX_DROP) {
3768 I802_DEBUG_INC(local->rx_handlers_drop);
3769 if (sta)
3770 sta->rx_dropped++;
3771 }
3772 if (res == TXRX_QUEUED)
3773 I802_DEBUG_INC(local->rx_handlers_queued);
3774 break;
3775 }
3776 }
3777
3778 if (res == TXRX_DROP) {
3779 dev_kfree_skb(rx->skb);
3780 }
3781 return res;
3782}
3783
3784static inline void ieee80211_invoke_rx_handlers(struct ieee80211_local *local,
3785 ieee80211_rx_handler *handlers,
3786 struct ieee80211_txrx_data *rx,
3787 struct sta_info *sta)
3788{
3789 if (__ieee80211_invoke_rx_handlers(local, handlers, rx, sta) ==
3790 TXRX_CONTINUE)
3791 dev_kfree_skb(rx->skb);
3792}
3793
3794/*
3795 * This is the receive path handler. It is called by a low level driver when an
3796 * 802.11 MPDU is received from the hardware.
3797 */
3798void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
3799 struct ieee80211_rx_status *status)
3800{
3801 struct ieee80211_local *local = hw_to_local(hw);
3802 struct ieee80211_sub_if_data *sdata;
3803 struct sta_info *sta;
3804 struct ieee80211_hdr *hdr;
3805 struct ieee80211_txrx_data rx;
3806 u16 type;
3807 int multicast;
3808 int radiotap_len = 0;
3809
3810 if (status->flag & RX_FLAG_RADIOTAP) {
3811 radiotap_len = ieee80211_get_radiotap_len(skb);
3812 skb_pull(skb, radiotap_len);
3813 }
3814
3815 hdr = (struct ieee80211_hdr *) skb->data;
3816 memset(&rx, 0, sizeof(rx));
3817 rx.skb = skb;
3818 rx.local = local;
3819
3820 rx.u.rx.status = status;
3821 rx.fc = skb->len >= 2 ? le16_to_cpu(hdr->frame_control) : 0;
3822 type = rx.fc & IEEE80211_FCTL_FTYPE;
3823 if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT)
3824 local->dot11ReceivedFragmentCount++;
3825 multicast = is_multicast_ether_addr(hdr->addr1);
3826
3827 if (skb->len >= 16)
3828 sta = rx.sta = sta_info_get(local, hdr->addr2);
3829 else
3830 sta = rx.sta = NULL;
3831
3832 if (sta) {
3833 rx.dev = sta->dev;
3834 rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
3835 }
3836
3837 if ((status->flag & RX_FLAG_MMIC_ERROR)) {
3838 ieee80211_rx_michael_mic_report(local->mdev, hdr, sta, &rx);
3839 goto end;
3840 }
3841
3842 if (unlikely(local->sta_scanning))
3843 rx.u.rx.in_scan = 1;
3844
3845 if (__ieee80211_invoke_rx_handlers(local, local->rx_pre_handlers, &rx,
3846 sta) != TXRX_CONTINUE)
3847 goto end;
3848 skb = rx.skb;
3849
3850 skb_push(skb, radiotap_len);
3851 if (sta && !sta->assoc_ap && !(sta->flags & WLAN_STA_WDS) &&
3852 !local->iff_promiscs && !multicast) {
3853 rx.u.rx.ra_match = 1;
3854 ieee80211_invoke_rx_handlers(local, local->rx_handlers, &rx,
3855 sta);
3856 } else {
3857 struct ieee80211_sub_if_data *prev = NULL;
3858 struct sk_buff *skb_new;
3859 u8 *bssid = ieee80211_get_bssid(hdr, skb->len - radiotap_len);
3860
3861 read_lock(&local->sub_if_lock);
3862 list_for_each_entry(sdata, &local->sub_if_list, list) {
3863 rx.u.rx.ra_match = 1;
3864 switch (sdata->type) {
3865 case IEEE80211_IF_TYPE_STA:
3866 if (!bssid)
3867 continue;
3868 if (!ieee80211_bssid_match(bssid,
3869 sdata->u.sta.bssid)) {
3870 if (!rx.u.rx.in_scan)
3871 continue;
3872 rx.u.rx.ra_match = 0;
3873 } else if (!multicast &&
3874 compare_ether_addr(sdata->dev->dev_addr,
3875 hdr->addr1) != 0) {
3876 if (!sdata->promisc)
3877 continue;
3878 rx.u.rx.ra_match = 0;
3879 }
3880 break;
3881 case IEEE80211_IF_TYPE_IBSS:
3882 if (!bssid)
3883 continue;
3884 if (!ieee80211_bssid_match(bssid,
3885 sdata->u.sta.bssid)) {
3886 if (!rx.u.rx.in_scan)
3887 continue;
3888 rx.u.rx.ra_match = 0;
3889 } else if (!multicast &&
3890 compare_ether_addr(sdata->dev->dev_addr,
3891 hdr->addr1) != 0) {
3892 if (!sdata->promisc)
3893 continue;
3894 rx.u.rx.ra_match = 0;
3895 } else if (!sta)
3896 sta = rx.sta =
3897 ieee80211_ibss_add_sta(sdata->dev,
3898 skb, bssid,
3899 hdr->addr2);
3900 break;
3901 case IEEE80211_IF_TYPE_AP:
3902 if (!bssid) {
3903 if (compare_ether_addr(sdata->dev->dev_addr,
3904 hdr->addr1) != 0)
3905 continue;
3906 } else if (!ieee80211_bssid_match(bssid,
3907 sdata->dev->dev_addr)) {
3908 if (!rx.u.rx.in_scan)
3909 continue;
3910 rx.u.rx.ra_match = 0;
3911 }
3912 if (sdata->dev == local->mdev &&
3913 !rx.u.rx.in_scan)
3914 /* do not receive anything via
3915 * master device when not scanning */
3916 continue;
3917 break;
3918 case IEEE80211_IF_TYPE_WDS:
3919 if (bssid ||
3920 (rx.fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
3921 continue;
3922 if (compare_ether_addr(sdata->u.wds.remote_addr,
3923 hdr->addr2) != 0)
3924 continue;
3925 break;
3926 }
3927
3928 if (prev) {
3929 skb_new = skb_copy(skb, GFP_ATOMIC);
3930 if (!skb_new) {
3931 if (net_ratelimit())
3932 printk(KERN_DEBUG "%s: failed to copy "
3933 "multicast frame for %s",
3934 local->mdev->name, prev->dev->name);
3935 continue;
3936 }
3937 rx.skb = skb_new;
3938 rx.dev = prev->dev;
3939 rx.sdata = prev;
3940 ieee80211_invoke_rx_handlers(local,
3941 local->rx_handlers,
3942 &rx, sta);
3943 }
3944 prev = sdata;
3945 }
3946 if (prev) {
3947 rx.skb = skb;
3948 rx.dev = prev->dev;
3949 rx.sdata = prev;
3950 ieee80211_invoke_rx_handlers(local, local->rx_handlers,
3951 &rx, sta);
3952 } else
3953 dev_kfree_skb(skb);
3954 read_unlock(&local->sub_if_lock);
3955 }
3956
3957 end:
3958 if (sta)
3959 sta_info_put(sta);
3960}
3961EXPORT_SYMBOL(__ieee80211_rx);
3962
3963static ieee80211_txrx_result
3964ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx)
3965{
3966 struct ieee80211_local *local = tx->local;
3967 struct ieee80211_hw_mode *mode = tx->u.tx.mode;
3968 struct sk_buff *skb = tx->skb;
3969 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
3970 u32 load = 0, hdrtime;
3971
3972 /* TODO: this could be part of tx_status handling, so that the number
3973 * of retries would be known; TX rate should in that case be stored
3974 * somewhere with the packet */
3975
3976 /* Estimate total channel use caused by this frame */
3977
3978 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values,
3979 * 1 usec = 1/8 * (1080 / 10) = 13.5 */
3980
3981 if (mode->mode == MODE_IEEE80211A ||
3982 mode->mode == MODE_ATHEROS_TURBO ||
3983 mode->mode == MODE_ATHEROS_TURBOG ||
3984 (mode->mode == MODE_IEEE80211G &&
3985 tx->u.tx.rate->flags & IEEE80211_RATE_ERP))
3986 hdrtime = CHAN_UTIL_HDR_SHORT;
3987 else
3988 hdrtime = CHAN_UTIL_HDR_LONG;
3989
3990 load = hdrtime;
3991 if (!is_multicast_ether_addr(hdr->addr1))
3992 load += hdrtime;
3993
3994 if (tx->u.tx.control->flags & IEEE80211_TXCTL_USE_RTS_CTS)
3995 load += 2 * hdrtime;
3996 else if (tx->u.tx.control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)
3997 load += hdrtime;
3998
3999 load += skb->len * tx->u.tx.rate->rate_inv;
4000
4001 if (tx->u.tx.extra_frag) {
4002 int i;
4003 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
4004 load += 2 * hdrtime;
4005 load += tx->u.tx.extra_frag[i]->len *
4006 tx->u.tx.rate->rate;
4007 }
4008 }
4009
4010 /* Divide channel_use by 8 to avoid wrapping around the counter */
4011 load >>= CHAN_UTIL_SHIFT;
4012 local->channel_use_raw += load;
4013 if (tx->sta)
4014 tx->sta->channel_use_raw += load;
4015 tx->sdata->channel_use_raw += load;
4016
4017 return TXRX_CONTINUE;
4018}
4019
4020
4021static ieee80211_txrx_result
4022ieee80211_rx_h_load_stats(struct ieee80211_txrx_data *rx)
4023{
4024 struct ieee80211_local *local = rx->local;
4025 struct sk_buff *skb = rx->skb;
4026 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
4027 u32 load = 0, hdrtime;
4028 struct ieee80211_rate *rate;
4029 struct ieee80211_hw_mode *mode = local->hw.conf.mode;
4030 int i;
4031
4032 /* Estimate total channel use caused by this frame */
4033
4034 if (unlikely(mode->num_rates < 0))
4035 return TXRX_CONTINUE;
4036
4037 rate = &mode->rates[0];
4038 for (i = 0; i < mode->num_rates; i++) {
4039 if (mode->rates[i].val == rx->u.rx.status->rate) {
4040 rate = &mode->rates[i];
4041 break;
4042 }
4043 }
4044
4045 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values,
4046 * 1 usec = 1/8 * (1080 / 10) = 13.5 */
4047
4048 if (mode->mode == MODE_IEEE80211A ||
4049 mode->mode == MODE_ATHEROS_TURBO ||
4050 mode->mode == MODE_ATHEROS_TURBOG ||
4051 (mode->mode == MODE_IEEE80211G &&
4052 rate->flags & IEEE80211_RATE_ERP))
4053 hdrtime = CHAN_UTIL_HDR_SHORT;
4054 else
4055 hdrtime = CHAN_UTIL_HDR_LONG;
4056
4057 load = hdrtime;
4058 if (!is_multicast_ether_addr(hdr->addr1))
4059 load += hdrtime;
4060
4061 load += skb->len * rate->rate_inv;
4062
4063 /* Divide channel_use by 8 to avoid wrapping around the counter */
4064 load >>= CHAN_UTIL_SHIFT;
4065 local->channel_use_raw += load;
4066 if (rx->sta)
4067 rx->sta->channel_use_raw += load;
4068 rx->u.rx.load = load;
4069
4070 return TXRX_CONTINUE;
4071}
4072
4073static ieee80211_txrx_result
4074ieee80211_rx_h_if_stats(struct ieee80211_txrx_data *rx)
4075{
4076 rx->sdata->channel_use_raw += rx->u.rx.load;
4077 return TXRX_CONTINUE;
4078}
4079
4080static void ieee80211_stat_refresh(unsigned long data)
4081{
4082 struct ieee80211_local *local = (struct ieee80211_local *) data;
4083 struct sta_info *sta;
4084 struct ieee80211_sub_if_data *sdata;
4085
4086 if (!local->stat_time)
4087 return;
4088
4089 /* go through all stations */
4090 spin_lock_bh(&local->sta_lock);
4091 list_for_each_entry(sta, &local->sta_list, list) {
4092 sta->channel_use = (sta->channel_use_raw / local->stat_time) /
4093 CHAN_UTIL_PER_10MS;
4094 sta->channel_use_raw = 0;
4095 }
4096 spin_unlock_bh(&local->sta_lock);
4097
4098 /* go through all subinterfaces */
4099 read_lock(&local->sub_if_lock);
4100 list_for_each_entry(sdata, &local->sub_if_list, list) {
4101 sdata->channel_use = (sdata->channel_use_raw /
4102 local->stat_time) / CHAN_UTIL_PER_10MS;
4103 sdata->channel_use_raw = 0;
4104 }
4105 read_unlock(&local->sub_if_lock);
4106
4107 /* hardware interface */
4108 local->channel_use = (local->channel_use_raw /
4109 local->stat_time) / CHAN_UTIL_PER_10MS;
4110 local->channel_use_raw = 0;
4111
4112 local->stat_timer.expires = jiffies + HZ * local->stat_time / 100;
4113 add_timer(&local->stat_timer);
4114}
4115
4116
4117/* This is a version of the rx handler that can be called from hard irq
4118 * context. Post the skb on the queue and schedule the tasklet */
4119void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb,
4120 struct ieee80211_rx_status *status)
4121{
4122 struct ieee80211_local *local = hw_to_local(hw);
4123
4124 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb));
4125
4126 skb->dev = local->mdev;
4127 /* copy status into skb->cb for use by tasklet */
4128 memcpy(skb->cb, status, sizeof(*status));
4129 skb->pkt_type = IEEE80211_RX_MSG;
4130 skb_queue_tail(&local->skb_queue, skb);
4131 tasklet_schedule(&local->tasklet);
4132}
4133EXPORT_SYMBOL(ieee80211_rx_irqsafe);
4134
4135void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
4136 struct sk_buff *skb,
4137 struct ieee80211_tx_status *status)
4138{
4139 struct ieee80211_local *local = hw_to_local(hw);
4140 struct ieee80211_tx_status *saved;
4141 int tmp;
4142
4143 skb->dev = local->mdev;
4144 saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC);
4145 if (unlikely(!saved)) {
4146 if (net_ratelimit())
4147 printk(KERN_WARNING "%s: Not enough memory, "
4148 "dropping tx status", skb->dev->name);
4149 /* should be dev_kfree_skb_irq, but due to this function being
4150 * named _irqsafe instead of just _irq we can't be sure that
4151 * people won't call it from non-irq contexts */
4152 dev_kfree_skb_any(skb);
4153 return;
4154 }
4155 memcpy(saved, status, sizeof(struct ieee80211_tx_status));
4156 /* copy pointer to saved status into skb->cb for use by tasklet */
4157 memcpy(skb->cb, &saved, sizeof(saved));
4158
4159 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
4160 skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ?
4161 &local->skb_queue : &local->skb_queue_unreliable, skb);
4162 tmp = skb_queue_len(&local->skb_queue) +
4163 skb_queue_len(&local->skb_queue_unreliable);
4164 while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
4165 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
4166 memcpy(&saved, skb->cb, sizeof(saved));
4167 kfree(saved);
4168 dev_kfree_skb_irq(skb);
4169 tmp--;
4170 I802_DEBUG_INC(local->tx_status_drop);
4171 }
4172 tasklet_schedule(&local->tasklet);
4173}
4174EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
4175
4176static void ieee80211_tasklet_handler(unsigned long data)
4177{
4178 struct ieee80211_local *local = (struct ieee80211_local *) data;
4179 struct sk_buff *skb;
4180 struct ieee80211_rx_status rx_status;
4181 struct ieee80211_tx_status *tx_status;
4182
4183 while ((skb = skb_dequeue(&local->skb_queue)) ||
4184 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
4185 switch (skb->pkt_type) {
4186 case IEEE80211_RX_MSG:
4187 /* status is in skb->cb */
4188 memcpy(&rx_status, skb->cb, sizeof(rx_status));
4189 /* Clear skb->type in order to not confuse kernel
4190 * netstack. */
4191 skb->pkt_type = 0;
4192 __ieee80211_rx(local_to_hw(local), skb, &rx_status);
4193 break;
4194 case IEEE80211_TX_STATUS_MSG:
4195 /* get pointer to saved status out of skb->cb */
4196 memcpy(&tx_status, skb->cb, sizeof(tx_status));
4197 skb->pkt_type = 0;
4198 ieee80211_tx_status(local_to_hw(local),
4199 skb, tx_status);
4200 kfree(tx_status);
4201 break;
4202 default: /* should never get here! */
4203 printk(KERN_ERR "%s: Unknown message type (%d)\n",
4204 local->mdev->name, skb->pkt_type);
4205 dev_kfree_skb(skb);
4206 break;
4207 }
4208 }
4209}
4210
4211
4212/* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
4213 * make a prepared TX frame (one that has been given to hw) to look like brand
4214 * new IEEE 802.11 frame that is ready to go through TX processing again.
4215 * Also, tx_packet_data in cb is restored from tx_control. */
4216static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
4217 struct ieee80211_key *key,
4218 struct sk_buff *skb,
4219 struct ieee80211_tx_control *control)
4220{
4221 int hdrlen, iv_len, mic_len;
4222 struct ieee80211_tx_packet_data *pkt_data;
4223
4224 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
4225 pkt_data->ifindex = control->ifindex;
4226 pkt_data->mgmt_iface = (control->type == IEEE80211_IF_TYPE_MGMT);
4227 pkt_data->req_tx_status = !!(control->flags & IEEE80211_TXCTL_REQ_TX_STATUS);
4228 pkt_data->do_not_encrypt = !!(control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT);
4229 pkt_data->requeue = !!(control->flags & IEEE80211_TXCTL_REQUEUE);
4230 pkt_data->queue = control->queue;
4231
4232 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
4233
4234 if (!key)
4235 goto no_key;
4236
4237 switch (key->alg) {
4238 case ALG_WEP:
4239 iv_len = WEP_IV_LEN;
4240 mic_len = WEP_ICV_LEN;
4241 break;
4242 case ALG_TKIP:
4243 iv_len = TKIP_IV_LEN;
4244 mic_len = TKIP_ICV_LEN;
4245 break;
4246 case ALG_CCMP:
4247 iv_len = CCMP_HDR_LEN;
4248 mic_len = CCMP_MIC_LEN;
4249 break;
4250 default:
4251 goto no_key;
4252 }
4253
4254 if (skb->len >= mic_len && key->force_sw_encrypt)
4255 skb_trim(skb, skb->len - mic_len);
4256 if (skb->len >= iv_len && skb->len > hdrlen) {
4257 memmove(skb->data + iv_len, skb->data, hdrlen);
4258 skb_pull(skb, iv_len);
4259 }
4260
4261no_key:
4262 {
4263 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
4264 u16 fc = le16_to_cpu(hdr->frame_control);
4265 if ((fc & 0x8C) == 0x88) /* QoS Control Field */ {
4266 fc &= ~IEEE80211_STYPE_QOS_DATA;
4267 hdr->frame_control = cpu_to_le16(fc);
4268 memmove(skb->data + 2, skb->data, hdrlen - 2);
4269 skb_pull(skb, 2);
4270 }
4271 }
4272}
4273
4274
4275void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
4276 struct ieee80211_tx_status *status)
4277{
4278 struct sk_buff *skb2;
4279 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
4280 struct ieee80211_local *local = hw_to_local(hw);
4281 u16 frag, type;
4282 u32 msg_type;
4283
4284 if (!status) {
4285 printk(KERN_ERR
4286 "%s: ieee80211_tx_status called with NULL status\n",
4287 local->mdev->name);
4288 dev_kfree_skb(skb);
4289 return;
4290 }
4291
4292 if (status->excessive_retries) {
4293 struct sta_info *sta;
4294 sta = sta_info_get(local, hdr->addr1);
4295 if (sta) {
4296 if (sta->flags & WLAN_STA_PS) {
4297 /* The STA is in power save mode, so assume
4298 * that this TX packet failed because of that.
4299 */
4300 status->excessive_retries = 0;
4301 status->flags |= IEEE80211_TX_STATUS_TX_FILTERED;
4302 }
4303 sta_info_put(sta);
4304 }
4305 }
4306
4307 if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) {
4308 struct sta_info *sta;
4309 sta = sta_info_get(local, hdr->addr1);
4310 if (sta) {
4311 sta->tx_filtered_count++;
4312
4313 /* Clear the TX filter mask for this STA when sending
4314 * the next packet. If the STA went to power save mode,
4315 * this will happen when it is waking up for the next
4316 * time. */
4317 sta->clear_dst_mask = 1;
4318
4319 /* TODO: Is the WLAN_STA_PS flag always set here or is
4320 * the race between RX and TX status causing some
4321 * packets to be filtered out before 80211.o gets an
4322 * update for PS status? This seems to be the case, so
4323 * no changes are likely to be needed. */
4324 if (sta->flags & WLAN_STA_PS &&
4325 skb_queue_len(&sta->tx_filtered) <
4326 STA_MAX_TX_BUFFER) {
4327 ieee80211_remove_tx_extra(local, sta->key,
4328 skb,
4329 &status->control);
4330 skb_queue_tail(&sta->tx_filtered, skb);
4331 } else if (!(sta->flags & WLAN_STA_PS) &&
4332 !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) {
4333 /* Software retry the packet once */
4334 status->control.flags |= IEEE80211_TXCTL_REQUEUE;
4335 ieee80211_remove_tx_extra(local, sta->key,
4336 skb,
4337 &status->control);
4338 dev_queue_xmit(skb);
4339 } else {
4340 if (net_ratelimit()) {
4341 printk(KERN_DEBUG "%s: dropped TX "
4342 "filtered frame queue_len=%d "
4343 "PS=%d @%lu\n",
4344 local->mdev->name,
4345 skb_queue_len(
4346 &sta->tx_filtered),
4347 !!(sta->flags & WLAN_STA_PS),
4348 jiffies);
4349 }
4350 dev_kfree_skb(skb);
4351 }
4352 sta_info_put(sta);
4353 return;
4354 }
4355 } else {
4356 /* FIXME: STUPID to call this with both local and local->mdev */
4357 rate_control_tx_status(local, local->mdev, skb, status);
4358 }
4359
4360 ieee80211_led_tx(local, 0);
4361
4362 /* SNMP counters
4363 * Fragments are passed to low-level drivers as separate skbs, so these
4364 * are actually fragments, not frames. Update frame counters only for
4365 * the first fragment of the frame. */
4366
4367 frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
4368 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
4369
4370 if (status->flags & IEEE80211_TX_STATUS_ACK) {
4371 if (frag == 0) {
4372 local->dot11TransmittedFrameCount++;
4373 if (is_multicast_ether_addr(hdr->addr1))
4374 local->dot11MulticastTransmittedFrameCount++;
4375 if (status->retry_count > 0)
4376 local->dot11RetryCount++;
4377 if (status->retry_count > 1)
4378 local->dot11MultipleRetryCount++;
4379 }
4380
4381 /* This counter shall be incremented for an acknowledged MPDU
4382 * with an individual address in the address 1 field or an MPDU
4383 * with a multicast address in the address 1 field of type Data
4384 * or Management. */
4385 if (!is_multicast_ether_addr(hdr->addr1) ||
4386 type == IEEE80211_FTYPE_DATA ||
4387 type == IEEE80211_FTYPE_MGMT)
4388 local->dot11TransmittedFragmentCount++;
4389 } else {
4390 if (frag == 0)
4391 local->dot11FailedCount++;
4392 }
4393
4394 if (!(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS)
4395 || unlikely(!local->apdev)) {
4396 dev_kfree_skb(skb);
4397 return;
4398 }
4399
4400 msg_type = (status->flags & IEEE80211_TX_STATUS_ACK) ?
4401 ieee80211_msg_tx_callback_ack : ieee80211_msg_tx_callback_fail;
4402
4403 /* skb was the original skb used for TX. Clone it and give the clone
4404 * to netif_rx(). Free original skb. */
4405 skb2 = skb_copy(skb, GFP_ATOMIC);
4406 if (!skb2) {
4407 dev_kfree_skb(skb);
4408 return;
4409 }
4410 dev_kfree_skb(skb);
4411 skb = skb2;
4412
4413 /* Send frame to hostapd */
4414 ieee80211_rx_mgmt(local, skb, NULL, msg_type);
4415}
4416EXPORT_SYMBOL(ieee80211_tx_status);
4417
4418/* TODO: implement register/unregister functions for adding TX/RX handlers
4419 * into ordered list */
4420
4421/* rx_pre handlers don't have dev and sdata fields available in
4422 * ieee80211_txrx_data */
4423static ieee80211_rx_handler ieee80211_rx_pre_handlers[] =
4424{
4425 ieee80211_rx_h_parse_qos,
4426 ieee80211_rx_h_load_stats,
4427 NULL
4428};
4429
4430static ieee80211_rx_handler ieee80211_rx_handlers[] =
4431{
4432 ieee80211_rx_h_if_stats,
4433 ieee80211_rx_h_monitor,
4434 ieee80211_rx_h_passive_scan,
4435 ieee80211_rx_h_check,
4436 ieee80211_rx_h_sta_process,
4437 ieee80211_rx_h_ccmp_decrypt,
4438 ieee80211_rx_h_tkip_decrypt,
4439 ieee80211_rx_h_wep_weak_iv_detection,
4440 ieee80211_rx_h_wep_decrypt,
4441 ieee80211_rx_h_defragment,
4442 ieee80211_rx_h_ps_poll,
4443 ieee80211_rx_h_michael_mic_verify,
4444 /* this must be after decryption - so header is counted in MPDU mic
4445 * must be before pae and data, so QOS_DATA format frames
4446 * are not passed to user space by these functions
4447 */
4448 ieee80211_rx_h_remove_qos_control,
4449 ieee80211_rx_h_802_1x_pae,
4450 ieee80211_rx_h_drop_unencrypted,
4451 ieee80211_rx_h_data,
4452 ieee80211_rx_h_mgmt,
4453 NULL
4454};
4455
4456static ieee80211_tx_handler ieee80211_tx_handlers[] =
4457{
4458 ieee80211_tx_h_check_assoc,
4459 ieee80211_tx_h_sequence,
4460 ieee80211_tx_h_ps_buf,
4461 ieee80211_tx_h_select_key,
4462 ieee80211_tx_h_michael_mic_add,
4463 ieee80211_tx_h_fragment,
4464 ieee80211_tx_h_tkip_encrypt,
4465 ieee80211_tx_h_ccmp_encrypt,
4466 ieee80211_tx_h_wep_encrypt,
4467 ieee80211_tx_h_rate_ctrl,
4468 ieee80211_tx_h_misc,
4469 ieee80211_tx_h_load_stats,
4470 NULL
4471};
4472
4473
4474int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
4475{
4476 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
4477 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4478 struct sta_info *sta;
4479
4480 if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0)
4481 return 0;
4482
4483 /* Create STA entry for the new peer */
4484 sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
4485 if (!sta)
4486 return -ENOMEM;
4487 sta_info_put(sta);
4488
4489 /* Remove STA entry for the old peer */
4490 sta = sta_info_get(local, sdata->u.wds.remote_addr);
4491 if (sta) {
4492 sta_info_put(sta);
4493 sta_info_free(sta, 0);
4494 } else {
4495 printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
4496 "peer " MAC_FMT "\n",
4497 dev->name, MAC_ARG(sdata->u.wds.remote_addr));
4498 }
4499
4500 /* Update WDS link data */
4501 memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
4502
4503 return 0;
4504}
4505
4506/* Must not be called for mdev and apdev */
4507void ieee80211_if_setup(struct net_device *dev)
4508{
4509 ether_setup(dev);
4510 dev->hard_start_xmit = ieee80211_subif_start_xmit;
4511 dev->wireless_handlers = &ieee80211_iw_handler_def;
4512 dev->set_multicast_list = ieee80211_set_multicast_list;
4513 dev->change_mtu = ieee80211_change_mtu;
4514 dev->get_stats = ieee80211_get_stats;
4515 dev->open = ieee80211_open;
4516 dev->stop = ieee80211_stop;
4517 dev->uninit = ieee80211_if_reinit;
4518 dev->destructor = ieee80211_if_free;
4519}
4520
4521void ieee80211_if_mgmt_setup(struct net_device *dev)
4522{
4523 ether_setup(dev);
4524 dev->hard_start_xmit = ieee80211_mgmt_start_xmit;
4525 dev->change_mtu = ieee80211_change_mtu_apdev;
4526 dev->get_stats = ieee80211_get_stats;
4527 dev->open = ieee80211_mgmt_open;
4528 dev->stop = ieee80211_mgmt_stop;
4529 dev->type = ARPHRD_IEEE80211_PRISM;
4530 dev->hard_header_parse = header_parse_80211;
4531 dev->uninit = ieee80211_if_reinit;
4532 dev->destructor = ieee80211_if_free;
4533}
4534
4535int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
4536 const char *name)
4537{
4538 struct rate_control_ref *ref, *old;
4539
4540 ASSERT_RTNL();
4541 if (local->open_count || netif_running(local->mdev) ||
4542 (local->apdev && netif_running(local->apdev)))
4543 return -EBUSY;
4544
4545 ref = rate_control_alloc(name, local);
4546 if (!ref) {
4547 printk(KERN_WARNING "%s: Failed to select rate control "
4548 "algorithm\n", local->mdev->name);
4549 return -ENOENT;
4550 }
4551
4552 old = local->rate_ctrl;
4553 local->rate_ctrl = ref;
4554 if (old) {
4555 rate_control_put(old);
4556 sta_info_flush(local, NULL);
4557 }
4558
4559 printk(KERN_DEBUG "%s: Selected rate control "
4560 "algorithm '%s'\n", local->mdev->name,
4561 ref->ops->name);
4562
4563
4564 return 0;
4565}
4566
4567static void rate_control_deinitialize(struct ieee80211_local *local)
4568{
4569 struct rate_control_ref *ref;
4570
4571 ref = local->rate_ctrl;
4572 local->rate_ctrl = NULL;
4573 rate_control_put(ref);
4574}
4575
4576struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
4577 const struct ieee80211_ops *ops)
4578{
4579 struct net_device *mdev;
4580 struct ieee80211_local *local;
4581 struct ieee80211_sub_if_data *sdata;
4582 int priv_size;
4583 struct wiphy *wiphy;
4584
4585 /* Ensure 32-byte alignment of our private data and hw private data.
4586 * We use the wiphy priv data for both our ieee80211_local and for
4587 * the driver's private data
4588 *
4589 * In memory it'll be like this:
4590 *
4591 * +-------------------------+
4592 * | struct wiphy |
4593 * +-------------------------+
4594 * | struct ieee80211_local |
4595 * +-------------------------+
4596 * | driver's private data |
4597 * +-------------------------+
4598 *
4599 */
4600 priv_size = ((sizeof(struct ieee80211_local) +
4601 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
4602 priv_data_len;
4603
4604 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
4605
4606 if (!wiphy)
4607 return NULL;
4608
4609 wiphy->privid = mac80211_wiphy_privid;
4610
4611 local = wiphy_priv(wiphy);
4612 local->hw.wiphy = wiphy;
4613
4614 local->hw.priv = (char *)local +
4615 ((sizeof(struct ieee80211_local) +
4616 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
4617
4618 local->ops = ops;
4619
4620 /* for now, mdev needs sub_if_data :/ */
4621 mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
4622 "wmaster%d", ether_setup);
4623 if (!mdev) {
4624 wiphy_free(wiphy);
4625 return NULL;
4626 }
4627
4628 sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
4629 mdev->ieee80211_ptr = &sdata->wdev;
4630 sdata->wdev.wiphy = wiphy;
4631
4632 local->hw.queues = 1; /* default */
4633
4634 local->mdev = mdev;
4635 local->rx_pre_handlers = ieee80211_rx_pre_handlers;
4636 local->rx_handlers = ieee80211_rx_handlers;
4637 local->tx_handlers = ieee80211_tx_handlers;
4638
4639 local->bridge_packets = 1;
4640
4641 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
4642 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
4643 local->short_retry_limit = 7;
4644 local->long_retry_limit = 4;
4645 local->hw.conf.radio_enabled = 1;
4646 local->rate_ctrl_num_up = RATE_CONTROL_NUM_UP;
4647 local->rate_ctrl_num_down = RATE_CONTROL_NUM_DOWN;
4648
4649 local->enabled_modes = (unsigned int) -1;
4650
4651 INIT_LIST_HEAD(&local->modes_list);
4652
4653 rwlock_init(&local->sub_if_lock);
4654 INIT_LIST_HEAD(&local->sub_if_list);
4655
4656 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
4657 init_timer(&local->stat_timer);
4658 local->stat_timer.function = ieee80211_stat_refresh;
4659 local->stat_timer.data = (unsigned long) local;
4660 ieee80211_rx_bss_list_init(mdev);
4661
4662 sta_info_init(local);
4663
4664 mdev->hard_start_xmit = ieee80211_master_start_xmit;
4665 mdev->open = ieee80211_master_open;
4666 mdev->stop = ieee80211_master_stop;
4667 mdev->type = ARPHRD_IEEE80211;
4668 mdev->hard_header_parse = header_parse_80211;
4669
4670 sdata->type = IEEE80211_IF_TYPE_AP;
4671 sdata->dev = mdev;
4672 sdata->local = local;
4673 sdata->u.ap.force_unicast_rateidx = -1;
4674 sdata->u.ap.max_ratectrl_rateidx = -1;
4675 ieee80211_if_sdata_init(sdata);
4676 list_add_tail(&sdata->list, &local->sub_if_list);
4677
4678 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
4679 (unsigned long)local);
4680 tasklet_disable(&local->tx_pending_tasklet);
4681
4682 tasklet_init(&local->tasklet,
4683 ieee80211_tasklet_handler,
4684 (unsigned long) local);
4685 tasklet_disable(&local->tasklet);
4686
4687 skb_queue_head_init(&local->skb_queue);
4688 skb_queue_head_init(&local->skb_queue_unreliable);
4689
4690 return local_to_hw(local);
4691}
4692EXPORT_SYMBOL(ieee80211_alloc_hw);
4693
4694int ieee80211_register_hw(struct ieee80211_hw *hw)
4695{
4696 struct ieee80211_local *local = hw_to_local(hw);
4697 const char *name;
4698 int result;
4699
4700 result = wiphy_register(local->hw.wiphy);
4701 if (result < 0)
4702 return result;
4703
4704 name = wiphy_dev(local->hw.wiphy)->driver->name;
4705 local->hw.workqueue = create_singlethread_workqueue(name);
4706 if (!local->hw.workqueue) {
4707 result = -ENOMEM;
4708 goto fail_workqueue;
4709 }
4710
4711 debugfs_hw_add(local);
4712
4713 local->hw.conf.beacon_int = 1000;
4714
4715 local->wstats_flags |= local->hw.max_rssi ?
4716 IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID;
4717 local->wstats_flags |= local->hw.max_signal ?
4718 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
4719 local->wstats_flags |= local->hw.max_noise ?
4720 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
4721 if (local->hw.max_rssi < 0 || local->hw.max_noise < 0)
4722 local->wstats_flags |= IW_QUAL_DBM;
4723
4724 result = sta_info_start(local);
4725 if (result < 0)
4726 goto fail_sta_info;
4727
4728 rtnl_lock();
4729 result = dev_alloc_name(local->mdev, local->mdev->name);
4730 if (result < 0)
4731 goto fail_dev;
4732
4733 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
4734 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
4735
4736 result = register_netdevice(local->mdev);
4737 if (result < 0)
4738 goto fail_dev;
4739
4740 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
4741
4742 result = ieee80211_init_rate_ctrl_alg(local, NULL);
4743 if (result < 0) {
4744 printk(KERN_DEBUG "%s: Failed to initialize rate control "
4745 "algorithm\n", local->mdev->name);
4746 goto fail_rate;
4747 }
4748
4749 result = ieee80211_wep_init(local);
4750
4751 if (result < 0) {
4752 printk(KERN_DEBUG "%s: Failed to initialize wep\n",
4753 local->mdev->name);
4754 goto fail_wep;
4755 }
4756
4757 ieee80211_install_qdisc(local->mdev);
4758
4759 /* add one default STA interface */
4760 result = ieee80211_if_add(local->mdev, "wlan%d", NULL,
4761 IEEE80211_IF_TYPE_STA);
4762 if (result)
4763 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
4764 local->mdev->name);
4765
4766 local->reg_state = IEEE80211_DEV_REGISTERED;
4767 rtnl_unlock();
4768
4769 ieee80211_led_init(local);
4770
4771 return 0;
4772
4773fail_wep:
4774 rate_control_deinitialize(local);
4775fail_rate:
4776 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
4777 unregister_netdevice(local->mdev);
4778fail_dev:
4779 rtnl_unlock();
4780 sta_info_stop(local);
4781fail_sta_info:
4782 debugfs_hw_del(local);
4783 destroy_workqueue(local->hw.workqueue);
4784fail_workqueue:
4785 wiphy_unregister(local->hw.wiphy);
4786 return result;
4787}
4788EXPORT_SYMBOL(ieee80211_register_hw);
4789
4790int ieee80211_register_hwmode(struct ieee80211_hw *hw,
4791 struct ieee80211_hw_mode *mode)
4792{
4793 struct ieee80211_local *local = hw_to_local(hw);
4794 struct ieee80211_rate *rate;
4795 int i;
4796
4797 INIT_LIST_HEAD(&mode->list);
4798 list_add_tail(&mode->list, &local->modes_list);
4799
4800 local->hw_modes |= (1 << mode->mode);
4801 for (i = 0; i < mode->num_rates; i++) {
4802 rate = &(mode->rates[i]);
4803 rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate;
4804 }
4805 ieee80211_prepare_rates(local, mode);
4806
4807 if (!local->oper_hw_mode) {
4808 /* Default to this mode */
4809 local->hw.conf.phymode = mode->mode;
4810 local->oper_hw_mode = local->scan_hw_mode = mode;
4811 local->oper_channel = local->scan_channel = &mode->channels[0];
4812 local->hw.conf.mode = local->oper_hw_mode;
4813 local->hw.conf.chan = local->oper_channel;
4814 }
4815
4816 if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED))
4817 ieee80211_init_client(local->mdev);
4818
4819 return 0;
4820}
4821EXPORT_SYMBOL(ieee80211_register_hwmode);
4822
4823void ieee80211_unregister_hw(struct ieee80211_hw *hw)
4824{
4825 struct ieee80211_local *local = hw_to_local(hw);
4826 struct ieee80211_sub_if_data *sdata, *tmp;
4827 struct list_head tmp_list;
4828 int i;
4829
4830 tasklet_kill(&local->tx_pending_tasklet);
4831 tasklet_kill(&local->tasklet);
4832
4833 rtnl_lock();
4834
4835 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
4836
4837 local->reg_state = IEEE80211_DEV_UNREGISTERED;
4838 if (local->apdev)
4839 ieee80211_if_del_mgmt(local);
4840
4841 write_lock_bh(&local->sub_if_lock);
4842 list_replace_init(&local->sub_if_list, &tmp_list);
4843 write_unlock_bh(&local->sub_if_lock);
4844
4845 list_for_each_entry_safe(sdata, tmp, &tmp_list, list)
4846 __ieee80211_if_del(local, sdata);
4847
4848 rtnl_unlock();
4849
4850 if (local->stat_time)
4851 del_timer_sync(&local->stat_timer);
4852
4853 ieee80211_rx_bss_list_deinit(local->mdev);
4854 ieee80211_clear_tx_pending(local);
4855 sta_info_stop(local);
4856 rate_control_deinitialize(local);
4857 debugfs_hw_del(local);
4858
4859 for (i = 0; i < NUM_IEEE80211_MODES; i++) {
4860 kfree(local->supp_rates[i]);
4861 kfree(local->basic_rates[i]);
4862 }
4863
4864 if (skb_queue_len(&local->skb_queue)
4865 || skb_queue_len(&local->skb_queue_unreliable))
4866 printk(KERN_WARNING "%s: skb_queue not empty\n",
4867 local->mdev->name);
4868 skb_queue_purge(&local->skb_queue);
4869 skb_queue_purge(&local->skb_queue_unreliable);
4870
4871 destroy_workqueue(local->hw.workqueue);
4872 wiphy_unregister(local->hw.wiphy);
4873 ieee80211_wep_free(local);
4874 ieee80211_led_exit(local);
4875}
4876EXPORT_SYMBOL(ieee80211_unregister_hw);
4877
4878void ieee80211_free_hw(struct ieee80211_hw *hw)
4879{
4880 struct ieee80211_local *local = hw_to_local(hw);
4881
4882 ieee80211_if_free(local->mdev);
4883 wiphy_free(local->hw.wiphy);
4884}
4885EXPORT_SYMBOL(ieee80211_free_hw);
4886
4887void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue)
4888{
4889 struct ieee80211_local *local = hw_to_local(hw);
4890
4891 if (test_and_clear_bit(IEEE80211_LINK_STATE_XOFF,
4892 &local->state[queue])) {
4893 if (test_bit(IEEE80211_LINK_STATE_PENDING,
4894 &local->state[queue]))
4895 tasklet_schedule(&local->tx_pending_tasklet);
4896 else
4897 if (!ieee80211_qdisc_installed(local->mdev)) {
4898 if (queue == 0)
4899 netif_wake_queue(local->mdev);
4900 } else
4901 __netif_schedule(local->mdev);
4902 }
4903}
4904EXPORT_SYMBOL(ieee80211_wake_queue);
4905
4906void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue)
4907{
4908 struct ieee80211_local *local = hw_to_local(hw);
4909
4910 if (!ieee80211_qdisc_installed(local->mdev) && queue == 0)
4911 netif_stop_queue(local->mdev);
4912 set_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]);
4913}
4914EXPORT_SYMBOL(ieee80211_stop_queue);
4915
4916void ieee80211_start_queues(struct ieee80211_hw *hw)
4917{
4918 struct ieee80211_local *local = hw_to_local(hw);
4919 int i;
4920
4921 for (i = 0; i < local->hw.queues; i++)
4922 clear_bit(IEEE80211_LINK_STATE_XOFF, &local->state[i]);
4923 if (!ieee80211_qdisc_installed(local->mdev))
4924 netif_start_queue(local->mdev);
4925}
4926EXPORT_SYMBOL(ieee80211_start_queues);
4927
4928void ieee80211_stop_queues(struct ieee80211_hw *hw)
4929{
4930 int i;
4931
4932 for (i = 0; i < hw->queues; i++)
4933 ieee80211_stop_queue(hw, i);
4934}
4935EXPORT_SYMBOL(ieee80211_stop_queues);
4936
4937void ieee80211_wake_queues(struct ieee80211_hw *hw)
4938{
4939 int i;
4940
4941 for (i = 0; i < hw->queues; i++)
4942 ieee80211_wake_queue(hw, i);
4943}
4944EXPORT_SYMBOL(ieee80211_wake_queues);
4945
4946struct net_device_stats *ieee80211_dev_stats(struct net_device *dev)
4947{
4948 struct ieee80211_sub_if_data *sdata;
4949 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4950 return &sdata->stats;
4951}
4952
4953static int __init ieee80211_init(void)
4954{
4955 struct sk_buff *skb;
4956 int ret;
4957
4958 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
4959
4960 ret = ieee80211_wme_register();
4961 if (ret) {
4962 printk(KERN_DEBUG "ieee80211_init: failed to "
4963 "initialize WME (err=%d)\n", ret);
4964 return ret;
4965 }
4966
4967 ieee80211_debugfs_netdev_init();
4968
4969 return 0;
4970}
4971
4972
4973static void __exit ieee80211_exit(void)
4974{
4975 ieee80211_wme_unregister();
4976 ieee80211_debugfs_netdev_exit();
4977}
4978
4979
4980module_init(ieee80211_init);
4981module_exit(ieee80211_exit);
4982
4983MODULE_DESCRIPTION("IEEE 802.11 subsystem");
4984MODULE_LICENSE("GPL");
diff --git a/net/mac80211/ieee80211_cfg.c b/net/mac80211/ieee80211_cfg.c
new file mode 100644
index 000000000000..509096edb324
--- /dev/null
+++ b/net/mac80211/ieee80211_cfg.c
@@ -0,0 +1,66 @@
1/*
2 * mac80211 configuration hooks for cfg80211
3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * This file is GPLv2 as found in COPYING.
7 */
8
9#include <linux/nl80211.h>
10#include <linux/rtnetlink.h>
11#include <net/cfg80211.h>
12#include "ieee80211_i.h"
13#include "ieee80211_cfg.h"
14
15static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
16 unsigned int type)
17{
18 struct ieee80211_local *local = wiphy_priv(wiphy);
19 int itype;
20
21 if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
22 return -ENODEV;
23
24 switch (type) {
25 case NL80211_IFTYPE_UNSPECIFIED:
26 itype = IEEE80211_IF_TYPE_STA;
27 break;
28 case NL80211_IFTYPE_ADHOC:
29 itype = IEEE80211_IF_TYPE_IBSS;
30 break;
31 case NL80211_IFTYPE_STATION:
32 itype = IEEE80211_IF_TYPE_STA;
33 break;
34 case NL80211_IFTYPE_MONITOR:
35 itype = IEEE80211_IF_TYPE_MNTR;
36 break;
37 default:
38 return -EINVAL;
39 }
40
41 return ieee80211_if_add(local->mdev, name, NULL, itype);
42}
43
44static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
45{
46 struct ieee80211_local *local = wiphy_priv(wiphy);
47 struct net_device *dev;
48 char *name;
49
50 if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
51 return -ENODEV;
52
53 dev = dev_get_by_index(ifindex);
54 if (!dev)
55 return 0;
56
57 name = dev->name;
58 dev_put(dev);
59
60 return ieee80211_if_remove(local->mdev, name, -1);
61}
62
63struct cfg80211_ops mac80211_config_ops = {
64 .add_virtual_intf = ieee80211_add_iface,
65 .del_virtual_intf = ieee80211_del_iface,
66};
diff --git a/net/mac80211/ieee80211_cfg.h b/net/mac80211/ieee80211_cfg.h
new file mode 100644
index 000000000000..85ed2c924878
--- /dev/null
+++ b/net/mac80211/ieee80211_cfg.h
@@ -0,0 +1,9 @@
1/*
2 * mac80211 configuration hooks for cfg80211
3 */
4#ifndef __IEEE80211_CFG_H
5#define __IEEE80211_CFG_H
6
7extern struct cfg80211_ops mac80211_config_ops;
8
9#endif /* __IEEE80211_CFG_H */
diff --git a/net/mac80211/ieee80211_common.h b/net/mac80211/ieee80211_common.h
new file mode 100644
index 000000000000..b9a73e7f5f75
--- /dev/null
+++ b/net/mac80211/ieee80211_common.h
@@ -0,0 +1,98 @@
1/*
2 * IEEE 802.11 driver (80211.o) -- hostapd interface
3 * Copyright 2002-2004, Instant802 Networks, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef IEEE80211_COMMON_H
11#define IEEE80211_COMMON_H
12
13#include <linux/types.h>
14
15/*
16 * This is common header information with user space. It is used on all
17 * frames sent to wlan#ap interface.
18 */
19
20#define IEEE80211_FI_VERSION 0x80211001
21
22struct ieee80211_frame_info {
23 __be32 version;
24 __be32 length;
25 __be64 mactime;
26 __be64 hosttime;
27 __be32 phytype;
28 __be32 channel;
29 __be32 datarate;
30 __be32 antenna;
31 __be32 priority;
32 __be32 ssi_type;
33 __be32 ssi_signal;
34 __be32 ssi_noise;
35 __be32 preamble;
36 __be32 encoding;
37
38 /* Note: this structure is otherwise identical to capture format used
39 * in linux-wlan-ng, but this additional field is used to provide meta
40 * data about the frame to hostapd. This was the easiest method for
41 * providing this information, but this might change in the future. */
42 __be32 msg_type;
43} __attribute__ ((packed));
44
45
46enum ieee80211_msg_type {
47 ieee80211_msg_normal = 0,
48 ieee80211_msg_tx_callback_ack = 1,
49 ieee80211_msg_tx_callback_fail = 2,
50 ieee80211_msg_passive_scan = 3,
51 ieee80211_msg_wep_frame_unknown_key = 4,
52 ieee80211_msg_michael_mic_failure = 5,
53 /* hole at 6, was monitor but never sent to userspace */
54 ieee80211_msg_sta_not_assoc = 7,
55 ieee80211_msg_set_aid_for_sta = 8 /* used by Intersil MVC driver */,
56 ieee80211_msg_key_threshold_notification = 9,
57 ieee80211_msg_radar = 11,
58};
59
60struct ieee80211_msg_set_aid_for_sta {
61 char sta_address[ETH_ALEN];
62 u16 aid;
63};
64
65struct ieee80211_msg_key_notification {
66 int tx_rx_count;
67 char ifname[IFNAMSIZ];
68 u8 addr[ETH_ALEN]; /* ff:ff:ff:ff:ff:ff for broadcast keys */
69};
70
71
72enum ieee80211_phytype {
73 ieee80211_phytype_fhss_dot11_97 = 1,
74 ieee80211_phytype_dsss_dot11_97 = 2,
75 ieee80211_phytype_irbaseband = 3,
76 ieee80211_phytype_dsss_dot11_b = 4,
77 ieee80211_phytype_pbcc_dot11_b = 5,
78 ieee80211_phytype_ofdm_dot11_g = 6,
79 ieee80211_phytype_pbcc_dot11_g = 7,
80 ieee80211_phytype_ofdm_dot11_a = 8,
81 ieee80211_phytype_dsss_dot11_turbog = 255,
82 ieee80211_phytype_dsss_dot11_turbo = 256,
83};
84
85enum ieee80211_ssi_type {
86 ieee80211_ssi_none = 0,
87 ieee80211_ssi_norm = 1, /* normalized, 0-1000 */
88 ieee80211_ssi_dbm = 2,
89 ieee80211_ssi_raw = 3, /* raw SSI */
90};
91
92struct ieee80211_radar_info {
93 int channel;
94 int radar;
95 int radar_type;
96};
97
98#endif /* IEEE80211_COMMON_H */
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
new file mode 100644
index 000000000000..af4d14d0b969
--- /dev/null
+++ b/net/mac80211/ieee80211_i.h
@@ -0,0 +1,798 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef IEEE80211_I_H
12#define IEEE80211_I_H
13
14#include <linux/kernel.h>
15#include <linux/device.h>
16#include <linux/if_ether.h>
17#include <linux/interrupt.h>
18#include <linux/list.h>
19#include <linux/netdevice.h>
20#include <linux/skbuff.h>
21#include <linux/workqueue.h>
22#include <linux/types.h>
23#include <linux/spinlock.h>
24#include <net/wireless.h>
25#include "ieee80211_key.h"
26#include "sta_info.h"
27
28/* ieee80211.o internal definitions, etc. These are not included into
29 * low-level drivers. */
30
31#ifndef ETH_P_PAE
32#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
33#endif /* ETH_P_PAE */
34
35#define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
36
37struct ieee80211_local;
38
39#define BIT(x) (1 << (x))
40
41#define IEEE80211_ALIGN32_PAD(a) ((4 - ((a) & 3)) & 3)
42
43/* Maximum number of broadcast/multicast frames to buffer when some of the
44 * associated stations are using power saving. */
45#define AP_MAX_BC_BUFFER 128
46
47/* Maximum number of frames buffered to all STAs, including multicast frames.
48 * Note: increasing this limit increases the potential memory requirement. Each
49 * frame can be up to about 2 kB long. */
50#define TOTAL_MAX_TX_BUFFER 512
51
52/* Required encryption head and tailroom */
53#define IEEE80211_ENCRYPT_HEADROOM 8
54#define IEEE80211_ENCRYPT_TAILROOM 12
55
56/* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
57 * reception of at least three fragmented frames. This limit can be increased
58 * by changing this define, at the cost of slower frame reassembly and
59 * increased memory use (about 2 kB of RAM per entry). */
60#define IEEE80211_FRAGMENT_MAX 4
61
62struct ieee80211_fragment_entry {
63 unsigned long first_frag_time;
64 unsigned int seq;
65 unsigned int rx_queue;
66 unsigned int last_frag;
67 unsigned int extra_len;
68 struct sk_buff_head skb_list;
69 int ccmp; /* Whether fragments were encrypted with CCMP */
70 u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
71};
72
73
74struct ieee80211_sta_bss {
75 struct list_head list;
76 struct ieee80211_sta_bss *hnext;
77 atomic_t users;
78
79 u8 bssid[ETH_ALEN];
80 u8 ssid[IEEE80211_MAX_SSID_LEN];
81 size_t ssid_len;
82 u16 capability; /* host byte order */
83 int hw_mode;
84 int channel;
85 int freq;
86 int rssi, signal, noise;
87 u8 *wpa_ie;
88 size_t wpa_ie_len;
89 u8 *rsn_ie;
90 size_t rsn_ie_len;
91 u8 *wmm_ie;
92 size_t wmm_ie_len;
93#define IEEE80211_MAX_SUPP_RATES 32
94 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
95 size_t supp_rates_len;
96 int beacon_int;
97 u64 timestamp;
98
99 int probe_resp;
100 unsigned long last_update;
101
102};
103
104
105typedef enum {
106 TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
107} ieee80211_txrx_result;
108
109struct ieee80211_txrx_data {
110 struct sk_buff *skb;
111 struct net_device *dev;
112 struct ieee80211_local *local;
113 struct ieee80211_sub_if_data *sdata;
114 struct sta_info *sta;
115 u16 fc, ethertype;
116 struct ieee80211_key *key;
117 unsigned int fragmented:1; /* whether the MSDU was fragmented */
118 union {
119 struct {
120 struct ieee80211_tx_control *control;
121 unsigned int unicast:1;
122 unsigned int ps_buffered:1;
123 unsigned int short_preamble:1;
124 unsigned int probe_last_frag:1;
125 struct ieee80211_hw_mode *mode;
126 struct ieee80211_rate *rate;
127 /* use this rate (if set) for last fragment; rate can
128 * be set to lower rate for the first fragments, e.g.,
129 * when using CTS protection with IEEE 802.11g. */
130 struct ieee80211_rate *last_frag_rate;
131 int last_frag_hwrate;
132 int mgmt_interface;
133
134 /* Extra fragments (in addition to the first fragment
135 * in skb) */
136 int num_extra_frag;
137 struct sk_buff **extra_frag;
138 } tx;
139 struct {
140 struct ieee80211_rx_status *status;
141 int sent_ps_buffered;
142 int queue;
143 int load;
144 unsigned int in_scan:1;
145 /* frame is destined to interface currently processed
146 * (including multicast frames) */
147 unsigned int ra_match:1;
148 } rx;
149 } u;
150};
151
152/* Stored in sk_buff->cb */
153struct ieee80211_tx_packet_data {
154 int ifindex;
155 unsigned long jiffies;
156 unsigned int req_tx_status:1;
157 unsigned int do_not_encrypt:1;
158 unsigned int requeue:1;
159 unsigned int mgmt_iface:1;
160 unsigned int queue:4;
161};
162
163struct ieee80211_tx_stored_packet {
164 struct ieee80211_tx_control control;
165 struct sk_buff *skb;
166 int num_extra_frag;
167 struct sk_buff **extra_frag;
168 int last_frag_rateidx;
169 int last_frag_hwrate;
170 struct ieee80211_rate *last_frag_rate;
171 unsigned int last_frag_rate_ctrl_probe:1;
172};
173
174typedef ieee80211_txrx_result (*ieee80211_tx_handler)
175(struct ieee80211_txrx_data *tx);
176
177typedef ieee80211_txrx_result (*ieee80211_rx_handler)
178(struct ieee80211_txrx_data *rx);
179
180struct ieee80211_if_ap {
181 u8 *beacon_head, *beacon_tail;
182 int beacon_head_len, beacon_tail_len;
183
184 u8 ssid[IEEE80211_MAX_SSID_LEN];
185 size_t ssid_len;
186 u8 *generic_elem;
187 size_t generic_elem_len;
188
189 /* yes, this looks ugly, but guarantees that we can later use
190 * bitmap_empty :)
191 * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */
192 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
193 atomic_t num_sta_ps; /* number of stations in PS mode */
194 struct sk_buff_head ps_bc_buf;
195 int dtim_period, dtim_count;
196 int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
197 int max_ratectrl_rateidx; /* max TX rateidx for rate control */
198 int num_beacons; /* number of TXed beacon frames for this BSS */
199};
200
201struct ieee80211_if_wds {
202 u8 remote_addr[ETH_ALEN];
203 struct sta_info *sta;
204};
205
206struct ieee80211_if_vlan {
207 u8 id;
208};
209
210struct ieee80211_if_sta {
211 enum {
212 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
213 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
214 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
215 } state;
216 struct timer_list timer;
217 struct work_struct work;
218 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
219 u8 ssid[IEEE80211_MAX_SSID_LEN];
220 size_t ssid_len;
221 u16 aid;
222 u16 ap_capab, capab;
223 u8 *extra_ie; /* to be added to the end of AssocReq */
224 size_t extra_ie_len;
225
226 /* The last AssocReq/Resp IEs */
227 u8 *assocreq_ies, *assocresp_ies;
228 size_t assocreq_ies_len, assocresp_ies_len;
229
230 int auth_tries, assoc_tries;
231
232 unsigned int ssid_set:1;
233 unsigned int bssid_set:1;
234 unsigned int prev_bssid_set:1;
235 unsigned int authenticated:1;
236 unsigned int associated:1;
237 unsigned int probereq_poll:1;
238 unsigned int use_protection:1;
239 unsigned int create_ibss:1;
240 unsigned int mixed_cell:1;
241 unsigned int wmm_enabled:1;
242 unsigned int auto_ssid_sel:1;
243 unsigned int auto_bssid_sel:1;
244 unsigned int auto_channel_sel:1;
245#define IEEE80211_STA_REQ_SCAN 0
246#define IEEE80211_STA_REQ_AUTH 1
247#define IEEE80211_STA_REQ_RUN 2
248 unsigned long request;
249 struct sk_buff_head skb_queue;
250
251 int key_mgmt;
252 unsigned long last_probe;
253
254#define IEEE80211_AUTH_ALG_OPEN BIT(0)
255#define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
256#define IEEE80211_AUTH_ALG_LEAP BIT(2)
257 unsigned int auth_algs; /* bitfield of allowed auth algs */
258 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
259 int auth_transaction;
260
261 unsigned long ibss_join_req;
262 struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
263 u32 supp_rates_bits;
264
265 int wmm_last_param_set;
266};
267
268
269struct ieee80211_sub_if_data {
270 struct list_head list;
271 unsigned int type;
272
273 struct wireless_dev wdev;
274
275 struct net_device *dev;
276 struct ieee80211_local *local;
277
278 int mc_count;
279 unsigned int allmulti:1;
280 unsigned int promisc:1;
281
282 struct net_device_stats stats;
283 int drop_unencrypted;
284 int eapol; /* 0 = process EAPOL frames as normal data frames,
285 * 1 = send EAPOL frames through wlan#ap to hostapd
286 * (default) */
287 int ieee802_1x; /* IEEE 802.1X PAE - drop packet to/from unauthorized
288 * port */
289
290 u16 sequence;
291
292 /* Fragment table for host-based reassembly */
293 struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
294 unsigned int fragment_next;
295
296#define NUM_DEFAULT_KEYS 4
297 struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
298 struct ieee80211_key *default_key;
299
300 struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
301
302 union {
303 struct ieee80211_if_ap ap;
304 struct ieee80211_if_wds wds;
305 struct ieee80211_if_vlan vlan;
306 struct ieee80211_if_sta sta;
307 } u;
308 int channel_use;
309 int channel_use_raw;
310
311#ifdef CONFIG_MAC80211_DEBUGFS
312 struct dentry *debugfsdir;
313 union {
314 struct {
315 struct dentry *channel_use;
316 struct dentry *drop_unencrypted;
317 struct dentry *eapol;
318 struct dentry *ieee8021_x;
319 struct dentry *state;
320 struct dentry *bssid;
321 struct dentry *prev_bssid;
322 struct dentry *ssid_len;
323 struct dentry *aid;
324 struct dentry *ap_capab;
325 struct dentry *capab;
326 struct dentry *extra_ie_len;
327 struct dentry *auth_tries;
328 struct dentry *assoc_tries;
329 struct dentry *auth_algs;
330 struct dentry *auth_alg;
331 struct dentry *auth_transaction;
332 struct dentry *flags;
333 } sta;
334 struct {
335 struct dentry *channel_use;
336 struct dentry *drop_unencrypted;
337 struct dentry *eapol;
338 struct dentry *ieee8021_x;
339 struct dentry *num_sta_ps;
340 struct dentry *dtim_period;
341 struct dentry *dtim_count;
342 struct dentry *num_beacons;
343 struct dentry *force_unicast_rateidx;
344 struct dentry *max_ratectrl_rateidx;
345 struct dentry *num_buffered_multicast;
346 struct dentry *beacon_head_len;
347 struct dentry *beacon_tail_len;
348 } ap;
349 struct {
350 struct dentry *channel_use;
351 struct dentry *drop_unencrypted;
352 struct dentry *eapol;
353 struct dentry *ieee8021_x;
354 struct dentry *peer;
355 } wds;
356 struct {
357 struct dentry *channel_use;
358 struct dentry *drop_unencrypted;
359 struct dentry *eapol;
360 struct dentry *ieee8021_x;
361 struct dentry *vlan_id;
362 } vlan;
363 struct {
364 struct dentry *mode;
365 } monitor;
366 struct dentry *default_key;
367 } debugfs;
368#endif
369};
370
371#define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
372
373enum {
374 IEEE80211_RX_MSG = 1,
375 IEEE80211_TX_STATUS_MSG = 2,
376};
377
378struct ieee80211_local {
379 /* embed the driver visible part.
380 * don't cast (use the static inlines below), but we keep
381 * it first anyway so they become a no-op */
382 struct ieee80211_hw hw;
383
384 const struct ieee80211_ops *ops;
385
386 /* List of registered struct ieee80211_hw_mode */
387 struct list_head modes_list;
388
389 struct net_device *mdev; /* wmaster# - "master" 802.11 device */
390 struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
391 int open_count;
392 int monitors;
393 struct iw_statistics wstats;
394 u8 wstats_flags;
395
396 enum {
397 IEEE80211_DEV_UNINITIALIZED = 0,
398 IEEE80211_DEV_REGISTERED,
399 IEEE80211_DEV_UNREGISTERED,
400 } reg_state;
401
402 /* Tasklet and skb queue to process calls from IRQ mode. All frames
403 * added to skb_queue will be processed, but frames in
404 * skb_queue_unreliable may be dropped if the total length of these
405 * queues increases over the limit. */
406#define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
407 struct tasklet_struct tasklet;
408 struct sk_buff_head skb_queue;
409 struct sk_buff_head skb_queue_unreliable;
410
411 /* Station data structures */
412 spinlock_t sta_lock; /* mutex for STA data structures */
413 int num_sta; /* number of stations in sta_list */
414 struct list_head sta_list;
415 struct list_head deleted_sta_list;
416 struct sta_info *sta_hash[STA_HASH_SIZE];
417 struct timer_list sta_cleanup;
418
419 unsigned long state[NUM_TX_DATA_QUEUES];
420 struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES];
421 struct tasklet_struct tx_pending_tasklet;
422
423 int mc_count; /* total count of multicast entries in all interfaces */
424 int iff_allmultis, iff_promiscs;
425 /* number of interfaces with corresponding IFF_ flags */
426
427 struct rate_control_ref *rate_ctrl;
428
429 int next_mode; /* MODE_IEEE80211*
430 * The mode preference for next channel change. This is
431 * used to select .11g vs. .11b channels (or 4.9 GHz vs.
432 * .11a) when the channel number is not unique. */
433
434 /* Supported and basic rate filters for different modes. These are
435 * pointers to -1 terminated lists and rates in 100 kbps units. */
436 int *supp_rates[NUM_IEEE80211_MODES];
437 int *basic_rates[NUM_IEEE80211_MODES];
438
439 int rts_threshold;
440 int cts_protect_erp_frames;
441 int fragmentation_threshold;
442 int short_retry_limit; /* dot11ShortRetryLimit */
443 int long_retry_limit; /* dot11LongRetryLimit */
444 int short_preamble; /* use short preamble with IEEE 802.11b */
445
446 struct crypto_blkcipher *wep_tx_tfm;
447 struct crypto_blkcipher *wep_rx_tfm;
448 u32 wep_iv;
449 int key_tx_rx_threshold; /* number of times any key can be used in TX
450 * or RX before generating a rekey
451 * notification; 0 = notification disabled. */
452
453 int bridge_packets; /* bridge packets between associated stations and
454 * deliver multicast frames both back to wireless
455 * media and to the local net stack */
456
457 ieee80211_rx_handler *rx_pre_handlers;
458 ieee80211_rx_handler *rx_handlers;
459 ieee80211_tx_handler *tx_handlers;
460
461 rwlock_t sub_if_lock; /* Protects sub_if_list. Cannot be taken under
462 * sta_bss_lock or sta_lock. */
463 struct list_head sub_if_list;
464 int sta_scanning;
465 int scan_channel_idx;
466 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
467 unsigned long last_scan_completed;
468 struct delayed_work scan_work;
469 struct net_device *scan_dev;
470 struct ieee80211_channel *oper_channel, *scan_channel;
471 struct ieee80211_hw_mode *oper_hw_mode, *scan_hw_mode;
472 u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
473 size_t scan_ssid_len;
474 struct list_head sta_bss_list;
475 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
476 spinlock_t sta_bss_lock;
477#define IEEE80211_SCAN_MATCH_SSID BIT(0)
478#define IEEE80211_SCAN_WPA_ONLY BIT(1)
479#define IEEE80211_SCAN_EXTRA_INFO BIT(2)
480 int scan_flags;
481
482 /* SNMP counters */
483 /* dot11CountersTable */
484 u32 dot11TransmittedFragmentCount;
485 u32 dot11MulticastTransmittedFrameCount;
486 u32 dot11FailedCount;
487 u32 dot11RetryCount;
488 u32 dot11MultipleRetryCount;
489 u32 dot11FrameDuplicateCount;
490 u32 dot11ReceivedFragmentCount;
491 u32 dot11MulticastReceivedFrameCount;
492 u32 dot11TransmittedFrameCount;
493 u32 dot11WEPUndecryptableCount;
494
495#ifdef CONFIG_MAC80211_LEDS
496 int tx_led_counter, rx_led_counter;
497 struct led_trigger *tx_led, *rx_led;
498 char tx_led_name[32], rx_led_name[32];
499#endif
500
501 u32 channel_use;
502 u32 channel_use_raw;
503 u32 stat_time;
504 struct timer_list stat_timer;
505
506#ifdef CONFIG_MAC80211_DEBUGFS
507 struct work_struct sta_debugfs_add;
508#endif
509
510 enum {
511 STA_ANTENNA_SEL_AUTO = 0,
512 STA_ANTENNA_SEL_SW_CTRL = 1,
513 STA_ANTENNA_SEL_SW_CTRL_DEBUG = 2
514 } sta_antenna_sel;
515
516 int rate_ctrl_num_up, rate_ctrl_num_down;
517
518#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
519 /* TX/RX handler statistics */
520 unsigned int tx_handlers_drop;
521 unsigned int tx_handlers_queued;
522 unsigned int tx_handlers_drop_unencrypted;
523 unsigned int tx_handlers_drop_fragment;
524 unsigned int tx_handlers_drop_wep;
525 unsigned int tx_handlers_drop_not_assoc;
526 unsigned int tx_handlers_drop_unauth_port;
527 unsigned int rx_handlers_drop;
528 unsigned int rx_handlers_queued;
529 unsigned int rx_handlers_drop_nullfunc;
530 unsigned int rx_handlers_drop_defrag;
531 unsigned int rx_handlers_drop_short;
532 unsigned int rx_handlers_drop_passive_scan;
533 unsigned int tx_expand_skb_head;
534 unsigned int tx_expand_skb_head_cloned;
535 unsigned int rx_expand_skb_head;
536 unsigned int rx_expand_skb_head2;
537 unsigned int rx_handlers_fragments;
538 unsigned int tx_status_drop;
539 unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
540 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
541#define I802_DEBUG_INC(c) (c)++
542#else /* CONFIG_MAC80211_DEBUG_COUNTERS */
543#define I802_DEBUG_INC(c) do { } while (0)
544#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
545
546
547 int default_wep_only; /* only default WEP keys are used with this
548 * interface; this is used to decide when hwaccel
549 * can be used with default keys */
550 int total_ps_buffered; /* total number of all buffered unicast and
551 * multicast packets for power saving stations
552 */
553 int allow_broadcast_always; /* whether to allow TX of broadcast frames
554 * even when there are no associated STAs
555 */
556
557 int wifi_wme_noack_test;
558 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
559
560 unsigned int enabled_modes; /* bitfield of allowed modes;
561 * (1 << MODE_*) */
562 unsigned int hw_modes; /* bitfield of supported hardware modes;
563 * (1 << MODE_*) */
564
565 int user_space_mlme;
566
567#ifdef CONFIG_MAC80211_DEBUGFS
568 struct local_debugfsdentries {
569 struct dentry *channel;
570 struct dentry *frequency;
571 struct dentry *radar_detect;
572 struct dentry *antenna_sel_tx;
573 struct dentry *antenna_sel_rx;
574 struct dentry *bridge_packets;
575 struct dentry *key_tx_rx_threshold;
576 struct dentry *rts_threshold;
577 struct dentry *fragmentation_threshold;
578 struct dentry *short_retry_limit;
579 struct dentry *long_retry_limit;
580 struct dentry *total_ps_buffered;
581 struct dentry *mode;
582 struct dentry *wep_iv;
583 struct dentry *tx_power_reduction;
584 struct dentry *modes;
585 struct dentry *statistics;
586 struct local_debugfsdentries_statsdentries {
587 struct dentry *transmitted_fragment_count;
588 struct dentry *multicast_transmitted_frame_count;
589 struct dentry *failed_count;
590 struct dentry *retry_count;
591 struct dentry *multiple_retry_count;
592 struct dentry *frame_duplicate_count;
593 struct dentry *received_fragment_count;
594 struct dentry *multicast_received_frame_count;
595 struct dentry *transmitted_frame_count;
596 struct dentry *wep_undecryptable_count;
597 struct dentry *num_scans;
598#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
599 struct dentry *tx_handlers_drop;
600 struct dentry *tx_handlers_queued;
601 struct dentry *tx_handlers_drop_unencrypted;
602 struct dentry *tx_handlers_drop_fragment;
603 struct dentry *tx_handlers_drop_wep;
604 struct dentry *tx_handlers_drop_not_assoc;
605 struct dentry *tx_handlers_drop_unauth_port;
606 struct dentry *rx_handlers_drop;
607 struct dentry *rx_handlers_queued;
608 struct dentry *rx_handlers_drop_nullfunc;
609 struct dentry *rx_handlers_drop_defrag;
610 struct dentry *rx_handlers_drop_short;
611 struct dentry *rx_handlers_drop_passive_scan;
612 struct dentry *tx_expand_skb_head;
613 struct dentry *tx_expand_skb_head_cloned;
614 struct dentry *rx_expand_skb_head;
615 struct dentry *rx_expand_skb_head2;
616 struct dentry *rx_handlers_fragments;
617 struct dentry *tx_status_drop;
618 struct dentry *wme_tx_queue;
619 struct dentry *wme_rx_queue;
620#endif
621 struct dentry *dot11ACKFailureCount;
622 struct dentry *dot11RTSFailureCount;
623 struct dentry *dot11FCSErrorCount;
624 struct dentry *dot11RTSSuccessCount;
625 } stats;
626 struct dentry *stations;
627 struct dentry *keys;
628 } debugfs;
629#endif
630};
631
632static inline struct ieee80211_local *hw_to_local(
633 struct ieee80211_hw *hw)
634{
635 return container_of(hw, struct ieee80211_local, hw);
636}
637
638static inline struct ieee80211_hw *local_to_hw(
639 struct ieee80211_local *local)
640{
641 return &local->hw;
642}
643
644enum ieee80211_link_state_t {
645 IEEE80211_LINK_STATE_XOFF = 0,
646 IEEE80211_LINK_STATE_PENDING,
647};
648
649struct sta_attribute {
650 struct attribute attr;
651 ssize_t (*show)(const struct sta_info *, char *buf);
652 ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
653};
654
655static inline void __bss_tim_set(struct ieee80211_if_ap *bss, int aid)
656{
657 /*
658 * This format has ben mandated by the IEEE specifications,
659 * so this line may not be changed to use the __set_bit() format.
660 */
661 bss->tim[(aid)/8] |= 1<<((aid) % 8);
662}
663
664static inline void bss_tim_set(struct ieee80211_local *local,
665 struct ieee80211_if_ap *bss, int aid)
666{
667 spin_lock_bh(&local->sta_lock);
668 __bss_tim_set(bss, aid);
669 spin_unlock_bh(&local->sta_lock);
670}
671
672static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, int aid)
673{
674 /*
675 * This format has ben mandated by the IEEE specifications,
676 * so this line may not be changed to use the __clear_bit() format.
677 */
678 bss->tim[(aid)/8] &= !(1<<((aid) % 8));
679}
680
681static inline void bss_tim_clear(struct ieee80211_local *local,
682 struct ieee80211_if_ap *bss, int aid)
683{
684 spin_lock_bh(&local->sta_lock);
685 __bss_tim_clear(bss, aid);
686 spin_unlock_bh(&local->sta_lock);
687}
688
689/**
690 * ieee80211_is_erp_rate - Check if a rate is an ERP rate
691 * @phymode: The PHY-mode for this rate (MODE_IEEE80211...)
692 * @rate: Transmission rate to check, in 100 kbps
693 *
694 * Check if a given rate is an Extended Rate PHY (ERP) rate.
695 */
696static inline int ieee80211_is_erp_rate(int phymode, int rate)
697{
698 if (phymode == MODE_IEEE80211G) {
699 if (rate != 10 && rate != 20 &&
700 rate != 55 && rate != 110)
701 return 1;
702 }
703 return 0;
704}
705
706/* ieee80211.c */
707int ieee80211_hw_config(struct ieee80211_local *local);
708int ieee80211_if_config(struct net_device *dev);
709int ieee80211_if_config_beacon(struct net_device *dev);
710struct ieee80211_key_conf *
711ieee80211_key_data2conf(struct ieee80211_local *local,
712 const struct ieee80211_key *data);
713struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
714 int idx, size_t key_len, gfp_t flags);
715void ieee80211_key_free(struct ieee80211_key *key);
716void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
717 struct ieee80211_rx_status *status, u32 msg_type);
718void ieee80211_prepare_rates(struct ieee80211_local *local,
719 struct ieee80211_hw_mode *mode);
720void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
721int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
722void ieee80211_if_setup(struct net_device *dev);
723void ieee80211_if_mgmt_setup(struct net_device *dev);
724int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
725 const char *name);
726struct net_device_stats *ieee80211_dev_stats(struct net_device *dev);
727
728/* ieee80211_ioctl.c */
729extern const struct iw_handler_def ieee80211_iw_handler_def;
730
731void ieee80211_update_default_wep_only(struct ieee80211_local *local);
732
733
734/* Least common multiple of the used rates (in 100 kbps). This is used to
735 * calculate rate_inv values for each rate so that only integers are needed. */
736#define CHAN_UTIL_RATE_LCM 95040
737/* 1 usec is 1/8 * (95040/10) = 1188 */
738#define CHAN_UTIL_PER_USEC 1188
739/* Amount of bits to shift the result right to scale the total utilization
740 * to values that will not wrap around 32-bit integers. */
741#define CHAN_UTIL_SHIFT 9
742/* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
743 * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
744 * raw value with about 23 should give utilization in 10th of a percentage
745 * (1/1000). However, utilization is only estimated and not all intervals
746 * between frames etc. are calculated. 18 seems to give numbers that are closer
747 * to the real maximum. */
748#define CHAN_UTIL_PER_10MS 18
749#define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
750#define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
751
752
753/* ieee80211_ioctl.c */
754int ieee80211_set_compression(struct ieee80211_local *local,
755 struct net_device *dev, struct sta_info *sta);
756int ieee80211_init_client(struct net_device *dev);
757int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq);
758/* ieee80211_sta.c */
759void ieee80211_sta_timer(unsigned long data);
760void ieee80211_sta_work(struct work_struct *work);
761void ieee80211_sta_scan_work(struct work_struct *work);
762void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
763 struct ieee80211_rx_status *rx_status);
764int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
765int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
766int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
767int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
768void ieee80211_sta_req_auth(struct net_device *dev,
769 struct ieee80211_if_sta *ifsta);
770int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
771void ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb,
772 struct ieee80211_rx_status *rx_status);
773void ieee80211_rx_bss_list_init(struct net_device *dev);
774void ieee80211_rx_bss_list_deinit(struct net_device *dev);
775int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
776struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
777 struct sk_buff *skb, u8 *bssid,
778 u8 *addr);
779int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
780int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
781
782/* ieee80211_iface.c */
783int ieee80211_if_add(struct net_device *dev, const char *name,
784 struct net_device **new_dev, int type);
785void ieee80211_if_set_type(struct net_device *dev, int type);
786void ieee80211_if_reinit(struct net_device *dev);
787void __ieee80211_if_del(struct ieee80211_local *local,
788 struct ieee80211_sub_if_data *sdata);
789int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
790void ieee80211_if_free(struct net_device *dev);
791void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
792int ieee80211_if_add_mgmt(struct ieee80211_local *local);
793void ieee80211_if_del_mgmt(struct ieee80211_local *local);
794
795/* for wiphy privid */
796extern void *mac80211_wiphy_privid;
797
798#endif /* IEEE80211_I_H */
diff --git a/net/mac80211/ieee80211_iface.c b/net/mac80211/ieee80211_iface.c
new file mode 100644
index 000000000000..cf0f32e8c2a2
--- /dev/null
+++ b/net/mac80211/ieee80211_iface.c
@@ -0,0 +1,352 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
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#include <linux/kernel.h>
11#include <linux/if_arp.h>
12#include <linux/netdevice.h>
13#include <linux/rtnetlink.h>
14#include <net/mac80211.h>
15#include "ieee80211_i.h"
16#include "sta_info.h"
17#include "debugfs_netdev.h"
18
19void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata)
20{
21 int i;
22
23 /* Default values for sub-interface parameters */
24 sdata->drop_unencrypted = 0;
25 sdata->eapol = 1;
26 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
27 skb_queue_head_init(&sdata->fragments[i].skb_list);
28}
29
30static void ieee80211_if_sdata_deinit(struct ieee80211_sub_if_data *sdata)
31{
32 int i;
33
34 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) {
35 __skb_queue_purge(&sdata->fragments[i].skb_list);
36 }
37}
38
39/* Must be called with rtnl lock held. */
40int ieee80211_if_add(struct net_device *dev, const char *name,
41 struct net_device **new_dev, int type)
42{
43 struct net_device *ndev;
44 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
45 struct ieee80211_sub_if_data *sdata = NULL;
46 int ret;
47
48 ASSERT_RTNL();
49 ndev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
50 name, ieee80211_if_setup);
51 if (!ndev)
52 return -ENOMEM;
53
54 ret = dev_alloc_name(ndev, ndev->name);
55 if (ret < 0)
56 goto fail;
57
58 memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
59 ndev->base_addr = dev->base_addr;
60 ndev->irq = dev->irq;
61 ndev->mem_start = dev->mem_start;
62 ndev->mem_end = dev->mem_end;
63 SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy));
64
65 sdata = IEEE80211_DEV_TO_SUB_IF(ndev);
66 ndev->ieee80211_ptr = &sdata->wdev;
67 sdata->wdev.wiphy = local->hw.wiphy;
68 sdata->type = IEEE80211_IF_TYPE_AP;
69 sdata->dev = ndev;
70 sdata->local = local;
71 ieee80211_if_sdata_init(sdata);
72
73 ret = register_netdevice(ndev);
74 if (ret)
75 goto fail;
76
77 ieee80211_debugfs_add_netdev(sdata);
78 ieee80211_if_set_type(ndev, type);
79
80 write_lock_bh(&local->sub_if_lock);
81 if (unlikely(local->reg_state == IEEE80211_DEV_UNREGISTERED)) {
82 write_unlock_bh(&local->sub_if_lock);
83 __ieee80211_if_del(local, sdata);
84 return -ENODEV;
85 }
86 list_add(&sdata->list, &local->sub_if_list);
87 if (new_dev)
88 *new_dev = ndev;
89 write_unlock_bh(&local->sub_if_lock);
90
91 ieee80211_update_default_wep_only(local);
92
93 return 0;
94
95fail:
96 free_netdev(ndev);
97 return ret;
98}
99
100int ieee80211_if_add_mgmt(struct ieee80211_local *local)
101{
102 struct net_device *ndev;
103 struct ieee80211_sub_if_data *nsdata;
104 int ret;
105
106 ASSERT_RTNL();
107
108 ndev = alloc_netdev(sizeof(struct ieee80211_sub_if_data), "wmgmt%d",
109 ieee80211_if_mgmt_setup);
110 if (!ndev)
111 return -ENOMEM;
112 ret = dev_alloc_name(ndev, ndev->name);
113 if (ret < 0)
114 goto fail;
115
116 memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
117 SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy));
118
119 nsdata = IEEE80211_DEV_TO_SUB_IF(ndev);
120 ndev->ieee80211_ptr = &nsdata->wdev;
121 nsdata->wdev.wiphy = local->hw.wiphy;
122 nsdata->type = IEEE80211_IF_TYPE_MGMT;
123 nsdata->dev = ndev;
124 nsdata->local = local;
125 ieee80211_if_sdata_init(nsdata);
126
127 ret = register_netdevice(ndev);
128 if (ret)
129 goto fail;
130
131 ieee80211_debugfs_add_netdev(nsdata);
132
133 if (local->open_count > 0)
134 dev_open(ndev);
135 local->apdev = ndev;
136 return 0;
137
138fail:
139 free_netdev(ndev);
140 return ret;
141}
142
143void ieee80211_if_del_mgmt(struct ieee80211_local *local)
144{
145 struct net_device *apdev;
146
147 ASSERT_RTNL();
148 apdev = local->apdev;
149 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(apdev));
150 local->apdev = NULL;
151 unregister_netdevice(apdev);
152}
153
154void ieee80211_if_set_type(struct net_device *dev, int type)
155{
156 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
157 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
158 int oldtype = sdata->type;
159
160 sdata->type = type;
161 switch (type) {
162 case IEEE80211_IF_TYPE_WDS:
163 sdata->bss = NULL;
164 break;
165 case IEEE80211_IF_TYPE_VLAN:
166 break;
167 case IEEE80211_IF_TYPE_AP:
168 sdata->u.ap.dtim_period = 2;
169 sdata->u.ap.force_unicast_rateidx = -1;
170 sdata->u.ap.max_ratectrl_rateidx = -1;
171 skb_queue_head_init(&sdata->u.ap.ps_bc_buf);
172 sdata->bss = &sdata->u.ap;
173 break;
174 case IEEE80211_IF_TYPE_STA:
175 case IEEE80211_IF_TYPE_IBSS: {
176 struct ieee80211_sub_if_data *msdata;
177 struct ieee80211_if_sta *ifsta;
178
179 ifsta = &sdata->u.sta;
180 INIT_WORK(&ifsta->work, ieee80211_sta_work);
181 setup_timer(&ifsta->timer, ieee80211_sta_timer,
182 (unsigned long) sdata);
183 skb_queue_head_init(&ifsta->skb_queue);
184
185 ifsta->capab = WLAN_CAPABILITY_ESS;
186 ifsta->auth_algs = IEEE80211_AUTH_ALG_OPEN |
187 IEEE80211_AUTH_ALG_SHARED_KEY;
188 ifsta->create_ibss = 1;
189 ifsta->wmm_enabled = 1;
190 ifsta->auto_channel_sel = 1;
191 ifsta->auto_bssid_sel = 1;
192
193 msdata = IEEE80211_DEV_TO_SUB_IF(sdata->local->mdev);
194 sdata->bss = &msdata->u.ap;
195 break;
196 }
197 case IEEE80211_IF_TYPE_MNTR:
198 dev->type = ARPHRD_IEEE80211_RADIOTAP;
199 break;
200 default:
201 printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x",
202 dev->name, __FUNCTION__, type);
203 }
204 ieee80211_debugfs_change_if_type(sdata, oldtype);
205 ieee80211_update_default_wep_only(local);
206}
207
208/* Must be called with rtnl lock held. */
209void ieee80211_if_reinit(struct net_device *dev)
210{
211 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
212 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
213 struct sta_info *sta;
214 int i;
215
216 ASSERT_RTNL();
217 ieee80211_if_sdata_deinit(sdata);
218 for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
219 if (!sdata->keys[i])
220 continue;
221#if 0
222 /* The interface is down at the moment, so there is not
223 * really much point in disabling the keys at this point. */
224 memset(addr, 0xff, ETH_ALEN);
225 if (local->ops->set_key)
226 local->ops->set_key(local_to_hw(local), DISABLE_KEY, addr,
227 local->keys[i], 0);
228#endif
229 ieee80211_key_free(sdata->keys[i]);
230 sdata->keys[i] = NULL;
231 }
232
233 switch (sdata->type) {
234 case IEEE80211_IF_TYPE_AP: {
235 /* Remove all virtual interfaces that use this BSS
236 * as their sdata->bss */
237 struct ieee80211_sub_if_data *tsdata, *n;
238 LIST_HEAD(tmp_list);
239
240 write_lock_bh(&local->sub_if_lock);
241 list_for_each_entry_safe(tsdata, n, &local->sub_if_list, list) {
242 if (tsdata != sdata && tsdata->bss == &sdata->u.ap) {
243 printk(KERN_DEBUG "%s: removing virtual "
244 "interface %s because its BSS interface"
245 " is being removed\n",
246 sdata->dev->name, tsdata->dev->name);
247 list_move_tail(&tsdata->list, &tmp_list);
248 }
249 }
250 write_unlock_bh(&local->sub_if_lock);
251
252 list_for_each_entry_safe(tsdata, n, &tmp_list, list)
253 __ieee80211_if_del(local, tsdata);
254
255 kfree(sdata->u.ap.beacon_head);
256 kfree(sdata->u.ap.beacon_tail);
257 kfree(sdata->u.ap.generic_elem);
258
259 if (dev != local->mdev) {
260 struct sk_buff *skb;
261 while ((skb = skb_dequeue(&sdata->u.ap.ps_bc_buf))) {
262 local->total_ps_buffered--;
263 dev_kfree_skb(skb);
264 }
265 }
266
267 break;
268 }
269 case IEEE80211_IF_TYPE_WDS:
270 sta = sta_info_get(local, sdata->u.wds.remote_addr);
271 if (sta) {
272 sta_info_put(sta);
273 sta_info_free(sta, 0);
274 } else {
275#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
276 printk(KERN_DEBUG "%s: Someone had deleted my STA "
277 "entry for the WDS link\n", dev->name);
278#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
279 }
280 break;
281 case IEEE80211_IF_TYPE_STA:
282 case IEEE80211_IF_TYPE_IBSS:
283 kfree(sdata->u.sta.extra_ie);
284 sdata->u.sta.extra_ie = NULL;
285 kfree(sdata->u.sta.assocreq_ies);
286 sdata->u.sta.assocreq_ies = NULL;
287 kfree(sdata->u.sta.assocresp_ies);
288 sdata->u.sta.assocresp_ies = NULL;
289 if (sdata->u.sta.probe_resp) {
290 dev_kfree_skb(sdata->u.sta.probe_resp);
291 sdata->u.sta.probe_resp = NULL;
292 }
293
294 break;
295 case IEEE80211_IF_TYPE_MNTR:
296 dev->type = ARPHRD_ETHER;
297 break;
298 }
299
300 /* remove all STAs that are bound to this virtual interface */
301 sta_info_flush(local, dev);
302
303 memset(&sdata->u, 0, sizeof(sdata->u));
304 ieee80211_if_sdata_init(sdata);
305}
306
307/* Must be called with rtnl lock held. */
308void __ieee80211_if_del(struct ieee80211_local *local,
309 struct ieee80211_sub_if_data *sdata)
310{
311 struct net_device *dev = sdata->dev;
312
313 ieee80211_debugfs_remove_netdev(sdata);
314 unregister_netdevice(dev);
315 /* Except master interface, the net_device will be freed by
316 * net_device->destructor (i. e. ieee80211_if_free). */
317}
318
319/* Must be called with rtnl lock held. */
320int ieee80211_if_remove(struct net_device *dev, const char *name, int id)
321{
322 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
323 struct ieee80211_sub_if_data *sdata, *n;
324
325 ASSERT_RTNL();
326
327 write_lock_bh(&local->sub_if_lock);
328 list_for_each_entry_safe(sdata, n, &local->sub_if_list, list) {
329 if ((sdata->type == id || id == -1) &&
330 strcmp(name, sdata->dev->name) == 0 &&
331 sdata->dev != local->mdev) {
332 list_del(&sdata->list);
333 write_unlock_bh(&local->sub_if_lock);
334 __ieee80211_if_del(local, sdata);
335 ieee80211_update_default_wep_only(local);
336 return 0;
337 }
338 }
339 write_unlock_bh(&local->sub_if_lock);
340 return -ENODEV;
341}
342
343void ieee80211_if_free(struct net_device *dev)
344{
345 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
346 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
347
348 /* local->apdev must be NULL when freeing management interface */
349 BUG_ON(dev == local->apdev);
350 ieee80211_if_sdata_deinit(sdata);
351 free_netdev(dev);
352}
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c
new file mode 100644
index 000000000000..352f03bd8a3a
--- /dev/null
+++ b/net/mac80211/ieee80211_ioctl.c
@@ -0,0 +1,1822 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/netdevice.h>
13#include <linux/types.h>
14#include <linux/slab.h>
15#include <linux/skbuff.h>
16#include <linux/etherdevice.h>
17#include <linux/if_arp.h>
18#include <linux/wireless.h>
19#include <net/iw_handler.h>
20#include <asm/uaccess.h>
21
22#include <net/mac80211.h>
23#include "ieee80211_i.h"
24#include "hostapd_ioctl.h"
25#include "ieee80211_rate.h"
26#include "wpa.h"
27#include "aes_ccm.h"
28#include "debugfs_key.h"
29
30static int ieee80211_regdom = 0x10; /* FCC */
31module_param(ieee80211_regdom, int, 0444);
32MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK");
33
34/*
35 * If firmware is upgraded by the vendor, additional channels can be used based
36 * on the new Japanese regulatory rules. This is indicated by setting
37 * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel
38 * module.
39 */
40static int ieee80211_japan_5ghz /* = 0 */;
41module_param(ieee80211_japan_5ghz, int, 0444);
42MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz");
43
44static void ieee80211_set_hw_encryption(struct net_device *dev,
45 struct sta_info *sta, u8 addr[ETH_ALEN],
46 struct ieee80211_key *key)
47{
48 struct ieee80211_key_conf *keyconf = NULL;
49 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
50
51 /* default to sw encryption; this will be cleared by low-level
52 * driver if the hw supports requested encryption */
53 if (key)
54 key->force_sw_encrypt = 1;
55
56 if (key && local->ops->set_key &&
57 (keyconf = ieee80211_key_data2conf(local, key))) {
58 if (local->ops->set_key(local_to_hw(local), SET_KEY, addr,
59 keyconf, sta ? sta->aid : 0)) {
60 key->force_sw_encrypt = 1;
61 key->hw_key_idx = HW_KEY_IDX_INVALID;
62 } else {
63 key->force_sw_encrypt =
64 !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
65 key->hw_key_idx =
66 keyconf->hw_key_idx;
67
68 }
69 }
70 kfree(keyconf);
71}
72
73
74static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
75 int idx, int alg, int set_tx_key,
76 const u8 *_key, size_t key_len)
77{
78 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
79 int ret = 0;
80 struct sta_info *sta;
81 struct ieee80211_key *key, *old_key;
82 int try_hwaccel = 1;
83 struct ieee80211_key_conf *keyconf;
84 struct ieee80211_sub_if_data *sdata;
85
86 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
87
88 if (is_broadcast_ether_addr(sta_addr)) {
89 sta = NULL;
90 if (idx >= NUM_DEFAULT_KEYS) {
91 printk(KERN_DEBUG "%s: set_encrypt - invalid idx=%d\n",
92 dev->name, idx);
93 return -EINVAL;
94 }
95 key = sdata->keys[idx];
96
97 /* TODO: consider adding hwaccel support for these; at least
98 * Atheros key cache should be able to handle this since AP is
99 * only transmitting frames with default keys. */
100 /* FIX: hw key cache can be used when only one virtual
101 * STA is associated with each AP. If more than one STA
102 * is associated to the same AP, software encryption
103 * must be used. This should be done automatically
104 * based on configured station devices. For the time
105 * being, this can be only set at compile time. */
106 } else {
107 set_tx_key = 0;
108 if (idx != 0) {
109 printk(KERN_DEBUG "%s: set_encrypt - non-zero idx for "
110 "individual key\n", dev->name);
111 return -EINVAL;
112 }
113
114 sta = sta_info_get(local, sta_addr);
115 if (!sta) {
116#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
117 printk(KERN_DEBUG "%s: set_encrypt - unknown addr "
118 MAC_FMT "\n",
119 dev->name, MAC_ARG(sta_addr));
120#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
121
122 return -ENOENT;
123 }
124
125 key = sta->key;
126 }
127
128 /* FIX:
129 * Cannot configure default hwaccel keys with WEP algorithm, if
130 * any of the virtual interfaces is using static WEP
131 * configuration because hwaccel would otherwise try to decrypt
132 * these frames.
133 *
134 * For now, just disable WEP hwaccel for broadcast when there is
135 * possibility of conflict with default keys. This can maybe later be
136 * optimized by using non-default keys (at least with Atheros ar521x).
137 */
138 if (!sta && alg == ALG_WEP && !local->default_wep_only &&
139 sdata->type != IEEE80211_IF_TYPE_IBSS &&
140 sdata->type != IEEE80211_IF_TYPE_AP) {
141 try_hwaccel = 0;
142 }
143
144 if (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP) {
145 /* Software encryption cannot be used with devices that hide
146 * encryption from the host system, so always try to use
147 * hardware acceleration with such devices. */
148 try_hwaccel = 1;
149 }
150
151 if ((local->hw.flags & IEEE80211_HW_NO_TKIP_WMM_HWACCEL) &&
152 alg == ALG_TKIP) {
153 if (sta && (sta->flags & WLAN_STA_WME)) {
154 /* Hardware does not support hwaccel with TKIP when using WMM.
155 */
156 try_hwaccel = 0;
157 }
158 else if (sdata->type == IEEE80211_IF_TYPE_STA) {
159 sta = sta_info_get(local, sdata->u.sta.bssid);
160 if (sta) {
161 if (sta->flags & WLAN_STA_WME) {
162 try_hwaccel = 0;
163 }
164 sta_info_put(sta);
165 sta = NULL;
166 }
167 }
168 }
169
170 if (alg == ALG_NONE) {
171 keyconf = NULL;
172 if (try_hwaccel && key &&
173 key->hw_key_idx != HW_KEY_IDX_INVALID &&
174 local->ops->set_key &&
175 (keyconf = ieee80211_key_data2conf(local, key)) != NULL &&
176 local->ops->set_key(local_to_hw(local), DISABLE_KEY,
177 sta_addr, keyconf, sta ? sta->aid : 0)) {
178 printk(KERN_DEBUG "%s: set_encrypt - low-level disable"
179 " failed\n", dev->name);
180 ret = -EINVAL;
181 }
182 kfree(keyconf);
183
184 if (set_tx_key || sdata->default_key == key) {
185 ieee80211_debugfs_key_remove_default(sdata);
186 sdata->default_key = NULL;
187 }
188 ieee80211_debugfs_key_remove(key);
189 if (sta)
190 sta->key = NULL;
191 else
192 sdata->keys[idx] = NULL;
193 ieee80211_key_free(key);
194 key = NULL;
195 } else {
196 old_key = key;
197 key = ieee80211_key_alloc(sta ? NULL : sdata, idx, key_len,
198 GFP_KERNEL);
199 if (!key) {
200 ret = -ENOMEM;
201 goto err_out;
202 }
203
204 /* default to sw encryption; low-level driver sets these if the
205 * requested encryption is supported */
206 key->hw_key_idx = HW_KEY_IDX_INVALID;
207 key->force_sw_encrypt = 1;
208
209 key->alg = alg;
210 key->keyidx = idx;
211 key->keylen = key_len;
212 memcpy(key->key, _key, key_len);
213 if (set_tx_key)
214 key->default_tx_key = 1;
215
216 if (alg == ALG_CCMP) {
217 /* Initialize AES key state here as an optimization
218 * so that it does not need to be initialized for every
219 * packet. */
220 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(
221 key->key);
222 if (!key->u.ccmp.tfm) {
223 ret = -ENOMEM;
224 goto err_free;
225 }
226 }
227
228 if (set_tx_key || sdata->default_key == old_key) {
229 ieee80211_debugfs_key_remove_default(sdata);
230 sdata->default_key = NULL;
231 }
232 ieee80211_debugfs_key_remove(old_key);
233 if (sta)
234 sta->key = key;
235 else
236 sdata->keys[idx] = key;
237 ieee80211_key_free(old_key);
238 ieee80211_debugfs_key_add(local, key);
239 if (sta)
240 ieee80211_debugfs_key_sta_link(key, sta);
241
242 if (try_hwaccel &&
243 (alg == ALG_WEP || alg == ALG_TKIP || alg == ALG_CCMP))
244 ieee80211_set_hw_encryption(dev, sta, sta_addr, key);
245 }
246
247 if (set_tx_key || (!sta && !sdata->default_key && key)) {
248 sdata->default_key = key;
249 if (key)
250 ieee80211_debugfs_key_add_default(sdata);
251
252 if (local->ops->set_key_idx &&
253 local->ops->set_key_idx(local_to_hw(local), idx))
254 printk(KERN_DEBUG "%s: failed to set TX key idx for "
255 "low-level driver\n", dev->name);
256 }
257
258 if (sta)
259 sta_info_put(sta);
260
261 return 0;
262
263err_free:
264 ieee80211_key_free(key);
265err_out:
266 if (sta)
267 sta_info_put(sta);
268 return ret;
269}
270
271static int ieee80211_ioctl_siwgenie(struct net_device *dev,
272 struct iw_request_info *info,
273 struct iw_point *data, char *extra)
274{
275 struct ieee80211_sub_if_data *sdata;
276 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
277
278 if (local->user_space_mlme)
279 return -EOPNOTSUPP;
280
281 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
282 if (sdata->type == IEEE80211_IF_TYPE_STA ||
283 sdata->type == IEEE80211_IF_TYPE_IBSS) {
284 int ret = ieee80211_sta_set_extra_ie(dev, extra, data->length);
285 if (ret)
286 return ret;
287 sdata->u.sta.auto_bssid_sel = 0;
288 ieee80211_sta_req_auth(dev, &sdata->u.sta);
289 return 0;
290 }
291
292 if (sdata->type == IEEE80211_IF_TYPE_AP) {
293 kfree(sdata->u.ap.generic_elem);
294 sdata->u.ap.generic_elem = kmalloc(data->length, GFP_KERNEL);
295 if (!sdata->u.ap.generic_elem)
296 return -ENOMEM;
297 memcpy(sdata->u.ap.generic_elem, extra, data->length);
298 sdata->u.ap.generic_elem_len = data->length;
299 return ieee80211_if_config(dev);
300 }
301 return -EOPNOTSUPP;
302}
303
304static int ieee80211_ioctl_set_radio_enabled(struct net_device *dev,
305 int val)
306{
307 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
308 struct ieee80211_conf *conf = &local->hw.conf;
309
310 conf->radio_enabled = val;
311 return ieee80211_hw_config(wdev_priv(dev->ieee80211_ptr));
312}
313
314static int ieee80211_ioctl_giwname(struct net_device *dev,
315 struct iw_request_info *info,
316 char *name, char *extra)
317{
318 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
319
320 switch (local->hw.conf.phymode) {
321 case MODE_IEEE80211A:
322 strcpy(name, "IEEE 802.11a");
323 break;
324 case MODE_IEEE80211B:
325 strcpy(name, "IEEE 802.11b");
326 break;
327 case MODE_IEEE80211G:
328 strcpy(name, "IEEE 802.11g");
329 break;
330 case MODE_ATHEROS_TURBO:
331 strcpy(name, "5GHz Turbo");
332 break;
333 default:
334 strcpy(name, "IEEE 802.11");
335 break;
336 }
337
338 return 0;
339}
340
341
342static int ieee80211_ioctl_giwrange(struct net_device *dev,
343 struct iw_request_info *info,
344 struct iw_point *data, char *extra)
345{
346 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
347 struct iw_range *range = (struct iw_range *) extra;
348
349 data->length = sizeof(struct iw_range);
350 memset(range, 0, sizeof(struct iw_range));
351
352 range->we_version_compiled = WIRELESS_EXT;
353 range->we_version_source = 21;
354 range->retry_capa = IW_RETRY_LIMIT;
355 range->retry_flags = IW_RETRY_LIMIT;
356 range->min_retry = 0;
357 range->max_retry = 255;
358 range->min_rts = 0;
359 range->max_rts = 2347;
360 range->min_frag = 256;
361 range->max_frag = 2346;
362
363 range->encoding_size[0] = 5;
364 range->encoding_size[1] = 13;
365 range->num_encoding_sizes = 2;
366 range->max_encoding_tokens = NUM_DEFAULT_KEYS;
367
368 range->max_qual.qual = local->hw.max_signal;
369 range->max_qual.level = local->hw.max_rssi;
370 range->max_qual.noise = local->hw.max_noise;
371 range->max_qual.updated = local->wstats_flags;
372
373 range->avg_qual.qual = local->hw.max_signal/2;
374 range->avg_qual.level = 0;
375 range->avg_qual.noise = 0;
376 range->avg_qual.updated = local->wstats_flags;
377
378 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
379 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
380
381 IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
382 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY);
383 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
384 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
385
386 return 0;
387}
388
389
390struct ieee80211_channel_range {
391 short start_freq;
392 short end_freq;
393 unsigned char power_level;
394 unsigned char antenna_max;
395};
396
397static const struct ieee80211_channel_range ieee80211_fcc_channels[] = {
398 { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */,
399 { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */,
400 { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */,
401 { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */,
402 { 0 }
403};
404
405static const struct ieee80211_channel_range ieee80211_mkk_channels[] = {
406 { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */,
407 { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */,
408 { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */,
409 { 0 }
410};
411
412
413static const struct ieee80211_channel_range *channel_range =
414 ieee80211_fcc_channels;
415
416
417static void ieee80211_unmask_channel(struct net_device *dev, int mode,
418 struct ieee80211_channel *chan)
419{
420 int i;
421
422 chan->flag = 0;
423
424 if (ieee80211_regdom == 64 &&
425 (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) {
426 /* Do not allow Turbo modes in Japan. */
427 return;
428 }
429
430 for (i = 0; channel_range[i].start_freq; i++) {
431 const struct ieee80211_channel_range *r = &channel_range[i];
432 if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) {
433 if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz &&
434 chan->freq >= 5260 && chan->freq <= 5320) {
435 /*
436 * Skip new channels in Japan since the
437 * firmware was not marked having been upgraded
438 * by the vendor.
439 */
440 continue;
441 }
442
443 if (ieee80211_regdom == 0x10 &&
444 (chan->freq == 5190 || chan->freq == 5210 ||
445 chan->freq == 5230)) {
446 /* Skip MKK channels when in FCC domain. */
447 continue;
448 }
449
450 chan->flag |= IEEE80211_CHAN_W_SCAN |
451 IEEE80211_CHAN_W_ACTIVE_SCAN |
452 IEEE80211_CHAN_W_IBSS;
453 chan->power_level = r->power_level;
454 chan->antenna_max = r->antenna_max;
455
456 if (ieee80211_regdom == 64 &&
457 (chan->freq == 5170 || chan->freq == 5190 ||
458 chan->freq == 5210 || chan->freq == 5230)) {
459 /*
460 * New regulatory rules in Japan have backwards
461 * compatibility with old channels in 5.15-5.25
462 * GHz band, but the station is not allowed to
463 * use active scan on these old channels.
464 */
465 chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN;
466 }
467
468 if (ieee80211_regdom == 64 &&
469 (chan->freq == 5260 || chan->freq == 5280 ||
470 chan->freq == 5300 || chan->freq == 5320)) {
471 /*
472 * IBSS is not allowed on 5.25-5.35 GHz band
473 * due to radar detection requirements.
474 */
475 chan->flag &= ~IEEE80211_CHAN_W_IBSS;
476 }
477
478 break;
479 }
480 }
481}
482
483
484static int ieee80211_unmask_channels(struct net_device *dev)
485{
486 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
487 struct ieee80211_hw_mode *mode;
488 int c;
489
490 list_for_each_entry(mode, &local->modes_list, list) {
491 for (c = 0; c < mode->num_channels; c++) {
492 ieee80211_unmask_channel(dev, mode->mode,
493 &mode->channels[c]);
494 }
495 }
496 return 0;
497}
498
499
500int ieee80211_init_client(struct net_device *dev)
501{
502 if (ieee80211_regdom == 0x40)
503 channel_range = ieee80211_mkk_channels;
504 ieee80211_unmask_channels(dev);
505 return 0;
506}
507
508
509static int ieee80211_ioctl_siwmode(struct net_device *dev,
510 struct iw_request_info *info,
511 __u32 *mode, char *extra)
512{
513 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
514 int type;
515
516 if (sdata->type == IEEE80211_IF_TYPE_VLAN)
517 return -EOPNOTSUPP;
518
519 switch (*mode) {
520 case IW_MODE_INFRA:
521 type = IEEE80211_IF_TYPE_STA;
522 break;
523 case IW_MODE_ADHOC:
524 type = IEEE80211_IF_TYPE_IBSS;
525 break;
526 case IW_MODE_MONITOR:
527 type = IEEE80211_IF_TYPE_MNTR;
528 break;
529 default:
530 return -EINVAL;
531 }
532
533 if (type == sdata->type)
534 return 0;
535 if (netif_running(dev))
536 return -EBUSY;
537
538 ieee80211_if_reinit(dev);
539 ieee80211_if_set_type(dev, type);
540
541 return 0;
542}
543
544
545static int ieee80211_ioctl_giwmode(struct net_device *dev,
546 struct iw_request_info *info,
547 __u32 *mode, char *extra)
548{
549 struct ieee80211_sub_if_data *sdata;
550
551 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
552 switch (sdata->type) {
553 case IEEE80211_IF_TYPE_AP:
554 *mode = IW_MODE_MASTER;
555 break;
556 case IEEE80211_IF_TYPE_STA:
557 *mode = IW_MODE_INFRA;
558 break;
559 case IEEE80211_IF_TYPE_IBSS:
560 *mode = IW_MODE_ADHOC;
561 break;
562 case IEEE80211_IF_TYPE_MNTR:
563 *mode = IW_MODE_MONITOR;
564 break;
565 case IEEE80211_IF_TYPE_WDS:
566 *mode = IW_MODE_REPEAT;
567 break;
568 case IEEE80211_IF_TYPE_VLAN:
569 *mode = IW_MODE_SECOND; /* FIXME */
570 break;
571 default:
572 *mode = IW_MODE_AUTO;
573 break;
574 }
575 return 0;
576}
577
578int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq)
579{
580 struct ieee80211_hw_mode *mode;
581 int c, set = 0;
582 int ret = -EINVAL;
583
584 list_for_each_entry(mode, &local->modes_list, list) {
585 if (!(local->enabled_modes & (1 << mode->mode)))
586 continue;
587 for (c = 0; c < mode->num_channels; c++) {
588 struct ieee80211_channel *chan = &mode->channels[c];
589 if (chan->flag & IEEE80211_CHAN_W_SCAN &&
590 ((chan->chan == channel) || (chan->freq == freq))) {
591 /* Use next_mode as the mode preference to
592 * resolve non-unique channel numbers. */
593 if (set && mode->mode != local->next_mode)
594 continue;
595
596 local->oper_channel = chan;
597 local->oper_hw_mode = mode;
598 set++;
599 }
600 }
601 }
602
603 if (set) {
604 if (local->sta_scanning)
605 ret = 0;
606 else
607 ret = ieee80211_hw_config(local);
608
609 rate_control_clear(local);
610 }
611
612 return ret;
613}
614
615static int ieee80211_ioctl_siwfreq(struct net_device *dev,
616 struct iw_request_info *info,
617 struct iw_freq *freq, char *extra)
618{
619 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
620 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
621
622 if (sdata->type == IEEE80211_IF_TYPE_STA)
623 sdata->u.sta.auto_channel_sel = 0;
624
625 /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
626 if (freq->e == 0) {
627 if (freq->m < 0) {
628 if (sdata->type == IEEE80211_IF_TYPE_STA)
629 sdata->u.sta.auto_channel_sel = 1;
630 return 0;
631 } else
632 return ieee80211_set_channel(local, freq->m, -1);
633 } else {
634 int i, div = 1000000;
635 for (i = 0; i < freq->e; i++)
636 div /= 10;
637 if (div > 0)
638 return ieee80211_set_channel(local, -1, freq->m / div);
639 else
640 return -EINVAL;
641 }
642}
643
644
645static int ieee80211_ioctl_giwfreq(struct net_device *dev,
646 struct iw_request_info *info,
647 struct iw_freq *freq, char *extra)
648{
649 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
650
651 /* TODO: in station mode (Managed/Ad-hoc) might need to poll low-level
652 * driver for the current channel with firmware-based management */
653
654 freq->m = local->hw.conf.freq;
655 freq->e = 6;
656
657 return 0;
658}
659
660
661static int ieee80211_ioctl_siwessid(struct net_device *dev,
662 struct iw_request_info *info,
663 struct iw_point *data, char *ssid)
664{
665 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
666 struct ieee80211_sub_if_data *sdata;
667 size_t len = data->length;
668
669 /* iwconfig uses nul termination in SSID.. */
670 if (len > 0 && ssid[len - 1] == '\0')
671 len--;
672
673 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
674 if (sdata->type == IEEE80211_IF_TYPE_STA ||
675 sdata->type == IEEE80211_IF_TYPE_IBSS) {
676 int ret;
677 if (local->user_space_mlme) {
678 if (len > IEEE80211_MAX_SSID_LEN)
679 return -EINVAL;
680 memcpy(sdata->u.sta.ssid, ssid, len);
681 sdata->u.sta.ssid_len = len;
682 return 0;
683 }
684 sdata->u.sta.auto_ssid_sel = !data->flags;
685 ret = ieee80211_sta_set_ssid(dev, ssid, len);
686 if (ret)
687 return ret;
688 ieee80211_sta_req_auth(dev, &sdata->u.sta);
689 return 0;
690 }
691
692 if (sdata->type == IEEE80211_IF_TYPE_AP) {
693 memcpy(sdata->u.ap.ssid, ssid, len);
694 memset(sdata->u.ap.ssid + len, 0,
695 IEEE80211_MAX_SSID_LEN - len);
696 sdata->u.ap.ssid_len = len;
697 return ieee80211_if_config(dev);
698 }
699 return -EOPNOTSUPP;
700}
701
702
703static int ieee80211_ioctl_giwessid(struct net_device *dev,
704 struct iw_request_info *info,
705 struct iw_point *data, char *ssid)
706{
707 size_t len;
708
709 struct ieee80211_sub_if_data *sdata;
710 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
711 if (sdata->type == IEEE80211_IF_TYPE_STA ||
712 sdata->type == IEEE80211_IF_TYPE_IBSS) {
713 int res = ieee80211_sta_get_ssid(dev, ssid, &len);
714 if (res == 0) {
715 data->length = len;
716 data->flags = 1;
717 } else
718 data->flags = 0;
719 return res;
720 }
721
722 if (sdata->type == IEEE80211_IF_TYPE_AP) {
723 len = sdata->u.ap.ssid_len;
724 if (len > IW_ESSID_MAX_SIZE)
725 len = IW_ESSID_MAX_SIZE;
726 memcpy(ssid, sdata->u.ap.ssid, len);
727 data->length = len;
728 data->flags = 1;
729 return 0;
730 }
731 return -EOPNOTSUPP;
732}
733
734
735static int ieee80211_ioctl_siwap(struct net_device *dev,
736 struct iw_request_info *info,
737 struct sockaddr *ap_addr, char *extra)
738{
739 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
740 struct ieee80211_sub_if_data *sdata;
741
742 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
743 if (sdata->type == IEEE80211_IF_TYPE_STA ||
744 sdata->type == IEEE80211_IF_TYPE_IBSS) {
745 int ret;
746 if (local->user_space_mlme) {
747 memcpy(sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data,
748 ETH_ALEN);
749 return 0;
750 }
751 if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) {
752 sdata->u.sta.auto_bssid_sel = 1;
753 sdata->u.sta.auto_channel_sel = 1;
754 } else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data))
755 sdata->u.sta.auto_bssid_sel = 1;
756 else
757 sdata->u.sta.auto_bssid_sel = 0;
758 ret = ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data);
759 if (ret)
760 return ret;
761 ieee80211_sta_req_auth(dev, &sdata->u.sta);
762 return 0;
763 } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
764 if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
765 ETH_ALEN) == 0)
766 return 0;
767 return ieee80211_if_update_wds(dev, (u8 *) &ap_addr->sa_data);
768 }
769
770 return -EOPNOTSUPP;
771}
772
773
774static int ieee80211_ioctl_giwap(struct net_device *dev,
775 struct iw_request_info *info,
776 struct sockaddr *ap_addr, char *extra)
777{
778 struct ieee80211_sub_if_data *sdata;
779
780 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
781 if (sdata->type == IEEE80211_IF_TYPE_STA ||
782 sdata->type == IEEE80211_IF_TYPE_IBSS) {
783 ap_addr->sa_family = ARPHRD_ETHER;
784 memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN);
785 return 0;
786 } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
787 ap_addr->sa_family = ARPHRD_ETHER;
788 memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN);
789 return 0;
790 }
791
792 return -EOPNOTSUPP;
793}
794
795
796static int ieee80211_ioctl_siwscan(struct net_device *dev,
797 struct iw_request_info *info,
798 struct iw_point *data, char *extra)
799{
800 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
801 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
802 u8 *ssid = NULL;
803 size_t ssid_len = 0;
804
805 if (!netif_running(dev))
806 return -ENETDOWN;
807
808 if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) {
809 if (sdata->type == IEEE80211_IF_TYPE_STA ||
810 sdata->type == IEEE80211_IF_TYPE_IBSS) {
811 ssid = sdata->u.sta.ssid;
812 ssid_len = sdata->u.sta.ssid_len;
813 } else if (sdata->type == IEEE80211_IF_TYPE_AP) {
814 ssid = sdata->u.ap.ssid;
815 ssid_len = sdata->u.ap.ssid_len;
816 } else
817 return -EINVAL;
818 }
819 return ieee80211_sta_req_scan(dev, ssid, ssid_len);
820}
821
822
823static int ieee80211_ioctl_giwscan(struct net_device *dev,
824 struct iw_request_info *info,
825 struct iw_point *data, char *extra)
826{
827 int res;
828 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
829 if (local->sta_scanning)
830 return -EAGAIN;
831 res = ieee80211_sta_scan_results(dev, extra, data->length);
832 if (res >= 0) {
833 data->length = res;
834 return 0;
835 }
836 data->length = 0;
837 return res;
838}
839
840
841static int ieee80211_ioctl_siwrts(struct net_device *dev,
842 struct iw_request_info *info,
843 struct iw_param *rts, char *extra)
844{
845 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
846
847 if (rts->disabled)
848 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
849 else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD)
850 return -EINVAL;
851 else
852 local->rts_threshold = rts->value;
853
854 /* If the wlan card performs RTS/CTS in hardware/firmware,
855 * configure it here */
856
857 if (local->ops->set_rts_threshold)
858 local->ops->set_rts_threshold(local_to_hw(local),
859 local->rts_threshold);
860
861 return 0;
862}
863
864static int ieee80211_ioctl_giwrts(struct net_device *dev,
865 struct iw_request_info *info,
866 struct iw_param *rts, char *extra)
867{
868 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
869
870 rts->value = local->rts_threshold;
871 rts->disabled = (rts->value >= IEEE80211_MAX_RTS_THRESHOLD);
872 rts->fixed = 1;
873
874 return 0;
875}
876
877
878static int ieee80211_ioctl_siwfrag(struct net_device *dev,
879 struct iw_request_info *info,
880 struct iw_param *frag, char *extra)
881{
882 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
883
884 if (frag->disabled)
885 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
886 else if (frag->value < 256 ||
887 frag->value > IEEE80211_MAX_FRAG_THRESHOLD)
888 return -EINVAL;
889 else {
890 /* Fragment length must be even, so strip LSB. */
891 local->fragmentation_threshold = frag->value & ~0x1;
892 }
893
894 /* If the wlan card performs fragmentation in hardware/firmware,
895 * configure it here */
896
897 if (local->ops->set_frag_threshold)
898 local->ops->set_frag_threshold(
899 local_to_hw(local),
900 local->fragmentation_threshold);
901
902 return 0;
903}
904
905static int ieee80211_ioctl_giwfrag(struct net_device *dev,
906 struct iw_request_info *info,
907 struct iw_param *frag, char *extra)
908{
909 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
910
911 frag->value = local->fragmentation_threshold;
912 frag->disabled = (frag->value >= IEEE80211_MAX_RTS_THRESHOLD);
913 frag->fixed = 1;
914
915 return 0;
916}
917
918
919static int ieee80211_ioctl_siwretry(struct net_device *dev,
920 struct iw_request_info *info,
921 struct iw_param *retry, char *extra)
922{
923 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
924
925 if (retry->disabled ||
926 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
927 return -EINVAL;
928
929 if (retry->flags & IW_RETRY_MAX)
930 local->long_retry_limit = retry->value;
931 else if (retry->flags & IW_RETRY_MIN)
932 local->short_retry_limit = retry->value;
933 else {
934 local->long_retry_limit = retry->value;
935 local->short_retry_limit = retry->value;
936 }
937
938 if (local->ops->set_retry_limit) {
939 return local->ops->set_retry_limit(
940 local_to_hw(local),
941 local->short_retry_limit,
942 local->long_retry_limit);
943 }
944
945 return 0;
946}
947
948
949static int ieee80211_ioctl_giwretry(struct net_device *dev,
950 struct iw_request_info *info,
951 struct iw_param *retry, char *extra)
952{
953 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
954
955 retry->disabled = 0;
956 if (retry->flags == 0 || retry->flags & IW_RETRY_MIN) {
957 /* first return min value, iwconfig will ask max value
958 * later if needed */
959 retry->flags |= IW_RETRY_LIMIT;
960 retry->value = local->short_retry_limit;
961 if (local->long_retry_limit != local->short_retry_limit)
962 retry->flags |= IW_RETRY_MIN;
963 return 0;
964 }
965 if (retry->flags & IW_RETRY_MAX) {
966 retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
967 retry->value = local->long_retry_limit;
968 }
969
970 return 0;
971}
972
973static int ieee80211_ioctl_clear_keys(struct net_device *dev)
974{
975 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
976 struct ieee80211_key_conf key;
977 int i;
978 u8 addr[ETH_ALEN];
979 struct ieee80211_key_conf *keyconf;
980 struct ieee80211_sub_if_data *sdata;
981 struct sta_info *sta;
982
983 memset(addr, 0xff, ETH_ALEN);
984 read_lock(&local->sub_if_lock);
985 list_for_each_entry(sdata, &local->sub_if_list, list) {
986 for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
987 keyconf = NULL;
988 if (sdata->keys[i] &&
989 !sdata->keys[i]->force_sw_encrypt &&
990 local->ops->set_key &&
991 (keyconf = ieee80211_key_data2conf(local,
992 sdata->keys[i])))
993 local->ops->set_key(local_to_hw(local),
994 DISABLE_KEY, addr,
995 keyconf, 0);
996 kfree(keyconf);
997 ieee80211_key_free(sdata->keys[i]);
998 sdata->keys[i] = NULL;
999 }
1000 sdata->default_key = NULL;
1001 }
1002 read_unlock(&local->sub_if_lock);
1003
1004 spin_lock_bh(&local->sta_lock);
1005 list_for_each_entry(sta, &local->sta_list, list) {
1006 keyconf = NULL;
1007 if (sta->key && !sta->key->force_sw_encrypt &&
1008 local->ops->set_key &&
1009 (keyconf = ieee80211_key_data2conf(local, sta->key)))
1010 local->ops->set_key(local_to_hw(local), DISABLE_KEY,
1011 sta->addr, keyconf, sta->aid);
1012 kfree(keyconf);
1013 ieee80211_key_free(sta->key);
1014 sta->key = NULL;
1015 }
1016 spin_unlock_bh(&local->sta_lock);
1017
1018 memset(&key, 0, sizeof(key));
1019 if (local->ops->set_key &&
1020 local->ops->set_key(local_to_hw(local), REMOVE_ALL_KEYS,
1021 NULL, &key, 0))
1022 printk(KERN_DEBUG "%s: failed to remove hwaccel keys\n",
1023 dev->name);
1024
1025 return 0;
1026}
1027
1028
1029static int
1030ieee80211_ioctl_force_unicast_rate(struct net_device *dev,
1031 struct ieee80211_sub_if_data *sdata,
1032 int rate)
1033{
1034 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1035 struct ieee80211_hw_mode *mode;
1036 int i;
1037
1038 if (sdata->type != IEEE80211_IF_TYPE_AP)
1039 return -ENOENT;
1040
1041 if (rate == 0) {
1042 sdata->u.ap.force_unicast_rateidx = -1;
1043 return 0;
1044 }
1045
1046 mode = local->oper_hw_mode;
1047 for (i = 0; i < mode->num_rates; i++) {
1048 if (mode->rates[i].rate == rate) {
1049 sdata->u.ap.force_unicast_rateidx = i;
1050 return 0;
1051 }
1052 }
1053 return -EINVAL;
1054}
1055
1056
1057static int
1058ieee80211_ioctl_max_ratectrl_rate(struct net_device *dev,
1059 struct ieee80211_sub_if_data *sdata,
1060 int rate)
1061{
1062 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1063 struct ieee80211_hw_mode *mode;
1064 int i;
1065
1066 if (sdata->type != IEEE80211_IF_TYPE_AP)
1067 return -ENOENT;
1068
1069 if (rate == 0) {
1070 sdata->u.ap.max_ratectrl_rateidx = -1;
1071 return 0;
1072 }
1073
1074 mode = local->oper_hw_mode;
1075 for (i = 0; i < mode->num_rates; i++) {
1076 if (mode->rates[i].rate == rate) {
1077 sdata->u.ap.max_ratectrl_rateidx = i;
1078 return 0;
1079 }
1080 }
1081 return -EINVAL;
1082}
1083
1084
1085static void ieee80211_key_enable_hwaccel(struct ieee80211_local *local,
1086 struct ieee80211_key *key)
1087{
1088 struct ieee80211_key_conf *keyconf;
1089 u8 addr[ETH_ALEN];
1090
1091 if (!key || key->alg != ALG_WEP || !key->force_sw_encrypt ||
1092 (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
1093 return;
1094
1095 memset(addr, 0xff, ETH_ALEN);
1096 keyconf = ieee80211_key_data2conf(local, key);
1097 if (keyconf && local->ops->set_key &&
1098 local->ops->set_key(local_to_hw(local),
1099 SET_KEY, addr, keyconf, 0) == 0) {
1100 key->force_sw_encrypt =
1101 !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
1102 key->hw_key_idx = keyconf->hw_key_idx;
1103 }
1104 kfree(keyconf);
1105}
1106
1107
1108static void ieee80211_key_disable_hwaccel(struct ieee80211_local *local,
1109 struct ieee80211_key *key)
1110{
1111 struct ieee80211_key_conf *keyconf;
1112 u8 addr[ETH_ALEN];
1113
1114 if (!key || key->alg != ALG_WEP || key->force_sw_encrypt ||
1115 (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
1116 return;
1117
1118 memset(addr, 0xff, ETH_ALEN);
1119 keyconf = ieee80211_key_data2conf(local, key);
1120 if (keyconf && local->ops->set_key)
1121 local->ops->set_key(local_to_hw(local), DISABLE_KEY,
1122 addr, keyconf, 0);
1123 kfree(keyconf);
1124 key->force_sw_encrypt = 1;
1125}
1126
1127
1128static int ieee80211_ioctl_default_wep_only(struct ieee80211_local *local,
1129 int value)
1130{
1131 int i;
1132 struct ieee80211_sub_if_data *sdata;
1133
1134 local->default_wep_only = value;
1135 read_lock(&local->sub_if_lock);
1136 list_for_each_entry(sdata, &local->sub_if_list, list)
1137 for (i = 0; i < NUM_DEFAULT_KEYS; i++)
1138 if (value)
1139 ieee80211_key_enable_hwaccel(local,
1140 sdata->keys[i]);
1141 else
1142 ieee80211_key_disable_hwaccel(local,
1143 sdata->keys[i]);
1144 read_unlock(&local->sub_if_lock);
1145
1146 return 0;
1147}
1148
1149
1150void ieee80211_update_default_wep_only(struct ieee80211_local *local)
1151{
1152 int i = 0;
1153 struct ieee80211_sub_if_data *sdata;
1154
1155 read_lock(&local->sub_if_lock);
1156 list_for_each_entry(sdata, &local->sub_if_list, list) {
1157
1158 if (sdata->dev == local->mdev)
1159 continue;
1160
1161 /* If there is an AP interface then depend on userspace to
1162 set default_wep_only correctly. */
1163 if (sdata->type == IEEE80211_IF_TYPE_AP) {
1164 read_unlock(&local->sub_if_lock);
1165 return;
1166 }
1167
1168 i++;
1169 }
1170
1171 read_unlock(&local->sub_if_lock);
1172
1173 if (i <= 1)
1174 ieee80211_ioctl_default_wep_only(local, 1);
1175 else
1176 ieee80211_ioctl_default_wep_only(local, 0);
1177}
1178
1179
1180static int ieee80211_ioctl_prism2_param(struct net_device *dev,
1181 struct iw_request_info *info,
1182 void *wrqu, char *extra)
1183{
1184 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1185 struct ieee80211_sub_if_data *sdata;
1186 int *i = (int *) extra;
1187 int param = *i;
1188 int value = *(i + 1);
1189 int ret = 0;
1190
1191 if (!capable(CAP_NET_ADMIN))
1192 return -EPERM;
1193
1194 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1195
1196 switch (param) {
1197 case PRISM2_PARAM_IEEE_802_1X:
1198 if (local->ops->set_ieee8021x)
1199 ret = local->ops->set_ieee8021x(local_to_hw(local),
1200 value);
1201 if (ret)
1202 printk(KERN_DEBUG "%s: failed to set IEEE 802.1X (%d) "
1203 "for low-level driver\n", dev->name, value);
1204 else
1205 sdata->ieee802_1x = value;
1206 break;
1207
1208 case PRISM2_PARAM_ANTSEL_TX:
1209 local->hw.conf.antenna_sel_tx = value;
1210 if (ieee80211_hw_config(local))
1211 ret = -EINVAL;
1212 break;
1213
1214 case PRISM2_PARAM_ANTSEL_RX:
1215 local->hw.conf.antenna_sel_rx = value;
1216 if (ieee80211_hw_config(local))
1217 ret = -EINVAL;
1218 break;
1219
1220 case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
1221 local->cts_protect_erp_frames = value;
1222 break;
1223
1224 case PRISM2_PARAM_DROP_UNENCRYPTED:
1225 sdata->drop_unencrypted = value;
1226 break;
1227
1228 case PRISM2_PARAM_PREAMBLE:
1229 local->short_preamble = value;
1230 break;
1231
1232 case PRISM2_PARAM_STAT_TIME:
1233 if (!local->stat_time && value) {
1234 local->stat_timer.expires = jiffies + HZ * value / 100;
1235 add_timer(&local->stat_timer);
1236 } else if (local->stat_time && !value) {
1237 del_timer_sync(&local->stat_timer);
1238 }
1239 local->stat_time = value;
1240 break;
1241 case PRISM2_PARAM_SHORT_SLOT_TIME:
1242 if (value)
1243 local->hw.conf.flags |= IEEE80211_CONF_SHORT_SLOT_TIME;
1244 else
1245 local->hw.conf.flags &= ~IEEE80211_CONF_SHORT_SLOT_TIME;
1246 if (ieee80211_hw_config(local))
1247 ret = -EINVAL;
1248 break;
1249
1250 case PRISM2_PARAM_NEXT_MODE:
1251 local->next_mode = value;
1252 break;
1253
1254 case PRISM2_PARAM_CLEAR_KEYS:
1255 ret = ieee80211_ioctl_clear_keys(dev);
1256 break;
1257
1258 case PRISM2_PARAM_RADIO_ENABLED:
1259 ret = ieee80211_ioctl_set_radio_enabled(dev, value);
1260 break;
1261
1262 case PRISM2_PARAM_ANTENNA_MODE:
1263 local->hw.conf.antenna_mode = value;
1264 if (ieee80211_hw_config(local))
1265 ret = -EINVAL;
1266 break;
1267
1268 case PRISM2_PARAM_STA_ANTENNA_SEL:
1269 local->sta_antenna_sel = value;
1270 break;
1271
1272 case PRISM2_PARAM_FORCE_UNICAST_RATE:
1273 ret = ieee80211_ioctl_force_unicast_rate(dev, sdata, value);
1274 break;
1275
1276 case PRISM2_PARAM_MAX_RATECTRL_RATE:
1277 ret = ieee80211_ioctl_max_ratectrl_rate(dev, sdata, value);
1278 break;
1279
1280 case PRISM2_PARAM_RATE_CTRL_NUM_UP:
1281 local->rate_ctrl_num_up = value;
1282 break;
1283
1284 case PRISM2_PARAM_RATE_CTRL_NUM_DOWN:
1285 local->rate_ctrl_num_down = value;
1286 break;
1287
1288 case PRISM2_PARAM_TX_POWER_REDUCTION:
1289 if (value < 0)
1290 ret = -EINVAL;
1291 else
1292 local->hw.conf.tx_power_reduction = value;
1293 break;
1294
1295 case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
1296 local->key_tx_rx_threshold = value;
1297 break;
1298
1299 case PRISM2_PARAM_DEFAULT_WEP_ONLY:
1300 ret = ieee80211_ioctl_default_wep_only(local, value);
1301 break;
1302
1303 case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
1304 local->wifi_wme_noack_test = value;
1305 break;
1306
1307 case PRISM2_PARAM_SCAN_FLAGS:
1308 local->scan_flags = value;
1309 break;
1310
1311 case PRISM2_PARAM_MIXED_CELL:
1312 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1313 sdata->type != IEEE80211_IF_TYPE_IBSS)
1314 ret = -EINVAL;
1315 else
1316 sdata->u.sta.mixed_cell = !!value;
1317 break;
1318
1319 case PRISM2_PARAM_HW_MODES:
1320 local->enabled_modes = value;
1321 break;
1322
1323 case PRISM2_PARAM_CREATE_IBSS:
1324 if (sdata->type != IEEE80211_IF_TYPE_IBSS)
1325 ret = -EINVAL;
1326 else
1327 sdata->u.sta.create_ibss = !!value;
1328 break;
1329 case PRISM2_PARAM_WMM_ENABLED:
1330 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1331 sdata->type != IEEE80211_IF_TYPE_IBSS)
1332 ret = -EINVAL;
1333 else
1334 sdata->u.sta.wmm_enabled = !!value;
1335 break;
1336 case PRISM2_PARAM_RADAR_DETECT:
1337 local->hw.conf.radar_detect = value;
1338 break;
1339 case PRISM2_PARAM_SPECTRUM_MGMT:
1340 local->hw.conf.spect_mgmt = value;
1341 break;
1342 default:
1343 ret = -EOPNOTSUPP;
1344 break;
1345 }
1346
1347 return ret;
1348}
1349
1350
1351static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
1352 struct iw_request_info *info,
1353 void *wrqu, char *extra)
1354{
1355 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1356 struct ieee80211_sub_if_data *sdata;
1357 int *param = (int *) extra;
1358 int ret = 0;
1359
1360 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1361
1362 switch (*param) {
1363 case PRISM2_PARAM_IEEE_802_1X:
1364 *param = sdata->ieee802_1x;
1365 break;
1366
1367 case PRISM2_PARAM_ANTSEL_TX:
1368 *param = local->hw.conf.antenna_sel_tx;
1369 break;
1370
1371 case PRISM2_PARAM_ANTSEL_RX:
1372 *param = local->hw.conf.antenna_sel_rx;
1373 break;
1374
1375 case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
1376 *param = local->cts_protect_erp_frames;
1377 break;
1378
1379 case PRISM2_PARAM_DROP_UNENCRYPTED:
1380 *param = sdata->drop_unencrypted;
1381 break;
1382
1383 case PRISM2_PARAM_PREAMBLE:
1384 *param = local->short_preamble;
1385 break;
1386
1387 case PRISM2_PARAM_STAT_TIME:
1388 *param = local->stat_time;
1389 break;
1390 case PRISM2_PARAM_SHORT_SLOT_TIME:
1391 *param = !!(local->hw.conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME);
1392 break;
1393
1394 case PRISM2_PARAM_NEXT_MODE:
1395 *param = local->next_mode;
1396 break;
1397
1398 case PRISM2_PARAM_ANTENNA_MODE:
1399 *param = local->hw.conf.antenna_mode;
1400 break;
1401
1402 case PRISM2_PARAM_STA_ANTENNA_SEL:
1403 *param = local->sta_antenna_sel;
1404 break;
1405
1406 case PRISM2_PARAM_RATE_CTRL_NUM_UP:
1407 *param = local->rate_ctrl_num_up;
1408 break;
1409
1410 case PRISM2_PARAM_RATE_CTRL_NUM_DOWN:
1411 *param = local->rate_ctrl_num_down;
1412 break;
1413
1414 case PRISM2_PARAM_TX_POWER_REDUCTION:
1415 *param = local->hw.conf.tx_power_reduction;
1416 break;
1417
1418 case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
1419 *param = local->key_tx_rx_threshold;
1420 break;
1421
1422 case PRISM2_PARAM_DEFAULT_WEP_ONLY:
1423 *param = local->default_wep_only;
1424 break;
1425
1426 case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
1427 *param = local->wifi_wme_noack_test;
1428 break;
1429
1430 case PRISM2_PARAM_SCAN_FLAGS:
1431 *param = local->scan_flags;
1432 break;
1433
1434 case PRISM2_PARAM_HW_MODES:
1435 *param = local->enabled_modes;
1436 break;
1437
1438 case PRISM2_PARAM_CREATE_IBSS:
1439 if (sdata->type != IEEE80211_IF_TYPE_IBSS)
1440 ret = -EINVAL;
1441 else
1442 *param = !!sdata->u.sta.create_ibss;
1443 break;
1444
1445 case PRISM2_PARAM_MIXED_CELL:
1446 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1447 sdata->type != IEEE80211_IF_TYPE_IBSS)
1448 ret = -EINVAL;
1449 else
1450 *param = !!sdata->u.sta.mixed_cell;
1451 break;
1452 case PRISM2_PARAM_WMM_ENABLED:
1453 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1454 sdata->type != IEEE80211_IF_TYPE_IBSS)
1455 ret = -EINVAL;
1456 else
1457 *param = !!sdata->u.sta.wmm_enabled;
1458 break;
1459 default:
1460 ret = -EOPNOTSUPP;
1461 break;
1462 }
1463
1464 return ret;
1465}
1466
1467static int ieee80211_ioctl_siwmlme(struct net_device *dev,
1468 struct iw_request_info *info,
1469 struct iw_point *data, char *extra)
1470{
1471 struct ieee80211_sub_if_data *sdata;
1472 struct iw_mlme *mlme = (struct iw_mlme *) extra;
1473
1474 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1475 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1476 sdata->type != IEEE80211_IF_TYPE_IBSS)
1477 return -EINVAL;
1478
1479 switch (mlme->cmd) {
1480 case IW_MLME_DEAUTH:
1481 /* TODO: mlme->addr.sa_data */
1482 return ieee80211_sta_deauthenticate(dev, mlme->reason_code);
1483 case IW_MLME_DISASSOC:
1484 /* TODO: mlme->addr.sa_data */
1485 return ieee80211_sta_disassociate(dev, mlme->reason_code);
1486 default:
1487 return -EOPNOTSUPP;
1488 }
1489}
1490
1491
1492static int ieee80211_ioctl_siwencode(struct net_device *dev,
1493 struct iw_request_info *info,
1494 struct iw_point *erq, char *keybuf)
1495{
1496 struct ieee80211_sub_if_data *sdata;
1497 int idx, i, alg = ALG_WEP;
1498 u8 bcaddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1499
1500 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1501
1502 idx = erq->flags & IW_ENCODE_INDEX;
1503 if (idx == 0) {
1504 if (sdata->default_key)
1505 for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1506 if (sdata->default_key == sdata->keys[i]) {
1507 idx = i;
1508 break;
1509 }
1510 }
1511 } else if (idx < 1 || idx > 4)
1512 return -EINVAL;
1513 else
1514 idx--;
1515
1516 if (erq->flags & IW_ENCODE_DISABLED)
1517 alg = ALG_NONE;
1518 else if (erq->length == 0) {
1519 /* No key data - just set the default TX key index */
1520 if (sdata->default_key != sdata->keys[idx]) {
1521 ieee80211_debugfs_key_remove_default(sdata);
1522 sdata->default_key = sdata->keys[idx];
1523 if (sdata->default_key)
1524 ieee80211_debugfs_key_add_default(sdata);
1525 }
1526 return 0;
1527 }
1528
1529 return ieee80211_set_encryption(
1530 dev, bcaddr,
1531 idx, alg,
1532 !sdata->default_key,
1533 keybuf, erq->length);
1534}
1535
1536
1537static int ieee80211_ioctl_giwencode(struct net_device *dev,
1538 struct iw_request_info *info,
1539 struct iw_point *erq, char *key)
1540{
1541 struct ieee80211_sub_if_data *sdata;
1542 int idx, i;
1543
1544 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1545
1546 idx = erq->flags & IW_ENCODE_INDEX;
1547 if (idx < 1 || idx > 4) {
1548 idx = -1;
1549 if (!sdata->default_key)
1550 idx = 0;
1551 else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1552 if (sdata->default_key == sdata->keys[i]) {
1553 idx = i;
1554 break;
1555 }
1556 }
1557 if (idx < 0)
1558 return -EINVAL;
1559 } else
1560 idx--;
1561
1562 erq->flags = idx + 1;
1563
1564 if (!sdata->keys[idx]) {
1565 erq->length = 0;
1566 erq->flags |= IW_ENCODE_DISABLED;
1567 return 0;
1568 }
1569
1570 memcpy(key, sdata->keys[idx]->key,
1571 min((int)erq->length, sdata->keys[idx]->keylen));
1572 erq->length = sdata->keys[idx]->keylen;
1573 erq->flags |= IW_ENCODE_ENABLED;
1574
1575 return 0;
1576}
1577
1578static int ieee80211_ioctl_siwauth(struct net_device *dev,
1579 struct iw_request_info *info,
1580 struct iw_param *data, char *extra)
1581{
1582 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1583 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1584 int ret = 0;
1585
1586 switch (data->flags & IW_AUTH_INDEX) {
1587 case IW_AUTH_WPA_VERSION:
1588 case IW_AUTH_CIPHER_PAIRWISE:
1589 case IW_AUTH_CIPHER_GROUP:
1590 case IW_AUTH_WPA_ENABLED:
1591 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1592 break;
1593 case IW_AUTH_KEY_MGMT:
1594 if (sdata->type != IEEE80211_IF_TYPE_STA)
1595 ret = -EINVAL;
1596 else {
1597 /*
1598 * TODO: sdata->u.sta.key_mgmt does not match with WE18
1599 * value completely; could consider modifying this to
1600 * be closer to WE18. For now, this value is not really
1601 * used for anything else than Privacy matching, so the
1602 * current code here should be more or less OK.
1603 */
1604 if (data->value & IW_AUTH_KEY_MGMT_802_1X) {
1605 sdata->u.sta.key_mgmt =
1606 IEEE80211_KEY_MGMT_WPA_EAP;
1607 } else if (data->value & IW_AUTH_KEY_MGMT_PSK) {
1608 sdata->u.sta.key_mgmt =
1609 IEEE80211_KEY_MGMT_WPA_PSK;
1610 } else {
1611 sdata->u.sta.key_mgmt =
1612 IEEE80211_KEY_MGMT_NONE;
1613 }
1614 }
1615 break;
1616 case IW_AUTH_80211_AUTH_ALG:
1617 if (sdata->type == IEEE80211_IF_TYPE_STA ||
1618 sdata->type == IEEE80211_IF_TYPE_IBSS)
1619 sdata->u.sta.auth_algs = data->value;
1620 else
1621 ret = -EOPNOTSUPP;
1622 break;
1623 case IW_AUTH_PRIVACY_INVOKED:
1624 if (local->ops->set_privacy_invoked)
1625 ret = local->ops->set_privacy_invoked(
1626 local_to_hw(local), data->value);
1627 break;
1628 default:
1629 ret = -EOPNOTSUPP;
1630 break;
1631 }
1632 return ret;
1633}
1634
1635/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
1636static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
1637{
1638 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1639 struct iw_statistics *wstats = &local->wstats;
1640 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1641 struct sta_info *sta = NULL;
1642
1643 if (sdata->type == IEEE80211_IF_TYPE_STA ||
1644 sdata->type == IEEE80211_IF_TYPE_IBSS)
1645 sta = sta_info_get(local, sdata->u.sta.bssid);
1646 if (!sta) {
1647 wstats->discard.fragment = 0;
1648 wstats->discard.misc = 0;
1649 wstats->qual.qual = 0;
1650 wstats->qual.level = 0;
1651 wstats->qual.noise = 0;
1652 wstats->qual.updated = IW_QUAL_ALL_INVALID;
1653 } else {
1654 wstats->qual.level = sta->last_rssi;
1655 wstats->qual.qual = sta->last_signal;
1656 wstats->qual.noise = sta->last_noise;
1657 wstats->qual.updated = local->wstats_flags;
1658 sta_info_put(sta);
1659 }
1660 return wstats;
1661}
1662
1663static int ieee80211_ioctl_giwauth(struct net_device *dev,
1664 struct iw_request_info *info,
1665 struct iw_param *data, char *extra)
1666{
1667 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1668 int ret = 0;
1669
1670 switch (data->flags & IW_AUTH_INDEX) {
1671 case IW_AUTH_80211_AUTH_ALG:
1672 if (sdata->type == IEEE80211_IF_TYPE_STA ||
1673 sdata->type == IEEE80211_IF_TYPE_IBSS)
1674 data->value = sdata->u.sta.auth_algs;
1675 else
1676 ret = -EOPNOTSUPP;
1677 break;
1678 default:
1679 ret = -EOPNOTSUPP;
1680 break;
1681 }
1682 return ret;
1683}
1684
1685
1686static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
1687 struct iw_request_info *info,
1688 struct iw_point *erq, char *extra)
1689{
1690 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1691 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
1692 int alg, idx, i;
1693
1694 switch (ext->alg) {
1695 case IW_ENCODE_ALG_NONE:
1696 alg = ALG_NONE;
1697 break;
1698 case IW_ENCODE_ALG_WEP:
1699 alg = ALG_WEP;
1700 break;
1701 case IW_ENCODE_ALG_TKIP:
1702 alg = ALG_TKIP;
1703 break;
1704 case IW_ENCODE_ALG_CCMP:
1705 alg = ALG_CCMP;
1706 break;
1707 default:
1708 return -EOPNOTSUPP;
1709 }
1710
1711 if (erq->flags & IW_ENCODE_DISABLED)
1712 alg = ALG_NONE;
1713
1714 idx = erq->flags & IW_ENCODE_INDEX;
1715 if (idx < 1 || idx > 4) {
1716 idx = -1;
1717 if (!sdata->default_key)
1718 idx = 0;
1719 else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1720 if (sdata->default_key == sdata->keys[i]) {
1721 idx = i;
1722 break;
1723 }
1724 }
1725 if (idx < 0)
1726 return -EINVAL;
1727 } else
1728 idx--;
1729
1730 return ieee80211_set_encryption(dev, ext->addr.sa_data, idx, alg,
1731 ext->ext_flags &
1732 IW_ENCODE_EXT_SET_TX_KEY,
1733 ext->key, ext->key_len);
1734}
1735
1736
1737static const struct iw_priv_args ieee80211_ioctl_priv[] = {
1738 { PRISM2_IOCTL_PRISM2_PARAM,
1739 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "param" },
1740 { PRISM2_IOCTL_GET_PRISM2_PARAM,
1741 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1742 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param" },
1743};
1744
1745/* Structures to export the Wireless Handlers */
1746
1747static const iw_handler ieee80211_handler[] =
1748{
1749 (iw_handler) NULL, /* SIOCSIWCOMMIT */
1750 (iw_handler) ieee80211_ioctl_giwname, /* SIOCGIWNAME */
1751 (iw_handler) NULL, /* SIOCSIWNWID */
1752 (iw_handler) NULL, /* SIOCGIWNWID */
1753 (iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */
1754 (iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */
1755 (iw_handler) ieee80211_ioctl_siwmode, /* SIOCSIWMODE */
1756 (iw_handler) ieee80211_ioctl_giwmode, /* SIOCGIWMODE */
1757 (iw_handler) NULL, /* SIOCSIWSENS */
1758 (iw_handler) NULL, /* SIOCGIWSENS */
1759 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
1760 (iw_handler) ieee80211_ioctl_giwrange, /* SIOCGIWRANGE */
1761 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
1762 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
1763 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
1764 (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
1765 iw_handler_set_spy, /* SIOCSIWSPY */
1766 iw_handler_get_spy, /* SIOCGIWSPY */
1767 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
1768 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
1769 (iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */
1770 (iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */
1771 (iw_handler) ieee80211_ioctl_siwmlme, /* SIOCSIWMLME */
1772 (iw_handler) NULL, /* SIOCGIWAPLIST */
1773 (iw_handler) ieee80211_ioctl_siwscan, /* SIOCSIWSCAN */
1774 (iw_handler) ieee80211_ioctl_giwscan, /* SIOCGIWSCAN */
1775 (iw_handler) ieee80211_ioctl_siwessid, /* SIOCSIWESSID */
1776 (iw_handler) ieee80211_ioctl_giwessid, /* SIOCGIWESSID */
1777 (iw_handler) NULL, /* SIOCSIWNICKN */
1778 (iw_handler) NULL, /* SIOCGIWNICKN */
1779 (iw_handler) NULL, /* -- hole -- */
1780 (iw_handler) NULL, /* -- hole -- */
1781 (iw_handler) NULL, /* SIOCSIWRATE */
1782 (iw_handler) NULL, /* SIOCGIWRATE */
1783 (iw_handler) ieee80211_ioctl_siwrts, /* SIOCSIWRTS */
1784 (iw_handler) ieee80211_ioctl_giwrts, /* SIOCGIWRTS */
1785 (iw_handler) ieee80211_ioctl_siwfrag, /* SIOCSIWFRAG */
1786 (iw_handler) ieee80211_ioctl_giwfrag, /* SIOCGIWFRAG */
1787 (iw_handler) NULL, /* SIOCSIWTXPOW */
1788 (iw_handler) NULL, /* SIOCGIWTXPOW */
1789 (iw_handler) ieee80211_ioctl_siwretry, /* SIOCSIWRETRY */
1790 (iw_handler) ieee80211_ioctl_giwretry, /* SIOCGIWRETRY */
1791 (iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */
1792 (iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */
1793 (iw_handler) NULL, /* SIOCSIWPOWER */
1794 (iw_handler) NULL, /* SIOCGIWPOWER */
1795 (iw_handler) NULL, /* -- hole -- */
1796 (iw_handler) NULL, /* -- hole -- */
1797 (iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */
1798 (iw_handler) NULL, /* SIOCGIWGENIE */
1799 (iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */
1800 (iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */
1801 (iw_handler) ieee80211_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
1802 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
1803 (iw_handler) NULL, /* SIOCSIWPMKSA */
1804 (iw_handler) NULL, /* -- hole -- */
1805};
1806
1807static const iw_handler ieee80211_private_handler[] =
1808{ /* SIOCIWFIRSTPRIV + */
1809 (iw_handler) ieee80211_ioctl_prism2_param, /* 0 */
1810 (iw_handler) ieee80211_ioctl_get_prism2_param, /* 1 */
1811};
1812
1813const struct iw_handler_def ieee80211_iw_handler_def =
1814{
1815 .num_standard = ARRAY_SIZE(ieee80211_handler),
1816 .num_private = ARRAY_SIZE(ieee80211_private_handler),
1817 .num_private_args = ARRAY_SIZE(ieee80211_ioctl_priv),
1818 .standard = (iw_handler *) ieee80211_handler,
1819 .private = (iw_handler *) ieee80211_private_handler,
1820 .private_args = (struct iw_priv_args *) ieee80211_ioctl_priv,
1821 .get_wireless_stats = ieee80211_get_wireless_stats,
1822};
diff --git a/net/mac80211/ieee80211_key.h b/net/mac80211/ieee80211_key.h
new file mode 100644
index 000000000000..c33384912782
--- /dev/null
+++ b/net/mac80211/ieee80211_key.h
@@ -0,0 +1,106 @@
1/*
2 * Copyright 2002-2004, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef IEEE80211_KEY_H
11#define IEEE80211_KEY_H
12
13#include <linux/types.h>
14#include <linux/kref.h>
15#include <linux/crypto.h>
16#include <net/mac80211.h>
17
18/* ALG_TKIP
19 * struct ieee80211_key::key is encoded as a 256-bit (32 byte) data block:
20 * Temporal Encryption Key (128 bits)
21 * Temporal Authenticator Tx MIC Key (64 bits)
22 * Temporal Authenticator Rx MIC Key (64 bits)
23 */
24
25#define WEP_IV_LEN 4
26#define WEP_ICV_LEN 4
27
28#define ALG_TKIP_KEY_LEN 32
29/* Starting offsets for each key */
30#define ALG_TKIP_TEMP_ENCR_KEY 0
31#define ALG_TKIP_TEMP_AUTH_TX_MIC_KEY 16
32#define ALG_TKIP_TEMP_AUTH_RX_MIC_KEY 24
33#define TKIP_IV_LEN 8
34#define TKIP_ICV_LEN 4
35
36#define ALG_CCMP_KEY_LEN 16
37#define CCMP_HDR_LEN 8
38#define CCMP_MIC_LEN 8
39#define CCMP_TK_LEN 16
40#define CCMP_PN_LEN 6
41
42#define NUM_RX_DATA_QUEUES 17
43
44struct ieee80211_key {
45 struct kref kref;
46
47 int hw_key_idx; /* filled and used by low-level driver */
48 ieee80211_key_alg alg;
49 union {
50 struct {
51 /* last used TSC */
52 u32 iv32;
53 u16 iv16;
54 u16 p1k[5];
55 int tx_initialized;
56
57 /* last received RSC */
58 u32 iv32_rx[NUM_RX_DATA_QUEUES];
59 u16 iv16_rx[NUM_RX_DATA_QUEUES];
60 u16 p1k_rx[NUM_RX_DATA_QUEUES][5];
61 int rx_initialized[NUM_RX_DATA_QUEUES];
62 } tkip;
63 struct {
64 u8 tx_pn[6];
65 u8 rx_pn[NUM_RX_DATA_QUEUES][6];
66 struct crypto_cipher *tfm;
67 u32 replays; /* dot11RSNAStatsCCMPReplays */
68 /* scratch buffers for virt_to_page() (crypto API) */
69#ifndef AES_BLOCK_LEN
70#define AES_BLOCK_LEN 16
71#endif
72 u8 tx_crypto_buf[6 * AES_BLOCK_LEN];
73 u8 rx_crypto_buf[6 * AES_BLOCK_LEN];
74 } ccmp;
75 } u;
76 int tx_rx_count; /* number of times this key has been used */
77 int keylen;
78
79 /* if the low level driver can provide hardware acceleration it should
80 * clear this flag */
81 unsigned int force_sw_encrypt:1;
82 unsigned int default_tx_key:1; /* This key is the new default TX key
83 * (used only for broadcast keys). */
84 s8 keyidx; /* WEP key index */
85
86#ifdef CONFIG_MAC80211_DEBUGFS
87 struct {
88 struct dentry *stalink;
89 struct dentry *dir;
90 struct dentry *keylen;
91 struct dentry *force_sw_encrypt;
92 struct dentry *keyidx;
93 struct dentry *hw_key_idx;
94 struct dentry *tx_rx_count;
95 struct dentry *algorithm;
96 struct dentry *tx_spec;
97 struct dentry *rx_spec;
98 struct dentry *replays;
99 struct dentry *key;
100 } debugfs;
101#endif
102
103 u8 key[0];
104};
105
106#endif /* IEEE80211_KEY_H */
diff --git a/net/mac80211/ieee80211_led.c b/net/mac80211/ieee80211_led.c
new file mode 100644
index 000000000000..719d75b20707
--- /dev/null
+++ b/net/mac80211/ieee80211_led.c
@@ -0,0 +1,91 @@
1/*
2 * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9/* just for IFNAMSIZ */
10#include <linux/if.h>
11#include "ieee80211_led.h"
12
13void ieee80211_led_rx(struct ieee80211_local *local)
14{
15 if (unlikely(!local->rx_led))
16 return;
17 if (local->rx_led_counter++ % 2 == 0)
18 led_trigger_event(local->rx_led, LED_OFF);
19 else
20 led_trigger_event(local->rx_led, LED_FULL);
21}
22
23/* q is 1 if a packet was enqueued, 0 if it has been transmitted */
24void ieee80211_led_tx(struct ieee80211_local *local, int q)
25{
26 if (unlikely(!local->tx_led))
27 return;
28 /* not sure how this is supposed to work ... */
29 local->tx_led_counter += 2*q-1;
30 if (local->tx_led_counter % 2 == 0)
31 led_trigger_event(local->tx_led, LED_OFF);
32 else
33 led_trigger_event(local->tx_led, LED_FULL);
34}
35
36void ieee80211_led_init(struct ieee80211_local *local)
37{
38 local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
39 if (!local->rx_led)
40 return;
41 snprintf(local->rx_led_name, sizeof(local->rx_led_name),
42 "%srx", wiphy_name(local->hw.wiphy));
43 local->rx_led->name = local->rx_led_name;
44 if (led_trigger_register(local->rx_led)) {
45 kfree(local->rx_led);
46 local->rx_led = NULL;
47 }
48
49 local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
50 if (!local->tx_led)
51 return;
52 snprintf(local->tx_led_name, sizeof(local->tx_led_name),
53 "%stx", wiphy_name(local->hw.wiphy));
54 local->tx_led->name = local->tx_led_name;
55 if (led_trigger_register(local->tx_led)) {
56 kfree(local->tx_led);
57 local->tx_led = NULL;
58 }
59}
60
61void ieee80211_led_exit(struct ieee80211_local *local)
62{
63 if (local->tx_led) {
64 led_trigger_unregister(local->tx_led);
65 kfree(local->tx_led);
66 }
67 if (local->rx_led) {
68 led_trigger_unregister(local->rx_led);
69 kfree(local->rx_led);
70 }
71}
72
73char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
74{
75 struct ieee80211_local *local = hw_to_local(hw);
76
77 if (local->tx_led)
78 return local->tx_led_name;
79 return NULL;
80}
81EXPORT_SYMBOL(__ieee80211_get_tx_led_name);
82
83char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
84{
85 struct ieee80211_local *local = hw_to_local(hw);
86
87 if (local->rx_led)
88 return local->rx_led_name;
89 return NULL;
90}
91EXPORT_SYMBOL(__ieee80211_get_rx_led_name);
diff --git a/net/mac80211/ieee80211_led.h b/net/mac80211/ieee80211_led.h
new file mode 100644
index 000000000000..5c8ab8263878
--- /dev/null
+++ b/net/mac80211/ieee80211_led.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/list.h>
10#include <linux/spinlock.h>
11#include <linux/leds.h>
12#include "ieee80211_i.h"
13
14#ifdef CONFIG_MAC80211_LEDS
15extern void ieee80211_led_rx(struct ieee80211_local *local);
16extern void ieee80211_led_tx(struct ieee80211_local *local, int q);
17extern void ieee80211_led_init(struct ieee80211_local *local);
18extern void ieee80211_led_exit(struct ieee80211_local *local);
19#else
20static inline void ieee80211_led_rx(struct ieee80211_local *local)
21{
22}
23static inline void ieee80211_led_tx(struct ieee80211_local *local, int q)
24{
25}
26static inline void ieee80211_led_init(struct ieee80211_local *local)
27{
28}
29static inline void ieee80211_led_exit(struct ieee80211_local *local)
30{
31}
32#endif
diff --git a/net/mac80211/ieee80211_rate.c b/net/mac80211/ieee80211_rate.c
new file mode 100644
index 000000000000..16e850864b8a
--- /dev/null
+++ b/net/mac80211/ieee80211_rate.c
@@ -0,0 +1,140 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include "ieee80211_rate.h"
13#include "ieee80211_i.h"
14
15struct rate_control_alg {
16 struct list_head list;
17 struct rate_control_ops *ops;
18};
19
20static LIST_HEAD(rate_ctrl_algs);
21static DEFINE_MUTEX(rate_ctrl_mutex);
22
23int ieee80211_rate_control_register(struct rate_control_ops *ops)
24{
25 struct rate_control_alg *alg;
26
27 alg = kmalloc(sizeof(*alg), GFP_KERNEL);
28 if (alg == NULL) {
29 return -ENOMEM;
30 }
31 memset(alg, 0, sizeof(*alg));
32 alg->ops = ops;
33
34 mutex_lock(&rate_ctrl_mutex);
35 list_add_tail(&alg->list, &rate_ctrl_algs);
36 mutex_unlock(&rate_ctrl_mutex);
37
38 return 0;
39}
40EXPORT_SYMBOL(ieee80211_rate_control_register);
41
42void ieee80211_rate_control_unregister(struct rate_control_ops *ops)
43{
44 struct rate_control_alg *alg;
45
46 mutex_lock(&rate_ctrl_mutex);
47 list_for_each_entry(alg, &rate_ctrl_algs, list) {
48 if (alg->ops == ops) {
49 list_del(&alg->list);
50 break;
51 }
52 }
53 mutex_unlock(&rate_ctrl_mutex);
54 kfree(alg);
55}
56EXPORT_SYMBOL(ieee80211_rate_control_unregister);
57
58static struct rate_control_ops *
59ieee80211_try_rate_control_ops_get(const char *name)
60{
61 struct rate_control_alg *alg;
62 struct rate_control_ops *ops = NULL;
63
64 mutex_lock(&rate_ctrl_mutex);
65 list_for_each_entry(alg, &rate_ctrl_algs, list) {
66 if (!name || !strcmp(alg->ops->name, name))
67 if (try_module_get(alg->ops->module)) {
68 ops = alg->ops;
69 break;
70 }
71 }
72 mutex_unlock(&rate_ctrl_mutex);
73 return ops;
74}
75
76/* Get the rate control algorithm. If `name' is NULL, get the first
77 * available algorithm. */
78static struct rate_control_ops *
79ieee80211_rate_control_ops_get(const char *name)
80{
81 struct rate_control_ops *ops;
82
83 ops = ieee80211_try_rate_control_ops_get(name);
84 if (!ops) {
85 request_module("rc80211_%s", name ? name : "default");
86 ops = ieee80211_try_rate_control_ops_get(name);
87 }
88 return ops;
89}
90
91static void ieee80211_rate_control_ops_put(struct rate_control_ops *ops)
92{
93 module_put(ops->module);
94}
95
96struct rate_control_ref *rate_control_alloc(const char *name,
97 struct ieee80211_local *local)
98{
99 struct rate_control_ref *ref;
100
101 ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL);
102 if (!ref)
103 goto fail_ref;
104 kref_init(&ref->kref);
105 ref->ops = ieee80211_rate_control_ops_get(name);
106 if (!ref->ops)
107 goto fail_ops;
108 ref->priv = ref->ops->alloc(local);
109 if (!ref->priv)
110 goto fail_priv;
111 return ref;
112
113fail_priv:
114 ieee80211_rate_control_ops_put(ref->ops);
115fail_ops:
116 kfree(ref);
117fail_ref:
118 return NULL;
119}
120
121static void rate_control_release(struct kref *kref)
122{
123 struct rate_control_ref *ctrl_ref;
124
125 ctrl_ref = container_of(kref, struct rate_control_ref, kref);
126 ctrl_ref->ops->free(ctrl_ref->priv);
127 ieee80211_rate_control_ops_put(ctrl_ref->ops);
128 kfree(ctrl_ref);
129}
130
131struct rate_control_ref *rate_control_get(struct rate_control_ref *ref)
132{
133 kref_get(&ref->kref);
134 return ref;
135}
136
137void rate_control_put(struct rate_control_ref *ref)
138{
139 kref_put(&ref->kref, rate_control_release);
140}
diff --git a/net/mac80211/ieee80211_rate.h b/net/mac80211/ieee80211_rate.h
new file mode 100644
index 000000000000..f021a028d9d0
--- /dev/null
+++ b/net/mac80211/ieee80211_rate.h
@@ -0,0 +1,144 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef IEEE80211_RATE_H
12#define IEEE80211_RATE_H
13
14#include <linux/netdevice.h>
15#include <linux/skbuff.h>
16#include <linux/types.h>
17#include <net/mac80211.h>
18#include "ieee80211_i.h"
19#include "sta_info.h"
20
21#define RATE_CONTROL_NUM_DOWN 20
22#define RATE_CONTROL_NUM_UP 15
23
24
25struct rate_control_extra {
26 /* values from rate_control_get_rate() to the caller: */
27 struct ieee80211_rate *probe; /* probe with this rate, or NULL for no
28 * probing */
29 struct ieee80211_rate *nonerp;
30
31 /* parameters from the caller to rate_control_get_rate(): */
32 struct ieee80211_hw_mode *mode;
33 int mgmt_data; /* this is data frame that is used for management
34 * (e.g., IEEE 802.1X EAPOL) */
35 u16 ethertype;
36};
37
38
39struct rate_control_ops {
40 struct module *module;
41 const char *name;
42 void (*tx_status)(void *priv, struct net_device *dev,
43 struct sk_buff *skb,
44 struct ieee80211_tx_status *status);
45 struct ieee80211_rate *(*get_rate)(void *priv, struct net_device *dev,
46 struct sk_buff *skb,
47 struct rate_control_extra *extra);
48 void (*rate_init)(void *priv, void *priv_sta,
49 struct ieee80211_local *local, struct sta_info *sta);
50 void (*clear)(void *priv);
51
52 void *(*alloc)(struct ieee80211_local *local);
53 void (*free)(void *priv);
54 void *(*alloc_sta)(void *priv, gfp_t gfp);
55 void (*free_sta)(void *priv, void *priv_sta);
56
57 int (*add_attrs)(void *priv, struct kobject *kobj);
58 void (*remove_attrs)(void *priv, struct kobject *kobj);
59 void (*add_sta_debugfs)(void *priv, void *priv_sta,
60 struct dentry *dir);
61 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
62};
63
64struct rate_control_ref {
65 struct rate_control_ops *ops;
66 void *priv;
67 struct kref kref;
68};
69
70int ieee80211_rate_control_register(struct rate_control_ops *ops);
71void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
72
73/* Get a reference to the rate control algorithm. If `name' is NULL, get the
74 * first available algorithm. */
75struct rate_control_ref *rate_control_alloc(const char *name,
76 struct ieee80211_local *local);
77struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
78void rate_control_put(struct rate_control_ref *ref);
79
80static inline void rate_control_tx_status(struct ieee80211_local *local,
81 struct net_device *dev,
82 struct sk_buff *skb,
83 struct ieee80211_tx_status *status)
84{
85 struct rate_control_ref *ref = local->rate_ctrl;
86 ref->ops->tx_status(ref->priv, dev, skb, status);
87}
88
89
90static inline struct ieee80211_rate *
91rate_control_get_rate(struct ieee80211_local *local, struct net_device *dev,
92 struct sk_buff *skb, struct rate_control_extra *extra)
93{
94 struct rate_control_ref *ref = local->rate_ctrl;
95 return ref->ops->get_rate(ref->priv, dev, skb, extra);
96}
97
98
99static inline void rate_control_rate_init(struct sta_info *sta,
100 struct ieee80211_local *local)
101{
102 struct rate_control_ref *ref = sta->rate_ctrl;
103 ref->ops->rate_init(ref->priv, sta->rate_ctrl_priv, local, sta);
104}
105
106
107static inline void rate_control_clear(struct ieee80211_local *local)
108{
109 struct rate_control_ref *ref = local->rate_ctrl;
110 ref->ops->clear(ref->priv);
111}
112
113static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
114 gfp_t gfp)
115{
116 return ref->ops->alloc_sta(ref->priv, gfp);
117}
118
119static inline void rate_control_free_sta(struct rate_control_ref *ref,
120 void *priv)
121{
122 ref->ops->free_sta(ref->priv, priv);
123}
124
125static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
126{
127#ifdef CONFIG_MAC80211_DEBUGFS
128 struct rate_control_ref *ref = sta->rate_ctrl;
129 if (sta->debugfs.dir && ref->ops->add_sta_debugfs)
130 ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
131 sta->debugfs.dir);
132#endif
133}
134
135static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
136{
137#ifdef CONFIG_MAC80211_DEBUGFS
138 struct rate_control_ref *ref = sta->rate_ctrl;
139 if (ref->ops->remove_sta_debugfs)
140 ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
141#endif
142}
143
144#endif /* IEEE80211_RATE_H */
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
new file mode 100644
index 000000000000..822917debeff
--- /dev/null
+++ b/net/mac80211/ieee80211_sta.c
@@ -0,0 +1,3060 @@
1/*
2 * BSS client mode implementation
3 * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi>
4 * Copyright 2004, Instant802 Networks, Inc.
5 * Copyright 2005, Devicescape Software, Inc.
6 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
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
14/* TODO:
15 * BSS table: use <BSSID,SSID> as the key to support multi-SSID APs
16 * order BSS list by RSSI(?) ("quality of AP")
17 * scan result table filtering (by capability (privacy, IBSS/BSS, WPA/RSN IE,
18 * SSID)
19 */
20#include <linux/if_ether.h>
21#include <linux/skbuff.h>
22#include <linux/netdevice.h>
23#include <linux/if_arp.h>
24#include <linux/wireless.h>
25#include <linux/random.h>
26#include <linux/etherdevice.h>
27#include <linux/rtnetlink.h>
28#include <net/iw_handler.h>
29#include <asm/types.h>
30#include <asm/delay.h>
31
32#include <net/mac80211.h>
33#include "ieee80211_i.h"
34#include "ieee80211_rate.h"
35#include "hostapd_ioctl.h"
36
37#define IEEE80211_AUTH_TIMEOUT (HZ / 5)
38#define IEEE80211_AUTH_MAX_TRIES 3
39#define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
40#define IEEE80211_ASSOC_MAX_TRIES 3
41#define IEEE80211_MONITORING_INTERVAL (2 * HZ)
42#define IEEE80211_PROBE_INTERVAL (60 * HZ)
43#define IEEE80211_RETRY_AUTH_INTERVAL (1 * HZ)
44#define IEEE80211_SCAN_INTERVAL (2 * HZ)
45#define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ)
46#define IEEE80211_IBSS_JOIN_TIMEOUT (20 * HZ)
47
48#define IEEE80211_PROBE_DELAY (HZ / 33)
49#define IEEE80211_CHANNEL_TIME (HZ / 33)
50#define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 5)
51#define IEEE80211_SCAN_RESULT_EXPIRE (10 * HZ)
52#define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ)
53#define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ)
54
55#define IEEE80211_IBSS_MAX_STA_ENTRIES 128
56
57
58#define IEEE80211_FC(type, stype) cpu_to_le16(type | stype)
59
60#define ERP_INFO_USE_PROTECTION BIT(1)
61
62static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst,
63 u8 *ssid, size_t ssid_len);
64static struct ieee80211_sta_bss *
65ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid);
66static void ieee80211_rx_bss_put(struct net_device *dev,
67 struct ieee80211_sta_bss *bss);
68static int ieee80211_sta_find_ibss(struct net_device *dev,
69 struct ieee80211_if_sta *ifsta);
70static int ieee80211_sta_wep_configured(struct net_device *dev);
71static int ieee80211_sta_start_scan(struct net_device *dev,
72 u8 *ssid, size_t ssid_len);
73static int ieee80211_sta_config_auth(struct net_device *dev,
74 struct ieee80211_if_sta *ifsta);
75
76
77/* Parsed Information Elements */
78struct ieee802_11_elems {
79 u8 *ssid;
80 u8 ssid_len;
81 u8 *supp_rates;
82 u8 supp_rates_len;
83 u8 *fh_params;
84 u8 fh_params_len;
85 u8 *ds_params;
86 u8 ds_params_len;
87 u8 *cf_params;
88 u8 cf_params_len;
89 u8 *tim;
90 u8 tim_len;
91 u8 *ibss_params;
92 u8 ibss_params_len;
93 u8 *challenge;
94 u8 challenge_len;
95 u8 *wpa;
96 u8 wpa_len;
97 u8 *rsn;
98 u8 rsn_len;
99 u8 *erp_info;
100 u8 erp_info_len;
101 u8 *ext_supp_rates;
102 u8 ext_supp_rates_len;
103 u8 *wmm_info;
104 u8 wmm_info_len;
105 u8 *wmm_param;
106 u8 wmm_param_len;
107};
108
109typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
110
111
112static ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
113 struct ieee802_11_elems *elems)
114{
115 size_t left = len;
116 u8 *pos = start;
117 int unknown = 0;
118
119 memset(elems, 0, sizeof(*elems));
120
121 while (left >= 2) {
122 u8 id, elen;
123
124 id = *pos++;
125 elen = *pos++;
126 left -= 2;
127
128 if (elen > left) {
129#if 0
130 if (net_ratelimit())
131 printk(KERN_DEBUG "IEEE 802.11 element parse "
132 "failed (id=%d elen=%d left=%d)\n",
133 id, elen, left);
134#endif
135 return ParseFailed;
136 }
137
138 switch (id) {
139 case WLAN_EID_SSID:
140 elems->ssid = pos;
141 elems->ssid_len = elen;
142 break;
143 case WLAN_EID_SUPP_RATES:
144 elems->supp_rates = pos;
145 elems->supp_rates_len = elen;
146 break;
147 case WLAN_EID_FH_PARAMS:
148 elems->fh_params = pos;
149 elems->fh_params_len = elen;
150 break;
151 case WLAN_EID_DS_PARAMS:
152 elems->ds_params = pos;
153 elems->ds_params_len = elen;
154 break;
155 case WLAN_EID_CF_PARAMS:
156 elems->cf_params = pos;
157 elems->cf_params_len = elen;
158 break;
159 case WLAN_EID_TIM:
160 elems->tim = pos;
161 elems->tim_len = elen;
162 break;
163 case WLAN_EID_IBSS_PARAMS:
164 elems->ibss_params = pos;
165 elems->ibss_params_len = elen;
166 break;
167 case WLAN_EID_CHALLENGE:
168 elems->challenge = pos;
169 elems->challenge_len = elen;
170 break;
171 case WLAN_EID_WPA:
172 if (elen >= 4 && pos[0] == 0x00 && pos[1] == 0x50 &&
173 pos[2] == 0xf2) {
174 /* Microsoft OUI (00:50:F2) */
175 if (pos[3] == 1) {
176 /* OUI Type 1 - WPA IE */
177 elems->wpa = pos;
178 elems->wpa_len = elen;
179 } else if (elen >= 5 && pos[3] == 2) {
180 if (pos[4] == 0) {
181 elems->wmm_info = pos;
182 elems->wmm_info_len = elen;
183 } else if (pos[4] == 1) {
184 elems->wmm_param = pos;
185 elems->wmm_param_len = elen;
186 }
187 }
188 }
189 break;
190 case WLAN_EID_RSN:
191 elems->rsn = pos;
192 elems->rsn_len = elen;
193 break;
194 case WLAN_EID_ERP_INFO:
195 elems->erp_info = pos;
196 elems->erp_info_len = elen;
197 break;
198 case WLAN_EID_EXT_SUPP_RATES:
199 elems->ext_supp_rates = pos;
200 elems->ext_supp_rates_len = elen;
201 break;
202 default:
203#if 0
204 printk(KERN_DEBUG "IEEE 802.11 element parse ignored "
205 "unknown element (id=%d elen=%d)\n",
206 id, elen);
207#endif
208 unknown++;
209 break;
210 }
211
212 left -= elen;
213 pos += elen;
214 }
215
216 /* Do not trigger error if left == 1 as Apple Airport base stations
217 * send AssocResps that are one spurious byte too long. */
218
219 return unknown ? ParseUnknown : ParseOK;
220}
221
222
223
224
225static int ecw2cw(int ecw)
226{
227 int cw = 1;
228 while (ecw > 0) {
229 cw <<= 1;
230 ecw--;
231 }
232 return cw - 1;
233}
234
235
236static void ieee80211_sta_wmm_params(struct net_device *dev,
237 struct ieee80211_if_sta *ifsta,
238 u8 *wmm_param, size_t wmm_param_len)
239{
240 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
241 struct ieee80211_tx_queue_params params;
242 size_t left;
243 int count;
244 u8 *pos;
245
246 if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1)
247 return;
248 count = wmm_param[6] & 0x0f;
249 if (count == ifsta->wmm_last_param_set)
250 return;
251 ifsta->wmm_last_param_set = count;
252
253 pos = wmm_param + 8;
254 left = wmm_param_len - 8;
255
256 memset(&params, 0, sizeof(params));
257
258 if (!local->ops->conf_tx)
259 return;
260
261 local->wmm_acm = 0;
262 for (; left >= 4; left -= 4, pos += 4) {
263 int aci = (pos[0] >> 5) & 0x03;
264 int acm = (pos[0] >> 4) & 0x01;
265 int queue;
266
267 switch (aci) {
268 case 1:
269 queue = IEEE80211_TX_QUEUE_DATA3;
270 if (acm) {
271 local->wmm_acm |= BIT(0) | BIT(3);
272 }
273 break;
274 case 2:
275 queue = IEEE80211_TX_QUEUE_DATA1;
276 if (acm) {
277 local->wmm_acm |= BIT(4) | BIT(5);
278 }
279 break;
280 case 3:
281 queue = IEEE80211_TX_QUEUE_DATA0;
282 if (acm) {
283 local->wmm_acm |= BIT(6) | BIT(7);
284 }
285 break;
286 case 0:
287 default:
288 queue = IEEE80211_TX_QUEUE_DATA2;
289 if (acm) {
290 local->wmm_acm |= BIT(1) | BIT(2);
291 }
292 break;
293 }
294
295 params.aifs = pos[0] & 0x0f;
296 params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4);
297 params.cw_min = ecw2cw(pos[1] & 0x0f);
298 /* TXOP is in units of 32 usec; burst_time in 0.1 ms */
299 params.burst_time = (pos[2] | (pos[3] << 8)) * 32 / 100;
300 printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d "
301 "cWmin=%d cWmax=%d burst=%d\n",
302 dev->name, queue, aci, acm, params.aifs, params.cw_min,
303 params.cw_max, params.burst_time);
304 /* TODO: handle ACM (block TX, fallback to next lowest allowed
305 * AC for now) */
306 if (local->ops->conf_tx(local_to_hw(local), queue, &params)) {
307 printk(KERN_DEBUG "%s: failed to set TX queue "
308 "parameters for queue %d\n", dev->name, queue);
309 }
310 }
311}
312
313
314static void ieee80211_sta_send_associnfo(struct net_device *dev,
315 struct ieee80211_if_sta *ifsta)
316{
317 char *buf;
318 size_t len;
319 int i;
320 union iwreq_data wrqu;
321
322 if (!ifsta->assocreq_ies && !ifsta->assocresp_ies)
323 return;
324
325 buf = kmalloc(50 + 2 * (ifsta->assocreq_ies_len +
326 ifsta->assocresp_ies_len), GFP_ATOMIC);
327 if (!buf)
328 return;
329
330 len = sprintf(buf, "ASSOCINFO(");
331 if (ifsta->assocreq_ies) {
332 len += sprintf(buf + len, "ReqIEs=");
333 for (i = 0; i < ifsta->assocreq_ies_len; i++) {
334 len += sprintf(buf + len, "%02x",
335 ifsta->assocreq_ies[i]);
336 }
337 }
338 if (ifsta->assocresp_ies) {
339 if (ifsta->assocreq_ies)
340 len += sprintf(buf + len, " ");
341 len += sprintf(buf + len, "RespIEs=");
342 for (i = 0; i < ifsta->assocresp_ies_len; i++) {
343 len += sprintf(buf + len, "%02x",
344 ifsta->assocresp_ies[i]);
345 }
346 }
347 len += sprintf(buf + len, ")");
348
349 if (len > IW_CUSTOM_MAX) {
350 len = sprintf(buf, "ASSOCRESPIE=");
351 for (i = 0; i < ifsta->assocresp_ies_len; i++) {
352 len += sprintf(buf + len, "%02x",
353 ifsta->assocresp_ies[i]);
354 }
355 }
356
357 memset(&wrqu, 0, sizeof(wrqu));
358 wrqu.data.length = len;
359 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
360
361 kfree(buf);
362}
363
364
365static void ieee80211_set_associated(struct net_device *dev,
366 struct ieee80211_if_sta *ifsta, int assoc)
367{
368 union iwreq_data wrqu;
369
370 if (ifsta->associated == assoc)
371 return;
372
373 ifsta->associated = assoc;
374
375 if (assoc) {
376 struct ieee80211_sub_if_data *sdata;
377 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
378 if (sdata->type != IEEE80211_IF_TYPE_STA)
379 return;
380 netif_carrier_on(dev);
381 ifsta->prev_bssid_set = 1;
382 memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN);
383 memcpy(wrqu.ap_addr.sa_data, sdata->u.sta.bssid, ETH_ALEN);
384 ieee80211_sta_send_associnfo(dev, ifsta);
385 } else {
386 netif_carrier_off(dev);
387 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
388 }
389 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
390 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
391 ifsta->last_probe = jiffies;
392}
393
394static void ieee80211_set_disassoc(struct net_device *dev,
395 struct ieee80211_if_sta *ifsta, int deauth)
396{
397 if (deauth)
398 ifsta->auth_tries = 0;
399 ifsta->assoc_tries = 0;
400 ieee80211_set_associated(dev, ifsta, 0);
401}
402
403static void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
404 int encrypt)
405{
406 struct ieee80211_sub_if_data *sdata;
407 struct ieee80211_tx_packet_data *pkt_data;
408
409 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
410 skb->dev = sdata->local->mdev;
411 skb_set_mac_header(skb, 0);
412 skb_set_network_header(skb, 0);
413 skb_set_transport_header(skb, 0);
414
415 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
416 memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data));
417 pkt_data->ifindex = sdata->dev->ifindex;
418 pkt_data->mgmt_iface = (sdata->type == IEEE80211_IF_TYPE_MGMT);
419 pkt_data->do_not_encrypt = !encrypt;
420
421 dev_queue_xmit(skb);
422}
423
424
425static void ieee80211_send_auth(struct net_device *dev,
426 struct ieee80211_if_sta *ifsta,
427 int transaction, u8 *extra, size_t extra_len,
428 int encrypt)
429{
430 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
431 struct sk_buff *skb;
432 struct ieee80211_mgmt *mgmt;
433
434 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
435 sizeof(*mgmt) + 6 + extra_len);
436 if (!skb) {
437 printk(KERN_DEBUG "%s: failed to allocate buffer for auth "
438 "frame\n", dev->name);
439 return;
440 }
441 skb_reserve(skb, local->hw.extra_tx_headroom);
442
443 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24 + 6);
444 memset(mgmt, 0, 24 + 6);
445 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
446 IEEE80211_STYPE_AUTH);
447 if (encrypt)
448 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
449 memcpy(mgmt->da, ifsta->bssid, ETH_ALEN);
450 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
451 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
452 mgmt->u.auth.auth_alg = cpu_to_le16(ifsta->auth_alg);
453 mgmt->u.auth.auth_transaction = cpu_to_le16(transaction);
454 ifsta->auth_transaction = transaction + 1;
455 mgmt->u.auth.status_code = cpu_to_le16(0);
456 if (extra)
457 memcpy(skb_put(skb, extra_len), extra, extra_len);
458
459 ieee80211_sta_tx(dev, skb, encrypt);
460}
461
462
463static void ieee80211_authenticate(struct net_device *dev,
464 struct ieee80211_if_sta *ifsta)
465{
466 ifsta->auth_tries++;
467 if (ifsta->auth_tries > IEEE80211_AUTH_MAX_TRIES) {
468 printk(KERN_DEBUG "%s: authentication with AP " MAC_FMT
469 " timed out\n",
470 dev->name, MAC_ARG(ifsta->bssid));
471 ifsta->state = IEEE80211_DISABLED;
472 return;
473 }
474
475 ifsta->state = IEEE80211_AUTHENTICATE;
476 printk(KERN_DEBUG "%s: authenticate with AP " MAC_FMT "\n",
477 dev->name, MAC_ARG(ifsta->bssid));
478
479 ieee80211_send_auth(dev, ifsta, 1, NULL, 0, 0);
480
481 mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT);
482}
483
484
485static void ieee80211_send_assoc(struct net_device *dev,
486 struct ieee80211_if_sta *ifsta)
487{
488 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
489 struct ieee80211_hw_mode *mode;
490 struct sk_buff *skb;
491 struct ieee80211_mgmt *mgmt;
492 u8 *pos, *ies;
493 int i, len;
494 u16 capab;
495 struct ieee80211_sta_bss *bss;
496 int wmm = 0;
497
498 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
499 sizeof(*mgmt) + 200 + ifsta->extra_ie_len +
500 ifsta->ssid_len);
501 if (!skb) {
502 printk(KERN_DEBUG "%s: failed to allocate buffer for assoc "
503 "frame\n", dev->name);
504 return;
505 }
506 skb_reserve(skb, local->hw.extra_tx_headroom);
507
508 mode = local->oper_hw_mode;
509 capab = ifsta->capab;
510 if (mode->mode == MODE_IEEE80211G) {
511 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME |
512 WLAN_CAPABILITY_SHORT_PREAMBLE;
513 }
514 bss = ieee80211_rx_bss_get(dev, ifsta->bssid);
515 if (bss) {
516 if (bss->capability & WLAN_CAPABILITY_PRIVACY)
517 capab |= WLAN_CAPABILITY_PRIVACY;
518 if (bss->wmm_ie) {
519 wmm = 1;
520 }
521 ieee80211_rx_bss_put(dev, bss);
522 }
523
524 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
525 memset(mgmt, 0, 24);
526 memcpy(mgmt->da, ifsta->bssid, ETH_ALEN);
527 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
528 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
529
530 if (ifsta->prev_bssid_set) {
531 skb_put(skb, 10);
532 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
533 IEEE80211_STYPE_REASSOC_REQ);
534 mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab);
535 mgmt->u.reassoc_req.listen_interval = cpu_to_le16(1);
536 memcpy(mgmt->u.reassoc_req.current_ap, ifsta->prev_bssid,
537 ETH_ALEN);
538 } else {
539 skb_put(skb, 4);
540 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
541 IEEE80211_STYPE_ASSOC_REQ);
542 mgmt->u.assoc_req.capab_info = cpu_to_le16(capab);
543 mgmt->u.assoc_req.listen_interval = cpu_to_le16(1);
544 }
545
546 /* SSID */
547 ies = pos = skb_put(skb, 2 + ifsta->ssid_len);
548 *pos++ = WLAN_EID_SSID;
549 *pos++ = ifsta->ssid_len;
550 memcpy(pos, ifsta->ssid, ifsta->ssid_len);
551
552 len = mode->num_rates;
553 if (len > 8)
554 len = 8;
555 pos = skb_put(skb, len + 2);
556 *pos++ = WLAN_EID_SUPP_RATES;
557 *pos++ = len;
558 for (i = 0; i < len; i++) {
559 int rate = mode->rates[i].rate;
560 if (mode->mode == MODE_ATHEROS_TURBO)
561 rate /= 2;
562 *pos++ = (u8) (rate / 5);
563 }
564
565 if (mode->num_rates > len) {
566 pos = skb_put(skb, mode->num_rates - len + 2);
567 *pos++ = WLAN_EID_EXT_SUPP_RATES;
568 *pos++ = mode->num_rates - len;
569 for (i = len; i < mode->num_rates; i++) {
570 int rate = mode->rates[i].rate;
571 if (mode->mode == MODE_ATHEROS_TURBO)
572 rate /= 2;
573 *pos++ = (u8) (rate / 5);
574 }
575 }
576
577 if (ifsta->extra_ie) {
578 pos = skb_put(skb, ifsta->extra_ie_len);
579 memcpy(pos, ifsta->extra_ie, ifsta->extra_ie_len);
580 }
581
582 if (wmm && ifsta->wmm_enabled) {
583 pos = skb_put(skb, 9);
584 *pos++ = WLAN_EID_VENDOR_SPECIFIC;
585 *pos++ = 7; /* len */
586 *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */
587 *pos++ = 0x50;
588 *pos++ = 0xf2;
589 *pos++ = 2; /* WME */
590 *pos++ = 0; /* WME info */
591 *pos++ = 1; /* WME ver */
592 *pos++ = 0;
593 }
594
595 kfree(ifsta->assocreq_ies);
596 ifsta->assocreq_ies_len = (skb->data + skb->len) - ies;
597 ifsta->assocreq_ies = kmalloc(ifsta->assocreq_ies_len, GFP_ATOMIC);
598 if (ifsta->assocreq_ies)
599 memcpy(ifsta->assocreq_ies, ies, ifsta->assocreq_ies_len);
600
601 ieee80211_sta_tx(dev, skb, 0);
602}
603
604
605static void ieee80211_send_deauth(struct net_device *dev,
606 struct ieee80211_if_sta *ifsta, u16 reason)
607{
608 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
609 struct sk_buff *skb;
610 struct ieee80211_mgmt *mgmt;
611
612 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
613 if (!skb) {
614 printk(KERN_DEBUG "%s: failed to allocate buffer for deauth "
615 "frame\n", dev->name);
616 return;
617 }
618 skb_reserve(skb, local->hw.extra_tx_headroom);
619
620 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
621 memset(mgmt, 0, 24);
622 memcpy(mgmt->da, ifsta->bssid, ETH_ALEN);
623 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
624 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
625 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
626 IEEE80211_STYPE_DEAUTH);
627 skb_put(skb, 2);
628 mgmt->u.deauth.reason_code = cpu_to_le16(reason);
629
630 ieee80211_sta_tx(dev, skb, 0);
631}
632
633
634static void ieee80211_send_disassoc(struct net_device *dev,
635 struct ieee80211_if_sta *ifsta, u16 reason)
636{
637 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
638 struct sk_buff *skb;
639 struct ieee80211_mgmt *mgmt;
640
641 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
642 if (!skb) {
643 printk(KERN_DEBUG "%s: failed to allocate buffer for disassoc "
644 "frame\n", dev->name);
645 return;
646 }
647 skb_reserve(skb, local->hw.extra_tx_headroom);
648
649 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
650 memset(mgmt, 0, 24);
651 memcpy(mgmt->da, ifsta->bssid, ETH_ALEN);
652 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
653 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
654 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
655 IEEE80211_STYPE_DISASSOC);
656 skb_put(skb, 2);
657 mgmt->u.disassoc.reason_code = cpu_to_le16(reason);
658
659 ieee80211_sta_tx(dev, skb, 0);
660}
661
662
663static int ieee80211_privacy_mismatch(struct net_device *dev,
664 struct ieee80211_if_sta *ifsta)
665{
666 struct ieee80211_sta_bss *bss;
667 int res = 0;
668
669 if (!ifsta || ifsta->mixed_cell ||
670 ifsta->key_mgmt != IEEE80211_KEY_MGMT_NONE)
671 return 0;
672
673 bss = ieee80211_rx_bss_get(dev, ifsta->bssid);
674 if (!bss)
675 return 0;
676
677 if (ieee80211_sta_wep_configured(dev) !=
678 !!(bss->capability & WLAN_CAPABILITY_PRIVACY))
679 res = 1;
680
681 ieee80211_rx_bss_put(dev, bss);
682
683 return res;
684}
685
686
687static void ieee80211_associate(struct net_device *dev,
688 struct ieee80211_if_sta *ifsta)
689{
690 ifsta->assoc_tries++;
691 if (ifsta->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) {
692 printk(KERN_DEBUG "%s: association with AP " MAC_FMT
693 " timed out\n",
694 dev->name, MAC_ARG(ifsta->bssid));
695 ifsta->state = IEEE80211_DISABLED;
696 return;
697 }
698
699 ifsta->state = IEEE80211_ASSOCIATE;
700 printk(KERN_DEBUG "%s: associate with AP " MAC_FMT "\n",
701 dev->name, MAC_ARG(ifsta->bssid));
702 if (ieee80211_privacy_mismatch(dev, ifsta)) {
703 printk(KERN_DEBUG "%s: mismatch in privacy configuration and "
704 "mixed-cell disabled - abort association\n", dev->name);
705 ifsta->state = IEEE80211_DISABLED;
706 return;
707 }
708
709 ieee80211_send_assoc(dev, ifsta);
710
711 mod_timer(&ifsta->timer, jiffies + IEEE80211_ASSOC_TIMEOUT);
712}
713
714
715static void ieee80211_associated(struct net_device *dev,
716 struct ieee80211_if_sta *ifsta)
717{
718 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
719 struct sta_info *sta;
720 int disassoc;
721
722 /* TODO: start monitoring current AP signal quality and number of
723 * missed beacons. Scan other channels every now and then and search
724 * for better APs. */
725 /* TODO: remove expired BSSes */
726
727 ifsta->state = IEEE80211_ASSOCIATED;
728
729 sta = sta_info_get(local, ifsta->bssid);
730 if (!sta) {
731 printk(KERN_DEBUG "%s: No STA entry for own AP " MAC_FMT "\n",
732 dev->name, MAC_ARG(ifsta->bssid));
733 disassoc = 1;
734 } else {
735 disassoc = 0;
736 if (time_after(jiffies,
737 sta->last_rx + IEEE80211_MONITORING_INTERVAL)) {
738 if (ifsta->probereq_poll) {
739 printk(KERN_DEBUG "%s: No ProbeResp from "
740 "current AP " MAC_FMT " - assume out of "
741 "range\n",
742 dev->name, MAC_ARG(ifsta->bssid));
743 disassoc = 1;
744 sta_info_free(sta, 0);
745 ifsta->probereq_poll = 0;
746 } else {
747 ieee80211_send_probe_req(dev, ifsta->bssid,
748 local->scan_ssid,
749 local->scan_ssid_len);
750 ifsta->probereq_poll = 1;
751 }
752 } else {
753 ifsta->probereq_poll = 0;
754 if (time_after(jiffies, ifsta->last_probe +
755 IEEE80211_PROBE_INTERVAL)) {
756 ifsta->last_probe = jiffies;
757 ieee80211_send_probe_req(dev, ifsta->bssid,
758 ifsta->ssid,
759 ifsta->ssid_len);
760 }
761 }
762 sta_info_put(sta);
763 }
764 if (disassoc) {
765 union iwreq_data wrqu;
766 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
767 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
768 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
769 mod_timer(&ifsta->timer, jiffies +
770 IEEE80211_MONITORING_INTERVAL + 30 * HZ);
771 } else {
772 mod_timer(&ifsta->timer, jiffies +
773 IEEE80211_MONITORING_INTERVAL);
774 }
775}
776
777
778static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst,
779 u8 *ssid, size_t ssid_len)
780{
781 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
782 struct ieee80211_hw_mode *mode;
783 struct sk_buff *skb;
784 struct ieee80211_mgmt *mgmt;
785 u8 *pos, *supp_rates, *esupp_rates = NULL;
786 int i;
787
788 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + 200);
789 if (!skb) {
790 printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
791 "request\n", dev->name);
792 return;
793 }
794 skb_reserve(skb, local->hw.extra_tx_headroom);
795
796 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
797 memset(mgmt, 0, 24);
798 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
799 IEEE80211_STYPE_PROBE_REQ);
800 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
801 if (dst) {
802 memcpy(mgmt->da, dst, ETH_ALEN);
803 memcpy(mgmt->bssid, dst, ETH_ALEN);
804 } else {
805 memset(mgmt->da, 0xff, ETH_ALEN);
806 memset(mgmt->bssid, 0xff, ETH_ALEN);
807 }
808 pos = skb_put(skb, 2 + ssid_len);
809 *pos++ = WLAN_EID_SSID;
810 *pos++ = ssid_len;
811 memcpy(pos, ssid, ssid_len);
812
813 supp_rates = skb_put(skb, 2);
814 supp_rates[0] = WLAN_EID_SUPP_RATES;
815 supp_rates[1] = 0;
816 mode = local->oper_hw_mode;
817 for (i = 0; i < mode->num_rates; i++) {
818 struct ieee80211_rate *rate = &mode->rates[i];
819 if (!(rate->flags & IEEE80211_RATE_SUPPORTED))
820 continue;
821 if (esupp_rates) {
822 pos = skb_put(skb, 1);
823 esupp_rates[1]++;
824 } else if (supp_rates[1] == 8) {
825 esupp_rates = skb_put(skb, 3);
826 esupp_rates[0] = WLAN_EID_EXT_SUPP_RATES;
827 esupp_rates[1] = 1;
828 pos = &esupp_rates[2];
829 } else {
830 pos = skb_put(skb, 1);
831 supp_rates[1]++;
832 }
833 if (mode->mode == MODE_ATHEROS_TURBO)
834 *pos = rate->rate / 10;
835 else
836 *pos = rate->rate / 5;
837 }
838
839 ieee80211_sta_tx(dev, skb, 0);
840}
841
842
843static int ieee80211_sta_wep_configured(struct net_device *dev)
844{
845 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
846 if (!sdata || !sdata->default_key ||
847 sdata->default_key->alg != ALG_WEP)
848 return 0;
849 return 1;
850}
851
852
853static void ieee80211_auth_completed(struct net_device *dev,
854 struct ieee80211_if_sta *ifsta)
855{
856 printk(KERN_DEBUG "%s: authenticated\n", dev->name);
857 ifsta->authenticated = 1;
858 ieee80211_associate(dev, ifsta);
859}
860
861
862static void ieee80211_auth_challenge(struct net_device *dev,
863 struct ieee80211_if_sta *ifsta,
864 struct ieee80211_mgmt *mgmt,
865 size_t len)
866{
867 u8 *pos;
868 struct ieee802_11_elems elems;
869
870 printk(KERN_DEBUG "%s: replying to auth challenge\n", dev->name);
871 pos = mgmt->u.auth.variable;
872 if (ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems)
873 == ParseFailed) {
874 printk(KERN_DEBUG "%s: failed to parse Auth(challenge)\n",
875 dev->name);
876 return;
877 }
878 if (!elems.challenge) {
879 printk(KERN_DEBUG "%s: no challenge IE in shared key auth "
880 "frame\n", dev->name);
881 return;
882 }
883 ieee80211_send_auth(dev, ifsta, 3, elems.challenge - 2,
884 elems.challenge_len + 2, 1);
885}
886
887
888static void ieee80211_rx_mgmt_auth(struct net_device *dev,
889 struct ieee80211_if_sta *ifsta,
890 struct ieee80211_mgmt *mgmt,
891 size_t len)
892{
893 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
894 u16 auth_alg, auth_transaction, status_code;
895
896 if (ifsta->state != IEEE80211_AUTHENTICATE &&
897 sdata->type != IEEE80211_IF_TYPE_IBSS) {
898 printk(KERN_DEBUG "%s: authentication frame received from "
899 MAC_FMT ", but not in authenticate state - ignored\n",
900 dev->name, MAC_ARG(mgmt->sa));
901 return;
902 }
903
904 if (len < 24 + 6) {
905 printk(KERN_DEBUG "%s: too short (%zd) authentication frame "
906 "received from " MAC_FMT " - ignored\n",
907 dev->name, len, MAC_ARG(mgmt->sa));
908 return;
909 }
910
911 if (sdata->type != IEEE80211_IF_TYPE_IBSS &&
912 memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) {
913 printk(KERN_DEBUG "%s: authentication frame received from "
914 "unknown AP (SA=" MAC_FMT " BSSID=" MAC_FMT ") - "
915 "ignored\n", dev->name, MAC_ARG(mgmt->sa),
916 MAC_ARG(mgmt->bssid));
917 return;
918 }
919
920 if (sdata->type != IEEE80211_IF_TYPE_IBSS &&
921 memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) {
922 printk(KERN_DEBUG "%s: authentication frame received from "
923 "unknown BSSID (SA=" MAC_FMT " BSSID=" MAC_FMT ") - "
924 "ignored\n", dev->name, MAC_ARG(mgmt->sa),
925 MAC_ARG(mgmt->bssid));
926 return;
927 }
928
929 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
930 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
931 status_code = le16_to_cpu(mgmt->u.auth.status_code);
932
933 printk(KERN_DEBUG "%s: RX authentication from " MAC_FMT " (alg=%d "
934 "transaction=%d status=%d)\n",
935 dev->name, MAC_ARG(mgmt->sa), auth_alg,
936 auth_transaction, status_code);
937
938 if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
939 /* IEEE 802.11 standard does not require authentication in IBSS
940 * networks and most implementations do not seem to use it.
941 * However, try to reply to authentication attempts if someone
942 * has actually implemented this.
943 * TODO: Could implement shared key authentication. */
944 if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1) {
945 printk(KERN_DEBUG "%s: unexpected IBSS authentication "
946 "frame (alg=%d transaction=%d)\n",
947 dev->name, auth_alg, auth_transaction);
948 return;
949 }
950 ieee80211_send_auth(dev, ifsta, 2, NULL, 0, 0);
951 }
952
953 if (auth_alg != ifsta->auth_alg ||
954 auth_transaction != ifsta->auth_transaction) {
955 printk(KERN_DEBUG "%s: unexpected authentication frame "
956 "(alg=%d transaction=%d)\n",
957 dev->name, auth_alg, auth_transaction);
958 return;
959 }
960
961 if (status_code != WLAN_STATUS_SUCCESS) {
962 printk(KERN_DEBUG "%s: AP denied authentication (auth_alg=%d "
963 "code=%d)\n", dev->name, ifsta->auth_alg, status_code);
964 if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {
965 u8 algs[3];
966 const int num_algs = ARRAY_SIZE(algs);
967 int i, pos;
968 algs[0] = algs[1] = algs[2] = 0xff;
969 if (ifsta->auth_algs & IEEE80211_AUTH_ALG_OPEN)
970 algs[0] = WLAN_AUTH_OPEN;
971 if (ifsta->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY)
972 algs[1] = WLAN_AUTH_SHARED_KEY;
973 if (ifsta->auth_algs & IEEE80211_AUTH_ALG_LEAP)
974 algs[2] = WLAN_AUTH_LEAP;
975 if (ifsta->auth_alg == WLAN_AUTH_OPEN)
976 pos = 0;
977 else if (ifsta->auth_alg == WLAN_AUTH_SHARED_KEY)
978 pos = 1;
979 else
980 pos = 2;
981 for (i = 0; i < num_algs; i++) {
982 pos++;
983 if (pos >= num_algs)
984 pos = 0;
985 if (algs[pos] == ifsta->auth_alg ||
986 algs[pos] == 0xff)
987 continue;
988 if (algs[pos] == WLAN_AUTH_SHARED_KEY &&
989 !ieee80211_sta_wep_configured(dev))
990 continue;
991 ifsta->auth_alg = algs[pos];
992 printk(KERN_DEBUG "%s: set auth_alg=%d for "
993 "next try\n",
994 dev->name, ifsta->auth_alg);
995 break;
996 }
997 }
998 return;
999 }
1000
1001 switch (ifsta->auth_alg) {
1002 case WLAN_AUTH_OPEN:
1003 case WLAN_AUTH_LEAP:
1004 ieee80211_auth_completed(dev, ifsta);
1005 break;
1006 case WLAN_AUTH_SHARED_KEY:
1007 if (ifsta->auth_transaction == 4)
1008 ieee80211_auth_completed(dev, ifsta);
1009 else
1010 ieee80211_auth_challenge(dev, ifsta, mgmt, len);
1011 break;
1012 }
1013}
1014
1015
1016static void ieee80211_rx_mgmt_deauth(struct net_device *dev,
1017 struct ieee80211_if_sta *ifsta,
1018 struct ieee80211_mgmt *mgmt,
1019 size_t len)
1020{
1021 u16 reason_code;
1022
1023 if (len < 24 + 2) {
1024 printk(KERN_DEBUG "%s: too short (%zd) deauthentication frame "
1025 "received from " MAC_FMT " - ignored\n",
1026 dev->name, len, MAC_ARG(mgmt->sa));
1027 return;
1028 }
1029
1030 if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) {
1031 printk(KERN_DEBUG "%s: deauthentication frame received from "
1032 "unknown AP (SA=" MAC_FMT " BSSID=" MAC_FMT ") - "
1033 "ignored\n", dev->name, MAC_ARG(mgmt->sa),
1034 MAC_ARG(mgmt->bssid));
1035 return;
1036 }
1037
1038 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
1039
1040 printk(KERN_DEBUG "%s: RX deauthentication from " MAC_FMT
1041 " (reason=%d)\n",
1042 dev->name, MAC_ARG(mgmt->sa), reason_code);
1043
1044 if (ifsta->authenticated) {
1045 printk(KERN_DEBUG "%s: deauthenticated\n", dev->name);
1046 }
1047
1048 if (ifsta->state == IEEE80211_AUTHENTICATE ||
1049 ifsta->state == IEEE80211_ASSOCIATE ||
1050 ifsta->state == IEEE80211_ASSOCIATED) {
1051 ifsta->state = IEEE80211_AUTHENTICATE;
1052 mod_timer(&ifsta->timer, jiffies +
1053 IEEE80211_RETRY_AUTH_INTERVAL);
1054 }
1055
1056 ieee80211_set_disassoc(dev, ifsta, 1);
1057 ifsta->authenticated = 0;
1058}
1059
1060
1061static void ieee80211_rx_mgmt_disassoc(struct net_device *dev,
1062 struct ieee80211_if_sta *ifsta,
1063 struct ieee80211_mgmt *mgmt,
1064 size_t len)
1065{
1066 u16 reason_code;
1067
1068 if (len < 24 + 2) {
1069 printk(KERN_DEBUG "%s: too short (%zd) disassociation frame "
1070 "received from " MAC_FMT " - ignored\n",
1071 dev->name, len, MAC_ARG(mgmt->sa));
1072 return;
1073 }
1074
1075 if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) {
1076 printk(KERN_DEBUG "%s: disassociation frame received from "
1077 "unknown AP (SA=" MAC_FMT " BSSID=" MAC_FMT ") - "
1078 "ignored\n", dev->name, MAC_ARG(mgmt->sa),
1079 MAC_ARG(mgmt->bssid));
1080 return;
1081 }
1082
1083 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
1084
1085 printk(KERN_DEBUG "%s: RX disassociation from " MAC_FMT
1086 " (reason=%d)\n",
1087 dev->name, MAC_ARG(mgmt->sa), reason_code);
1088
1089 if (ifsta->associated)
1090 printk(KERN_DEBUG "%s: disassociated\n", dev->name);
1091
1092 if (ifsta->state == IEEE80211_ASSOCIATED) {
1093 ifsta->state = IEEE80211_ASSOCIATE;
1094 mod_timer(&ifsta->timer, jiffies +
1095 IEEE80211_RETRY_AUTH_INTERVAL);
1096 }
1097
1098 ieee80211_set_disassoc(dev, ifsta, 0);
1099}
1100
1101
1102static void ieee80211_rx_mgmt_assoc_resp(struct net_device *dev,
1103 struct ieee80211_if_sta *ifsta,
1104 struct ieee80211_mgmt *mgmt,
1105 size_t len,
1106 int reassoc)
1107{
1108 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1109 struct ieee80211_hw_mode *mode;
1110 struct sta_info *sta;
1111 u32 rates;
1112 u16 capab_info, status_code, aid;
1113 struct ieee802_11_elems elems;
1114 u8 *pos;
1115 int i, j;
1116
1117 /* AssocResp and ReassocResp have identical structure, so process both
1118 * of them in this function. */
1119
1120 if (ifsta->state != IEEE80211_ASSOCIATE) {
1121 printk(KERN_DEBUG "%s: association frame received from "
1122 MAC_FMT ", but not in associate state - ignored\n",
1123 dev->name, MAC_ARG(mgmt->sa));
1124 return;
1125 }
1126
1127 if (len < 24 + 6) {
1128 printk(KERN_DEBUG "%s: too short (%zd) association frame "
1129 "received from " MAC_FMT " - ignored\n",
1130 dev->name, len, MAC_ARG(mgmt->sa));
1131 return;
1132 }
1133
1134 if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) {
1135 printk(KERN_DEBUG "%s: association frame received from "
1136 "unknown AP (SA=" MAC_FMT " BSSID=" MAC_FMT ") - "
1137 "ignored\n", dev->name, MAC_ARG(mgmt->sa),
1138 MAC_ARG(mgmt->bssid));
1139 return;
1140 }
1141
1142 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
1143 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
1144 aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
1145 if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14)))
1146 printk(KERN_DEBUG "%s: invalid aid value %d; bits 15:14 not "
1147 "set\n", dev->name, aid);
1148 aid &= ~(BIT(15) | BIT(14));
1149
1150 printk(KERN_DEBUG "%s: RX %sssocResp from " MAC_FMT " (capab=0x%x "
1151 "status=%d aid=%d)\n",
1152 dev->name, reassoc ? "Rea" : "A", MAC_ARG(mgmt->sa),
1153 capab_info, status_code, aid);
1154
1155 if (status_code != WLAN_STATUS_SUCCESS) {
1156 printk(KERN_DEBUG "%s: AP denied association (code=%d)\n",
1157 dev->name, status_code);
1158 return;
1159 }
1160
1161 pos = mgmt->u.assoc_resp.variable;
1162 if (ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems)
1163 == ParseFailed) {
1164 printk(KERN_DEBUG "%s: failed to parse AssocResp\n",
1165 dev->name);
1166 return;
1167 }
1168
1169 if (!elems.supp_rates) {
1170 printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n",
1171 dev->name);
1172 return;
1173 }
1174
1175 printk(KERN_DEBUG "%s: associated\n", dev->name);
1176 ifsta->aid = aid;
1177 ifsta->ap_capab = capab_info;
1178
1179 kfree(ifsta->assocresp_ies);
1180 ifsta->assocresp_ies_len = len - (pos - (u8 *) mgmt);
1181 ifsta->assocresp_ies = kmalloc(ifsta->assocresp_ies_len, GFP_ATOMIC);
1182 if (ifsta->assocresp_ies)
1183 memcpy(ifsta->assocresp_ies, pos, ifsta->assocresp_ies_len);
1184
1185 ieee80211_set_associated(dev, ifsta, 1);
1186
1187 /* Add STA entry for the AP */
1188 sta = sta_info_get(local, ifsta->bssid);
1189 if (!sta) {
1190 struct ieee80211_sta_bss *bss;
1191 sta = sta_info_add(local, dev, ifsta->bssid, GFP_ATOMIC);
1192 if (!sta) {
1193 printk(KERN_DEBUG "%s: failed to add STA entry for the"
1194 " AP\n", dev->name);
1195 return;
1196 }
1197 bss = ieee80211_rx_bss_get(dev, ifsta->bssid);
1198 if (bss) {
1199 sta->last_rssi = bss->rssi;
1200 sta->last_signal = bss->signal;
1201 sta->last_noise = bss->noise;
1202 ieee80211_rx_bss_put(dev, bss);
1203 }
1204 }
1205
1206 sta->dev = dev;
1207 sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
1208 sta->assoc_ap = 1;
1209
1210 rates = 0;
1211 mode = local->oper_hw_mode;
1212 for (i = 0; i < elems.supp_rates_len; i++) {
1213 int rate = (elems.supp_rates[i] & 0x7f) * 5;
1214 if (mode->mode == MODE_ATHEROS_TURBO)
1215 rate *= 2;
1216 for (j = 0; j < mode->num_rates; j++)
1217 if (mode->rates[j].rate == rate)
1218 rates |= BIT(j);
1219 }
1220 for (i = 0; i < elems.ext_supp_rates_len; i++) {
1221 int rate = (elems.ext_supp_rates[i] & 0x7f) * 5;
1222 if (mode->mode == MODE_ATHEROS_TURBO)
1223 rate *= 2;
1224 for (j = 0; j < mode->num_rates; j++)
1225 if (mode->rates[j].rate == rate)
1226 rates |= BIT(j);
1227 }
1228 sta->supp_rates = rates;
1229
1230 rate_control_rate_init(sta, local);
1231
1232 if (elems.wmm_param && ifsta->wmm_enabled) {
1233 sta->flags |= WLAN_STA_WME;
1234 ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param,
1235 elems.wmm_param_len);
1236 }
1237
1238
1239 sta_info_put(sta);
1240
1241 ieee80211_associated(dev, ifsta);
1242}
1243
1244
1245/* Caller must hold local->sta_bss_lock */
1246static void __ieee80211_rx_bss_hash_add(struct net_device *dev,
1247 struct ieee80211_sta_bss *bss)
1248{
1249 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1250 bss->hnext = local->sta_bss_hash[STA_HASH(bss->bssid)];
1251 local->sta_bss_hash[STA_HASH(bss->bssid)] = bss;
1252}
1253
1254
1255/* Caller must hold local->sta_bss_lock */
1256static void __ieee80211_rx_bss_hash_del(struct net_device *dev,
1257 struct ieee80211_sta_bss *bss)
1258{
1259 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1260 struct ieee80211_sta_bss *b, *prev = NULL;
1261 b = local->sta_bss_hash[STA_HASH(bss->bssid)];
1262 while (b) {
1263 if (b == bss) {
1264 if (!prev)
1265 local->sta_bss_hash[STA_HASH(bss->bssid)] =
1266 bss->hnext;
1267 else
1268 prev->hnext = bss->hnext;
1269 break;
1270 }
1271 prev = b;
1272 b = b->hnext;
1273 }
1274}
1275
1276
1277static struct ieee80211_sta_bss *
1278ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid)
1279{
1280 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1281 struct ieee80211_sta_bss *bss;
1282
1283 bss = kmalloc(sizeof(*bss), GFP_ATOMIC);
1284 if (!bss)
1285 return NULL;
1286 memset(bss, 0, sizeof(*bss));
1287 atomic_inc(&bss->users);
1288 atomic_inc(&bss->users);
1289 memcpy(bss->bssid, bssid, ETH_ALEN);
1290
1291 spin_lock_bh(&local->sta_bss_lock);
1292 /* TODO: order by RSSI? */
1293 list_add_tail(&bss->list, &local->sta_bss_list);
1294 __ieee80211_rx_bss_hash_add(dev, bss);
1295 spin_unlock_bh(&local->sta_bss_lock);
1296 return bss;
1297}
1298
1299
1300static struct ieee80211_sta_bss *
1301ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid)
1302{
1303 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1304 struct ieee80211_sta_bss *bss;
1305
1306 spin_lock_bh(&local->sta_bss_lock);
1307 bss = local->sta_bss_hash[STA_HASH(bssid)];
1308 while (bss) {
1309 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
1310 atomic_inc(&bss->users);
1311 break;
1312 }
1313 bss = bss->hnext;
1314 }
1315 spin_unlock_bh(&local->sta_bss_lock);
1316 return bss;
1317}
1318
1319
1320static void ieee80211_rx_bss_free(struct ieee80211_sta_bss *bss)
1321{
1322 kfree(bss->wpa_ie);
1323 kfree(bss->rsn_ie);
1324 kfree(bss->wmm_ie);
1325 kfree(bss);
1326}
1327
1328
1329static void ieee80211_rx_bss_put(struct net_device *dev,
1330 struct ieee80211_sta_bss *bss)
1331{
1332 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1333 if (!atomic_dec_and_test(&bss->users))
1334 return;
1335
1336 spin_lock_bh(&local->sta_bss_lock);
1337 __ieee80211_rx_bss_hash_del(dev, bss);
1338 list_del(&bss->list);
1339 spin_unlock_bh(&local->sta_bss_lock);
1340 ieee80211_rx_bss_free(bss);
1341}
1342
1343
1344void ieee80211_rx_bss_list_init(struct net_device *dev)
1345{
1346 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1347 spin_lock_init(&local->sta_bss_lock);
1348 INIT_LIST_HEAD(&local->sta_bss_list);
1349}
1350
1351
1352void ieee80211_rx_bss_list_deinit(struct net_device *dev)
1353{
1354 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1355 struct ieee80211_sta_bss *bss, *tmp;
1356
1357 list_for_each_entry_safe(bss, tmp, &local->sta_bss_list, list)
1358 ieee80211_rx_bss_put(dev, bss);
1359}
1360
1361
1362static void ieee80211_rx_bss_info(struct net_device *dev,
1363 struct ieee80211_mgmt *mgmt,
1364 size_t len,
1365 struct ieee80211_rx_status *rx_status,
1366 int beacon)
1367{
1368 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1369 struct ieee802_11_elems elems;
1370 size_t baselen;
1371 int channel, invalid = 0, clen;
1372 struct ieee80211_sta_bss *bss;
1373 struct sta_info *sta;
1374 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1375 u64 timestamp;
1376
1377 if (!beacon && memcmp(mgmt->da, dev->dev_addr, ETH_ALEN))
1378 return; /* ignore ProbeResp to foreign address */
1379
1380#if 0
1381 printk(KERN_DEBUG "%s: RX %s from " MAC_FMT " to " MAC_FMT "\n",
1382 dev->name, beacon ? "Beacon" : "Probe Response",
1383 MAC_ARG(mgmt->sa), MAC_ARG(mgmt->da));
1384#endif
1385
1386 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
1387 if (baselen > len)
1388 return;
1389
1390 timestamp = le64_to_cpu(mgmt->u.beacon.timestamp);
1391
1392 if (sdata->type == IEEE80211_IF_TYPE_IBSS && beacon &&
1393 memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) {
1394#ifdef CONFIG_MAC80211_IBSS_DEBUG
1395 static unsigned long last_tsf_debug = 0;
1396 u64 tsf;
1397 if (local->ops->get_tsf)
1398 tsf = local->ops->get_tsf(local_to_hw(local));
1399 else
1400 tsf = -1LLU;
1401 if (time_after(jiffies, last_tsf_debug + 5 * HZ)) {
1402 printk(KERN_DEBUG "RX beacon SA=" MAC_FMT " BSSID="
1403 MAC_FMT " TSF=0x%llx BCN=0x%llx diff=%lld "
1404 "@%lu\n",
1405 MAC_ARG(mgmt->sa), MAC_ARG(mgmt->bssid),
1406 (unsigned long long)tsf,
1407 (unsigned long long)timestamp,
1408 (unsigned long long)(tsf - timestamp),
1409 jiffies);
1410 last_tsf_debug = jiffies;
1411 }
1412#endif /* CONFIG_MAC80211_IBSS_DEBUG */
1413 }
1414
1415 if (ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen,
1416 &elems) == ParseFailed)
1417 invalid = 1;
1418
1419 if (sdata->type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates &&
1420 memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 &&
1421 (sta = sta_info_get(local, mgmt->sa))) {
1422 struct ieee80211_hw_mode *mode;
1423 struct ieee80211_rate *rates;
1424 size_t num_rates;
1425 u32 supp_rates, prev_rates;
1426 int i, j;
1427
1428 mode = local->sta_scanning ?
1429 local->scan_hw_mode : local->oper_hw_mode;
1430 rates = mode->rates;
1431 num_rates = mode->num_rates;
1432
1433 supp_rates = 0;
1434 for (i = 0; i < elems.supp_rates_len +
1435 elems.ext_supp_rates_len; i++) {
1436 u8 rate = 0;
1437 int own_rate;
1438 if (i < elems.supp_rates_len)
1439 rate = elems.supp_rates[i];
1440 else if (elems.ext_supp_rates)
1441 rate = elems.ext_supp_rates
1442 [i - elems.supp_rates_len];
1443 own_rate = 5 * (rate & 0x7f);
1444 if (mode->mode == MODE_ATHEROS_TURBO)
1445 own_rate *= 2;
1446 for (j = 0; j < num_rates; j++)
1447 if (rates[j].rate == own_rate)
1448 supp_rates |= BIT(j);
1449 }
1450
1451 prev_rates = sta->supp_rates;
1452 sta->supp_rates &= supp_rates;
1453 if (sta->supp_rates == 0) {
1454 /* No matching rates - this should not really happen.
1455 * Make sure that at least one rate is marked
1456 * supported to avoid issues with TX rate ctrl. */
1457 sta->supp_rates = sdata->u.sta.supp_rates_bits;
1458 }
1459 if (sta->supp_rates != prev_rates) {
1460 printk(KERN_DEBUG "%s: updated supp_rates set for "
1461 MAC_FMT " based on beacon info (0x%x & 0x%x -> "
1462 "0x%x)\n",
1463 dev->name, MAC_ARG(sta->addr), prev_rates,
1464 supp_rates, sta->supp_rates);
1465 }
1466 sta_info_put(sta);
1467 }
1468
1469 if (!elems.ssid)
1470 return;
1471
1472 if (elems.ds_params && elems.ds_params_len == 1)
1473 channel = elems.ds_params[0];
1474 else
1475 channel = rx_status->channel;
1476
1477 bss = ieee80211_rx_bss_get(dev, mgmt->bssid);
1478 if (!bss) {
1479 bss = ieee80211_rx_bss_add(dev, mgmt->bssid);
1480 if (!bss)
1481 return;
1482 } else {
1483#if 0
1484 /* TODO: order by RSSI? */
1485 spin_lock_bh(&local->sta_bss_lock);
1486 list_move_tail(&bss->list, &local->sta_bss_list);
1487 spin_unlock_bh(&local->sta_bss_lock);
1488#endif
1489 }
1490
1491 if (bss->probe_resp && beacon) {
1492 /* Do not allow beacon to override data from Probe Response. */
1493 ieee80211_rx_bss_put(dev, bss);
1494 return;
1495 }
1496
1497 bss->beacon_int = le16_to_cpu(mgmt->u.beacon.beacon_int);
1498 bss->capability = le16_to_cpu(mgmt->u.beacon.capab_info);
1499 if (elems.ssid && elems.ssid_len <= IEEE80211_MAX_SSID_LEN) {
1500 memcpy(bss->ssid, elems.ssid, elems.ssid_len);
1501 bss->ssid_len = elems.ssid_len;
1502 }
1503
1504 bss->supp_rates_len = 0;
1505 if (elems.supp_rates) {
1506 clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len;
1507 if (clen > elems.supp_rates_len)
1508 clen = elems.supp_rates_len;
1509 memcpy(&bss->supp_rates[bss->supp_rates_len], elems.supp_rates,
1510 clen);
1511 bss->supp_rates_len += clen;
1512 }
1513 if (elems.ext_supp_rates) {
1514 clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len;
1515 if (clen > elems.ext_supp_rates_len)
1516 clen = elems.ext_supp_rates_len;
1517 memcpy(&bss->supp_rates[bss->supp_rates_len],
1518 elems.ext_supp_rates, clen);
1519 bss->supp_rates_len += clen;
1520 }
1521
1522 if (elems.wpa &&
1523 (!bss->wpa_ie || bss->wpa_ie_len != elems.wpa_len ||
1524 memcmp(bss->wpa_ie, elems.wpa, elems.wpa_len))) {
1525 kfree(bss->wpa_ie);
1526 bss->wpa_ie = kmalloc(elems.wpa_len + 2, GFP_ATOMIC);
1527 if (bss->wpa_ie) {
1528 memcpy(bss->wpa_ie, elems.wpa - 2, elems.wpa_len + 2);
1529 bss->wpa_ie_len = elems.wpa_len + 2;
1530 } else
1531 bss->wpa_ie_len = 0;
1532 } else if (!elems.wpa && bss->wpa_ie) {
1533 kfree(bss->wpa_ie);
1534 bss->wpa_ie = NULL;
1535 bss->wpa_ie_len = 0;
1536 }
1537
1538 if (elems.rsn &&
1539 (!bss->rsn_ie || bss->rsn_ie_len != elems.rsn_len ||
1540 memcmp(bss->rsn_ie, elems.rsn, elems.rsn_len))) {
1541 kfree(bss->rsn_ie);
1542 bss->rsn_ie = kmalloc(elems.rsn_len + 2, GFP_ATOMIC);
1543 if (bss->rsn_ie) {
1544 memcpy(bss->rsn_ie, elems.rsn - 2, elems.rsn_len + 2);
1545 bss->rsn_ie_len = elems.rsn_len + 2;
1546 } else
1547 bss->rsn_ie_len = 0;
1548 } else if (!elems.rsn && bss->rsn_ie) {
1549 kfree(bss->rsn_ie);
1550 bss->rsn_ie = NULL;
1551 bss->rsn_ie_len = 0;
1552 }
1553
1554 if (elems.wmm_param &&
1555 (!bss->wmm_ie || bss->wmm_ie_len != elems.wmm_param_len ||
1556 memcmp(bss->wmm_ie, elems.wmm_param, elems.wmm_param_len))) {
1557 kfree(bss->wmm_ie);
1558 bss->wmm_ie = kmalloc(elems.wmm_param_len + 2, GFP_ATOMIC);
1559 if (bss->wmm_ie) {
1560 memcpy(bss->wmm_ie, elems.wmm_param - 2,
1561 elems.wmm_param_len + 2);
1562 bss->wmm_ie_len = elems.wmm_param_len + 2;
1563 } else
1564 bss->wmm_ie_len = 0;
1565 } else if (!elems.wmm_param && bss->wmm_ie) {
1566 kfree(bss->wmm_ie);
1567 bss->wmm_ie = NULL;
1568 bss->wmm_ie_len = 0;
1569 }
1570
1571
1572 bss->hw_mode = rx_status->phymode;
1573 bss->channel = channel;
1574 bss->freq = rx_status->freq;
1575 if (channel != rx_status->channel &&
1576 (bss->hw_mode == MODE_IEEE80211G ||
1577 bss->hw_mode == MODE_IEEE80211B) &&
1578 channel >= 1 && channel <= 14) {
1579 static const int freq_list[] = {
1580 2412, 2417, 2422, 2427, 2432, 2437, 2442,
1581 2447, 2452, 2457, 2462, 2467, 2472, 2484
1582 };
1583 /* IEEE 802.11g/b mode can receive packets from neighboring
1584 * channels, so map the channel into frequency. */
1585 bss->freq = freq_list[channel - 1];
1586 }
1587 bss->timestamp = timestamp;
1588 bss->last_update = jiffies;
1589 bss->rssi = rx_status->ssi;
1590 bss->signal = rx_status->signal;
1591 bss->noise = rx_status->noise;
1592 if (!beacon)
1593 bss->probe_resp++;
1594 ieee80211_rx_bss_put(dev, bss);
1595}
1596
1597
1598static void ieee80211_rx_mgmt_probe_resp(struct net_device *dev,
1599 struct ieee80211_mgmt *mgmt,
1600 size_t len,
1601 struct ieee80211_rx_status *rx_status)
1602{
1603 ieee80211_rx_bss_info(dev, mgmt, len, rx_status, 0);
1604}
1605
1606
1607static void ieee80211_rx_mgmt_beacon(struct net_device *dev,
1608 struct ieee80211_mgmt *mgmt,
1609 size_t len,
1610 struct ieee80211_rx_status *rx_status)
1611{
1612 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1613 struct ieee80211_sub_if_data *sdata;
1614 struct ieee80211_if_sta *ifsta;
1615 int use_protection;
1616 size_t baselen;
1617 struct ieee802_11_elems elems;
1618
1619 ieee80211_rx_bss_info(dev, mgmt, len, rx_status, 1);
1620
1621 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1622 if (sdata->type != IEEE80211_IF_TYPE_STA)
1623 return;
1624 ifsta = &sdata->u.sta;
1625
1626 if (!ifsta->associated ||
1627 memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0)
1628 return;
1629
1630 /* Process beacon from the current BSS */
1631 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
1632 if (baselen > len)
1633 return;
1634
1635 if (ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen,
1636 &elems) == ParseFailed)
1637 return;
1638
1639 use_protection = 0;
1640 if (elems.erp_info && elems.erp_info_len >= 1) {
1641 use_protection =
1642 (elems.erp_info[0] & ERP_INFO_USE_PROTECTION) != 0;
1643 }
1644
1645 if (use_protection != !!ifsta->use_protection) {
1646 if (net_ratelimit()) {
1647 printk(KERN_DEBUG "%s: CTS protection %s (BSSID="
1648 MAC_FMT ")\n",
1649 dev->name,
1650 use_protection ? "enabled" : "disabled",
1651 MAC_ARG(ifsta->bssid));
1652 }
1653 ifsta->use_protection = use_protection ? 1 : 0;
1654 local->cts_protect_erp_frames = use_protection;
1655 }
1656
1657 if (elems.wmm_param && ifsta->wmm_enabled) {
1658 ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param,
1659 elems.wmm_param_len);
1660 }
1661}
1662
1663
1664static void ieee80211_rx_mgmt_probe_req(struct net_device *dev,
1665 struct ieee80211_if_sta *ifsta,
1666 struct ieee80211_mgmt *mgmt,
1667 size_t len,
1668 struct ieee80211_rx_status *rx_status)
1669{
1670 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1671 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1672 int tx_last_beacon;
1673 struct sk_buff *skb;
1674 struct ieee80211_mgmt *resp;
1675 u8 *pos, *end;
1676
1677 if (sdata->type != IEEE80211_IF_TYPE_IBSS ||
1678 ifsta->state != IEEE80211_IBSS_JOINED ||
1679 len < 24 + 2 || !ifsta->probe_resp)
1680 return;
1681
1682 if (local->ops->tx_last_beacon)
1683 tx_last_beacon = local->ops->tx_last_beacon(local_to_hw(local));
1684 else
1685 tx_last_beacon = 1;
1686
1687#ifdef CONFIG_MAC80211_IBSS_DEBUG
1688 printk(KERN_DEBUG "%s: RX ProbeReq SA=" MAC_FMT " DA=" MAC_FMT " BSSID="
1689 MAC_FMT " (tx_last_beacon=%d)\n",
1690 dev->name, MAC_ARG(mgmt->sa), MAC_ARG(mgmt->da),
1691 MAC_ARG(mgmt->bssid), tx_last_beacon);
1692#endif /* CONFIG_MAC80211_IBSS_DEBUG */
1693
1694 if (!tx_last_beacon)
1695 return;
1696
1697 if (memcmp(mgmt->bssid, ifsta->bssid, ETH_ALEN) != 0 &&
1698 memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0)
1699 return;
1700
1701 end = ((u8 *) mgmt) + len;
1702 pos = mgmt->u.probe_req.variable;
1703 if (pos[0] != WLAN_EID_SSID ||
1704 pos + 2 + pos[1] > end) {
1705 if (net_ratelimit()) {
1706 printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq "
1707 "from " MAC_FMT "\n",
1708 dev->name, MAC_ARG(mgmt->sa));
1709 }
1710 return;
1711 }
1712 if (pos[1] != 0 &&
1713 (pos[1] != ifsta->ssid_len ||
1714 memcmp(pos + 2, ifsta->ssid, ifsta->ssid_len) != 0)) {
1715 /* Ignore ProbeReq for foreign SSID */
1716 return;
1717 }
1718
1719 /* Reply with ProbeResp */
1720 skb = skb_copy(ifsta->probe_resp, GFP_ATOMIC);
1721 if (!skb)
1722 return;
1723
1724 resp = (struct ieee80211_mgmt *) skb->data;
1725 memcpy(resp->da, mgmt->sa, ETH_ALEN);
1726#ifdef CONFIG_MAC80211_IBSS_DEBUG
1727 printk(KERN_DEBUG "%s: Sending ProbeResp to " MAC_FMT "\n",
1728 dev->name, MAC_ARG(resp->da));
1729#endif /* CONFIG_MAC80211_IBSS_DEBUG */
1730 ieee80211_sta_tx(dev, skb, 0);
1731}
1732
1733
1734void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
1735 struct ieee80211_rx_status *rx_status)
1736{
1737 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1738 struct ieee80211_sub_if_data *sdata;
1739 struct ieee80211_if_sta *ifsta;
1740 struct ieee80211_mgmt *mgmt;
1741 u16 fc;
1742
1743 if (skb->len < 24)
1744 goto fail;
1745
1746 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1747 ifsta = &sdata->u.sta;
1748
1749 mgmt = (struct ieee80211_mgmt *) skb->data;
1750 fc = le16_to_cpu(mgmt->frame_control);
1751
1752 switch (fc & IEEE80211_FCTL_STYPE) {
1753 case IEEE80211_STYPE_PROBE_REQ:
1754 case IEEE80211_STYPE_PROBE_RESP:
1755 case IEEE80211_STYPE_BEACON:
1756 memcpy(skb->cb, rx_status, sizeof(*rx_status));
1757 case IEEE80211_STYPE_AUTH:
1758 case IEEE80211_STYPE_ASSOC_RESP:
1759 case IEEE80211_STYPE_REASSOC_RESP:
1760 case IEEE80211_STYPE_DEAUTH:
1761 case IEEE80211_STYPE_DISASSOC:
1762 skb_queue_tail(&ifsta->skb_queue, skb);
1763 queue_work(local->hw.workqueue, &ifsta->work);
1764 return;
1765 default:
1766 printk(KERN_DEBUG "%s: received unknown management frame - "
1767 "stype=%d\n", dev->name,
1768 (fc & IEEE80211_FCTL_STYPE) >> 4);
1769 break;
1770 }
1771
1772 fail:
1773 kfree_skb(skb);
1774}
1775
1776
1777static void ieee80211_sta_rx_queued_mgmt(struct net_device *dev,
1778 struct sk_buff *skb)
1779{
1780 struct ieee80211_rx_status *rx_status;
1781 struct ieee80211_sub_if_data *sdata;
1782 struct ieee80211_if_sta *ifsta;
1783 struct ieee80211_mgmt *mgmt;
1784 u16 fc;
1785
1786 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1787 ifsta = &sdata->u.sta;
1788
1789 rx_status = (struct ieee80211_rx_status *) skb->cb;
1790 mgmt = (struct ieee80211_mgmt *) skb->data;
1791 fc = le16_to_cpu(mgmt->frame_control);
1792
1793 switch (fc & IEEE80211_FCTL_STYPE) {
1794 case IEEE80211_STYPE_PROBE_REQ:
1795 ieee80211_rx_mgmt_probe_req(dev, ifsta, mgmt, skb->len,
1796 rx_status);
1797 break;
1798 case IEEE80211_STYPE_PROBE_RESP:
1799 ieee80211_rx_mgmt_probe_resp(dev, mgmt, skb->len, rx_status);
1800 break;
1801 case IEEE80211_STYPE_BEACON:
1802 ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len, rx_status);
1803 break;
1804 case IEEE80211_STYPE_AUTH:
1805 ieee80211_rx_mgmt_auth(dev, ifsta, mgmt, skb->len);
1806 break;
1807 case IEEE80211_STYPE_ASSOC_RESP:
1808 ieee80211_rx_mgmt_assoc_resp(dev, ifsta, mgmt, skb->len, 0);
1809 break;
1810 case IEEE80211_STYPE_REASSOC_RESP:
1811 ieee80211_rx_mgmt_assoc_resp(dev, ifsta, mgmt, skb->len, 1);
1812 break;
1813 case IEEE80211_STYPE_DEAUTH:
1814 ieee80211_rx_mgmt_deauth(dev, ifsta, mgmt, skb->len);
1815 break;
1816 case IEEE80211_STYPE_DISASSOC:
1817 ieee80211_rx_mgmt_disassoc(dev, ifsta, mgmt, skb->len);
1818 break;
1819 }
1820
1821 kfree_skb(skb);
1822}
1823
1824
1825void ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb,
1826 struct ieee80211_rx_status *rx_status)
1827{
1828 struct ieee80211_mgmt *mgmt;
1829 u16 fc;
1830
1831 if (skb->len < 24) {
1832 dev_kfree_skb(skb);
1833 return;
1834 }
1835
1836 mgmt = (struct ieee80211_mgmt *) skb->data;
1837 fc = le16_to_cpu(mgmt->frame_control);
1838
1839 if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) {
1840 if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP) {
1841 ieee80211_rx_mgmt_probe_resp(dev, mgmt,
1842 skb->len, rx_status);
1843 } else if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) {
1844 ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len,
1845 rx_status);
1846 }
1847 }
1848
1849 dev_kfree_skb(skb);
1850}
1851
1852
1853static int ieee80211_sta_active_ibss(struct net_device *dev)
1854{
1855 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1856 int active = 0;
1857 struct sta_info *sta;
1858
1859 spin_lock_bh(&local->sta_lock);
1860 list_for_each_entry(sta, &local->sta_list, list) {
1861 if (sta->dev == dev &&
1862 time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL,
1863 jiffies)) {
1864 active++;
1865 break;
1866 }
1867 }
1868 spin_unlock_bh(&local->sta_lock);
1869
1870 return active;
1871}
1872
1873
1874static void ieee80211_sta_expire(struct net_device *dev)
1875{
1876 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1877 struct sta_info *sta, *tmp;
1878
1879 spin_lock_bh(&local->sta_lock);
1880 list_for_each_entry_safe(sta, tmp, &local->sta_list, list)
1881 if (time_after(jiffies, sta->last_rx +
1882 IEEE80211_IBSS_INACTIVITY_LIMIT)) {
1883 printk(KERN_DEBUG "%s: expiring inactive STA " MAC_FMT
1884 "\n", dev->name, MAC_ARG(sta->addr));
1885 sta_info_free(sta, 1);
1886 }
1887 spin_unlock_bh(&local->sta_lock);
1888}
1889
1890
1891static void ieee80211_sta_merge_ibss(struct net_device *dev,
1892 struct ieee80211_if_sta *ifsta)
1893{
1894 mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL);
1895
1896 ieee80211_sta_expire(dev);
1897 if (ieee80211_sta_active_ibss(dev))
1898 return;
1899
1900 printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other "
1901 "IBSS networks with same SSID (merge)\n", dev->name);
1902 ieee80211_sta_req_scan(dev, ifsta->ssid, ifsta->ssid_len);
1903}
1904
1905
1906void ieee80211_sta_timer(unsigned long data)
1907{
1908 struct ieee80211_sub_if_data *sdata =
1909 (struct ieee80211_sub_if_data *) data;
1910 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
1911 struct ieee80211_local *local = wdev_priv(&sdata->wdev);
1912
1913 set_bit(IEEE80211_STA_REQ_RUN, &ifsta->request);
1914 queue_work(local->hw.workqueue, &ifsta->work);
1915}
1916
1917
1918void ieee80211_sta_work(struct work_struct *work)
1919{
1920 struct ieee80211_sub_if_data *sdata =
1921 container_of(work, struct ieee80211_sub_if_data, u.sta.work);
1922 struct net_device *dev = sdata->dev;
1923 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1924 struct ieee80211_if_sta *ifsta;
1925 struct sk_buff *skb;
1926
1927 if (!netif_running(dev))
1928 return;
1929
1930 if (local->sta_scanning)
1931 return;
1932
1933 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1934 sdata->type != IEEE80211_IF_TYPE_IBSS) {
1935 printk(KERN_DEBUG "%s: ieee80211_sta_work: non-STA interface "
1936 "(type=%d)\n", dev->name, sdata->type);
1937 return;
1938 }
1939 ifsta = &sdata->u.sta;
1940
1941 while ((skb = skb_dequeue(&ifsta->skb_queue)))
1942 ieee80211_sta_rx_queued_mgmt(dev, skb);
1943
1944 if (ifsta->state != IEEE80211_AUTHENTICATE &&
1945 ifsta->state != IEEE80211_ASSOCIATE &&
1946 test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) {
1947 ieee80211_sta_start_scan(dev, NULL, 0);
1948 return;
1949 }
1950
1951 if (test_and_clear_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request)) {
1952 if (ieee80211_sta_config_auth(dev, ifsta))
1953 return;
1954 clear_bit(IEEE80211_STA_REQ_RUN, &ifsta->request);
1955 } else if (!test_and_clear_bit(IEEE80211_STA_REQ_RUN, &ifsta->request))
1956 return;
1957
1958 switch (ifsta->state) {
1959 case IEEE80211_DISABLED:
1960 break;
1961 case IEEE80211_AUTHENTICATE:
1962 ieee80211_authenticate(dev, ifsta);
1963 break;
1964 case IEEE80211_ASSOCIATE:
1965 ieee80211_associate(dev, ifsta);
1966 break;
1967 case IEEE80211_ASSOCIATED:
1968 ieee80211_associated(dev, ifsta);
1969 break;
1970 case IEEE80211_IBSS_SEARCH:
1971 ieee80211_sta_find_ibss(dev, ifsta);
1972 break;
1973 case IEEE80211_IBSS_JOINED:
1974 ieee80211_sta_merge_ibss(dev, ifsta);
1975 break;
1976 default:
1977 printk(KERN_DEBUG "ieee80211_sta_work: Unknown state %d\n",
1978 ifsta->state);
1979 break;
1980 }
1981
1982 if (ieee80211_privacy_mismatch(dev, ifsta)) {
1983 printk(KERN_DEBUG "%s: privacy configuration mismatch and "
1984 "mixed-cell disabled - disassociate\n", dev->name);
1985
1986 ieee80211_send_disassoc(dev, ifsta, WLAN_REASON_UNSPECIFIED);
1987 ieee80211_set_disassoc(dev, ifsta, 0);
1988 }
1989}
1990
1991
1992static void ieee80211_sta_reset_auth(struct net_device *dev,
1993 struct ieee80211_if_sta *ifsta)
1994{
1995 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1996
1997 if (local->ops->reset_tsf) {
1998 /* Reset own TSF to allow time synchronization work. */
1999 local->ops->reset_tsf(local_to_hw(local));
2000 }
2001
2002 ifsta->wmm_last_param_set = -1; /* allow any WMM update */
2003
2004
2005 if (ifsta->auth_algs & IEEE80211_AUTH_ALG_OPEN)
2006 ifsta->auth_alg = WLAN_AUTH_OPEN;
2007 else if (ifsta->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY)
2008 ifsta->auth_alg = WLAN_AUTH_SHARED_KEY;
2009 else if (ifsta->auth_algs & IEEE80211_AUTH_ALG_LEAP)
2010 ifsta->auth_alg = WLAN_AUTH_LEAP;
2011 else
2012 ifsta->auth_alg = WLAN_AUTH_OPEN;
2013 printk(KERN_DEBUG "%s: Initial auth_alg=%d\n", dev->name,
2014 ifsta->auth_alg);
2015 ifsta->auth_transaction = -1;
2016 ifsta->associated = ifsta->auth_tries = ifsta->assoc_tries = 0;
2017 netif_carrier_off(dev);
2018}
2019
2020
2021void ieee80211_sta_req_auth(struct net_device *dev,
2022 struct ieee80211_if_sta *ifsta)
2023{
2024 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2025 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2026
2027 if (sdata->type != IEEE80211_IF_TYPE_STA)
2028 return;
2029
2030 if ((ifsta->bssid_set || ifsta->auto_bssid_sel) &&
2031 (ifsta->ssid_set || ifsta->auto_ssid_sel)) {
2032 set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request);
2033 queue_work(local->hw.workqueue, &ifsta->work);
2034 }
2035}
2036
2037static int ieee80211_sta_match_ssid(struct ieee80211_if_sta *ifsta,
2038 const char *ssid, int ssid_len)
2039{
2040 int tmp, hidden_ssid;
2041
2042 if (!memcmp(ifsta->ssid, ssid, ssid_len))
2043 return 1;
2044
2045 if (ifsta->auto_bssid_sel)
2046 return 0;
2047
2048 hidden_ssid = 1;
2049 tmp = ssid_len;
2050 while (tmp--) {
2051 if (ssid[tmp] != '\0') {
2052 hidden_ssid = 0;
2053 break;
2054 }
2055 }
2056
2057 if (hidden_ssid && ifsta->ssid_len == ssid_len)
2058 return 1;
2059
2060 if (ssid_len == 1 && ssid[0] == ' ')
2061 return 1;
2062
2063 return 0;
2064}
2065
2066static int ieee80211_sta_config_auth(struct net_device *dev,
2067 struct ieee80211_if_sta *ifsta)
2068{
2069 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2070 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2071 struct ieee80211_sta_bss *bss, *selected = NULL;
2072 int top_rssi = 0, freq;
2073
2074 rtnl_lock();
2075
2076 if (!ifsta->auto_channel_sel && !ifsta->auto_bssid_sel &&
2077 !ifsta->auto_ssid_sel) {
2078 ifsta->state = IEEE80211_AUTHENTICATE;
2079 rtnl_unlock();
2080 ieee80211_sta_reset_auth(dev, ifsta);
2081 return 0;
2082 }
2083
2084 spin_lock_bh(&local->sta_bss_lock);
2085 freq = local->oper_channel->freq;
2086 list_for_each_entry(bss, &local->sta_bss_list, list) {
2087 if (!(bss->capability & WLAN_CAPABILITY_ESS))
2088 continue;
2089
2090 if (!!(bss->capability & WLAN_CAPABILITY_PRIVACY) ^
2091 !!sdata->default_key)
2092 continue;
2093
2094 if (!ifsta->auto_channel_sel && bss->freq != freq)
2095 continue;
2096
2097 if (!ifsta->auto_bssid_sel &&
2098 memcmp(bss->bssid, ifsta->bssid, ETH_ALEN))
2099 continue;
2100
2101 if (!ifsta->auto_ssid_sel &&
2102 !ieee80211_sta_match_ssid(ifsta, bss->ssid, bss->ssid_len))
2103 continue;
2104
2105 if (!selected || top_rssi < bss->rssi) {
2106 selected = bss;
2107 top_rssi = bss->rssi;
2108 }
2109 }
2110 if (selected)
2111 atomic_inc(&selected->users);
2112 spin_unlock_bh(&local->sta_bss_lock);
2113
2114 if (selected) {
2115 ieee80211_set_channel(local, -1, selected->freq);
2116 if (!ifsta->ssid_set)
2117 ieee80211_sta_set_ssid(dev, selected->ssid,
2118 selected->ssid_len);
2119 ieee80211_sta_set_bssid(dev, selected->bssid);
2120 ieee80211_rx_bss_put(dev, selected);
2121 ifsta->state = IEEE80211_AUTHENTICATE;
2122 rtnl_unlock();
2123 ieee80211_sta_reset_auth(dev, ifsta);
2124 return 0;
2125 } else {
2126 if (ifsta->state != IEEE80211_AUTHENTICATE) {
2127 ieee80211_sta_start_scan(dev, NULL, 0);
2128 ifsta->state = IEEE80211_AUTHENTICATE;
2129 set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request);
2130 } else
2131 ifsta->state = IEEE80211_DISABLED;
2132 }
2133 rtnl_unlock();
2134 return -1;
2135}
2136
2137static int ieee80211_sta_join_ibss(struct net_device *dev,
2138 struct ieee80211_if_sta *ifsta,
2139 struct ieee80211_sta_bss *bss)
2140{
2141 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2142 int res, rates, i, j;
2143 struct sk_buff *skb;
2144 struct ieee80211_mgmt *mgmt;
2145 struct ieee80211_tx_control control;
2146 struct ieee80211_rate *rate;
2147 struct ieee80211_hw_mode *mode;
2148 struct rate_control_extra extra;
2149 u8 *pos;
2150 struct ieee80211_sub_if_data *sdata;
2151
2152 /* Remove possible STA entries from other IBSS networks. */
2153 sta_info_flush(local, NULL);
2154
2155 if (local->ops->reset_tsf) {
2156 /* Reset own TSF to allow time synchronization work. */
2157 local->ops->reset_tsf(local_to_hw(local));
2158 }
2159 memcpy(ifsta->bssid, bss->bssid, ETH_ALEN);
2160 res = ieee80211_if_config(dev);
2161 if (res)
2162 return res;
2163
2164 local->hw.conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10;
2165
2166 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2167 sdata->drop_unencrypted = bss->capability &
2168 WLAN_CAPABILITY_PRIVACY ? 1 : 0;
2169
2170 res = ieee80211_set_channel(local, -1, bss->freq);
2171
2172 if (!(local->oper_channel->flag & IEEE80211_CHAN_W_IBSS)) {
2173 printk(KERN_DEBUG "%s: IBSS not allowed on channel %d "
2174 "(%d MHz)\n", dev->name, local->hw.conf.channel,
2175 local->hw.conf.freq);
2176 return -1;
2177 }
2178
2179 /* Set beacon template based on scan results */
2180 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
2181 do {
2182 if (!skb)
2183 break;
2184
2185 skb_reserve(skb, local->hw.extra_tx_headroom);
2186
2187 mgmt = (struct ieee80211_mgmt *)
2188 skb_put(skb, 24 + sizeof(mgmt->u.beacon));
2189 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
2190 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
2191 IEEE80211_STYPE_BEACON);
2192 memset(mgmt->da, 0xff, ETH_ALEN);
2193 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
2194 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
2195 mgmt->u.beacon.beacon_int =
2196 cpu_to_le16(local->hw.conf.beacon_int);
2197 mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
2198
2199 pos = skb_put(skb, 2 + ifsta->ssid_len);
2200 *pos++ = WLAN_EID_SSID;
2201 *pos++ = ifsta->ssid_len;
2202 memcpy(pos, ifsta->ssid, ifsta->ssid_len);
2203
2204 rates = bss->supp_rates_len;
2205 if (rates > 8)
2206 rates = 8;
2207 pos = skb_put(skb, 2 + rates);
2208 *pos++ = WLAN_EID_SUPP_RATES;
2209 *pos++ = rates;
2210 memcpy(pos, bss->supp_rates, rates);
2211
2212 pos = skb_put(skb, 2 + 1);
2213 *pos++ = WLAN_EID_DS_PARAMS;
2214 *pos++ = 1;
2215 *pos++ = bss->channel;
2216
2217 pos = skb_put(skb, 2 + 2);
2218 *pos++ = WLAN_EID_IBSS_PARAMS;
2219 *pos++ = 2;
2220 /* FIX: set ATIM window based on scan results */
2221 *pos++ = 0;
2222 *pos++ = 0;
2223
2224 if (bss->supp_rates_len > 8) {
2225 rates = bss->supp_rates_len - 8;
2226 pos = skb_put(skb, 2 + rates);
2227 *pos++ = WLAN_EID_EXT_SUPP_RATES;
2228 *pos++ = rates;
2229 memcpy(pos, &bss->supp_rates[8], rates);
2230 }
2231
2232 memset(&control, 0, sizeof(control));
2233 memset(&extra, 0, sizeof(extra));
2234 extra.mode = local->oper_hw_mode;
2235 rate = rate_control_get_rate(local, dev, skb, &extra);
2236 if (!rate) {
2237 printk(KERN_DEBUG "%s: Failed to determine TX rate "
2238 "for IBSS beacon\n", dev->name);
2239 break;
2240 }
2241 control.tx_rate = (local->short_preamble &&
2242 (rate->flags & IEEE80211_RATE_PREAMBLE2)) ?
2243 rate->val2 : rate->val;
2244 control.antenna_sel_tx = local->hw.conf.antenna_sel_tx;
2245 control.power_level = local->hw.conf.power_level;
2246 control.flags |= IEEE80211_TXCTL_NO_ACK;
2247 control.retry_limit = 1;
2248
2249 ifsta->probe_resp = skb_copy(skb, GFP_ATOMIC);
2250 if (ifsta->probe_resp) {
2251 mgmt = (struct ieee80211_mgmt *)
2252 ifsta->probe_resp->data;
2253 mgmt->frame_control =
2254 IEEE80211_FC(IEEE80211_FTYPE_MGMT,
2255 IEEE80211_STYPE_PROBE_RESP);
2256 } else {
2257 printk(KERN_DEBUG "%s: Could not allocate ProbeResp "
2258 "template for IBSS\n", dev->name);
2259 }
2260
2261 if (local->ops->beacon_update &&
2262 local->ops->beacon_update(local_to_hw(local),
2263 skb, &control) == 0) {
2264 printk(KERN_DEBUG "%s: Configured IBSS beacon "
2265 "template based on scan results\n", dev->name);
2266 skb = NULL;
2267 }
2268
2269 rates = 0;
2270 mode = local->oper_hw_mode;
2271 for (i = 0; i < bss->supp_rates_len; i++) {
2272 int bitrate = (bss->supp_rates[i] & 0x7f) * 5;
2273 if (mode->mode == MODE_ATHEROS_TURBO)
2274 bitrate *= 2;
2275 for (j = 0; j < mode->num_rates; j++)
2276 if (mode->rates[j].rate == bitrate)
2277 rates |= BIT(j);
2278 }
2279 ifsta->supp_rates_bits = rates;
2280 } while (0);
2281
2282 if (skb) {
2283 printk(KERN_DEBUG "%s: Failed to configure IBSS beacon "
2284 "template\n", dev->name);
2285 dev_kfree_skb(skb);
2286 }
2287
2288 ifsta->state = IEEE80211_IBSS_JOINED;
2289 mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL);
2290
2291 ieee80211_rx_bss_put(dev, bss);
2292
2293 return res;
2294}
2295
2296
2297static int ieee80211_sta_create_ibss(struct net_device *dev,
2298 struct ieee80211_if_sta *ifsta)
2299{
2300 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2301 struct ieee80211_sta_bss *bss;
2302 struct ieee80211_sub_if_data *sdata;
2303 struct ieee80211_hw_mode *mode;
2304 u8 bssid[ETH_ALEN], *pos;
2305 int i;
2306
2307#if 0
2308 /* Easier testing, use fixed BSSID. */
2309 memset(bssid, 0xfe, ETH_ALEN);
2310#else
2311 /* Generate random, not broadcast, locally administered BSSID. Mix in
2312 * own MAC address to make sure that devices that do not have proper
2313 * random number generator get different BSSID. */
2314 get_random_bytes(bssid, ETH_ALEN);
2315 for (i = 0; i < ETH_ALEN; i++)
2316 bssid[i] ^= dev->dev_addr[i];
2317 bssid[0] &= ~0x01;
2318 bssid[0] |= 0x02;
2319#endif
2320
2321 printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID " MAC_FMT "\n",
2322 dev->name, MAC_ARG(bssid));
2323
2324 bss = ieee80211_rx_bss_add(dev, bssid);
2325 if (!bss)
2326 return -ENOMEM;
2327
2328 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2329 mode = local->oper_hw_mode;
2330
2331 if (local->hw.conf.beacon_int == 0)
2332 local->hw.conf.beacon_int = 100;
2333 bss->beacon_int = local->hw.conf.beacon_int;
2334 bss->hw_mode = local->hw.conf.phymode;
2335 bss->channel = local->hw.conf.channel;
2336 bss->freq = local->hw.conf.freq;
2337 bss->last_update = jiffies;
2338 bss->capability = WLAN_CAPABILITY_IBSS;
2339 if (sdata->default_key) {
2340 bss->capability |= WLAN_CAPABILITY_PRIVACY;
2341 } else
2342 sdata->drop_unencrypted = 0;
2343 bss->supp_rates_len = mode->num_rates;
2344 pos = bss->supp_rates;
2345 for (i = 0; i < mode->num_rates; i++) {
2346 int rate = mode->rates[i].rate;
2347 if (mode->mode == MODE_ATHEROS_TURBO)
2348 rate /= 2;
2349 *pos++ = (u8) (rate / 5);
2350 }
2351
2352 return ieee80211_sta_join_ibss(dev, ifsta, bss);
2353}
2354
2355
2356static int ieee80211_sta_find_ibss(struct net_device *dev,
2357 struct ieee80211_if_sta *ifsta)
2358{
2359 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2360 struct ieee80211_sta_bss *bss;
2361 int found = 0;
2362 u8 bssid[ETH_ALEN];
2363 int active_ibss;
2364
2365 if (ifsta->ssid_len == 0)
2366 return -EINVAL;
2367
2368 active_ibss = ieee80211_sta_active_ibss(dev);
2369#ifdef CONFIG_MAC80211_IBSS_DEBUG
2370 printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n",
2371 dev->name, active_ibss);
2372#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2373 spin_lock_bh(&local->sta_bss_lock);
2374 list_for_each_entry(bss, &local->sta_bss_list, list) {
2375 if (ifsta->ssid_len != bss->ssid_len ||
2376 memcmp(ifsta->ssid, bss->ssid, bss->ssid_len) != 0
2377 || !(bss->capability & WLAN_CAPABILITY_IBSS))
2378 continue;
2379#ifdef CONFIG_MAC80211_IBSS_DEBUG
2380 printk(KERN_DEBUG " bssid=" MAC_FMT " found\n",
2381 MAC_ARG(bss->bssid));
2382#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2383 memcpy(bssid, bss->bssid, ETH_ALEN);
2384 found = 1;
2385 if (active_ibss || memcmp(bssid, ifsta->bssid, ETH_ALEN) != 0)
2386 break;
2387 }
2388 spin_unlock_bh(&local->sta_bss_lock);
2389
2390#ifdef CONFIG_MAC80211_IBSS_DEBUG
2391 printk(KERN_DEBUG " sta_find_ibss: selected " MAC_FMT " current "
2392 MAC_FMT "\n", MAC_ARG(bssid), MAC_ARG(ifsta->bssid));
2393#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2394 if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0 &&
2395 (bss = ieee80211_rx_bss_get(dev, bssid))) {
2396 printk(KERN_DEBUG "%s: Selected IBSS BSSID " MAC_FMT
2397 " based on configured SSID\n",
2398 dev->name, MAC_ARG(bssid));
2399 return ieee80211_sta_join_ibss(dev, ifsta, bss);
2400 }
2401#ifdef CONFIG_MAC80211_IBSS_DEBUG
2402 printk(KERN_DEBUG " did not try to join ibss\n");
2403#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2404
2405 /* Selected IBSS not found in current scan results - try to scan */
2406 if (ifsta->state == IEEE80211_IBSS_JOINED &&
2407 !ieee80211_sta_active_ibss(dev)) {
2408 mod_timer(&ifsta->timer, jiffies +
2409 IEEE80211_IBSS_MERGE_INTERVAL);
2410 } else if (time_after(jiffies, local->last_scan_completed +
2411 IEEE80211_SCAN_INTERVAL)) {
2412 printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to "
2413 "join\n", dev->name);
2414 return ieee80211_sta_req_scan(dev, ifsta->ssid,
2415 ifsta->ssid_len);
2416 } else if (ifsta->state != IEEE80211_IBSS_JOINED) {
2417 int interval = IEEE80211_SCAN_INTERVAL;
2418
2419 if (time_after(jiffies, ifsta->ibss_join_req +
2420 IEEE80211_IBSS_JOIN_TIMEOUT)) {
2421 if (ifsta->create_ibss &&
2422 local->oper_channel->flag & IEEE80211_CHAN_W_IBSS)
2423 return ieee80211_sta_create_ibss(dev, ifsta);
2424 if (ifsta->create_ibss) {
2425 printk(KERN_DEBUG "%s: IBSS not allowed on the"
2426 " configured channel %d (%d MHz)\n",
2427 dev->name, local->hw.conf.channel,
2428 local->hw.conf.freq);
2429 }
2430
2431 /* No IBSS found - decrease scan interval and continue
2432 * scanning. */
2433 interval = IEEE80211_SCAN_INTERVAL_SLOW;
2434 }
2435
2436 ifsta->state = IEEE80211_IBSS_SEARCH;
2437 mod_timer(&ifsta->timer, jiffies + interval);
2438 return 0;
2439 }
2440
2441 return 0;
2442}
2443
2444
2445int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len)
2446{
2447 struct ieee80211_sub_if_data *sdata;
2448 struct ieee80211_if_sta *ifsta;
2449 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2450
2451 if (len > IEEE80211_MAX_SSID_LEN)
2452 return -EINVAL;
2453
2454 /* TODO: This should always be done for IBSS, even if IEEE80211_QOS is
2455 * not defined. */
2456 if (local->ops->conf_tx) {
2457 struct ieee80211_tx_queue_params qparam;
2458 int i;
2459
2460 memset(&qparam, 0, sizeof(qparam));
2461 /* TODO: are these ok defaults for all hw_modes? */
2462 qparam.aifs = 2;
2463 qparam.cw_min =
2464 local->hw.conf.phymode == MODE_IEEE80211B ? 31 : 15;
2465 qparam.cw_max = 1023;
2466 qparam.burst_time = 0;
2467 for (i = IEEE80211_TX_QUEUE_DATA0; i < NUM_TX_DATA_QUEUES; i++)
2468 {
2469 local->ops->conf_tx(local_to_hw(local),
2470 i + IEEE80211_TX_QUEUE_DATA0,
2471 &qparam);
2472 }
2473 /* IBSS uses different parameters for Beacon sending */
2474 qparam.cw_min++;
2475 qparam.cw_min *= 2;
2476 qparam.cw_min--;
2477 local->ops->conf_tx(local_to_hw(local),
2478 IEEE80211_TX_QUEUE_BEACON, &qparam);
2479 }
2480
2481 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2482 ifsta = &sdata->u.sta;
2483
2484 if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0)
2485 ifsta->prev_bssid_set = 0;
2486 memcpy(ifsta->ssid, ssid, len);
2487 memset(ifsta->ssid + len, 0, IEEE80211_MAX_SSID_LEN - len);
2488 ifsta->ssid_len = len;
2489
2490 ifsta->ssid_set = len ? 1 : 0;
2491 if (sdata->type == IEEE80211_IF_TYPE_IBSS && !ifsta->bssid_set) {
2492 ifsta->ibss_join_req = jiffies;
2493 ifsta->state = IEEE80211_IBSS_SEARCH;
2494 return ieee80211_sta_find_ibss(dev, ifsta);
2495 }
2496 return 0;
2497}
2498
2499
2500int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len)
2501{
2502 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2503 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
2504 memcpy(ssid, ifsta->ssid, ifsta->ssid_len);
2505 *len = ifsta->ssid_len;
2506 return 0;
2507}
2508
2509
2510int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid)
2511{
2512 struct ieee80211_sub_if_data *sdata;
2513 struct ieee80211_if_sta *ifsta;
2514 int res;
2515
2516 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2517 ifsta = &sdata->u.sta;
2518
2519 if (memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) {
2520 memcpy(ifsta->bssid, bssid, ETH_ALEN);
2521 res = ieee80211_if_config(dev);
2522 if (res) {
2523 printk(KERN_DEBUG "%s: Failed to config new BSSID to "
2524 "the low-level driver\n", dev->name);
2525 return res;
2526 }
2527 }
2528
2529 if (!is_valid_ether_addr(bssid))
2530 ifsta->bssid_set = 0;
2531 else
2532 ifsta->bssid_set = 1;
2533 return 0;
2534}
2535
2536
2537static void ieee80211_send_nullfunc(struct ieee80211_local *local,
2538 struct ieee80211_sub_if_data *sdata,
2539 int powersave)
2540{
2541 struct sk_buff *skb;
2542 struct ieee80211_hdr *nullfunc;
2543 u16 fc;
2544
2545 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24);
2546 if (!skb) {
2547 printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc "
2548 "frame\n", sdata->dev->name);
2549 return;
2550 }
2551 skb_reserve(skb, local->hw.extra_tx_headroom);
2552
2553 nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24);
2554 memset(nullfunc, 0, 24);
2555 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
2556 IEEE80211_FCTL_TODS;
2557 if (powersave)
2558 fc |= IEEE80211_FCTL_PM;
2559 nullfunc->frame_control = cpu_to_le16(fc);
2560 memcpy(nullfunc->addr1, sdata->u.sta.bssid, ETH_ALEN);
2561 memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN);
2562 memcpy(nullfunc->addr3, sdata->u.sta.bssid, ETH_ALEN);
2563
2564 ieee80211_sta_tx(sdata->dev, skb, 0);
2565}
2566
2567
2568void ieee80211_scan_completed(struct ieee80211_hw *hw)
2569{
2570 struct ieee80211_local *local = hw_to_local(hw);
2571 struct net_device *dev = local->scan_dev;
2572 struct ieee80211_sub_if_data *sdata;
2573 union iwreq_data wrqu;
2574
2575 local->last_scan_completed = jiffies;
2576 wmb();
2577 local->sta_scanning = 0;
2578
2579 if (ieee80211_hw_config(local))
2580 printk(KERN_DEBUG "%s: failed to restore operational"
2581 "channel after scan\n", dev->name);
2582
2583 if (!(local->hw.flags & IEEE80211_HW_NO_PROBE_FILTERING) &&
2584 ieee80211_if_config(dev))
2585 printk(KERN_DEBUG "%s: failed to restore operational"
2586 "BSSID after scan\n", dev->name);
2587
2588 memset(&wrqu, 0, sizeof(wrqu));
2589 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
2590
2591 read_lock(&local->sub_if_lock);
2592 list_for_each_entry(sdata, &local->sub_if_list, list) {
2593 if (sdata->type == IEEE80211_IF_TYPE_STA) {
2594 if (sdata->u.sta.associated)
2595 ieee80211_send_nullfunc(local, sdata, 0);
2596 ieee80211_sta_timer((unsigned long)sdata);
2597 }
2598 netif_wake_queue(sdata->dev);
2599 }
2600 read_unlock(&local->sub_if_lock);
2601
2602 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2603 if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
2604 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
2605 if (!ifsta->bssid_set ||
2606 (!ifsta->state == IEEE80211_IBSS_JOINED &&
2607 !ieee80211_sta_active_ibss(dev)))
2608 ieee80211_sta_find_ibss(dev, ifsta);
2609 }
2610}
2611EXPORT_SYMBOL(ieee80211_scan_completed);
2612
2613void ieee80211_sta_scan_work(struct work_struct *work)
2614{
2615 struct ieee80211_local *local =
2616 container_of(work, struct ieee80211_local, scan_work.work);
2617 struct net_device *dev = local->scan_dev;
2618 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2619 struct ieee80211_hw_mode *mode;
2620 struct ieee80211_channel *chan;
2621 int skip;
2622 unsigned long next_delay = 0;
2623
2624 if (!local->sta_scanning)
2625 return;
2626
2627 switch (local->scan_state) {
2628 case SCAN_SET_CHANNEL:
2629 mode = local->scan_hw_mode;
2630 if (local->scan_hw_mode->list.next == &local->modes_list &&
2631 local->scan_channel_idx >= mode->num_channels) {
2632 ieee80211_scan_completed(local_to_hw(local));
2633 return;
2634 }
2635 skip = !(local->enabled_modes & (1 << mode->mode));
2636 chan = &mode->channels[local->scan_channel_idx];
2637 if (!(chan->flag & IEEE80211_CHAN_W_SCAN) ||
2638 (sdata->type == IEEE80211_IF_TYPE_IBSS &&
2639 !(chan->flag & IEEE80211_CHAN_W_IBSS)) ||
2640 (local->hw_modes & local->enabled_modes &
2641 (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B))
2642 skip = 1;
2643
2644 if (!skip) {
2645#if 0
2646 printk(KERN_DEBUG "%s: scan channel %d (%d MHz)\n",
2647 dev->name, chan->chan, chan->freq);
2648#endif
2649
2650 local->scan_channel = chan;
2651 if (ieee80211_hw_config(local)) {
2652 printk(KERN_DEBUG "%s: failed to set channel "
2653 "%d (%d MHz) for scan\n", dev->name,
2654 chan->chan, chan->freq);
2655 skip = 1;
2656 }
2657 }
2658
2659 local->scan_channel_idx++;
2660 if (local->scan_channel_idx >= local->scan_hw_mode->num_channels) {
2661 if (local->scan_hw_mode->list.next != &local->modes_list) {
2662 local->scan_hw_mode = list_entry(local->scan_hw_mode->list.next,
2663 struct ieee80211_hw_mode,
2664 list);
2665 local->scan_channel_idx = 0;
2666 }
2667 }
2668
2669 if (skip)
2670 break;
2671
2672 next_delay = IEEE80211_PROBE_DELAY +
2673 usecs_to_jiffies(local->hw.channel_change_time);
2674 local->scan_state = SCAN_SEND_PROBE;
2675 break;
2676 case SCAN_SEND_PROBE:
2677 if (local->scan_channel->flag & IEEE80211_CHAN_W_ACTIVE_SCAN) {
2678 ieee80211_send_probe_req(dev, NULL, local->scan_ssid,
2679 local->scan_ssid_len);
2680 next_delay = IEEE80211_CHANNEL_TIME;
2681 } else
2682 next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
2683 local->scan_state = SCAN_SET_CHANNEL;
2684 break;
2685 }
2686
2687 if (local->sta_scanning)
2688 queue_delayed_work(local->hw.workqueue, &local->scan_work,
2689 next_delay);
2690}
2691
2692
2693static int ieee80211_sta_start_scan(struct net_device *dev,
2694 u8 *ssid, size_t ssid_len)
2695{
2696 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2697 struct ieee80211_sub_if_data *sdata;
2698
2699 if (ssid_len > IEEE80211_MAX_SSID_LEN)
2700 return -EINVAL;
2701
2702 /* MLME-SCAN.request (page 118) page 144 (11.1.3.1)
2703 * BSSType: INFRASTRUCTURE, INDEPENDENT, ANY_BSS
2704 * BSSID: MACAddress
2705 * SSID
2706 * ScanType: ACTIVE, PASSIVE
2707 * ProbeDelay: delay (in microseconds) to be used prior to transmitting
2708 * a Probe frame during active scanning
2709 * ChannelList
2710 * MinChannelTime (>= ProbeDelay), in TU
2711 * MaxChannelTime: (>= MinChannelTime), in TU
2712 */
2713
2714 /* MLME-SCAN.confirm
2715 * BSSDescriptionSet
2716 * ResultCode: SUCCESS, INVALID_PARAMETERS
2717 */
2718
2719 if (local->sta_scanning) {
2720 if (local->scan_dev == dev)
2721 return 0;
2722 return -EBUSY;
2723 }
2724
2725 if (local->ops->hw_scan) {
2726 int rc = local->ops->hw_scan(local_to_hw(local),
2727 ssid, ssid_len);
2728 if (!rc) {
2729 local->sta_scanning = 1;
2730 local->scan_dev = dev;
2731 }
2732 return rc;
2733 }
2734
2735 local->sta_scanning = 1;
2736
2737 read_lock(&local->sub_if_lock);
2738 list_for_each_entry(sdata, &local->sub_if_list, list) {
2739 netif_stop_queue(sdata->dev);
2740 if (sdata->type == IEEE80211_IF_TYPE_STA &&
2741 sdata->u.sta.associated)
2742 ieee80211_send_nullfunc(local, sdata, 1);
2743 }
2744 read_unlock(&local->sub_if_lock);
2745
2746 if (ssid) {
2747 local->scan_ssid_len = ssid_len;
2748 memcpy(local->scan_ssid, ssid, ssid_len);
2749 } else
2750 local->scan_ssid_len = 0;
2751 local->scan_state = SCAN_SET_CHANNEL;
2752 local->scan_hw_mode = list_entry(local->modes_list.next,
2753 struct ieee80211_hw_mode,
2754 list);
2755 local->scan_channel_idx = 0;
2756 local->scan_dev = dev;
2757
2758 if (!(local->hw.flags & IEEE80211_HW_NO_PROBE_FILTERING) &&
2759 ieee80211_if_config(dev))
2760 printk(KERN_DEBUG "%s: failed to set BSSID for scan\n",
2761 dev->name);
2762
2763 /* TODO: start scan as soon as all nullfunc frames are ACKed */
2764 queue_delayed_work(local->hw.workqueue, &local->scan_work,
2765 IEEE80211_CHANNEL_TIME);
2766
2767 return 0;
2768}
2769
2770
2771int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len)
2772{
2773 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2774 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
2775 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2776
2777 if (sdata->type != IEEE80211_IF_TYPE_STA)
2778 return ieee80211_sta_start_scan(dev, ssid, ssid_len);
2779
2780 if (local->sta_scanning) {
2781 if (local->scan_dev == dev)
2782 return 0;
2783 return -EBUSY;
2784 }
2785
2786 set_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request);
2787 queue_work(local->hw.workqueue, &ifsta->work);
2788 return 0;
2789}
2790
2791static char *
2792ieee80211_sta_scan_result(struct net_device *dev,
2793 struct ieee80211_sta_bss *bss,
2794 char *current_ev, char *end_buf)
2795{
2796 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2797 struct iw_event iwe;
2798
2799 if (time_after(jiffies,
2800 bss->last_update + IEEE80211_SCAN_RESULT_EXPIRE))
2801 return current_ev;
2802
2803 if (!(local->enabled_modes & (1 << bss->hw_mode)))
2804 return current_ev;
2805
2806 if (local->scan_flags & IEEE80211_SCAN_WPA_ONLY &&
2807 !bss->wpa_ie && !bss->rsn_ie)
2808 return current_ev;
2809
2810 if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID &&
2811 (local->scan_ssid_len != bss->ssid_len ||
2812 memcmp(local->scan_ssid, bss->ssid, bss->ssid_len) != 0))
2813 return current_ev;
2814
2815 memset(&iwe, 0, sizeof(iwe));
2816 iwe.cmd = SIOCGIWAP;
2817 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
2818 memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN);
2819 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
2820 IW_EV_ADDR_LEN);
2821
2822 memset(&iwe, 0, sizeof(iwe));
2823 iwe.cmd = SIOCGIWESSID;
2824 iwe.u.data.length = bss->ssid_len;
2825 iwe.u.data.flags = 1;
2826 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
2827 bss->ssid);
2828
2829 if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
2830 memset(&iwe, 0, sizeof(iwe));
2831 iwe.cmd = SIOCGIWMODE;
2832 if (bss->capability & WLAN_CAPABILITY_ESS)
2833 iwe.u.mode = IW_MODE_MASTER;
2834 else
2835 iwe.u.mode = IW_MODE_ADHOC;
2836 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
2837 IW_EV_UINT_LEN);
2838 }
2839
2840 memset(&iwe, 0, sizeof(iwe));
2841 iwe.cmd = SIOCGIWFREQ;
2842 iwe.u.freq.m = bss->channel;
2843 iwe.u.freq.e = 0;
2844 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
2845 IW_EV_FREQ_LEN);
2846 iwe.u.freq.m = bss->freq * 100000;
2847 iwe.u.freq.e = 1;
2848 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
2849 IW_EV_FREQ_LEN);
2850
2851 memset(&iwe, 0, sizeof(iwe));
2852 iwe.cmd = IWEVQUAL;
2853 iwe.u.qual.qual = bss->signal;
2854 iwe.u.qual.level = bss->rssi;
2855 iwe.u.qual.noise = bss->noise;
2856 iwe.u.qual.updated = local->wstats_flags;
2857 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
2858 IW_EV_QUAL_LEN);
2859
2860 memset(&iwe, 0, sizeof(iwe));
2861 iwe.cmd = SIOCGIWENCODE;
2862 if (bss->capability & WLAN_CAPABILITY_PRIVACY)
2863 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
2864 else
2865 iwe.u.data.flags = IW_ENCODE_DISABLED;
2866 iwe.u.data.length = 0;
2867 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
2868
2869 if (bss && bss->wpa_ie) {
2870 memset(&iwe, 0, sizeof(iwe));
2871 iwe.cmd = IWEVGENIE;
2872 iwe.u.data.length = bss->wpa_ie_len;
2873 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
2874 bss->wpa_ie);
2875 }
2876
2877 if (bss && bss->rsn_ie) {
2878 memset(&iwe, 0, sizeof(iwe));
2879 iwe.cmd = IWEVGENIE;
2880 iwe.u.data.length = bss->rsn_ie_len;
2881 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
2882 bss->rsn_ie);
2883 }
2884
2885 if (bss && bss->supp_rates_len > 0) {
2886 /* display all supported rates in readable format */
2887 char *p = current_ev + IW_EV_LCP_LEN;
2888 int i;
2889
2890 memset(&iwe, 0, sizeof(iwe));
2891 iwe.cmd = SIOCGIWRATE;
2892 /* Those two flags are ignored... */
2893 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
2894
2895 for (i = 0; i < bss->supp_rates_len; i++) {
2896 iwe.u.bitrate.value = ((bss->supp_rates[i] &
2897 0x7f) * 500000);
2898 p = iwe_stream_add_value(current_ev, p,
2899 end_buf, &iwe, IW_EV_PARAM_LEN);
2900 }
2901 current_ev = p;
2902 }
2903
2904 if (bss) {
2905 char *buf;
2906 buf = kmalloc(30, GFP_ATOMIC);
2907 if (buf) {
2908 memset(&iwe, 0, sizeof(iwe));
2909 iwe.cmd = IWEVCUSTOM;
2910 sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp));
2911 iwe.u.data.length = strlen(buf);
2912 current_ev = iwe_stream_add_point(current_ev, end_buf,
2913 &iwe, buf);
2914 kfree(buf);
2915 }
2916 }
2917
2918 do {
2919 char *buf;
2920
2921 if (!(local->scan_flags & IEEE80211_SCAN_EXTRA_INFO))
2922 break;
2923
2924 buf = kmalloc(100, GFP_ATOMIC);
2925 if (!buf)
2926 break;
2927
2928 memset(&iwe, 0, sizeof(iwe));
2929 iwe.cmd = IWEVCUSTOM;
2930 sprintf(buf, "bcn_int=%d", bss->beacon_int);
2931 iwe.u.data.length = strlen(buf);
2932 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
2933 buf);
2934
2935 memset(&iwe, 0, sizeof(iwe));
2936 iwe.cmd = IWEVCUSTOM;
2937 sprintf(buf, "capab=0x%04x", bss->capability);
2938 iwe.u.data.length = strlen(buf);
2939 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
2940 buf);
2941
2942 kfree(buf);
2943 break;
2944 } while (0);
2945
2946 return current_ev;
2947}
2948
2949
2950int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len)
2951{
2952 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2953 char *current_ev = buf;
2954 char *end_buf = buf + len;
2955 struct ieee80211_sta_bss *bss;
2956
2957 spin_lock_bh(&local->sta_bss_lock);
2958 list_for_each_entry(bss, &local->sta_bss_list, list) {
2959 if (buf + len - current_ev <= IW_EV_ADDR_LEN) {
2960 spin_unlock_bh(&local->sta_bss_lock);
2961 return -E2BIG;
2962 }
2963 current_ev = ieee80211_sta_scan_result(dev, bss, current_ev,
2964 end_buf);
2965 }
2966 spin_unlock_bh(&local->sta_bss_lock);
2967 return current_ev - buf;
2968}
2969
2970
2971int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len)
2972{
2973 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2974 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
2975 kfree(ifsta->extra_ie);
2976 if (len == 0) {
2977 ifsta->extra_ie = NULL;
2978 ifsta->extra_ie_len = 0;
2979 return 0;
2980 }
2981 ifsta->extra_ie = kmalloc(len, GFP_KERNEL);
2982 if (!ifsta->extra_ie) {
2983 ifsta->extra_ie_len = 0;
2984 return -ENOMEM;
2985 }
2986 memcpy(ifsta->extra_ie, ie, len);
2987 ifsta->extra_ie_len = len;
2988 return 0;
2989}
2990
2991
2992struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
2993 struct sk_buff *skb, u8 *bssid,
2994 u8 *addr)
2995{
2996 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2997 struct sta_info *sta;
2998 struct ieee80211_sub_if_data *sdata = NULL;
2999
3000 /* TODO: Could consider removing the least recently used entry and
3001 * allow new one to be added. */
3002 if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) {
3003 if (net_ratelimit()) {
3004 printk(KERN_DEBUG "%s: No room for a new IBSS STA "
3005 "entry " MAC_FMT "\n", dev->name, MAC_ARG(addr));
3006 }
3007 return NULL;
3008 }
3009
3010 printk(KERN_DEBUG "%s: Adding new IBSS station " MAC_FMT " (dev=%s)\n",
3011 local->mdev->name, MAC_ARG(addr), dev->name);
3012
3013 sta = sta_info_add(local, dev, addr, GFP_ATOMIC);
3014 if (!sta)
3015 return NULL;
3016
3017 sta->supp_rates = sdata->u.sta.supp_rates_bits;
3018
3019 rate_control_rate_init(sta, local);
3020
3021 return sta; /* caller will call sta_info_put() */
3022}
3023
3024
3025int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason)
3026{
3027 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3028 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
3029
3030 printk(KERN_DEBUG "%s: deauthenticate(reason=%d)\n",
3031 dev->name, reason);
3032
3033 if (sdata->type != IEEE80211_IF_TYPE_STA &&
3034 sdata->type != IEEE80211_IF_TYPE_IBSS)
3035 return -EINVAL;
3036
3037 ieee80211_send_deauth(dev, ifsta, reason);
3038 ieee80211_set_disassoc(dev, ifsta, 1);
3039 return 0;
3040}
3041
3042
3043int ieee80211_sta_disassociate(struct net_device *dev, u16 reason)
3044{
3045 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3046 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
3047
3048 printk(KERN_DEBUG "%s: disassociate(reason=%d)\n",
3049 dev->name, reason);
3050
3051 if (sdata->type != IEEE80211_IF_TYPE_STA)
3052 return -EINVAL;
3053
3054 if (!ifsta->associated)
3055 return -1;
3056
3057 ieee80211_send_disassoc(dev, ifsta, reason);
3058 ieee80211_set_disassoc(dev, ifsta, 0);
3059 return 0;
3060}
diff --git a/net/mac80211/michael.c b/net/mac80211/michael.c
new file mode 100644
index 000000000000..0f844f7895f1
--- /dev/null
+++ b/net/mac80211/michael.c
@@ -0,0 +1,104 @@
1/*
2 * Michael MIC implementation - optimized for TKIP MIC operations
3 * Copyright 2002-2003, Instant802 Networks, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/types.h>
11
12#include "michael.h"
13
14static inline u32 rotr(u32 val, int bits)
15{
16 return (val >> bits) | (val << (32 - bits));
17}
18
19
20static inline u32 rotl(u32 val, int bits)
21{
22 return (val << bits) | (val >> (32 - bits));
23}
24
25
26static inline u32 xswap(u32 val)
27{
28 return ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8);
29}
30
31
32#define michael_block(l, r) \
33do { \
34 r ^= rotl(l, 17); \
35 l += r; \
36 r ^= xswap(l); \
37 l += r; \
38 r ^= rotl(l, 3); \
39 l += r; \
40 r ^= rotr(l, 2); \
41 l += r; \
42} while (0)
43
44
45static inline u32 michael_get32(u8 *data)
46{
47 return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
48}
49
50
51static inline void michael_put32(u32 val, u8 *data)
52{
53 data[0] = val & 0xff;
54 data[1] = (val >> 8) & 0xff;
55 data[2] = (val >> 16) & 0xff;
56 data[3] = (val >> 24) & 0xff;
57}
58
59
60void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
61 u8 *data, size_t data_len, u8 *mic)
62{
63 u32 l, r, val;
64 size_t block, blocks, left;
65
66 l = michael_get32(key);
67 r = michael_get32(key + 4);
68
69 /* A pseudo header (DA, SA, Priority, 0, 0, 0) is used in Michael MIC
70 * calculation, but it is _not_ transmitted */
71 l ^= michael_get32(da);
72 michael_block(l, r);
73 l ^= da[4] | (da[5] << 8) | (sa[0] << 16) | (sa[1] << 24);
74 michael_block(l, r);
75 l ^= michael_get32(&sa[2]);
76 michael_block(l, r);
77 l ^= priority;
78 michael_block(l, r);
79
80 /* Real data */
81 blocks = data_len / 4;
82 left = data_len % 4;
83
84 for (block = 0; block < blocks; block++) {
85 l ^= michael_get32(&data[block * 4]);
86 michael_block(l, r);
87 }
88
89 /* Partial block of 0..3 bytes and padding: 0x5a + 4..7 zeros to make
90 * total length a multiple of 4. */
91 val = 0x5a;
92 while (left > 0) {
93 val <<= 8;
94 left--;
95 val |= data[blocks * 4 + left];
96 }
97 l ^= val;
98 michael_block(l, r);
99 /* last block is zero, so l ^ 0 = l */
100 michael_block(l, r);
101
102 michael_put32(l, mic);
103 michael_put32(r, mic + 4);
104}
diff --git a/net/mac80211/michael.h b/net/mac80211/michael.h
new file mode 100644
index 000000000000..2e6aebabeea1
--- /dev/null
+++ b/net/mac80211/michael.h
@@ -0,0 +1,20 @@
1/*
2 * Michael MIC implementation - optimized for TKIP MIC operations
3 * Copyright 2002-2003, Instant802 Networks, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef MICHAEL_H
11#define MICHAEL_H
12
13#include <linux/types.h>
14
15#define MICHAEL_MIC_LEN 8
16
17void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
18 u8 *data, size_t data_len, u8 *mic);
19
20#endif /* MICHAEL_H */
diff --git a/net/mac80211/rc80211_simple.c b/net/mac80211/rc80211_simple.c
new file mode 100644
index 000000000000..2048cfd1ca70
--- /dev/null
+++ b/net/mac80211/rc80211_simple.c
@@ -0,0 +1,432 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/netdevice.h>
13#include <linux/types.h>
14#include <linux/slab.h>
15#include <linux/skbuff.h>
16#include <linux/compiler.h>
17
18#include <net/mac80211.h>
19#include "ieee80211_i.h"
20#include "ieee80211_rate.h"
21#include "debugfs.h"
22
23
24/* This is a minimal implementation of TX rate controlling that can be used
25 * as the default when no improved mechanisms are available. */
26
27
28#define RATE_CONTROL_EMERG_DEC 2
29#define RATE_CONTROL_INTERVAL (HZ / 20)
30#define RATE_CONTROL_MIN_TX 10
31
32MODULE_ALIAS("rc80211_default");
33
34static void rate_control_rate_inc(struct ieee80211_local *local,
35 struct sta_info *sta)
36{
37 struct ieee80211_sub_if_data *sdata;
38 struct ieee80211_hw_mode *mode;
39 int i = sta->txrate;
40 int maxrate;
41
42 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
43 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) {
44 /* forced unicast rate - do not change STA rate */
45 return;
46 }
47
48 mode = local->oper_hw_mode;
49 maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1;
50
51 if (i > mode->num_rates)
52 i = mode->num_rates - 2;
53
54 while (i + 1 < mode->num_rates) {
55 i++;
56 if (sta->supp_rates & BIT(i) &&
57 mode->rates[i].flags & IEEE80211_RATE_SUPPORTED &&
58 (maxrate < 0 || i <= maxrate)) {
59 sta->txrate = i;
60 break;
61 }
62 }
63}
64
65
66static void rate_control_rate_dec(struct ieee80211_local *local,
67 struct sta_info *sta)
68{
69 struct ieee80211_sub_if_data *sdata;
70 struct ieee80211_hw_mode *mode;
71 int i = sta->txrate;
72
73 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
74 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) {
75 /* forced unicast rate - do not change STA rate */
76 return;
77 }
78
79 mode = local->oper_hw_mode;
80 if (i > mode->num_rates)
81 i = mode->num_rates;
82
83 while (i > 0) {
84 i--;
85 if (sta->supp_rates & BIT(i) &&
86 mode->rates[i].flags & IEEE80211_RATE_SUPPORTED) {
87 sta->txrate = i;
88 break;
89 }
90 }
91}
92
93
94static struct ieee80211_rate *
95rate_control_lowest_rate(struct ieee80211_local *local,
96 struct ieee80211_hw_mode *mode)
97{
98 int i;
99
100 for (i = 0; i < mode->num_rates; i++) {
101 struct ieee80211_rate *rate = &mode->rates[i];
102
103 if (rate->flags & IEEE80211_RATE_SUPPORTED)
104 return rate;
105 }
106
107 printk(KERN_DEBUG "rate_control_lowest_rate - no supported rates "
108 "found\n");
109 return &mode->rates[0];
110}
111
112
113struct global_rate_control {
114 int dummy;
115};
116
117struct sta_rate_control {
118 unsigned long last_rate_change;
119 u32 tx_num_failures;
120 u32 tx_num_xmit;
121
122 unsigned long avg_rate_update;
123 u32 tx_avg_rate_sum;
124 u32 tx_avg_rate_num;
125
126#ifdef CONFIG_MAC80211_DEBUGFS
127 struct dentry *tx_avg_rate_sum_dentry;
128 struct dentry *tx_avg_rate_num_dentry;
129#endif
130};
131
132
133static void rate_control_simple_tx_status(void *priv, struct net_device *dev,
134 struct sk_buff *skb,
135 struct ieee80211_tx_status *status)
136{
137 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
138 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
139 struct sta_info *sta;
140 struct sta_rate_control *srctrl;
141
142 sta = sta_info_get(local, hdr->addr1);
143
144 if (!sta)
145 return;
146
147 srctrl = sta->rate_ctrl_priv;
148 srctrl->tx_num_xmit++;
149 if (status->excessive_retries) {
150 sta->antenna_sel_tx = sta->antenna_sel_tx == 1 ? 2 : 1;
151 sta->antenna_sel_rx = sta->antenna_sel_rx == 1 ? 2 : 1;
152 if (local->sta_antenna_sel == STA_ANTENNA_SEL_SW_CTRL_DEBUG) {
153 printk(KERN_DEBUG "%s: " MAC_FMT " TX antenna --> %d "
154 "RX antenna --> %d (@%lu)\n",
155 dev->name, MAC_ARG(hdr->addr1),
156 sta->antenna_sel_tx, sta->antenna_sel_rx, jiffies);
157 }
158 srctrl->tx_num_failures++;
159 sta->tx_retry_failed++;
160 sta->tx_num_consecutive_failures++;
161 sta->tx_num_mpdu_fail++;
162 } else {
163 sta->last_ack_rssi[0] = sta->last_ack_rssi[1];
164 sta->last_ack_rssi[1] = sta->last_ack_rssi[2];
165 sta->last_ack_rssi[2] = status->ack_signal;
166 sta->tx_num_consecutive_failures = 0;
167 sta->tx_num_mpdu_ok++;
168 }
169 sta->tx_retry_count += status->retry_count;
170 sta->tx_num_mpdu_fail += status->retry_count;
171
172 if (time_after(jiffies,
173 srctrl->last_rate_change + RATE_CONTROL_INTERVAL) &&
174 srctrl->tx_num_xmit > RATE_CONTROL_MIN_TX) {
175 u32 per_failed;
176 srctrl->last_rate_change = jiffies;
177
178 per_failed = (100 * sta->tx_num_mpdu_fail) /
179 (sta->tx_num_mpdu_fail + sta->tx_num_mpdu_ok);
180 /* TODO: calculate average per_failed to make adjusting
181 * parameters easier */
182#if 0
183 if (net_ratelimit()) {
184 printk(KERN_DEBUG "MPDU fail=%d ok=%d per_failed=%d\n",
185 sta->tx_num_mpdu_fail, sta->tx_num_mpdu_ok,
186 per_failed);
187 }
188#endif
189
190 if (per_failed > local->rate_ctrl_num_down) {
191 rate_control_rate_dec(local, sta);
192 } else if (per_failed < local->rate_ctrl_num_up) {
193 rate_control_rate_inc(local, sta);
194 }
195 srctrl->tx_avg_rate_sum += status->control.rate->rate;
196 srctrl->tx_avg_rate_num++;
197 srctrl->tx_num_failures = 0;
198 srctrl->tx_num_xmit = 0;
199 } else if (sta->tx_num_consecutive_failures >=
200 RATE_CONTROL_EMERG_DEC) {
201 rate_control_rate_dec(local, sta);
202 }
203
204 if (srctrl->avg_rate_update + 60 * HZ < jiffies) {
205 srctrl->avg_rate_update = jiffies;
206 if (srctrl->tx_avg_rate_num > 0) {
207#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
208 printk(KERN_DEBUG "%s: STA " MAC_FMT " Average rate: "
209 "%d (%d/%d)\n",
210 dev->name, MAC_ARG(sta->addr),
211 srctrl->tx_avg_rate_sum /
212 srctrl->tx_avg_rate_num,
213 srctrl->tx_avg_rate_sum,
214 srctrl->tx_avg_rate_num);
215#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
216 srctrl->tx_avg_rate_sum = 0;
217 srctrl->tx_avg_rate_num = 0;
218 }
219 }
220
221 sta_info_put(sta);
222}
223
224
225static struct ieee80211_rate *
226rate_control_simple_get_rate(void *priv, struct net_device *dev,
227 struct sk_buff *skb,
228 struct rate_control_extra *extra)
229{
230 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
231 struct ieee80211_sub_if_data *sdata;
232 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
233 struct ieee80211_hw_mode *mode = extra->mode;
234 struct sta_info *sta;
235 int rateidx, nonerp_idx;
236 u16 fc;
237
238 memset(extra, 0, sizeof(*extra));
239
240 fc = le16_to_cpu(hdr->frame_control);
241 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
242 (hdr->addr1[0] & 0x01)) {
243 /* Send management frames and broadcast/multicast data using
244 * lowest rate. */
245 /* TODO: this could probably be improved.. */
246 return rate_control_lowest_rate(local, mode);
247 }
248
249 sta = sta_info_get(local, hdr->addr1);
250
251 if (!sta)
252 return rate_control_lowest_rate(local, mode);
253
254 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
255 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1)
256 sta->txrate = sdata->bss->force_unicast_rateidx;
257
258 rateidx = sta->txrate;
259
260 if (rateidx >= mode->num_rates)
261 rateidx = mode->num_rates - 1;
262
263 sta->last_txrate = rateidx;
264 nonerp_idx = rateidx;
265 while (nonerp_idx > 0 &&
266 ((mode->rates[nonerp_idx].flags & IEEE80211_RATE_ERP) ||
267 !(mode->rates[nonerp_idx].flags & IEEE80211_RATE_SUPPORTED) ||
268 !(sta->supp_rates & BIT(nonerp_idx))))
269 nonerp_idx--;
270 extra->nonerp = &mode->rates[nonerp_idx];
271
272 sta_info_put(sta);
273
274 return &mode->rates[rateidx];
275}
276
277
278static void rate_control_simple_rate_init(void *priv, void *priv_sta,
279 struct ieee80211_local *local,
280 struct sta_info *sta)
281{
282 struct ieee80211_hw_mode *mode;
283 int i;
284 sta->txrate = 0;
285 mode = local->oper_hw_mode;
286 /* TODO: what is a good starting rate for STA? About middle? Maybe not
287 * the lowest or the highest rate.. Could consider using RSSI from
288 * previous packets? Need to have IEEE 802.1X auth succeed immediately
289 * after assoc.. */
290 for (i = 0; i < mode->num_rates; i++) {
291 if ((sta->supp_rates & BIT(i)) &&
292 (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED))
293 sta->txrate = i;
294 }
295}
296
297
298static void * rate_control_simple_alloc(struct ieee80211_local *local)
299{
300 struct global_rate_control *rctrl;
301
302 rctrl = kzalloc(sizeof(*rctrl), GFP_ATOMIC);
303
304 return rctrl;
305}
306
307
308static void rate_control_simple_free(void *priv)
309{
310 struct global_rate_control *rctrl = priv;
311 kfree(rctrl);
312}
313
314
315static void rate_control_simple_clear(void *priv)
316{
317}
318
319
320static void * rate_control_simple_alloc_sta(void *priv, gfp_t gfp)
321{
322 struct sta_rate_control *rctrl;
323
324 rctrl = kzalloc(sizeof(*rctrl), gfp);
325
326 return rctrl;
327}
328
329
330static void rate_control_simple_free_sta(void *priv, void *priv_sta)
331{
332 struct sta_rate_control *rctrl = priv_sta;
333 kfree(rctrl);
334}
335
336#ifdef CONFIG_MAC80211_DEBUGFS
337
338static int open_file_generic(struct inode *inode, struct file *file)
339{
340 file->private_data = inode->i_private;
341 return 0;
342}
343
344static ssize_t sta_tx_avg_rate_sum_read(struct file *file,
345 char __user *userbuf,
346 size_t count, loff_t *ppos)
347{
348 struct sta_rate_control *srctrl = file->private_data;
349 char buf[20];
350
351 sprintf(buf, "%d\n", srctrl->tx_avg_rate_sum);
352 return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
353}
354
355static const struct file_operations sta_tx_avg_rate_sum_ops = {
356 .read = sta_tx_avg_rate_sum_read,
357 .open = open_file_generic,
358};
359
360static ssize_t sta_tx_avg_rate_num_read(struct file *file,
361 char __user *userbuf,
362 size_t count, loff_t *ppos)
363{
364 struct sta_rate_control *srctrl = file->private_data;
365 char buf[20];
366
367 sprintf(buf, "%d\n", srctrl->tx_avg_rate_num);
368 return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
369}
370
371static const struct file_operations sta_tx_avg_rate_num_ops = {
372 .read = sta_tx_avg_rate_num_read,
373 .open = open_file_generic,
374};
375
376static void rate_control_simple_add_sta_debugfs(void *priv, void *priv_sta,
377 struct dentry *dir)
378{
379 struct sta_rate_control *srctrl = priv_sta;
380
381 srctrl->tx_avg_rate_num_dentry =
382 debugfs_create_file("rc_simple_sta_tx_avg_rate_num", 0400,
383 dir, srctrl, &sta_tx_avg_rate_num_ops);
384 srctrl->tx_avg_rate_sum_dentry =
385 debugfs_create_file("rc_simple_sta_tx_avg_rate_sum", 0400,
386 dir, srctrl, &sta_tx_avg_rate_sum_ops);
387}
388
389static void rate_control_simple_remove_sta_debugfs(void *priv, void *priv_sta)
390{
391 struct sta_rate_control *srctrl = priv_sta;
392
393 debugfs_remove(srctrl->tx_avg_rate_sum_dentry);
394 debugfs_remove(srctrl->tx_avg_rate_num_dentry);
395}
396#endif
397
398static struct rate_control_ops rate_control_simple = {
399 .module = THIS_MODULE,
400 .name = "simple",
401 .tx_status = rate_control_simple_tx_status,
402 .get_rate = rate_control_simple_get_rate,
403 .rate_init = rate_control_simple_rate_init,
404 .clear = rate_control_simple_clear,
405 .alloc = rate_control_simple_alloc,
406 .free = rate_control_simple_free,
407 .alloc_sta = rate_control_simple_alloc_sta,
408 .free_sta = rate_control_simple_free_sta,
409#ifdef CONFIG_MAC80211_DEBUGFS
410 .add_sta_debugfs = rate_control_simple_add_sta_debugfs,
411 .remove_sta_debugfs = rate_control_simple_remove_sta_debugfs,
412#endif
413};
414
415
416static int __init rate_control_simple_init(void)
417{
418 return ieee80211_rate_control_register(&rate_control_simple);
419}
420
421
422static void __exit rate_control_simple_exit(void)
423{
424 ieee80211_rate_control_unregister(&rate_control_simple);
425}
426
427
428module_init(rate_control_simple_init);
429module_exit(rate_control_simple_exit);
430
431MODULE_DESCRIPTION("Simple rate control algorithm for ieee80211");
432MODULE_LICENSE("GPL");
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
new file mode 100644
index 000000000000..ab7b1f067c6e
--- /dev/null
+++ b/net/mac80211/sta_info.c
@@ -0,0 +1,470 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/netdevice.h>
13#include <linux/types.h>
14#include <linux/slab.h>
15#include <linux/skbuff.h>
16#include <linux/if_arp.h>
17
18#include <net/mac80211.h>
19#include "ieee80211_i.h"
20#include "ieee80211_rate.h"
21#include "sta_info.h"
22#include "debugfs_key.h"
23#include "debugfs_sta.h"
24
25/* Caller must hold local->sta_lock */
26static void sta_info_hash_add(struct ieee80211_local *local,
27 struct sta_info *sta)
28{
29 sta->hnext = local->sta_hash[STA_HASH(sta->addr)];
30 local->sta_hash[STA_HASH(sta->addr)] = sta;
31}
32
33
34/* Caller must hold local->sta_lock */
35static void sta_info_hash_del(struct ieee80211_local *local,
36 struct sta_info *sta)
37{
38 struct sta_info *s;
39
40 s = local->sta_hash[STA_HASH(sta->addr)];
41 if (!s)
42 return;
43 if (memcmp(s->addr, sta->addr, ETH_ALEN) == 0) {
44 local->sta_hash[STA_HASH(sta->addr)] = s->hnext;
45 return;
46 }
47
48 while (s->hnext && memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
49 s = s->hnext;
50 if (s->hnext)
51 s->hnext = s->hnext->hnext;
52 else
53 printk(KERN_ERR "%s: could not remove STA " MAC_FMT " from "
54 "hash table\n", local->mdev->name, MAC_ARG(sta->addr));
55}
56
57static inline void __sta_info_get(struct sta_info *sta)
58{
59 kref_get(&sta->kref);
60}
61
62struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr)
63{
64 struct sta_info *sta;
65
66 spin_lock_bh(&local->sta_lock);
67 sta = local->sta_hash[STA_HASH(addr)];
68 while (sta) {
69 if (memcmp(sta->addr, addr, ETH_ALEN) == 0) {
70 __sta_info_get(sta);
71 break;
72 }
73 sta = sta->hnext;
74 }
75 spin_unlock_bh(&local->sta_lock);
76
77 return sta;
78}
79EXPORT_SYMBOL(sta_info_get);
80
81int sta_info_min_txrate_get(struct ieee80211_local *local)
82{
83 struct sta_info *sta;
84 struct ieee80211_hw_mode *mode;
85 int min_txrate = 9999999;
86 int i;
87
88 spin_lock_bh(&local->sta_lock);
89 mode = local->oper_hw_mode;
90 for (i = 0; i < STA_HASH_SIZE; i++) {
91 sta = local->sta_hash[i];
92 while (sta) {
93 if (sta->txrate < min_txrate)
94 min_txrate = sta->txrate;
95 sta = sta->hnext;
96 }
97 }
98 spin_unlock_bh(&local->sta_lock);
99 if (min_txrate == 9999999)
100 min_txrate = 0;
101
102 return mode->rates[min_txrate].rate;
103}
104
105
106static void sta_info_release(struct kref *kref)
107{
108 struct sta_info *sta = container_of(kref, struct sta_info, kref);
109 struct ieee80211_local *local = sta->local;
110 struct sk_buff *skb;
111
112 /* free sta structure; it has already been removed from
113 * hash table etc. external structures. Make sure that all
114 * buffered frames are release (one might have been added
115 * after sta_info_free() was called). */
116 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
117 local->total_ps_buffered--;
118 dev_kfree_skb_any(skb);
119 }
120 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
121 dev_kfree_skb_any(skb);
122 }
123 rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv);
124 rate_control_put(sta->rate_ctrl);
125 if (sta->key)
126 ieee80211_debugfs_key_sta_del(sta->key, sta);
127 kfree(sta);
128}
129
130
131void sta_info_put(struct sta_info *sta)
132{
133 kref_put(&sta->kref, sta_info_release);
134}
135EXPORT_SYMBOL(sta_info_put);
136
137
138struct sta_info * sta_info_add(struct ieee80211_local *local,
139 struct net_device *dev, u8 *addr, gfp_t gfp)
140{
141 struct sta_info *sta;
142
143 sta = kzalloc(sizeof(*sta), gfp);
144 if (!sta)
145 return NULL;
146
147 kref_init(&sta->kref);
148
149 sta->rate_ctrl = rate_control_get(local->rate_ctrl);
150 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, gfp);
151 if (!sta->rate_ctrl_priv) {
152 rate_control_put(sta->rate_ctrl);
153 kref_put(&sta->kref, sta_info_release);
154 kfree(sta);
155 return NULL;
156 }
157
158 memcpy(sta->addr, addr, ETH_ALEN);
159 sta->local = local;
160 sta->dev = dev;
161 skb_queue_head_init(&sta->ps_tx_buf);
162 skb_queue_head_init(&sta->tx_filtered);
163 __sta_info_get(sta); /* sta used by caller, decremented by
164 * sta_info_put() */
165 spin_lock_bh(&local->sta_lock);
166 list_add(&sta->list, &local->sta_list);
167 local->num_sta++;
168 sta_info_hash_add(local, sta);
169 spin_unlock_bh(&local->sta_lock);
170 if (local->ops->sta_table_notification)
171 local->ops->sta_table_notification(local_to_hw(local),
172 local->num_sta);
173 sta->key_idx_compression = HW_KEY_IDX_INVALID;
174
175#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
176 printk(KERN_DEBUG "%s: Added STA " MAC_FMT "\n",
177 local->mdev->name, MAC_ARG(addr));
178#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
179
180#ifdef CONFIG_MAC80211_DEBUGFS
181 if (!in_interrupt()) {
182 sta->debugfs_registered = 1;
183 ieee80211_sta_debugfs_add(sta);
184 rate_control_add_sta_debugfs(sta);
185 } else {
186 /* debugfs entry adding might sleep, so schedule process
187 * context task for adding entry for STAs that do not yet
188 * have one. */
189 queue_work(local->hw.workqueue, &local->sta_debugfs_add);
190 }
191#endif
192
193 return sta;
194}
195
196static void finish_sta_info_free(struct ieee80211_local *local,
197 struct sta_info *sta)
198{
199#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
200 printk(KERN_DEBUG "%s: Removed STA " MAC_FMT "\n",
201 local->mdev->name, MAC_ARG(sta->addr));
202#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
203
204 if (sta->key) {
205 ieee80211_debugfs_key_remove(sta->key);
206 ieee80211_key_free(sta->key);
207 sta->key = NULL;
208 }
209
210 rate_control_remove_sta_debugfs(sta);
211 ieee80211_sta_debugfs_remove(sta);
212
213 sta_info_put(sta);
214}
215
216static void sta_info_remove(struct sta_info *sta)
217{
218 struct ieee80211_local *local = sta->local;
219 struct ieee80211_sub_if_data *sdata;
220
221 sta_info_hash_del(local, sta);
222 list_del(&sta->list);
223 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
224 if (sta->flags & WLAN_STA_PS) {
225 sta->flags &= ~WLAN_STA_PS;
226 if (sdata->bss)
227 atomic_dec(&sdata->bss->num_sta_ps);
228 }
229 local->num_sta--;
230 sta_info_remove_aid_ptr(sta);
231}
232
233void sta_info_free(struct sta_info *sta, int locked)
234{
235 struct sk_buff *skb;
236 struct ieee80211_local *local = sta->local;
237
238 if (!locked) {
239 spin_lock_bh(&local->sta_lock);
240 sta_info_remove(sta);
241 spin_unlock_bh(&local->sta_lock);
242 } else {
243 sta_info_remove(sta);
244 }
245 if (local->ops->sta_table_notification)
246 local->ops->sta_table_notification(local_to_hw(local),
247 local->num_sta);
248
249 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
250 local->total_ps_buffered--;
251 dev_kfree_skb_any(skb);
252 }
253 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
254 dev_kfree_skb_any(skb);
255 }
256
257 if (sta->key) {
258 if (local->ops->set_key) {
259 struct ieee80211_key_conf *key;
260 key = ieee80211_key_data2conf(local, sta->key);
261 if (key) {
262 local->ops->set_key(local_to_hw(local),
263 DISABLE_KEY,
264 sta->addr, key, sta->aid);
265 kfree(key);
266 }
267 }
268 } else if (sta->key_idx_compression != HW_KEY_IDX_INVALID) {
269 struct ieee80211_key_conf conf;
270 memset(&conf, 0, sizeof(conf));
271 conf.hw_key_idx = sta->key_idx_compression;
272 conf.alg = ALG_NULL;
273 conf.flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT;
274 local->ops->set_key(local_to_hw(local), DISABLE_KEY,
275 sta->addr, &conf, sta->aid);
276 sta->key_idx_compression = HW_KEY_IDX_INVALID;
277 }
278
279#ifdef CONFIG_MAC80211_DEBUGFS
280 if (in_atomic()) {
281 list_add(&sta->list, &local->deleted_sta_list);
282 queue_work(local->hw.workqueue, &local->sta_debugfs_add);
283 } else
284#endif
285 finish_sta_info_free(local, sta);
286}
287
288
289static inline int sta_info_buffer_expired(struct ieee80211_local *local,
290 struct sta_info *sta,
291 struct sk_buff *skb)
292{
293 struct ieee80211_tx_packet_data *pkt_data;
294 int timeout;
295
296 if (!skb)
297 return 0;
298
299 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
300
301 /* Timeout: (2 * listen_interval * beacon_int * 1024 / 1000000) sec */
302 timeout = (sta->listen_interval * local->hw.conf.beacon_int * 32 /
303 15625) * HZ;
304 if (timeout < STA_TX_BUFFER_EXPIRE)
305 timeout = STA_TX_BUFFER_EXPIRE;
306 return time_after(jiffies, pkt_data->jiffies + timeout);
307}
308
309
310static void sta_info_cleanup_expire_buffered(struct ieee80211_local *local,
311 struct sta_info *sta)
312{
313 unsigned long flags;
314 struct sk_buff *skb;
315
316 if (skb_queue_empty(&sta->ps_tx_buf))
317 return;
318
319 for (;;) {
320 spin_lock_irqsave(&sta->ps_tx_buf.lock, flags);
321 skb = skb_peek(&sta->ps_tx_buf);
322 if (sta_info_buffer_expired(local, sta, skb)) {
323 skb = __skb_dequeue(&sta->ps_tx_buf);
324 if (skb_queue_empty(&sta->ps_tx_buf))
325 sta->flags &= ~WLAN_STA_TIM;
326 } else
327 skb = NULL;
328 spin_unlock_irqrestore(&sta->ps_tx_buf.lock, flags);
329
330 if (skb) {
331 local->total_ps_buffered--;
332 printk(KERN_DEBUG "Buffered frame expired (STA "
333 MAC_FMT ")\n", MAC_ARG(sta->addr));
334 dev_kfree_skb(skb);
335 } else
336 break;
337 }
338}
339
340
341static void sta_info_cleanup(unsigned long data)
342{
343 struct ieee80211_local *local = (struct ieee80211_local *) data;
344 struct sta_info *sta;
345
346 spin_lock_bh(&local->sta_lock);
347 list_for_each_entry(sta, &local->sta_list, list) {
348 __sta_info_get(sta);
349 sta_info_cleanup_expire_buffered(local, sta);
350 sta_info_put(sta);
351 }
352 spin_unlock_bh(&local->sta_lock);
353
354 local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL;
355 add_timer(&local->sta_cleanup);
356}
357
358#ifdef CONFIG_MAC80211_DEBUGFS
359static void sta_info_debugfs_add_task(struct work_struct *work)
360{
361 struct ieee80211_local *local =
362 container_of(work, struct ieee80211_local, sta_debugfs_add);
363 struct sta_info *sta, *tmp;
364
365 while (1) {
366 spin_lock_bh(&local->sta_lock);
367 if (!list_empty(&local->deleted_sta_list)) {
368 sta = list_entry(local->deleted_sta_list.next,
369 struct sta_info, list);
370 list_del(local->deleted_sta_list.next);
371 } else
372 sta = NULL;
373 spin_unlock_bh(&local->sta_lock);
374 if (!sta)
375 break;
376 finish_sta_info_free(local, sta);
377 }
378
379 while (1) {
380 sta = NULL;
381 spin_lock_bh(&local->sta_lock);
382 list_for_each_entry(tmp, &local->sta_list, list) {
383 if (!tmp->debugfs_registered) {
384 sta = tmp;
385 __sta_info_get(sta);
386 break;
387 }
388 }
389 spin_unlock_bh(&local->sta_lock);
390
391 if (!sta)
392 break;
393
394 sta->debugfs_registered = 1;
395 ieee80211_sta_debugfs_add(sta);
396 rate_control_add_sta_debugfs(sta);
397 sta_info_put(sta);
398 }
399}
400#endif
401
402void sta_info_init(struct ieee80211_local *local)
403{
404 spin_lock_init(&local->sta_lock);
405 INIT_LIST_HEAD(&local->sta_list);
406 INIT_LIST_HEAD(&local->deleted_sta_list);
407
408 init_timer(&local->sta_cleanup);
409 local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL;
410 local->sta_cleanup.data = (unsigned long) local;
411 local->sta_cleanup.function = sta_info_cleanup;
412
413#ifdef CONFIG_MAC80211_DEBUGFS
414 INIT_WORK(&local->sta_debugfs_add, sta_info_debugfs_add_task);
415#endif
416}
417
418int sta_info_start(struct ieee80211_local *local)
419{
420 add_timer(&local->sta_cleanup);
421 return 0;
422}
423
424void sta_info_stop(struct ieee80211_local *local)
425{
426 struct sta_info *sta, *tmp;
427
428 del_timer(&local->sta_cleanup);
429
430 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
431 /* sta_info_free must be called with 0 as the last
432 * parameter to ensure all debugfs sta entries are
433 * unregistered. We don't need locking at this
434 * point. */
435 sta_info_free(sta, 0);
436 }
437}
438
439void sta_info_remove_aid_ptr(struct sta_info *sta)
440{
441 struct ieee80211_sub_if_data *sdata;
442
443 if (sta->aid <= 0)
444 return;
445
446 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
447
448 if (sdata->local->ops->set_tim)
449 sdata->local->ops->set_tim(local_to_hw(sdata->local),
450 sta->aid, 0);
451 if (sdata->bss)
452 __bss_tim_clear(sdata->bss, sta->aid);
453}
454
455
456/**
457 * sta_info_flush - flush matching STA entries from the STA table
458 * @local: local interface data
459 * @dev: matching rule for the net device (sta->dev) or %NULL to match all STAs
460 */
461void sta_info_flush(struct ieee80211_local *local, struct net_device *dev)
462{
463 struct sta_info *sta, *tmp;
464
465 spin_lock_bh(&local->sta_lock);
466 list_for_each_entry_safe(sta, tmp, &local->sta_list, list)
467 if (!dev || dev == sta->dev)
468 sta_info_free(sta, 1);
469 spin_unlock_bh(&local->sta_lock);
470}
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
new file mode 100644
index 000000000000..b5591d2f60a4
--- /dev/null
+++ b/net/mac80211/sta_info.h
@@ -0,0 +1,164 @@
1/*
2 * Copyright 2002-2005, Devicescape Software, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef STA_INFO_H
10#define STA_INFO_H
11
12#include <linux/list.h>
13#include <linux/types.h>
14#include <linux/if_ether.h>
15#include <linux/kref.h>
16#include "ieee80211_key.h"
17
18/* Stations flags (struct sta_info::flags) */
19#define WLAN_STA_AUTH BIT(0)
20#define WLAN_STA_ASSOC BIT(1)
21#define WLAN_STA_PS BIT(2)
22#define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */
23#define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */
24#define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is
25 * controlling whether STA is authorized to
26 * send and receive non-IEEE 802.1X frames
27 */
28#define WLAN_STA_SHORT_PREAMBLE BIT(7)
29#define WLAN_STA_WME BIT(9)
30#define WLAN_STA_WDS BIT(27)
31
32
33struct sta_info {
34 struct kref kref;
35 struct list_head list;
36 struct sta_info *hnext; /* next entry in hash table list */
37
38 struct ieee80211_local *local;
39
40 u8 addr[ETH_ALEN];
41 u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */
42 u32 flags; /* WLAN_STA_ */
43
44 struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in
45 * power saving state */
46 int pspoll; /* whether STA has send a PS Poll frame */
47 struct sk_buff_head tx_filtered; /* buffer of TX frames that were
48 * already given to low-level driver,
49 * but were filtered */
50 int clear_dst_mask;
51
52 unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */
53 unsigned long rx_bytes, tx_bytes;
54 unsigned long tx_retry_failed, tx_retry_count;
55 unsigned long tx_filtered_count;
56
57 unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */
58
59 unsigned long last_rx;
60 u32 supp_rates; /* bitmap of supported rates in local->curr_rates */
61 int txrate; /* index in local->curr_rates */
62 int last_txrate; /* last rate used to send a frame to this STA */
63 int last_nonerp_idx;
64
65 struct net_device *dev; /* which net device is this station associated
66 * to */
67
68 struct ieee80211_key *key;
69
70 u32 tx_num_consecutive_failures;
71 u32 tx_num_mpdu_ok;
72 u32 tx_num_mpdu_fail;
73
74 struct rate_control_ref *rate_ctrl;
75 void *rate_ctrl_priv;
76
77 /* last received seq/frag number from this STA (per RX queue) */
78 __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES];
79 unsigned long num_duplicates; /* number of duplicate frames received
80 * from this STA */
81 unsigned long tx_fragments; /* number of transmitted MPDUs */
82 unsigned long rx_fragments; /* number of received MPDUs */
83 unsigned long rx_dropped; /* number of dropped MPDUs from this STA */
84
85 int last_rssi; /* RSSI of last received frame from this STA */
86 int last_signal; /* signal of last received frame from this STA */
87 int last_noise; /* noise of last received frame from this STA */
88 int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */
89 unsigned long last_ack;
90 int channel_use;
91 int channel_use_raw;
92
93 u8 antenna_sel_tx;
94 u8 antenna_sel_rx;
95
96
97 int key_idx_compression; /* key table index for compression and TX
98 * filtering; used only if sta->key is not
99 * set */
100
101#ifdef CONFIG_MAC80211_DEBUGFS
102 int debugfs_registered;
103#endif
104 int assoc_ap; /* whether this is an AP that we are
105 * associated with as a client */
106
107#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
108 unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
109 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
110#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
111
112 int vlan_id;
113
114 u16 listen_interval;
115
116#ifdef CONFIG_MAC80211_DEBUGFS
117 struct sta_info_debugfsdentries {
118 struct dentry *dir;
119 struct dentry *flags;
120 struct dentry *num_ps_buf_frames;
121 struct dentry *last_ack_rssi;
122 struct dentry *last_ack_ms;
123 struct dentry *inactive_ms;
124 struct dentry *last_seq_ctrl;
125#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
126 struct dentry *wme_rx_queue;
127 struct dentry *wme_tx_queue;
128#endif
129 } debugfs;
130#endif
131};
132
133
134/* Maximum number of concurrently registered stations */
135#define MAX_STA_COUNT 2007
136
137#define STA_HASH_SIZE 256
138#define STA_HASH(sta) (sta[5])
139
140
141/* Maximum number of frames to buffer per power saving station */
142#define STA_MAX_TX_BUFFER 128
143
144/* Minimum buffered frame expiry time. If STA uses listen interval that is
145 * smaller than this value, the minimum value here is used instead. */
146#define STA_TX_BUFFER_EXPIRE (10 * HZ)
147
148/* How often station data is cleaned up (e.g., expiration of buffered frames)
149 */
150#define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
151
152struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
153int sta_info_min_txrate_get(struct ieee80211_local *local);
154void sta_info_put(struct sta_info *sta);
155struct sta_info * sta_info_add(struct ieee80211_local *local,
156 struct net_device *dev, u8 *addr, gfp_t gfp);
157void sta_info_free(struct sta_info *sta, int locked);
158void sta_info_init(struct ieee80211_local *local);
159int sta_info_start(struct ieee80211_local *local);
160void sta_info_stop(struct ieee80211_local *local);
161void sta_info_remove_aid_ptr(struct sta_info *sta);
162void sta_info_flush(struct ieee80211_local *local, struct net_device *dev);
163
164#endif /* STA_INFO_H */
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c
new file mode 100644
index 000000000000..41621720e560
--- /dev/null
+++ b/net/mac80211/tkip.c
@@ -0,0 +1,341 @@
1/*
2 * Copyright 2002-2004, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/kernel.h>
11#include <linux/types.h>
12#include <linux/netdevice.h>
13
14#include <net/mac80211.h>
15#include "ieee80211_key.h"
16#include "tkip.h"
17#include "wep.h"
18
19
20/* TKIP key mixing functions */
21
22
23#define PHASE1_LOOP_COUNT 8
24
25
26/* 2-byte by 2-byte subset of the full AES S-box table; second part of this
27 * table is identical to first part but byte-swapped */
28static const u16 tkip_sbox[256] =
29{
30 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
31 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
32 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
33 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
34 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
35 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
36 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
37 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
38 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
39 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
40 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
41 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
42 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
43 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
44 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
45 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
46 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
47 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
48 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
49 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
50 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
51 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
52 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
53 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
54 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
55 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
56 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
57 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
58 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
59 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
60 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
61 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
62};
63
64
65static inline u16 Mk16(u8 x, u8 y)
66{
67 return ((u16) x << 8) | (u16) y;
68}
69
70
71static inline u8 Hi8(u16 v)
72{
73 return v >> 8;
74}
75
76
77static inline u8 Lo8(u16 v)
78{
79 return v & 0xff;
80}
81
82
83static inline u16 Hi16(u32 v)
84{
85 return v >> 16;
86}
87
88
89static inline u16 Lo16(u32 v)
90{
91 return v & 0xffff;
92}
93
94
95static inline u16 RotR1(u16 v)
96{
97 return (v >> 1) | ((v & 0x0001) << 15);
98}
99
100
101static inline u16 tkip_S(u16 val)
102{
103 u16 a = tkip_sbox[Hi8(val)];
104
105 return tkip_sbox[Lo8(val)] ^ Hi8(a) ^ (Lo8(a) << 8);
106}
107
108
109
110/* P1K := Phase1(TA, TK, TSC)
111 * TA = transmitter address (48 bits)
112 * TK = dot11DefaultKeyValue or dot11KeyMappingValue (128 bits)
113 * TSC = TKIP sequence counter (48 bits, only 32 msb bits used)
114 * P1K: 80 bits
115 */
116static void tkip_mixing_phase1(const u8 *ta, const u8 *tk, u32 tsc_IV32,
117 u16 *p1k)
118{
119 int i, j;
120
121 p1k[0] = Lo16(tsc_IV32);
122 p1k[1] = Hi16(tsc_IV32);
123 p1k[2] = Mk16(ta[1], ta[0]);
124 p1k[3] = Mk16(ta[3], ta[2]);
125 p1k[4] = Mk16(ta[5], ta[4]);
126
127 for (i = 0; i < PHASE1_LOOP_COUNT; i++) {
128 j = 2 * (i & 1);
129 p1k[0] += tkip_S(p1k[4] ^ Mk16(tk[ 1 + j], tk[ 0 + j]));
130 p1k[1] += tkip_S(p1k[0] ^ Mk16(tk[ 5 + j], tk[ 4 + j]));
131 p1k[2] += tkip_S(p1k[1] ^ Mk16(tk[ 9 + j], tk[ 8 + j]));
132 p1k[3] += tkip_S(p1k[2] ^ Mk16(tk[13 + j], tk[12 + j]));
133 p1k[4] += tkip_S(p1k[3] ^ Mk16(tk[ 1 + j], tk[ 0 + j])) + i;
134 }
135}
136
137
138static void tkip_mixing_phase2(const u16 *p1k, const u8 *tk, u16 tsc_IV16,
139 u8 *rc4key)
140{
141 u16 ppk[6];
142 int i;
143
144 ppk[0] = p1k[0];
145 ppk[1] = p1k[1];
146 ppk[2] = p1k[2];
147 ppk[3] = p1k[3];
148 ppk[4] = p1k[4];
149 ppk[5] = p1k[4] + tsc_IV16;
150
151 ppk[0] += tkip_S(ppk[5] ^ Mk16(tk[ 1], tk[ 0]));
152 ppk[1] += tkip_S(ppk[0] ^ Mk16(tk[ 3], tk[ 2]));
153 ppk[2] += tkip_S(ppk[1] ^ Mk16(tk[ 5], tk[ 4]));
154 ppk[3] += tkip_S(ppk[2] ^ Mk16(tk[ 7], tk[ 6]));
155 ppk[4] += tkip_S(ppk[3] ^ Mk16(tk[ 9], tk[ 8]));
156 ppk[5] += tkip_S(ppk[4] ^ Mk16(tk[11], tk[10]));
157 ppk[0] += RotR1(ppk[5] ^ Mk16(tk[13], tk[12]));
158 ppk[1] += RotR1(ppk[0] ^ Mk16(tk[15], tk[14]));
159 ppk[2] += RotR1(ppk[1]);
160 ppk[3] += RotR1(ppk[2]);
161 ppk[4] += RotR1(ppk[3]);
162 ppk[5] += RotR1(ppk[4]);
163
164 rc4key[0] = Hi8(tsc_IV16);
165 rc4key[1] = (Hi8(tsc_IV16) | 0x20) & 0x7f;
166 rc4key[2] = Lo8(tsc_IV16);
167 rc4key[3] = Lo8((ppk[5] ^ Mk16(tk[1], tk[0])) >> 1);
168
169 for (i = 0; i < 6; i++) {
170 rc4key[4 + 2 * i] = Lo8(ppk[i]);
171 rc4key[5 + 2 * i] = Hi8(ppk[i]);
172 }
173}
174
175
176/* Add TKIP IV and Ext. IV at @pos. @iv0, @iv1, and @iv2 are the first octets
177 * of the IV. Returns pointer to the octet following IVs (i.e., beginning of
178 * the packet payload). */
179u8 * ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key,
180 u8 iv0, u8 iv1, u8 iv2)
181{
182 *pos++ = iv0;
183 *pos++ = iv1;
184 *pos++ = iv2;
185 *pos++ = (key->keyidx << 6) | (1 << 5) /* Ext IV */;
186 *pos++ = key->u.tkip.iv32 & 0xff;
187 *pos++ = (key->u.tkip.iv32 >> 8) & 0xff;
188 *pos++ = (key->u.tkip.iv32 >> 16) & 0xff;
189 *pos++ = (key->u.tkip.iv32 >> 24) & 0xff;
190 return pos;
191}
192
193
194void ieee80211_tkip_gen_phase1key(struct ieee80211_key *key, u8 *ta,
195 u16 *phase1key)
196{
197 tkip_mixing_phase1(ta, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
198 key->u.tkip.iv32, phase1key);
199}
200
201void ieee80211_tkip_gen_rc4key(struct ieee80211_key *key, u8 *ta,
202 u8 *rc4key)
203{
204 /* Calculate per-packet key */
205 if (key->u.tkip.iv16 == 0 || !key->u.tkip.tx_initialized) {
206 /* IV16 wrapped around - perform TKIP phase 1 */
207 tkip_mixing_phase1(ta, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
208 key->u.tkip.iv32, key->u.tkip.p1k);
209 key->u.tkip.tx_initialized = 1;
210 }
211
212 tkip_mixing_phase2(key->u.tkip.p1k, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
213 key->u.tkip.iv16, rc4key);
214}
215
216/* Encrypt packet payload with TKIP using @key. @pos is a pointer to the
217 * beginning of the buffer containing payload. This payload must include
218 * headroom of eight octets for IV and Ext. IV and taildroom of four octets
219 * for ICV. @payload_len is the length of payload (_not_ including extra
220 * headroom and tailroom). @ta is the transmitter addresses. */
221void ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm,
222 struct ieee80211_key *key,
223 u8 *pos, size_t payload_len, u8 *ta)
224{
225 u8 rc4key[16];
226
227 ieee80211_tkip_gen_rc4key(key, ta, rc4key);
228 pos = ieee80211_tkip_add_iv(pos, key, rc4key[0], rc4key[1], rc4key[2]);
229 ieee80211_wep_encrypt_data(tfm, rc4key, 16, pos, payload_len);
230}
231
232
233/* Decrypt packet payload with TKIP using @key. @pos is a pointer to the
234 * beginning of the buffer containing IEEE 802.11 header payload, i.e.,
235 * including IV, Ext. IV, real data, Michael MIC, ICV. @payload_len is the
236 * length of payload, including IV, Ext. IV, MIC, ICV. */
237int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
238 struct ieee80211_key *key,
239 u8 *payload, size_t payload_len, u8 *ta,
240 int only_iv, int queue)
241{
242 u32 iv32;
243 u32 iv16;
244 u8 rc4key[16], keyid, *pos = payload;
245 int res;
246
247 if (payload_len < 12)
248 return -1;
249
250 iv16 = (pos[0] << 8) | pos[2];
251 keyid = pos[3];
252 iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
253 pos += 8;
254#ifdef CONFIG_TKIP_DEBUG
255 {
256 int i;
257 printk(KERN_DEBUG "TKIP decrypt: data(len=%zd)", payload_len);
258 for (i = 0; i < payload_len; i++)
259 printk(" %02x", payload[i]);
260 printk("\n");
261 printk(KERN_DEBUG "TKIP decrypt: iv16=%04x iv32=%08x\n",
262 iv16, iv32);
263 }
264#endif /* CONFIG_TKIP_DEBUG */
265
266 if (!(keyid & (1 << 5)))
267 return TKIP_DECRYPT_NO_EXT_IV;
268
269 if ((keyid >> 6) != key->keyidx)
270 return TKIP_DECRYPT_INVALID_KEYIDX;
271
272 if (key->u.tkip.rx_initialized[queue] &&
273 (iv32 < key->u.tkip.iv32_rx[queue] ||
274 (iv32 == key->u.tkip.iv32_rx[queue] &&
275 iv16 <= key->u.tkip.iv16_rx[queue]))) {
276#ifdef CONFIG_TKIP_DEBUG
277 printk(KERN_DEBUG "TKIP replay detected for RX frame from "
278 MAC_FMT " (RX IV (%04x,%02x) <= prev. IV (%04x,%02x)\n",
279 MAC_ARG(ta),
280 iv32, iv16, key->u.tkip.iv32_rx[queue],
281 key->u.tkip.iv16_rx[queue]);
282#endif /* CONFIG_TKIP_DEBUG */
283 return TKIP_DECRYPT_REPLAY;
284 }
285
286 if (only_iv) {
287 res = TKIP_DECRYPT_OK;
288 key->u.tkip.rx_initialized[queue] = 1;
289 goto done;
290 }
291
292 if (!key->u.tkip.rx_initialized[queue] ||
293 key->u.tkip.iv32_rx[queue] != iv32) {
294 key->u.tkip.rx_initialized[queue] = 1;
295 /* IV16 wrapped around - perform TKIP phase 1 */
296 tkip_mixing_phase1(ta, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
297 iv32, key->u.tkip.p1k_rx[queue]);
298#ifdef CONFIG_TKIP_DEBUG
299 {
300 int i;
301 printk(KERN_DEBUG "TKIP decrypt: Phase1 TA=" MAC_FMT
302 " TK=", MAC_ARG(ta));
303 for (i = 0; i < 16; i++)
304 printk("%02x ",
305 key->key[ALG_TKIP_TEMP_ENCR_KEY + i]);
306 printk("\n");
307 printk(KERN_DEBUG "TKIP decrypt: P1K=");
308 for (i = 0; i < 5; i++)
309 printk("%04x ", key->u.tkip.p1k_rx[queue][i]);
310 printk("\n");
311 }
312#endif /* CONFIG_TKIP_DEBUG */
313 }
314
315 tkip_mixing_phase2(key->u.tkip.p1k_rx[queue],
316 &key->key[ALG_TKIP_TEMP_ENCR_KEY],
317 iv16, rc4key);
318#ifdef CONFIG_TKIP_DEBUG
319 {
320 int i;
321 printk(KERN_DEBUG "TKIP decrypt: Phase2 rc4key=");
322 for (i = 0; i < 16; i++)
323 printk("%02x ", rc4key[i]);
324 printk("\n");
325 }
326#endif /* CONFIG_TKIP_DEBUG */
327
328 res = ieee80211_wep_decrypt_data(tfm, rc4key, 16, pos, payload_len - 12);
329 done:
330 if (res == TKIP_DECRYPT_OK) {
331 /* FIX: these should be updated only after Michael MIC has been
332 * verified */
333 /* Record previously received IV */
334 key->u.tkip.iv32_rx[queue] = iv32;
335 key->u.tkip.iv16_rx[queue] = iv16;
336 }
337
338 return res;
339}
340
341
diff --git a/net/mac80211/tkip.h b/net/mac80211/tkip.h
new file mode 100644
index 000000000000..a0d181a18049
--- /dev/null
+++ b/net/mac80211/tkip.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2002-2004, Instant802 Networks, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef TKIP_H
10#define TKIP_H
11
12#include <linux/types.h>
13#include <linux/crypto.h>
14#include "ieee80211_key.h"
15
16u8 * ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key,
17 u8 iv0, u8 iv1, u8 iv2);
18void ieee80211_tkip_gen_phase1key(struct ieee80211_key *key, u8 *ta,
19 u16 *phase1key);
20void ieee80211_tkip_gen_rc4key(struct ieee80211_key *key, u8 *ta,
21 u8 *rc4key);
22void ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm,
23 struct ieee80211_key *key,
24 u8 *pos, size_t payload_len, u8 *ta);
25enum {
26 TKIP_DECRYPT_OK = 0,
27 TKIP_DECRYPT_NO_EXT_IV = -1,
28 TKIP_DECRYPT_INVALID_KEYIDX = -2,
29 TKIP_DECRYPT_REPLAY = -3,
30};
31int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
32 struct ieee80211_key *key,
33 u8 *payload, size_t payload_len, u8 *ta,
34 int only_iv, int queue);
35
36#endif /* TKIP_H */
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
new file mode 100644
index 000000000000..1ad3d75281cc
--- /dev/null
+++ b/net/mac80211/wep.c
@@ -0,0 +1,328 @@
1/*
2 * Software WEP encryption implementation
3 * Copyright 2002, Jouni Malinen <jkmaline@cc.hut.fi>
4 * Copyright 2003, Instant802 Networks, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/netdevice.h>
12#include <linux/types.h>
13#include <linux/random.h>
14#include <linux/compiler.h>
15#include <linux/crc32.h>
16#include <linux/crypto.h>
17#include <linux/err.h>
18#include <linux/mm.h>
19#include <asm/scatterlist.h>
20
21#include <net/mac80211.h>
22#include "ieee80211_i.h"
23#include "wep.h"
24
25
26int ieee80211_wep_init(struct ieee80211_local *local)
27{
28 /* start WEP IV from a random value */
29 get_random_bytes(&local->wep_iv, WEP_IV_LEN);
30
31 local->wep_tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0,
32 CRYPTO_ALG_ASYNC);
33 if (IS_ERR(local->wep_tx_tfm))
34 return -ENOMEM;
35
36 local->wep_rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0,
37 CRYPTO_ALG_ASYNC);
38 if (IS_ERR(local->wep_rx_tfm)) {
39 crypto_free_blkcipher(local->wep_tx_tfm);
40 return -ENOMEM;
41 }
42
43 return 0;
44}
45
46void ieee80211_wep_free(struct ieee80211_local *local)
47{
48 crypto_free_blkcipher(local->wep_tx_tfm);
49 crypto_free_blkcipher(local->wep_rx_tfm);
50}
51
52static inline int ieee80211_wep_weak_iv(u32 iv, int keylen)
53{
54 /* Fluhrer, Mantin, and Shamir have reported weaknesses in the
55 * key scheduling algorithm of RC4. At least IVs (KeyByte + 3,
56 * 0xff, N) can be used to speedup attacks, so avoid using them. */
57 if ((iv & 0xff00) == 0xff00) {
58 u8 B = (iv >> 16) & 0xff;
59 if (B >= 3 && B < 3 + keylen)
60 return 1;
61 }
62 return 0;
63}
64
65
66void ieee80211_wep_get_iv(struct ieee80211_local *local,
67 struct ieee80211_key *key, u8 *iv)
68{
69 local->wep_iv++;
70 if (ieee80211_wep_weak_iv(local->wep_iv, key->keylen))
71 local->wep_iv += 0x0100;
72
73 if (!iv)
74 return;
75
76 *iv++ = (local->wep_iv >> 16) & 0xff;
77 *iv++ = (local->wep_iv >> 8) & 0xff;
78 *iv++ = local->wep_iv & 0xff;
79 *iv++ = key->keyidx << 6;
80}
81
82
83u8 * ieee80211_wep_add_iv(struct ieee80211_local *local,
84 struct sk_buff *skb,
85 struct ieee80211_key *key)
86{
87 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
88 u16 fc;
89 int hdrlen;
90 u8 *newhdr;
91
92 fc = le16_to_cpu(hdr->frame_control);
93 fc |= IEEE80211_FCTL_PROTECTED;
94 hdr->frame_control = cpu_to_le16(fc);
95
96 if ((skb_headroom(skb) < WEP_IV_LEN ||
97 skb_tailroom(skb) < WEP_ICV_LEN)) {
98 I802_DEBUG_INC(local->tx_expand_skb_head);
99 if (unlikely(pskb_expand_head(skb, WEP_IV_LEN, WEP_ICV_LEN,
100 GFP_ATOMIC)))
101 return NULL;
102 }
103
104 hdrlen = ieee80211_get_hdrlen(fc);
105 newhdr = skb_push(skb, WEP_IV_LEN);
106 memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen);
107 ieee80211_wep_get_iv(local, key, newhdr + hdrlen);
108 return newhdr + hdrlen;
109}
110
111
112void ieee80211_wep_remove_iv(struct ieee80211_local *local,
113 struct sk_buff *skb,
114 struct ieee80211_key *key)
115{
116 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
117 u16 fc;
118 int hdrlen;
119
120 fc = le16_to_cpu(hdr->frame_control);
121 hdrlen = ieee80211_get_hdrlen(fc);
122 memmove(skb->data + WEP_IV_LEN, skb->data, hdrlen);
123 skb_pull(skb, WEP_IV_LEN);
124}
125
126
127/* Perform WEP encryption using given key. data buffer must have tailroom
128 * for 4-byte ICV. data_len must not include this ICV. Note: this function
129 * does _not_ add IV. data = RC4(data | CRC32(data)) */
130void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
131 size_t klen, u8 *data, size_t data_len)
132{
133 struct blkcipher_desc desc = { .tfm = tfm };
134 struct scatterlist sg;
135 __le32 *icv;
136
137 icv = (__le32 *)(data + data_len);
138 *icv = cpu_to_le32(~crc32_le(~0, data, data_len));
139
140 crypto_blkcipher_setkey(tfm, rc4key, klen);
141 sg.page = virt_to_page(data);
142 sg.offset = offset_in_page(data);
143 sg.length = data_len + WEP_ICV_LEN;
144 crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length);
145}
146
147
148/* Perform WEP encryption on given skb. 4 bytes of extra space (IV) in the
149 * beginning of the buffer 4 bytes of extra space (ICV) in the end of the
150 * buffer will be added. Both IV and ICV will be transmitted, so the
151 * payload length increases with 8 bytes.
152 *
153 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
154 */
155int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
156 struct ieee80211_key *key)
157{
158 u32 klen;
159 u8 *rc4key, *iv;
160 size_t len;
161
162 if (!key || key->alg != ALG_WEP)
163 return -1;
164
165 klen = 3 + key->keylen;
166 rc4key = kmalloc(klen, GFP_ATOMIC);
167 if (!rc4key)
168 return -1;
169
170 iv = ieee80211_wep_add_iv(local, skb, key);
171 if (!iv) {
172 kfree(rc4key);
173 return -1;
174 }
175
176 len = skb->len - (iv + WEP_IV_LEN - skb->data);
177
178 /* Prepend 24-bit IV to RC4 key */
179 memcpy(rc4key, iv, 3);
180
181 /* Copy rest of the WEP key (the secret part) */
182 memcpy(rc4key + 3, key->key, key->keylen);
183
184 /* Add room for ICV */
185 skb_put(skb, WEP_ICV_LEN);
186
187 ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, klen,
188 iv + WEP_IV_LEN, len);
189
190 kfree(rc4key);
191
192 return 0;
193}
194
195
196/* Perform WEP decryption using given key. data buffer includes encrypted
197 * payload, including 4-byte ICV, but _not_ IV. data_len must not include ICV.
198 * Return 0 on success and -1 on ICV mismatch. */
199int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
200 size_t klen, u8 *data, size_t data_len)
201{
202 struct blkcipher_desc desc = { .tfm = tfm };
203 struct scatterlist sg;
204 __le32 crc;
205
206 crypto_blkcipher_setkey(tfm, rc4key, klen);
207 sg.page = virt_to_page(data);
208 sg.offset = offset_in_page(data);
209 sg.length = data_len + WEP_ICV_LEN;
210 crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length);
211
212 crc = cpu_to_le32(~crc32_le(~0, data, data_len));
213 if (memcmp(&crc, data + data_len, WEP_ICV_LEN) != 0)
214 /* ICV mismatch */
215 return -1;
216
217 return 0;
218}
219
220
221/* Perform WEP decryption on given skb. Buffer includes whole WEP part of
222 * the frame: IV (4 bytes), encrypted payload (including SNAP header),
223 * ICV (4 bytes). skb->len includes both IV and ICV.
224 *
225 * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
226 * failure. If frame is OK, IV and ICV will be removed, i.e., decrypted payload
227 * is moved to the beginning of the skb and skb length will be reduced.
228 */
229int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
230 struct ieee80211_key *key)
231{
232 u32 klen;
233 u8 *rc4key;
234 u8 keyidx;
235 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
236 u16 fc;
237 int hdrlen;
238 size_t len;
239 int ret = 0;
240
241 fc = le16_to_cpu(hdr->frame_control);
242 if (!(fc & IEEE80211_FCTL_PROTECTED))
243 return -1;
244
245 hdrlen = ieee80211_get_hdrlen(fc);
246
247 if (skb->len < 8 + hdrlen)
248 return -1;
249
250 len = skb->len - hdrlen - 8;
251
252 keyidx = skb->data[hdrlen + 3] >> 6;
253
254 if (!key || keyidx != key->keyidx || key->alg != ALG_WEP)
255 return -1;
256
257 klen = 3 + key->keylen;
258
259 rc4key = kmalloc(klen, GFP_ATOMIC);
260 if (!rc4key)
261 return -1;
262
263 /* Prepend 24-bit IV to RC4 key */
264 memcpy(rc4key, skb->data + hdrlen, 3);
265
266 /* Copy rest of the WEP key (the secret part) */
267 memcpy(rc4key + 3, key->key, key->keylen);
268
269 if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen,
270 skb->data + hdrlen + WEP_IV_LEN,
271 len)) {
272 printk(KERN_DEBUG "WEP decrypt failed (ICV)\n");
273 ret = -1;
274 }
275
276 kfree(rc4key);
277
278 /* Trim ICV */
279 skb_trim(skb, skb->len - WEP_ICV_LEN);
280
281 /* Remove IV */
282 memmove(skb->data + WEP_IV_LEN, skb->data, hdrlen);
283 skb_pull(skb, WEP_IV_LEN);
284
285 return ret;
286}
287
288
289int ieee80211_wep_get_keyidx(struct sk_buff *skb)
290{
291 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
292 u16 fc;
293 int hdrlen;
294
295 fc = le16_to_cpu(hdr->frame_control);
296 if (!(fc & IEEE80211_FCTL_PROTECTED))
297 return -1;
298
299 hdrlen = ieee80211_get_hdrlen(fc);
300
301 if (skb->len < 8 + hdrlen)
302 return -1;
303
304 return skb->data[hdrlen + 3] >> 6;
305}
306
307
308u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
309{
310 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
311 u16 fc;
312 int hdrlen;
313 u8 *ivpos;
314 u32 iv;
315
316 fc = le16_to_cpu(hdr->frame_control);
317 if (!(fc & IEEE80211_FCTL_PROTECTED))
318 return NULL;
319
320 hdrlen = ieee80211_get_hdrlen(fc);
321 ivpos = skb->data + hdrlen;
322 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
323
324 if (ieee80211_wep_weak_iv(iv, key->keylen))
325 return ivpos;
326
327 return NULL;
328}
diff --git a/net/mac80211/wep.h b/net/mac80211/wep.h
new file mode 100644
index 000000000000..bfe29e8e10aa
--- /dev/null
+++ b/net/mac80211/wep.h
@@ -0,0 +1,40 @@
1/*
2 * Software WEP encryption implementation
3 * Copyright 2002, Jouni Malinen <jkmaline@cc.hut.fi>
4 * Copyright 2003, Instant802 Networks, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef WEP_H
12#define WEP_H
13
14#include <linux/skbuff.h>
15#include <linux/types.h>
16#include "ieee80211_i.h"
17#include "ieee80211_key.h"
18
19int ieee80211_wep_init(struct ieee80211_local *local);
20void ieee80211_wep_free(struct ieee80211_local *local);
21void ieee80211_wep_get_iv(struct ieee80211_local *local,
22 struct ieee80211_key *key, u8 *iv);
23u8 * ieee80211_wep_add_iv(struct ieee80211_local *local,
24 struct sk_buff *skb,
25 struct ieee80211_key *key);
26void ieee80211_wep_remove_iv(struct ieee80211_local *local,
27 struct sk_buff *skb,
28 struct ieee80211_key *key);
29void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
30 size_t klen, u8 *data, size_t data_len);
31int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
32 size_t klen, u8 *data, size_t data_len);
33int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
34 struct ieee80211_key *key);
35int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
36 struct ieee80211_key *key);
37int ieee80211_wep_get_keyidx(struct sk_buff *skb);
38u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
39
40#endif /* WEP_H */
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
new file mode 100644
index 000000000000..89ce81529694
--- /dev/null
+++ b/net/mac80211/wme.c
@@ -0,0 +1,678 @@
1/*
2 * Copyright 2004, Instant802 Networks, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/netdevice.h>
10#include <linux/skbuff.h>
11#include <linux/module.h>
12#include <linux/if_arp.h>
13#include <linux/types.h>
14#include <net/ip.h>
15#include <net/pkt_sched.h>
16
17#include <net/mac80211.h>
18#include "ieee80211_i.h"
19#include "wme.h"
20
21static inline int WLAN_FC_IS_QOS_DATA(u16 fc)
22{
23 return (fc & 0x8C) == 0x88;
24}
25
26
27ieee80211_txrx_result
28ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx)
29{
30 u8 *data = rx->skb->data;
31 int tid;
32
33 /* does the frame have a qos control field? */
34 if (WLAN_FC_IS_QOS_DATA(rx->fc)) {
35 u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN;
36 /* frame has qos control */
37 tid = qc[0] & QOS_CONTROL_TID_MASK;
38 } else {
39 if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) {
40 /* Separate TID for management frames */
41 tid = NUM_RX_DATA_QUEUES - 1;
42 } else {
43 /* no qos control present */
44 tid = 0; /* 802.1d - Best Effort */
45 }
46 }
47#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
48 I802_DEBUG_INC(rx->local->wme_rx_queue[tid]);
49 if (rx->sta) {
50 I802_DEBUG_INC(rx->sta->wme_rx_queue[tid]);
51 }
52#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
53
54 rx->u.rx.queue = tid;
55 /* Set skb->priority to 1d tag if highest order bit of TID is not set.
56 * For now, set skb->priority to 0 for other cases. */
57 rx->skb->priority = (tid > 7) ? 0 : tid;
58
59 return TXRX_CONTINUE;
60}
61
62
63ieee80211_txrx_result
64ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx)
65{
66 u16 fc = rx->fc;
67 u8 *data = rx->skb->data;
68 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data;
69
70 if (!WLAN_FC_IS_QOS_DATA(fc))
71 return TXRX_CONTINUE;
72
73 /* remove the qos control field, update frame type and meta-data */
74 memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2);
75 hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2);
76 /* change frame type to non QOS */
77 rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA;
78 hdr->frame_control = cpu_to_le16(fc);
79
80 return TXRX_CONTINUE;
81}
82
83
84#ifdef CONFIG_NET_SCHED
85/* maximum number of hardware queues we support. */
86#define TC_80211_MAX_QUEUES 8
87
88struct ieee80211_sched_data
89{
90 struct tcf_proto *filter_list;
91 struct Qdisc *queues[TC_80211_MAX_QUEUES];
92 struct sk_buff_head requeued[TC_80211_MAX_QUEUES];
93};
94
95
96/* given a data frame determine the 802.1p/1d tag to use */
97static inline unsigned classify_1d(struct sk_buff *skb, struct Qdisc *qd)
98{
99 struct iphdr *ip;
100 int dscp;
101 int offset;
102
103 struct ieee80211_sched_data *q = qdisc_priv(qd);
104 struct tcf_result res = { -1, 0 };
105
106 /* if there is a user set filter list, call out to that */
107 if (q->filter_list) {
108 tc_classify(skb, q->filter_list, &res);
109 if (res.class != -1)
110 return res.class;
111 }
112
113 /* skb->priority values from 256->263 are magic values to
114 * directly indicate a specific 802.1d priority.
115 * This is used to allow 802.1d priority to be passed directly in
116 * from VLAN tags, etc. */
117 if (skb->priority >= 256 && skb->priority <= 263)
118 return skb->priority - 256;
119
120 /* check there is a valid IP header present */
121 offset = ieee80211_get_hdrlen_from_skb(skb) + 8 /* LLC + proto */;
122 if (skb->protocol != __constant_htons(ETH_P_IP) ||
123 skb->len < offset + sizeof(*ip))
124 return 0;
125
126 ip = (struct iphdr *) (skb->data + offset);
127
128 dscp = ip->tos & 0xfc;
129 if (dscp & 0x1c)
130 return 0;
131 return dscp >> 5;
132}
133
134
135static inline int wme_downgrade_ac(struct sk_buff *skb)
136{
137 switch (skb->priority) {
138 case 6:
139 case 7:
140 skb->priority = 5; /* VO -> VI */
141 return 0;
142 case 4:
143 case 5:
144 skb->priority = 3; /* VI -> BE */
145 return 0;
146 case 0:
147 case 3:
148 skb->priority = 2; /* BE -> BK */
149 return 0;
150 default:
151 return -1;
152 }
153}
154
155
156/* positive return value indicates which queue to use
157 * negative return value indicates to drop the frame */
158static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
159{
160 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
161 struct ieee80211_tx_packet_data *pkt_data =
162 (struct ieee80211_tx_packet_data *) skb->cb;
163 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
164 unsigned short fc = le16_to_cpu(hdr->frame_control);
165 int qos;
166 const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
167
168 /* see if frame is data or non data frame */
169 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) {
170 /* management frames go on AC_VO queue, but are sent
171 * without QoS control fields */
172 return IEEE80211_TX_QUEUE_DATA0;
173 }
174
175 if (unlikely(pkt_data->mgmt_iface)) {
176 /* Data frames from hostapd (mainly, EAPOL) use AC_VO
177 * and they will include QoS control fields if
178 * the target STA is using WME. */
179 skb->priority = 7;
180 return ieee802_1d_to_ac[skb->priority];
181 }
182
183 /* is this a QoS frame? */
184 qos = fc & IEEE80211_STYPE_QOS_DATA;
185
186 if (!qos) {
187 skb->priority = 0; /* required for correct WPA/11i MIC */
188 return ieee802_1d_to_ac[skb->priority];
189 }
190
191 /* use the data classifier to determine what 802.1d tag the
192 * data frame has */
193 skb->priority = classify_1d(skb, qd);
194
195 /* incase we are a client verify acm is not set for this ac */
196 while (unlikely(local->wmm_acm & BIT(skb->priority))) {
197 if (wme_downgrade_ac(skb)) {
198 /* No AC with lower priority has acm=0,
199 * drop packet. */
200 return -1;
201 }
202 }
203
204 /* look up which queue to use for frames with this 1d tag */
205 return ieee802_1d_to_ac[skb->priority];
206}
207
208
209static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
210{
211 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
212 struct ieee80211_sched_data *q = qdisc_priv(qd);
213 struct ieee80211_tx_packet_data *pkt_data =
214 (struct ieee80211_tx_packet_data *) skb->cb;
215 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
216 unsigned short fc = le16_to_cpu(hdr->frame_control);
217 struct Qdisc *qdisc;
218 int err, queue;
219
220 if (pkt_data->requeue) {
221 skb_queue_tail(&q->requeued[pkt_data->queue], skb);
222 qd->q.qlen++;
223 return 0;
224 }
225
226 queue = classify80211(skb, qd);
227
228 /* now we know the 1d priority, fill in the QoS header if there is one
229 */
230 if (WLAN_FC_IS_QOS_DATA(fc)) {
231 u8 *p = skb->data + ieee80211_get_hdrlen(fc) - 2;
232 u8 qos_hdr = skb->priority & QOS_CONTROL_TAG1D_MASK;
233 if (local->wifi_wme_noack_test)
234 qos_hdr |= QOS_CONTROL_ACK_POLICY_NOACK <<
235 QOS_CONTROL_ACK_POLICY_SHIFT;
236 /* qos header is 2 bytes, second reserved */
237 *p = qos_hdr;
238 p++;
239 *p = 0;
240 }
241
242 if (unlikely(queue >= local->hw.queues)) {
243#if 0
244 if (net_ratelimit()) {
245 printk(KERN_DEBUG "%s - queue=%d (hw does not "
246 "support) -> %d\n",
247 __func__, queue, local->hw.queues - 1);
248 }
249#endif
250 queue = local->hw.queues - 1;
251 }
252
253 if (unlikely(queue < 0)) {
254 kfree_skb(skb);
255 err = NET_XMIT_DROP;
256 } else {
257 pkt_data->queue = (unsigned int) queue;
258 qdisc = q->queues[queue];
259 err = qdisc->enqueue(skb, qdisc);
260 if (err == NET_XMIT_SUCCESS) {
261 qd->q.qlen++;
262 qd->bstats.bytes += skb->len;
263 qd->bstats.packets++;
264 return NET_XMIT_SUCCESS;
265 }
266 }
267 qd->qstats.drops++;
268 return err;
269}
270
271
272/* TODO: clean up the cases where master_hard_start_xmit
273 * returns non 0 - it shouldn't ever do that. Once done we
274 * can remove this function */
275static int wme_qdiscop_requeue(struct sk_buff *skb, struct Qdisc* qd)
276{
277 struct ieee80211_sched_data *q = qdisc_priv(qd);
278 struct ieee80211_tx_packet_data *pkt_data =
279 (struct ieee80211_tx_packet_data *) skb->cb;
280 struct Qdisc *qdisc;
281 int err;
282
283 /* we recorded which queue to use earlier! */
284 qdisc = q->queues[pkt_data->queue];
285
286 if ((err = qdisc->ops->requeue(skb, qdisc)) == 0) {
287 qd->q.qlen++;
288 return 0;
289 }
290 qd->qstats.drops++;
291 return err;
292}
293
294
295static struct sk_buff *wme_qdiscop_dequeue(struct Qdisc* qd)
296{
297 struct ieee80211_sched_data *q = qdisc_priv(qd);
298 struct net_device *dev = qd->dev;
299 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
300 struct ieee80211_hw *hw = &local->hw;
301 struct sk_buff *skb;
302 struct Qdisc *qdisc;
303 int queue;
304
305 /* check all the h/w queues in numeric/priority order */
306 for (queue = 0; queue < hw->queues; queue++) {
307 /* see if there is room in this hardware queue */
308 if (test_bit(IEEE80211_LINK_STATE_XOFF,
309 &local->state[queue]) ||
310 test_bit(IEEE80211_LINK_STATE_PENDING,
311 &local->state[queue]))
312 continue;
313
314 /* there is space - try and get a frame */
315 skb = skb_dequeue(&q->requeued[queue]);
316 if (skb) {
317 qd->q.qlen--;
318 return skb;
319 }
320
321 qdisc = q->queues[queue];
322 skb = qdisc->dequeue(qdisc);
323 if (skb) {
324 qd->q.qlen--;
325 return skb;
326 }
327 }
328 /* returning a NULL here when all the h/w queues are full means we
329 * never need to call netif_stop_queue in the driver */
330 return NULL;
331}
332
333
334static void wme_qdiscop_reset(struct Qdisc* qd)
335{
336 struct ieee80211_sched_data *q = qdisc_priv(qd);
337 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
338 struct ieee80211_hw *hw = &local->hw;
339 int queue;
340
341 /* QUESTION: should we have some hardware flush functionality here? */
342
343 for (queue = 0; queue < hw->queues; queue++) {
344 skb_queue_purge(&q->requeued[queue]);
345 qdisc_reset(q->queues[queue]);
346 }
347 qd->q.qlen = 0;
348}
349
350
351static void wme_qdiscop_destroy(struct Qdisc* qd)
352{
353 struct ieee80211_sched_data *q = qdisc_priv(qd);
354 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
355 struct ieee80211_hw *hw = &local->hw;
356 int queue;
357
358 tcf_destroy_chain(q->filter_list);
359 q->filter_list = NULL;
360
361 for (queue=0; queue < hw->queues; queue++) {
362 skb_queue_purge(&q->requeued[queue]);
363 qdisc_destroy(q->queues[queue]);
364 q->queues[queue] = &noop_qdisc;
365 }
366}
367
368
369/* called whenever parameters are updated on existing qdisc */
370static int wme_qdiscop_tune(struct Qdisc *qd, struct rtattr *opt)
371{
372/* struct ieee80211_sched_data *q = qdisc_priv(qd);
373*/
374 /* check our options block is the right size */
375 /* copy any options to our local structure */
376/* Ignore options block for now - always use static mapping
377 struct tc_ieee80211_qopt *qopt = RTA_DATA(opt);
378
379 if (opt->rta_len < RTA_LENGTH(sizeof(*qopt)))
380 return -EINVAL;
381 memcpy(q->tag2queue, qopt->tag2queue, sizeof(qopt->tag2queue));
382*/
383 return 0;
384}
385
386
387/* called during initial creation of qdisc on device */
388static int wme_qdiscop_init(struct Qdisc *qd, struct rtattr *opt)
389{
390 struct ieee80211_sched_data *q = qdisc_priv(qd);
391 struct net_device *dev = qd->dev;
392 struct ieee80211_local *local;
393 int queues;
394 int err = 0, i;
395
396 /* check that device is a mac80211 device */
397 if (!dev->ieee80211_ptr ||
398 dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
399 return -EINVAL;
400
401 /* check this device is an ieee80211 master type device */
402 if (dev->type != ARPHRD_IEEE80211)
403 return -EINVAL;
404
405 /* check that there is no qdisc currently attached to device
406 * this ensures that we will be the root qdisc. (I can't find a better
407 * way to test this explicitly) */
408 if (dev->qdisc_sleeping != &noop_qdisc)
409 return -EINVAL;
410
411 if (qd->flags & TCQ_F_INGRESS)
412 return -EINVAL;
413
414 local = wdev_priv(dev->ieee80211_ptr);
415 queues = local->hw.queues;
416
417 /* if options were passed in, set them */
418 if (opt) {
419 err = wme_qdiscop_tune(qd, opt);
420 }
421
422 /* create child queues */
423 for (i = 0; i < queues; i++) {
424 skb_queue_head_init(&q->requeued[i]);
425 q->queues[i] = qdisc_create_dflt(qd->dev, &pfifo_qdisc_ops,
426 qd->handle);
427 if (q->queues[i] == 0) {
428 q->queues[i] = &noop_qdisc;
429 printk(KERN_ERR "%s child qdisc %i creation failed", dev->name, i);
430 }
431 }
432
433 return err;
434}
435
436static int wme_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb)
437{
438/* struct ieee80211_sched_data *q = qdisc_priv(qd);
439 unsigned char *p = skb->tail;
440 struct tc_ieee80211_qopt opt;
441
442 memcpy(&opt.tag2queue, q->tag2queue, TC_80211_MAX_TAG + 1);
443 RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
444*/ return skb->len;
445/*
446rtattr_failure:
447 skb_trim(skb, p - skb->data);*/
448 return -1;
449}
450
451
452static int wme_classop_graft(struct Qdisc *qd, unsigned long arg,
453 struct Qdisc *new, struct Qdisc **old)
454{
455 struct ieee80211_sched_data *q = qdisc_priv(qd);
456 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
457 struct ieee80211_hw *hw = &local->hw;
458 unsigned long queue = arg - 1;
459
460 if (queue >= hw->queues)
461 return -EINVAL;
462
463 if (!new)
464 new = &noop_qdisc;
465
466 sch_tree_lock(qd);
467 *old = q->queues[queue];
468 q->queues[queue] = new;
469 qdisc_reset(*old);
470 sch_tree_unlock(qd);
471
472 return 0;
473}
474
475
476static struct Qdisc *
477wme_classop_leaf(struct Qdisc *qd, unsigned long arg)
478{
479 struct ieee80211_sched_data *q = qdisc_priv(qd);
480 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
481 struct ieee80211_hw *hw = &local->hw;
482 unsigned long queue = arg - 1;
483
484 if (queue >= hw->queues)
485 return NULL;
486
487 return q->queues[queue];
488}
489
490
491static unsigned long wme_classop_get(struct Qdisc *qd, u32 classid)
492{
493 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
494 struct ieee80211_hw *hw = &local->hw;
495 unsigned long queue = TC_H_MIN(classid);
496
497 if (queue - 1 >= hw->queues)
498 return 0;
499
500 return queue;
501}
502
503
504static unsigned long wme_classop_bind(struct Qdisc *qd, unsigned long parent,
505 u32 classid)
506{
507 return wme_classop_get(qd, classid);
508}
509
510
511static void wme_classop_put(struct Qdisc *q, unsigned long cl)
512{
513}
514
515
516static int wme_classop_change(struct Qdisc *qd, u32 handle, u32 parent,
517 struct rtattr **tca, unsigned long *arg)
518{
519 unsigned long cl = *arg;
520 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
521 struct ieee80211_hw *hw = &local->hw;
522
523 if (cl - 1 > hw->queues)
524 return -ENOENT;
525
526 /* TODO: put code to program hardware queue parameters here,
527 * to allow programming from tc command line */
528
529 return 0;
530}
531
532
533/* we don't support deleting hardware queues
534 * when we add WMM-SA support - TSPECs may be deleted here */
535static int wme_classop_delete(struct Qdisc *qd, unsigned long cl)
536{
537 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
538 struct ieee80211_hw *hw = &local->hw;
539
540 if (cl - 1 > hw->queues)
541 return -ENOENT;
542 return 0;
543}
544
545
546static int wme_classop_dump_class(struct Qdisc *qd, unsigned long cl,
547 struct sk_buff *skb, struct tcmsg *tcm)
548{
549 struct ieee80211_sched_data *q = qdisc_priv(qd);
550 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
551 struct ieee80211_hw *hw = &local->hw;
552
553 if (cl - 1 > hw->queues)
554 return -ENOENT;
555 tcm->tcm_handle = TC_H_MIN(cl);
556 tcm->tcm_parent = qd->handle;
557 tcm->tcm_info = q->queues[cl-1]->handle; /* do we need this? */
558 return 0;
559}
560
561
562static void wme_classop_walk(struct Qdisc *qd, struct qdisc_walker *arg)
563{
564 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
565 struct ieee80211_hw *hw = &local->hw;
566 int queue;
567
568 if (arg->stop)
569 return;
570
571 for (queue = 0; queue < hw->queues; queue++) {
572 if (arg->count < arg->skip) {
573 arg->count++;
574 continue;
575 }
576 /* we should return classids for our internal queues here
577 * as well as the external ones */
578 if (arg->fn(qd, queue+1, arg) < 0) {
579 arg->stop = 1;
580 break;
581 }
582 arg->count++;
583 }
584}
585
586
587static struct tcf_proto ** wme_classop_find_tcf(struct Qdisc *qd,
588 unsigned long cl)
589{
590 struct ieee80211_sched_data *q = qdisc_priv(qd);
591
592 if (cl)
593 return NULL;
594
595 return &q->filter_list;
596}
597
598
599/* this qdisc is classful (i.e. has classes, some of which may have leaf qdiscs attached)
600 * - these are the operations on the classes */
601static struct Qdisc_class_ops class_ops =
602{
603 .graft = wme_classop_graft,
604 .leaf = wme_classop_leaf,
605
606 .get = wme_classop_get,
607 .put = wme_classop_put,
608 .change = wme_classop_change,
609 .delete = wme_classop_delete,
610 .walk = wme_classop_walk,
611
612 .tcf_chain = wme_classop_find_tcf,
613 .bind_tcf = wme_classop_bind,
614 .unbind_tcf = wme_classop_put,
615
616 .dump = wme_classop_dump_class,
617};
618
619
620/* queueing discipline operations */
621static struct Qdisc_ops wme_qdisc_ops =
622{
623 .next = NULL,
624 .cl_ops = &class_ops,
625 .id = "ieee80211",
626 .priv_size = sizeof(struct ieee80211_sched_data),
627
628 .enqueue = wme_qdiscop_enqueue,
629 .dequeue = wme_qdiscop_dequeue,
630 .requeue = wme_qdiscop_requeue,
631 .drop = NULL, /* drop not needed since we are always the root qdisc */
632
633 .init = wme_qdiscop_init,
634 .reset = wme_qdiscop_reset,
635 .destroy = wme_qdiscop_destroy,
636 .change = wme_qdiscop_tune,
637
638 .dump = wme_qdiscop_dump,
639};
640
641
642void ieee80211_install_qdisc(struct net_device *dev)
643{
644 struct Qdisc *qdisc;
645
646 qdisc = qdisc_create_dflt(dev, &wme_qdisc_ops, TC_H_ROOT);
647 if (!qdisc) {
648 printk(KERN_ERR "%s: qdisc installation failed\n", dev->name);
649 return;
650 }
651
652 /* same handle as would be allocated by qdisc_alloc_handle() */
653 qdisc->handle = 0x80010000;
654
655 qdisc_lock_tree(dev);
656 list_add_tail(&qdisc->list, &dev->qdisc_list);
657 dev->qdisc_sleeping = qdisc;
658 qdisc_unlock_tree(dev);
659}
660
661
662int ieee80211_qdisc_installed(struct net_device *dev)
663{
664 return dev->qdisc_sleeping->ops == &wme_qdisc_ops;
665}
666
667
668int ieee80211_wme_register(void)
669{
670 return register_qdisc(&wme_qdisc_ops);
671}
672
673
674void ieee80211_wme_unregister(void)
675{
676 unregister_qdisc(&wme_qdisc_ops);
677}
678#endif /* CONFIG_NET_SCHED */
diff --git a/net/mac80211/wme.h b/net/mac80211/wme.h
new file mode 100644
index 000000000000..f0bff10f0e08
--- /dev/null
+++ b/net/mac80211/wme.h
@@ -0,0 +1,57 @@
1/*
2 * IEEE 802.11 driver (80211.o) - QoS datatypes
3 * Copyright 2004, Instant802 Networks, Inc.
4 * Copyright 2005, Devicescape Software, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _WME_H
12#define _WME_H
13
14#include <linux/netdevice.h>
15#include "ieee80211_i.h"
16
17#define QOS_CONTROL_LEN 2
18
19#define QOS_CONTROL_ACK_POLICY_NORMAL 0
20#define QOS_CONTROL_ACK_POLICY_NOACK 1
21
22#define QOS_CONTROL_TID_MASK 0x0f
23#define QOS_CONTROL_ACK_POLICY_SHIFT 5
24
25#define QOS_CONTROL_TAG1D_MASK 0x07
26
27ieee80211_txrx_result
28ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx);
29
30ieee80211_txrx_result
31ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx);
32
33#ifdef CONFIG_NET_SCHED
34void ieee80211_install_qdisc(struct net_device *dev);
35int ieee80211_qdisc_installed(struct net_device *dev);
36
37int ieee80211_wme_register(void);
38void ieee80211_wme_unregister(void);
39#else
40static inline void ieee80211_install_qdisc(struct net_device *dev)
41{
42}
43static inline int ieee80211_qdisc_installed(struct net_device *dev)
44{
45 return 0;
46}
47
48static inline int ieee80211_wme_register(void)
49{
50 return 0;
51}
52static inline void ieee80211_wme_unregister(void)
53{
54}
55#endif /* CONFIG_NET_SCHED */
56
57#endif /* _WME_H */
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
new file mode 100644
index 000000000000..783af32c6911
--- /dev/null
+++ b/net/mac80211/wpa.c
@@ -0,0 +1,660 @@
1/*
2 * Copyright 2002-2004, Instant802 Networks, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/netdevice.h>
10#include <linux/types.h>
11#include <linux/slab.h>
12#include <linux/skbuff.h>
13#include <linux/compiler.h>
14#include <net/iw_handler.h>
15
16#include <net/mac80211.h>
17#include "ieee80211_common.h"
18#include "ieee80211_i.h"
19#include "michael.h"
20#include "tkip.h"
21#include "aes_ccm.h"
22#include "wpa.h"
23
24static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da,
25 u8 *qos_tid, u8 **data, size_t *data_len)
26{
27 struct ieee80211_hdr *hdr;
28 size_t hdrlen;
29 u16 fc;
30 int a4_included;
31 u8 *pos;
32
33 hdr = (struct ieee80211_hdr *) skb->data;
34 fc = le16_to_cpu(hdr->frame_control);
35
36 hdrlen = 24;
37 if ((fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) ==
38 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
39 hdrlen += ETH_ALEN;
40 *sa = hdr->addr4;
41 *da = hdr->addr3;
42 } else if (fc & IEEE80211_FCTL_FROMDS) {
43 *sa = hdr->addr3;
44 *da = hdr->addr1;
45 } else if (fc & IEEE80211_FCTL_TODS) {
46 *sa = hdr->addr2;
47 *da = hdr->addr3;
48 } else {
49 *sa = hdr->addr2;
50 *da = hdr->addr1;
51 }
52
53 if (fc & 0x80)
54 hdrlen += 2;
55
56 *data = skb->data + hdrlen;
57 *data_len = skb->len - hdrlen;
58
59 a4_included = (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
60 (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
61 if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
62 fc & IEEE80211_STYPE_QOS_DATA) {
63 pos = (u8 *) &hdr->addr4;
64 if (a4_included)
65 pos += 6;
66 *qos_tid = pos[0] & 0x0f;
67 *qos_tid |= 0x80; /* qos_included flag */
68 } else
69 *qos_tid = 0;
70
71 return skb->len < hdrlen ? -1 : 0;
72}
73
74
75ieee80211_txrx_result
76ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
77{
78 u8 *data, *sa, *da, *key, *mic, qos_tid;
79 size_t data_len;
80 u16 fc;
81 struct sk_buff *skb = tx->skb;
82 int authenticator;
83 int wpa_test = 0;
84
85 fc = tx->fc;
86
87 if (!tx->key || tx->key->alg != ALG_TKIP || skb->len < 24 ||
88 !WLAN_FC_DATA_PRESENT(fc))
89 return TXRX_CONTINUE;
90
91 if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len))
92 return TXRX_DROP;
93
94 if (!tx->key->force_sw_encrypt &&
95 !tx->fragmented &&
96 !(tx->local->hw.flags & IEEE80211_HW_TKIP_INCLUDE_MMIC) &&
97 !wpa_test) {
98 /* hwaccel - with no need for preallocated room for Michael MIC
99 */
100 return TXRX_CONTINUE;
101 }
102
103 if (skb_tailroom(skb) < MICHAEL_MIC_LEN) {
104 I802_DEBUG_INC(tx->local->tx_expand_skb_head);
105 if (unlikely(pskb_expand_head(skb, TKIP_IV_LEN,
106 MICHAEL_MIC_LEN + TKIP_ICV_LEN,
107 GFP_ATOMIC))) {
108 printk(KERN_DEBUG "%s: failed to allocate more memory "
109 "for Michael MIC\n", tx->dev->name);
110 return TXRX_DROP;
111 }
112 }
113
114#if 0
115 authenticator = fc & IEEE80211_FCTL_FROMDS; /* FIX */
116#else
117 authenticator = 1;
118#endif
119 key = &tx->key->key[authenticator ? ALG_TKIP_TEMP_AUTH_TX_MIC_KEY :
120 ALG_TKIP_TEMP_AUTH_RX_MIC_KEY];
121 mic = skb_put(skb, MICHAEL_MIC_LEN);
122 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
123
124 return TXRX_CONTINUE;
125}
126
127
128ieee80211_txrx_result
129ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
130{
131 u8 *data, *sa, *da, *key = NULL, qos_tid;
132 size_t data_len;
133 u16 fc;
134 u8 mic[MICHAEL_MIC_LEN];
135 struct sk_buff *skb = rx->skb;
136 int authenticator = 1, wpa_test = 0;
137
138 fc = rx->fc;
139
140 /* If device handles decryption totally, skip this check */
141 if ((rx->local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP) ||
142 (rx->local->hw.flags & IEEE80211_HW_DEVICE_STRIPS_MIC))
143 return TXRX_CONTINUE;
144
145 if (!rx->key || rx->key->alg != ALG_TKIP ||
146 !(rx->fc & IEEE80211_FCTL_PROTECTED) || !WLAN_FC_DATA_PRESENT(fc))
147 return TXRX_CONTINUE;
148
149 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
150 !rx->key->force_sw_encrypt) {
151 if (rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) {
152 if (skb->len < MICHAEL_MIC_LEN)
153 return TXRX_DROP;
154 }
155 /* Need to verify Michael MIC sometimes in software even when
156 * hwaccel is used. Atheros ar5212: fragmented frames and QoS
157 * frames. */
158 if (!rx->fragmented && !wpa_test)
159 goto remove_mic;
160 }
161
162 if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len)
163 || data_len < MICHAEL_MIC_LEN)
164 return TXRX_DROP;
165
166 data_len -= MICHAEL_MIC_LEN;
167
168#if 0
169 authenticator = fc & IEEE80211_FCTL_TODS; /* FIX */
170#else
171 authenticator = 1;
172#endif
173 key = &rx->key->key[authenticator ? ALG_TKIP_TEMP_AUTH_RX_MIC_KEY :
174 ALG_TKIP_TEMP_AUTH_TX_MIC_KEY];
175 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
176 if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) {
177 if (!rx->u.rx.ra_match)
178 return TXRX_DROP;
179
180 printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from "
181 MAC_FMT "\n", rx->dev->name, MAC_ARG(sa));
182
183 do {
184 struct ieee80211_hdr *hdr;
185 union iwreq_data wrqu;
186 char *buf = kmalloc(128, GFP_ATOMIC);
187 if (!buf)
188 break;
189
190 /* TODO: needed parameters: count, key type, TSC */
191 hdr = (struct ieee80211_hdr *) skb->data;
192 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
193 "keyid=%d %scast addr=" MAC_FMT ")",
194 rx->key->keyidx,
195 hdr->addr1[0] & 0x01 ? "broad" : "uni",
196 MAC_ARG(hdr->addr2));
197 memset(&wrqu, 0, sizeof(wrqu));
198 wrqu.data.length = strlen(buf);
199 wireless_send_event(rx->dev, IWEVCUSTOM, &wrqu, buf);
200 kfree(buf);
201 } while (0);
202
203 if (!rx->local->apdev)
204 return TXRX_DROP;
205
206 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
207 ieee80211_msg_michael_mic_failure);
208
209 return TXRX_QUEUED;
210 }
211
212 remove_mic:
213 /* remove Michael MIC from payload */
214 skb_trim(skb, skb->len - MICHAEL_MIC_LEN);
215
216 return TXRX_CONTINUE;
217}
218
219
220static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
221 struct sk_buff *skb, int test)
222{
223 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
224 struct ieee80211_key *key = tx->key;
225 int hdrlen, len, tailneed;
226 u16 fc;
227 u8 *pos;
228
229 fc = le16_to_cpu(hdr->frame_control);
230 hdrlen = ieee80211_get_hdrlen(fc);
231 len = skb->len - hdrlen;
232
233 tailneed = !tx->key->force_sw_encrypt ? 0 : TKIP_ICV_LEN;
234 if ((skb_headroom(skb) < TKIP_IV_LEN ||
235 skb_tailroom(skb) < tailneed)) {
236 I802_DEBUG_INC(tx->local->tx_expand_skb_head);
237 if (unlikely(pskb_expand_head(skb, TKIP_IV_LEN, tailneed,
238 GFP_ATOMIC)))
239 return -1;
240 }
241
242 pos = skb_push(skb, TKIP_IV_LEN);
243 memmove(pos, pos + TKIP_IV_LEN, hdrlen);
244 pos += hdrlen;
245
246 /* Increase IV for the frame */
247 key->u.tkip.iv16++;
248 if (key->u.tkip.iv16 == 0)
249 key->u.tkip.iv32++;
250
251 if (!tx->key->force_sw_encrypt) {
252 u32 flags = tx->local->hw.flags;
253 hdr = (struct ieee80211_hdr *)skb->data;
254
255 /* hwaccel - with preallocated room for IV */
256 ieee80211_tkip_add_iv(pos, key,
257 (u8) (key->u.tkip.iv16 >> 8),
258 (u8) (((key->u.tkip.iv16 >> 8) | 0x20) &
259 0x7f),
260 (u8) key->u.tkip.iv16);
261
262 if (flags & IEEE80211_HW_TKIP_REQ_PHASE2_KEY)
263 ieee80211_tkip_gen_rc4key(key, hdr->addr2,
264 tx->u.tx.control->tkip_key);
265 else if (flags & IEEE80211_HW_TKIP_REQ_PHASE1_KEY) {
266 if (key->u.tkip.iv16 == 0 ||
267 !key->u.tkip.tx_initialized) {
268 ieee80211_tkip_gen_phase1key(key, hdr->addr2,
269 (u16 *)tx->u.tx.control->tkip_key);
270 key->u.tkip.tx_initialized = 1;
271 tx->u.tx.control->flags |=
272 IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY;
273 } else
274 tx->u.tx.control->flags &=
275 ~IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY;
276 }
277
278 tx->u.tx.control->key_idx = tx->key->hw_key_idx;
279 return 0;
280 }
281
282 /* Add room for ICV */
283 skb_put(skb, TKIP_ICV_LEN);
284
285 hdr = (struct ieee80211_hdr *) skb->data;
286 ieee80211_tkip_encrypt_data(tx->local->wep_tx_tfm,
287 key, pos, len, hdr->addr2);
288 return 0;
289}
290
291
292ieee80211_txrx_result
293ieee80211_tx_h_tkip_encrypt(struct ieee80211_txrx_data *tx)
294{
295 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
296 u16 fc;
297 struct ieee80211_key *key = tx->key;
298 struct sk_buff *skb = tx->skb;
299 int wpa_test = 0, test = 0;
300
301 fc = le16_to_cpu(hdr->frame_control);
302
303 if (!key || key->alg != ALG_TKIP || !WLAN_FC_DATA_PRESENT(fc))
304 return TXRX_CONTINUE;
305
306 tx->u.tx.control->icv_len = TKIP_ICV_LEN;
307 tx->u.tx.control->iv_len = TKIP_IV_LEN;
308 ieee80211_tx_set_iswep(tx);
309
310 if (!tx->key->force_sw_encrypt &&
311 !(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) &&
312 !wpa_test) {
313 /* hwaccel - with no need for preallocated room for IV/ICV */
314 tx->u.tx.control->key_idx = tx->key->hw_key_idx;
315 return TXRX_CONTINUE;
316 }
317
318 if (tkip_encrypt_skb(tx, skb, test) < 0)
319 return TXRX_DROP;
320
321 if (tx->u.tx.extra_frag) {
322 int i;
323 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
324 if (tkip_encrypt_skb(tx, tx->u.tx.extra_frag[i], test)
325 < 0)
326 return TXRX_DROP;
327 }
328 }
329
330 return TXRX_CONTINUE;
331}
332
333
334ieee80211_txrx_result
335ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx)
336{
337 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
338 u16 fc;
339 int hdrlen, res, hwaccel = 0, wpa_test = 0;
340 struct ieee80211_key *key = rx->key;
341 struct sk_buff *skb = rx->skb;
342
343 fc = le16_to_cpu(hdr->frame_control);
344 hdrlen = ieee80211_get_hdrlen(fc);
345
346 if (!rx->key || rx->key->alg != ALG_TKIP ||
347 !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
348 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
349 return TXRX_CONTINUE;
350
351 if (!rx->sta || skb->len - hdrlen < 12)
352 return TXRX_DROP;
353
354 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
355 !rx->key->force_sw_encrypt) {
356 if (!(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) {
357 /* Hardware takes care of all processing, including
358 * replay protection, so no need to continue here. */
359 return TXRX_CONTINUE;
360 }
361
362 /* let TKIP code verify IV, but skip decryption */
363 hwaccel = 1;
364 }
365
366 res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm,
367 key, skb->data + hdrlen,
368 skb->len - hdrlen, rx->sta->addr,
369 hwaccel, rx->u.rx.queue);
370 if (res != TKIP_DECRYPT_OK || wpa_test) {
371 printk(KERN_DEBUG "%s: TKIP decrypt failed for RX frame from "
372 MAC_FMT " (res=%d)\n",
373 rx->dev->name, MAC_ARG(rx->sta->addr), res);
374 return TXRX_DROP;
375 }
376
377 /* Trim ICV */
378 skb_trim(skb, skb->len - TKIP_ICV_LEN);
379
380 /* Remove IV */
381 memmove(skb->data + TKIP_IV_LEN, skb->data, hdrlen);
382 skb_pull(skb, TKIP_IV_LEN);
383
384 return TXRX_CONTINUE;
385}
386
387
388static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad,
389 int encrypted)
390{
391 u16 fc;
392 int a4_included, qos_included;
393 u8 qos_tid, *fc_pos, *data, *sa, *da;
394 int len_a;
395 size_t data_len;
396 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
397
398 fc_pos = (u8 *) &hdr->frame_control;
399 fc = fc_pos[0] ^ (fc_pos[1] << 8);
400 a4_included = (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
401 (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
402
403 ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len);
404 data_len -= CCMP_HDR_LEN + (encrypted ? CCMP_MIC_LEN : 0);
405 if (qos_tid & 0x80) {
406 qos_included = 1;
407 qos_tid &= 0x0f;
408 } else
409 qos_included = 0;
410 /* First block, b_0 */
411
412 b_0[0] = 0x59; /* flags: Adata: 1, M: 011, L: 001 */
413 /* Nonce: QoS Priority | A2 | PN */
414 b_0[1] = qos_tid;
415 memcpy(&b_0[2], hdr->addr2, 6);
416 memcpy(&b_0[8], pn, CCMP_PN_LEN);
417 /* l(m) */
418 b_0[14] = (data_len >> 8) & 0xff;
419 b_0[15] = data_len & 0xff;
420
421
422 /* AAD (extra authenticate-only data) / masked 802.11 header
423 * FC | A1 | A2 | A3 | SC | [A4] | [QC] */
424
425 len_a = a4_included ? 28 : 22;
426 if (qos_included)
427 len_a += 2;
428
429 aad[0] = 0; /* (len_a >> 8) & 0xff; */
430 aad[1] = len_a & 0xff;
431 /* Mask FC: zero subtype b4 b5 b6 */
432 aad[2] = fc_pos[0] & ~(BIT(4) | BIT(5) | BIT(6));
433 /* Retry, PwrMgt, MoreData; set Protected */
434 aad[3] = (fc_pos[1] & ~(BIT(3) | BIT(4) | BIT(5))) | BIT(6);
435 memcpy(&aad[4], &hdr->addr1, 18);
436
437 /* Mask Seq#, leave Frag# */
438 aad[22] = *((u8 *) &hdr->seq_ctrl) & 0x0f;
439 aad[23] = 0;
440 if (a4_included) {
441 memcpy(&aad[24], hdr->addr4, 6);
442 aad[30] = 0;
443 aad[31] = 0;
444 } else
445 memset(&aad[24], 0, 8);
446 if (qos_included) {
447 u8 *dpos = &aad[a4_included ? 30 : 24];
448
449 /* Mask QoS Control field */
450 dpos[0] = qos_tid;
451 dpos[1] = 0;
452 }
453}
454
455
456static inline void ccmp_pn2hdr(u8 *hdr, u8 *pn, int key_id)
457{
458 hdr[0] = pn[5];
459 hdr[1] = pn[4];
460 hdr[2] = 0;
461 hdr[3] = 0x20 | (key_id << 6);
462 hdr[4] = pn[3];
463 hdr[5] = pn[2];
464 hdr[6] = pn[1];
465 hdr[7] = pn[0];
466}
467
468
469static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr)
470{
471 pn[0] = hdr[7];
472 pn[1] = hdr[6];
473 pn[2] = hdr[5];
474 pn[3] = hdr[4];
475 pn[4] = hdr[1];
476 pn[5] = hdr[0];
477 return (hdr[3] >> 6) & 0x03;
478}
479
480
481static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
482 struct sk_buff *skb, int test)
483{
484 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
485 struct ieee80211_key *key = tx->key;
486 int hdrlen, len, tailneed;
487 u16 fc;
488 u8 *pos, *pn, *b_0, *aad, *scratch;
489 int i;
490
491 scratch = key->u.ccmp.tx_crypto_buf;
492 b_0 = scratch + 3 * AES_BLOCK_LEN;
493 aad = scratch + 4 * AES_BLOCK_LEN;
494
495 fc = le16_to_cpu(hdr->frame_control);
496 hdrlen = ieee80211_get_hdrlen(fc);
497 len = skb->len - hdrlen;
498
499 tailneed = !key->force_sw_encrypt ? 0 : CCMP_MIC_LEN;
500
501 if ((skb_headroom(skb) < CCMP_HDR_LEN ||
502 skb_tailroom(skb) < tailneed)) {
503 I802_DEBUG_INC(tx->local->tx_expand_skb_head);
504 if (unlikely(pskb_expand_head(skb, CCMP_HDR_LEN, tailneed,
505 GFP_ATOMIC)))
506 return -1;
507 }
508
509 pos = skb_push(skb, CCMP_HDR_LEN);
510 memmove(pos, pos + CCMP_HDR_LEN, hdrlen);
511 hdr = (struct ieee80211_hdr *) pos;
512 pos += hdrlen;
513
514 /* PN = PN + 1 */
515 pn = key->u.ccmp.tx_pn;
516
517 for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
518 pn[i]++;
519 if (pn[i])
520 break;
521 }
522
523 ccmp_pn2hdr(pos, pn, key->keyidx);
524
525 if (!key->force_sw_encrypt) {
526 /* hwaccel - with preallocated room for CCMP header */
527 tx->u.tx.control->key_idx = key->hw_key_idx;
528 return 0;
529 }
530
531 pos += CCMP_HDR_LEN;
532 ccmp_special_blocks(skb, pn, b_0, aad, 0);
533 ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, scratch, b_0, aad, pos, len,
534 pos, skb_put(skb, CCMP_MIC_LEN));
535
536 return 0;
537}
538
539
540ieee80211_txrx_result
541ieee80211_tx_h_ccmp_encrypt(struct ieee80211_txrx_data *tx)
542{
543 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
544 struct ieee80211_key *key = tx->key;
545 u16 fc;
546 struct sk_buff *skb = tx->skb;
547 int test = 0;
548
549 fc = le16_to_cpu(hdr->frame_control);
550
551 if (!key || key->alg != ALG_CCMP || !WLAN_FC_DATA_PRESENT(fc))
552 return TXRX_CONTINUE;
553
554 tx->u.tx.control->icv_len = CCMP_MIC_LEN;
555 tx->u.tx.control->iv_len = CCMP_HDR_LEN;
556 ieee80211_tx_set_iswep(tx);
557
558 if (!tx->key->force_sw_encrypt &&
559 !(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) {
560 /* hwaccel - with no need for preallocated room for CCMP "
561 * header or MIC fields */
562 tx->u.tx.control->key_idx = tx->key->hw_key_idx;
563 return TXRX_CONTINUE;
564 }
565
566 if (ccmp_encrypt_skb(tx, skb, test) < 0)
567 return TXRX_DROP;
568
569 if (tx->u.tx.extra_frag) {
570 int i;
571
572 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
573 if (ccmp_encrypt_skb(tx, tx->u.tx.extra_frag[i], test)
574 < 0)
575 return TXRX_DROP;
576 }
577 }
578
579 return TXRX_CONTINUE;
580}
581
582
583ieee80211_txrx_result
584ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
585{
586 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
587 u16 fc;
588 int hdrlen;
589 struct ieee80211_key *key = rx->key;
590 struct sk_buff *skb = rx->skb;
591 u8 pn[CCMP_PN_LEN];
592 int data_len;
593
594 fc = le16_to_cpu(hdr->frame_control);
595 hdrlen = ieee80211_get_hdrlen(fc);
596
597 if (!key || key->alg != ALG_CCMP ||
598 !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
599 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
600 return TXRX_CONTINUE;
601
602 data_len = skb->len - hdrlen - CCMP_HDR_LEN - CCMP_MIC_LEN;
603 if (!rx->sta || data_len < 0)
604 return TXRX_DROP;
605
606 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
607 !key->force_sw_encrypt &&
608 !(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV))
609 return TXRX_CONTINUE;
610
611 (void) ccmp_hdr2pn(pn, skb->data + hdrlen);
612
613 if (memcmp(pn, key->u.ccmp.rx_pn[rx->u.rx.queue], CCMP_PN_LEN) <= 0) {
614#ifdef CONFIG_MAC80211_DEBUG
615 u8 *ppn = key->u.ccmp.rx_pn[rx->u.rx.queue];
616 printk(KERN_DEBUG "%s: CCMP replay detected for RX frame from "
617 MAC_FMT " (RX PN %02x%02x%02x%02x%02x%02x <= prev. PN "
618 "%02x%02x%02x%02x%02x%02x)\n", rx->dev->name,
619 MAC_ARG(rx->sta->addr),
620 pn[0], pn[1], pn[2], pn[3], pn[4], pn[5],
621 ppn[0], ppn[1], ppn[2], ppn[3], ppn[4], ppn[5]);
622#endif /* CONFIG_MAC80211_DEBUG */
623 key->u.ccmp.replays++;
624 return TXRX_DROP;
625 }
626
627 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
628 !key->force_sw_encrypt) {
629 /* hwaccel has already decrypted frame and verified MIC */
630 } else {
631 u8 *scratch, *b_0, *aad;
632
633 scratch = key->u.ccmp.rx_crypto_buf;
634 b_0 = scratch + 3 * AES_BLOCK_LEN;
635 aad = scratch + 4 * AES_BLOCK_LEN;
636
637 ccmp_special_blocks(skb, pn, b_0, aad, 1);
638
639 if (ieee80211_aes_ccm_decrypt(
640 key->u.ccmp.tfm, scratch, b_0, aad,
641 skb->data + hdrlen + CCMP_HDR_LEN, data_len,
642 skb->data + skb->len - CCMP_MIC_LEN,
643 skb->data + hdrlen + CCMP_HDR_LEN)) {
644 printk(KERN_DEBUG "%s: CCMP decrypt failed for RX "
645 "frame from " MAC_FMT "\n", rx->dev->name,
646 MAC_ARG(rx->sta->addr));
647 return TXRX_DROP;
648 }
649 }
650
651 memcpy(key->u.ccmp.rx_pn[rx->u.rx.queue], pn, CCMP_PN_LEN);
652
653 /* Remove CCMP header and MIC */
654 skb_trim(skb, skb->len - CCMP_MIC_LEN);
655 memmove(skb->data + CCMP_HDR_LEN, skb->data, hdrlen);
656 skb_pull(skb, CCMP_HDR_LEN);
657
658 return TXRX_CONTINUE;
659}
660
diff --git a/net/mac80211/wpa.h b/net/mac80211/wpa.h
new file mode 100644
index 000000000000..da3b9594f9c3
--- /dev/null
+++ b/net/mac80211/wpa.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright 2002-2004, Instant802 Networks, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef WPA_H
10#define WPA_H
11
12#include <linux/skbuff.h>
13#include <linux/types.h>
14#include "ieee80211_i.h"
15
16ieee80211_txrx_result
17ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx);
18ieee80211_txrx_result
19ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx);
20
21ieee80211_txrx_result
22ieee80211_tx_h_tkip_encrypt(struct ieee80211_txrx_data *tx);
23ieee80211_txrx_result
24ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx);
25
26ieee80211_txrx_result
27ieee80211_tx_h_ccmp_encrypt(struct ieee80211_txrx_data *tx);
28ieee80211_txrx_result
29ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx);
30
31#endif /* WPA_H */
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 42d2fb94eff1..507828d7d4ae 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -140,6 +140,14 @@ static struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid)
140 140
141static void netlink_sock_destruct(struct sock *sk) 141static void netlink_sock_destruct(struct sock *sk)
142{ 142{
143 struct netlink_sock *nlk = nlk_sk(sk);
144
145 if (nlk->cb) {
146 if (nlk->cb->done)
147 nlk->cb->done(nlk->cb);
148 netlink_destroy_callback(nlk->cb);
149 }
150
143 skb_queue_purge(&sk->sk_receive_queue); 151 skb_queue_purge(&sk->sk_receive_queue);
144 152
145 if (!sock_flag(sk, SOCK_DEAD)) { 153 if (!sock_flag(sk, SOCK_DEAD)) {
@@ -148,7 +156,6 @@ static void netlink_sock_destruct(struct sock *sk)
148 } 156 }
149 BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); 157 BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc));
150 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); 158 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc));
151 BUG_TRAP(!nlk_sk(sk)->cb);
152 BUG_TRAP(!nlk_sk(sk)->groups); 159 BUG_TRAP(!nlk_sk(sk)->groups);
153} 160}
154 161
@@ -456,17 +463,10 @@ static int netlink_release(struct socket *sock)
456 sock_orphan(sk); 463 sock_orphan(sk);
457 nlk = nlk_sk(sk); 464 nlk = nlk_sk(sk);
458 465
459 mutex_lock(nlk->cb_mutex); 466 /*
460 if (nlk->cb) { 467 * OK. Socket is unlinked, any packets that arrive now
461 if (nlk->cb->done) 468 * will be purged.
462 nlk->cb->done(nlk->cb); 469 */
463 netlink_destroy_callback(nlk->cb);
464 nlk->cb = NULL;
465 }
466 mutex_unlock(nlk->cb_mutex);
467
468 /* OK. Socket is unlinked, and, therefore,
469 no new packets will arrive */
470 470
471 sock->sk = NULL; 471 sock->sk = NULL;
472 wake_up_interruptible_all(&nlk->wait); 472 wake_up_interruptible_all(&nlk->wait);
@@ -1245,16 +1245,14 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
1245 siocb->scm = &scm; 1245 siocb->scm = &scm;
1246 } 1246 }
1247 siocb->scm->creds = *NETLINK_CREDS(skb); 1247 siocb->scm->creds = *NETLINK_CREDS(skb);
1248 if (flags & MSG_TRUNC)
1249 copied = skb->len;
1248 skb_free_datagram(sk, skb); 1250 skb_free_datagram(sk, skb);
1249 1251
1250 if (nlk->cb && atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) 1252 if (nlk->cb && atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2)
1251 netlink_dump(sk); 1253 netlink_dump(sk);
1252 1254
1253 scm_recv(sock, msg, siocb->scm, flags); 1255 scm_recv(sock, msg, siocb->scm, flags);
1254
1255 if (flags & MSG_TRUNC)
1256 copied = skb->len;
1257
1258out: 1256out:
1259 netlink_rcv_wake(sk); 1257 netlink_rcv_wake(sk);
1260 return err ? : copied; 1258 return err ? : copied;
@@ -1426,9 +1424,9 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
1426 return -ECONNREFUSED; 1424 return -ECONNREFUSED;
1427 } 1425 }
1428 nlk = nlk_sk(sk); 1426 nlk = nlk_sk(sk);
1429 /* A dump or destruction is in progress... */ 1427 /* A dump is in progress... */
1430 mutex_lock(nlk->cb_mutex); 1428 mutex_lock(nlk->cb_mutex);
1431 if (nlk->cb || sock_flag(sk, SOCK_DEAD)) { 1429 if (nlk->cb) {
1432 mutex_unlock(nlk->cb_mutex); 1430 mutex_unlock(nlk->cb_mutex);
1433 netlink_destroy_callback(cb); 1431 netlink_destroy_callback(cb);
1434 sock_put(sk); 1432 sock_put(sk);
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
index 8e6bd4e9d82c..2f76e062609d 100644
--- a/net/netrom/nr_route.c
+++ b/net/netrom/nr_route.c
@@ -598,7 +598,7 @@ struct net_device *nr_dev_first(void)
598 struct net_device *dev, *first = NULL; 598 struct net_device *dev, *first = NULL;
599 599
600 read_lock(&dev_base_lock); 600 read_lock(&dev_base_lock);
601 for (dev = dev_base; dev != NULL; dev = dev->next) { 601 for_each_netdev(dev) {
602 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM) 602 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM)
603 if (first == NULL || strncmp(dev->name, first->name, 3) < 0) 603 if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
604 first = dev; 604 first = dev;
@@ -618,12 +618,13 @@ struct net_device *nr_dev_get(ax25_address *addr)
618 struct net_device *dev; 618 struct net_device *dev;
619 619
620 read_lock(&dev_base_lock); 620 read_lock(&dev_base_lock);
621 for (dev = dev_base; dev != NULL; dev = dev->next) { 621 for_each_netdev(dev) {
622 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0) { 622 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0) {
623 dev_hold(dev); 623 dev_hold(dev);
624 goto out; 624 goto out;
625 } 625 }
626 } 626 }
627 dev = NULL;
627out: 628out:
628 read_unlock(&dev_base_lock); 629 read_unlock(&dev_base_lock);
629 return dev; 630 return dev;
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 1f9aefd95a99..929a784a86d7 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -596,7 +596,7 @@ struct net_device *rose_dev_first(void)
596 struct net_device *dev, *first = NULL; 596 struct net_device *dev, *first = NULL;
597 597
598 read_lock(&dev_base_lock); 598 read_lock(&dev_base_lock);
599 for (dev = dev_base; dev != NULL; dev = dev->next) { 599 for_each_netdev(dev) {
600 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE) 600 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE)
601 if (first == NULL || strncmp(dev->name, first->name, 3) < 0) 601 if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
602 first = dev; 602 first = dev;
@@ -614,12 +614,13 @@ struct net_device *rose_dev_get(rose_address *addr)
614 struct net_device *dev; 614 struct net_device *dev;
615 615
616 read_lock(&dev_base_lock); 616 read_lock(&dev_base_lock);
617 for (dev = dev_base; dev != NULL; dev = dev->next) { 617 for_each_netdev(dev) {
618 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) { 618 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) {
619 dev_hold(dev); 619 dev_hold(dev);
620 goto out; 620 goto out;
621 } 621 }
622 } 622 }
623 dev = NULL;
623out: 624out:
624 read_unlock(&dev_base_lock); 625 read_unlock(&dev_base_lock);
625 return dev; 626 return dev;
@@ -630,10 +631,11 @@ static int rose_dev_exists(rose_address *addr)
630 struct net_device *dev; 631 struct net_device *dev;
631 632
632 read_lock(&dev_base_lock); 633 read_lock(&dev_base_lock);
633 for (dev = dev_base; dev != NULL; dev = dev->next) { 634 for_each_netdev(dev) {
634 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) 635 if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0)
635 goto out; 636 goto out;
636 } 637 }
638 dev = NULL;
637out: 639out:
638 read_unlock(&dev_base_lock); 640 read_unlock(&dev_base_lock);
639 return dev != NULL; 641 return dev != NULL;
diff --git a/net/rxrpc/Kconfig b/net/rxrpc/Kconfig
index 8750f6da6bc7..91b3d52f6f1a 100644
--- a/net/rxrpc/Kconfig
+++ b/net/rxrpc/Kconfig
@@ -5,6 +5,7 @@
5config AF_RXRPC 5config AF_RXRPC
6 tristate "RxRPC session sockets" 6 tristate "RxRPC session sockets"
7 depends on EXPERIMENTAL 7 depends on EXPERIMENTAL
8 select KEYS
8 help 9 help
9 Say Y or M here to include support for RxRPC session sockets (just 10 Say Y or M here to include support for RxRPC session sockets (just
10 the transport part, not the presentation part: (un)marshalling is 11 the transport part, not the presentation part: (un)marshalling is
@@ -29,7 +30,7 @@ config AF_RXRPC_DEBUG
29 30
30config RXKAD 31config RXKAD
31 tristate "RxRPC Kerberos security" 32 tristate "RxRPC Kerberos security"
32 depends on AF_RXRPC && KEYS 33 depends on AF_RXRPC
33 select CRYPTO 34 select CRYPTO
34 select CRYPTO_MANAGER 35 select CRYPTO_MANAGER
35 select CRYPTO_BLKCIPHER 36 select CRYPTO_BLKCIPHER
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index fc07a926df56..657ee69f2133 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -543,6 +543,38 @@ static void rxrpc_zap_tx_window(struct rxrpc_call *call)
543} 543}
544 544
545/* 545/*
546 * process the extra information that may be appended to an ACK packet
547 */
548static void rxrpc_extract_ackinfo(struct rxrpc_call *call, struct sk_buff *skb,
549 unsigned latest, int nAcks)
550{
551 struct rxrpc_ackinfo ackinfo;
552 struct rxrpc_peer *peer;
553 unsigned mtu;
554
555 if (skb_copy_bits(skb, nAcks + 3, &ackinfo, sizeof(ackinfo)) < 0) {
556 _leave(" [no ackinfo]");
557 return;
558 }
559
560 _proto("Rx ACK %%%u Info { rx=%u max=%u rwin=%u jm=%u }",
561 latest,
562 ntohl(ackinfo.rxMTU), ntohl(ackinfo.maxMTU),
563 ntohl(ackinfo.rwind), ntohl(ackinfo.jumbo_max));
564
565 mtu = min(ntohl(ackinfo.rxMTU), ntohl(ackinfo.maxMTU));
566
567 peer = call->conn->trans->peer;
568 if (mtu < peer->maxdata) {
569 spin_lock_bh(&peer->lock);
570 peer->maxdata = mtu;
571 peer->mtu = mtu + peer->hdrsize;
572 spin_unlock_bh(&peer->lock);
573 _net("Net MTU %u (maxdata %u)", peer->mtu, peer->maxdata);
574 }
575}
576
577/*
546 * process packets in the reception queue 578 * process packets in the reception queue
547 */ 579 */
548static int rxrpc_process_rx_queue(struct rxrpc_call *call, 580static int rxrpc_process_rx_queue(struct rxrpc_call *call,
@@ -606,6 +638,8 @@ process_further:
606 rxrpc_acks[ack.reason], 638 rxrpc_acks[ack.reason],
607 ack.nAcks); 639 ack.nAcks);
608 640
641 rxrpc_extract_ackinfo(call, skb, latest, ack.nAcks);
642
609 if (ack.reason == RXRPC_ACK_PING) { 643 if (ack.reason == RXRPC_ACK_PING) {
610 _proto("Rx ACK %%%u PING Request", latest); 644 _proto("Rx ACK %%%u PING Request", latest);
611 rxrpc_propose_ACK(call, RXRPC_ACK_PING_RESPONSE, 645 rxrpc_propose_ACK(call, RXRPC_ACK_PING_RESPONSE,
@@ -801,9 +835,9 @@ void rxrpc_process_call(struct work_struct *work)
801 struct msghdr msg; 835 struct msghdr msg;
802 struct kvec iov[5]; 836 struct kvec iov[5];
803 unsigned long bits; 837 unsigned long bits;
804 __be32 data; 838 __be32 data, pad;
805 size_t len; 839 size_t len;
806 int genbit, loop, nbit, ioc, ret; 840 int genbit, loop, nbit, ioc, ret, mtu;
807 u32 abort_code = RX_PROTOCOL_ERROR; 841 u32 abort_code = RX_PROTOCOL_ERROR;
808 u8 *acks = NULL; 842 u8 *acks = NULL;
809 843
@@ -899,9 +933,30 @@ void rxrpc_process_call(struct work_struct *work)
899 } 933 }
900 934
901 if (test_bit(RXRPC_CALL_ACK_FINAL, &call->events)) { 935 if (test_bit(RXRPC_CALL_ACK_FINAL, &call->events)) {
902 hdr.type = RXRPC_PACKET_TYPE_ACKALL;
903 genbit = RXRPC_CALL_ACK_FINAL; 936 genbit = RXRPC_CALL_ACK_FINAL;
904 goto send_message; 937
938 ack.bufferSpace = htons(8);
939 ack.maxSkew = 0;
940 ack.serial = 0;
941 ack.reason = RXRPC_ACK_IDLE;
942 ack.nAcks = 0;
943 call->ackr_reason = 0;
944
945 spin_lock_bh(&call->lock);
946 ack.serial = call->ackr_serial;
947 ack.previousPacket = call->ackr_prev_seq;
948 ack.firstPacket = htonl(call->rx_data_eaten + 1);
949 spin_unlock_bh(&call->lock);
950
951 pad = 0;
952
953 iov[1].iov_base = &ack;
954 iov[1].iov_len = sizeof(ack);
955 iov[2].iov_base = &pad;
956 iov[2].iov_len = 3;
957 iov[3].iov_base = &ackinfo;
958 iov[3].iov_len = sizeof(ackinfo);
959 goto send_ACK;
905 } 960 }
906 961
907 if (call->events & ((1 << RXRPC_CALL_RCVD_BUSY) | 962 if (call->events & ((1 << RXRPC_CALL_RCVD_BUSY) |
@@ -971,8 +1026,6 @@ void rxrpc_process_call(struct work_struct *work)
971 1026
972 /* consider sending an ordinary ACK */ 1027 /* consider sending an ordinary ACK */
973 if (test_bit(RXRPC_CALL_ACK, &call->events)) { 1028 if (test_bit(RXRPC_CALL_ACK, &call->events)) {
974 __be32 pad;
975
976 _debug("send ACK: window: %d - %d { %lx }", 1029 _debug("send ACK: window: %d - %d { %lx }",
977 call->rx_data_eaten, call->ackr_win_top, 1030 call->rx_data_eaten, call->ackr_win_top,
978 call->ackr_window[0]); 1031 call->ackr_window[0]);
@@ -997,12 +1050,6 @@ void rxrpc_process_call(struct work_struct *work)
997 ack.serial = 0; 1050 ack.serial = 0;
998 ack.reason = 0; 1051 ack.reason = 0;
999 1052
1000 ackinfo.rxMTU = htonl(5692);
1001// ackinfo.rxMTU = htonl(call->conn->trans->peer->maxdata);
1002 ackinfo.maxMTU = htonl(call->conn->trans->peer->maxdata);
1003 ackinfo.rwind = htonl(32);
1004 ackinfo.jumbo_max = htonl(4);
1005
1006 spin_lock_bh(&call->lock); 1053 spin_lock_bh(&call->lock);
1007 ack.reason = call->ackr_reason; 1054 ack.reason = call->ackr_reason;
1008 ack.serial = call->ackr_serial; 1055 ack.serial = call->ackr_serial;
@@ -1116,6 +1163,15 @@ send_ACK_with_skew:
1116 ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) - 1163 ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
1117 ntohl(ack.serial)); 1164 ntohl(ack.serial));
1118send_ACK: 1165send_ACK:
1166 mtu = call->conn->trans->peer->if_mtu;
1167 mtu -= call->conn->trans->peer->hdrsize;
1168 ackinfo.maxMTU = htonl(mtu);
1169 ackinfo.rwind = htonl(32);
1170
1171 /* permit the peer to send us jumbo packets if it wants to */
1172 ackinfo.rxMTU = htonl(5692);
1173 ackinfo.jumbo_max = htonl(4);
1174
1119 hdr.serial = htonl(atomic_inc_return(&call->conn->serial)); 1175 hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
1120 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }", 1176 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
1121 ntohl(hdr.serial), 1177 ntohl(hdr.serial),
diff --git a/net/rxrpc/ar-error.c b/net/rxrpc/ar-error.c
index 2c27df1ffa17..6cb3e8890e7e 100644
--- a/net/rxrpc/ar-error.c
+++ b/net/rxrpc/ar-error.c
@@ -100,8 +100,10 @@ void rxrpc_UDP_error_report(struct sock *sk)
100 } 100 }
101 101
102 if (mtu < peer->mtu) { 102 if (mtu < peer->mtu) {
103 spin_lock_bh(&peer->lock);
103 peer->mtu = mtu; 104 peer->mtu = mtu;
104 peer->maxdata = peer->mtu - peer->hdrsize; 105 peer->maxdata = peer->mtu - peer->hdrsize;
106 spin_unlock_bh(&peer->lock);
105 _net("Net MTU %u (maxdata %u)", 107 _net("Net MTU %u (maxdata %u)",
106 peer->mtu, peer->maxdata); 108 peer->mtu, peer->maxdata);
107 } 109 }
diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
index 5cdde4a48ed1..591c4422205e 100644
--- a/net/rxrpc/ar-output.c
+++ b/net/rxrpc/ar-output.c
@@ -582,7 +582,7 @@ static int rxrpc_send_data(struct kiocb *iocb,
582 max &= ~(call->conn->size_align - 1UL); 582 max &= ~(call->conn->size_align - 1UL);
583 583
584 chunk = max; 584 chunk = max;
585 if (chunk > len) 585 if (chunk > len && !more)
586 chunk = len; 586 chunk = len;
587 587
588 space = chunk + call->conn->size_align; 588 space = chunk + call->conn->size_align;
diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
index d399de4a7fe2..ce08b78647ce 100644
--- a/net/rxrpc/ar-peer.c
+++ b/net/rxrpc/ar-peer.c
@@ -19,6 +19,7 @@
19#include <net/sock.h> 19#include <net/sock.h>
20#include <net/af_rxrpc.h> 20#include <net/af_rxrpc.h>
21#include <net/ip.h> 21#include <net/ip.h>
22#include <net/route.h>
22#include "ar-internal.h" 23#include "ar-internal.h"
23 24
24static LIST_HEAD(rxrpc_peers); 25static LIST_HEAD(rxrpc_peers);
@@ -28,6 +29,47 @@ static DECLARE_WAIT_QUEUE_HEAD(rxrpc_peer_wq);
28static void rxrpc_destroy_peer(struct work_struct *work); 29static void rxrpc_destroy_peer(struct work_struct *work);
29 30
30/* 31/*
32 * assess the MTU size for the network interface through which this peer is
33 * reached
34 */
35static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer)
36{
37 struct rtable *rt;
38 struct flowi fl;
39 int ret;
40
41 peer->if_mtu = 1500;
42
43 memset(&fl, 0, sizeof(fl));
44
45 switch (peer->srx.transport.family) {
46 case AF_INET:
47 fl.oif = 0;
48 fl.proto = IPPROTO_UDP,
49 fl.nl_u.ip4_u.saddr = 0;
50 fl.nl_u.ip4_u.daddr = peer->srx.transport.sin.sin_addr.s_addr;
51 fl.nl_u.ip4_u.tos = 0;
52 /* assume AFS.CM talking to AFS.FS */
53 fl.uli_u.ports.sport = htons(7001);
54 fl.uli_u.ports.dport = htons(7000);
55 break;
56 default:
57 BUG();
58 }
59
60 ret = ip_route_output_key(&rt, &fl);
61 if (ret < 0) {
62 kleave(" [route err %d]", ret);
63 return;
64 }
65
66 peer->if_mtu = dst_mtu(&rt->u.dst);
67 dst_release(&rt->u.dst);
68
69 kleave(" [if_mtu %u]", peer->if_mtu);
70}
71
72/*
31 * allocate a new peer 73 * allocate a new peer
32 */ 74 */
33static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx, 75static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
@@ -47,7 +89,8 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
47 peer->debug_id = atomic_inc_return(&rxrpc_debug_id); 89 peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
48 memcpy(&peer->srx, srx, sizeof(*srx)); 90 memcpy(&peer->srx, srx, sizeof(*srx));
49 91
50 peer->mtu = peer->if_mtu = 65535; 92 rxrpc_assess_MTU_size(peer);
93 peer->mtu = peer->if_mtu;
51 94
52 if (srx->transport.family == AF_INET) { 95 if (srx->transport.family == AF_INET) {
53 peer->hdrsize = sizeof(struct iphdr); 96 peer->hdrsize = sizeof(struct iphdr);
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 8699e7006d80..bec600af03ca 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -894,9 +894,10 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
894 s_idx = cb->args[0]; 894 s_idx = cb->args[0];
895 s_q_idx = q_idx = cb->args[1]; 895 s_q_idx = q_idx = cb->args[1];
896 read_lock(&dev_base_lock); 896 read_lock(&dev_base_lock);
897 for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) { 897 idx = 0;
898 for_each_netdev(dev) {
898 if (idx < s_idx) 899 if (idx < s_idx)
899 continue; 900 goto cont;
900 if (idx > s_idx) 901 if (idx > s_idx)
901 s_q_idx = 0; 902 s_q_idx = 0;
902 q_idx = 0; 903 q_idx = 0;
@@ -910,6 +911,8 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
910 goto done; 911 goto done;
911 q_idx++; 912 q_idx++;
912 } 913 }
914cont:
915 idx++;
913 } 916 }
914 917
915done: 918done:
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index db73ef97485a..df94e3cdfba3 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1103,6 +1103,13 @@ void sctp_assoc_update(struct sctp_association *asoc,
1103 asoc->ssnmap = new->ssnmap; 1103 asoc->ssnmap = new->ssnmap;
1104 new->ssnmap = NULL; 1104 new->ssnmap = NULL;
1105 } 1105 }
1106
1107 if (!asoc->assoc_id) {
1108 /* get a new association id since we don't have one
1109 * yet.
1110 */
1111 sctp_assoc_set_id(asoc, GFP_ATOMIC);
1112 }
1106 } 1113 }
1107} 1114}
1108 1115
@@ -1375,3 +1382,25 @@ out:
1375 sctp_read_unlock(&asoc->base.addr_lock); 1382 sctp_read_unlock(&asoc->base.addr_lock);
1376 return found; 1383 return found;
1377} 1384}
1385
1386/* Set an association id for a given association */
1387int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
1388{
1389 int assoc_id;
1390 int error = 0;
1391retry:
1392 if (unlikely(!idr_pre_get(&sctp_assocs_id, gfp)))
1393 return -ENOMEM;
1394
1395 spin_lock_bh(&sctp_assocs_id_lock);
1396 error = idr_get_new_above(&sctp_assocs_id, (void *)asoc,
1397 1, &assoc_id);
1398 spin_unlock_bh(&sctp_assocs_id_lock);
1399 if (error == -EAGAIN)
1400 goto retry;
1401 else if (error)
1402 return error;
1403
1404 asoc->assoc_id = (sctp_assoc_t) assoc_id;
1405 return error;
1406}
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index ca527a27dd05..84cd53635fe8 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -992,45 +992,52 @@ static struct sctp_pf sctp_pf_inet6_specific = {
992 .af = &sctp_ipv6_specific, 992 .af = &sctp_ipv6_specific,
993}; 993};
994 994
995/* Initialize IPv6 support and register with inet6 stack. */ 995/* Initialize IPv6 support and register with socket layer. */
996int sctp_v6_init(void) 996int sctp_v6_init(void)
997{ 997{
998 int rc = proto_register(&sctpv6_prot, 1); 998 int rc;
999 999
1000 /* Register the SCTP specific PF_INET6 functions. */
1001 sctp_register_pf(&sctp_pf_inet6_specific, PF_INET6);
1002
1003 /* Register the SCTP specific AF_INET6 functions. */
1004 sctp_register_af(&sctp_ipv6_specific);
1005
1006 rc = proto_register(&sctpv6_prot, 1);
1000 if (rc) 1007 if (rc)
1001 goto out; 1008 return rc;
1002 /* Register inet6 protocol. */
1003 rc = -EAGAIN;
1004 if (inet6_add_protocol(&sctpv6_protocol, IPPROTO_SCTP) < 0)
1005 goto out_unregister_sctp_proto;
1006 1009
1007 /* Add SCTPv6(UDP and TCP style) to inetsw6 linked list. */ 1010 /* Add SCTPv6(UDP and TCP style) to inetsw6 linked list. */
1008 inet6_register_protosw(&sctpv6_seqpacket_protosw); 1011 inet6_register_protosw(&sctpv6_seqpacket_protosw);
1009 inet6_register_protosw(&sctpv6_stream_protosw); 1012 inet6_register_protosw(&sctpv6_stream_protosw);
1010 1013
1011 /* Register the SCTP specific PF_INET6 functions. */ 1014 return 0;
1012 sctp_register_pf(&sctp_pf_inet6_specific, PF_INET6); 1015}
1013
1014 /* Register the SCTP specific AF_INET6 functions. */
1015 sctp_register_af(&sctp_ipv6_specific);
1016 1016
1017/* Register with inet6 layer. */
1018int sctp_v6_add_protocol(void)
1019{
1017 /* Register notifier for inet6 address additions/deletions. */ 1020 /* Register notifier for inet6 address additions/deletions. */
1018 register_inet6addr_notifier(&sctp_inet6addr_notifier); 1021 register_inet6addr_notifier(&sctp_inet6addr_notifier);
1019 rc = 0; 1022
1020out: 1023 if (inet6_add_protocol(&sctpv6_protocol, IPPROTO_SCTP) < 0)
1021 return rc; 1024 return -EAGAIN;
1022out_unregister_sctp_proto: 1025
1023 proto_unregister(&sctpv6_prot); 1026 return 0;
1024 goto out;
1025} 1027}
1026 1028
1027/* IPv6 specific exit support. */ 1029/* IPv6 specific exit support. */
1028void sctp_v6_exit(void) 1030void sctp_v6_exit(void)
1029{ 1031{
1030 list_del(&sctp_ipv6_specific.list);
1031 inet6_del_protocol(&sctpv6_protocol, IPPROTO_SCTP);
1032 inet6_unregister_protosw(&sctpv6_seqpacket_protosw); 1032 inet6_unregister_protosw(&sctpv6_seqpacket_protosw);
1033 inet6_unregister_protosw(&sctpv6_stream_protosw); 1033 inet6_unregister_protosw(&sctpv6_stream_protosw);
1034 unregister_inet6addr_notifier(&sctp_inet6addr_notifier);
1035 proto_unregister(&sctpv6_prot); 1034 proto_unregister(&sctpv6_prot);
1035 list_del(&sctp_ipv6_specific.list);
1036}
1037
1038/* Unregister with inet6 layer. */
1039void sctp_v6_del_protocol(void)
1040{
1041 inet6_del_protocol(&sctpv6_protocol, IPPROTO_SCTP);
1042 unregister_inet6addr_notifier(&sctp_inet6addr_notifier);
1036} 1043}
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index c361deb6cea9..34bab36637ac 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -170,7 +170,7 @@ static void sctp_get_local_addr_list(void)
170 struct sctp_af *af; 170 struct sctp_af *af;
171 171
172 read_lock(&dev_base_lock); 172 read_lock(&dev_base_lock);
173 for (dev = dev_base; dev; dev = dev->next) { 173 for_each_netdev(dev) {
174 __list_for_each(pos, &sctp_address_families) { 174 __list_for_each(pos, &sctp_address_families) {
175 af = list_entry(pos, struct sctp_af, list); 175 af = list_entry(pos, struct sctp_af, list);
176 af->copy_addrlist(&sctp_local_addr_list, dev); 176 af->copy_addrlist(&sctp_local_addr_list, dev);
@@ -975,28 +975,14 @@ SCTP_STATIC __init int sctp_init(void)
975 if (!sctp_sanity_check()) 975 if (!sctp_sanity_check())
976 goto out; 976 goto out;
977 977
978 status = proto_register(&sctp_prot, 1); 978 /* Allocate bind_bucket and chunk caches. */
979 if (status)
980 goto out;
981
982 /* Add SCTP to inet_protos hash table. */
983 status = -EAGAIN;
984 if (inet_add_protocol(&sctp_protocol, IPPROTO_SCTP) < 0)
985 goto err_add_protocol;
986
987 /* Add SCTP(TCP and UDP style) to inetsw linked list. */
988 inet_register_protosw(&sctp_seqpacket_protosw);
989 inet_register_protosw(&sctp_stream_protosw);
990
991 /* Allocate a cache pools. */
992 status = -ENOBUFS; 979 status = -ENOBUFS;
993 sctp_bucket_cachep = kmem_cache_create("sctp_bind_bucket", 980 sctp_bucket_cachep = kmem_cache_create("sctp_bind_bucket",
994 sizeof(struct sctp_bind_bucket), 981 sizeof(struct sctp_bind_bucket),
995 0, SLAB_HWCACHE_ALIGN, 982 0, SLAB_HWCACHE_ALIGN,
996 NULL, NULL); 983 NULL, NULL);
997
998 if (!sctp_bucket_cachep) 984 if (!sctp_bucket_cachep)
999 goto err_bucket_cachep; 985 goto out;
1000 986
1001 sctp_chunk_cachep = kmem_cache_create("sctp_chunk", 987 sctp_chunk_cachep = kmem_cache_create("sctp_chunk",
1002 sizeof(struct sctp_chunk), 988 sizeof(struct sctp_chunk),
@@ -1153,6 +1139,14 @@ SCTP_STATIC __init int sctp_init(void)
1153 INIT_LIST_HEAD(&sctp_address_families); 1139 INIT_LIST_HEAD(&sctp_address_families);
1154 sctp_register_af(&sctp_ipv4_specific); 1140 sctp_register_af(&sctp_ipv4_specific);
1155 1141
1142 status = proto_register(&sctp_prot, 1);
1143 if (status)
1144 goto err_proto_register;
1145
1146 /* Register SCTP(UDP and TCP style) with socket layer. */
1147 inet_register_protosw(&sctp_seqpacket_protosw);
1148 inet_register_protosw(&sctp_stream_protosw);
1149
1156 status = sctp_v6_init(); 1150 status = sctp_v6_init();
1157 if (status) 1151 if (status)
1158 goto err_v6_init; 1152 goto err_v6_init;
@@ -1166,19 +1160,39 @@ SCTP_STATIC __init int sctp_init(void)
1166 1160
1167 /* Initialize the local address list. */ 1161 /* Initialize the local address list. */
1168 INIT_LIST_HEAD(&sctp_local_addr_list); 1162 INIT_LIST_HEAD(&sctp_local_addr_list);
1169
1170 sctp_get_local_addr_list(); 1163 sctp_get_local_addr_list();
1171 1164
1172 /* Register notifier for inet address additions/deletions. */ 1165 /* Register notifier for inet address additions/deletions. */
1173 register_inetaddr_notifier(&sctp_inetaddr_notifier); 1166 register_inetaddr_notifier(&sctp_inetaddr_notifier);
1174 1167
1168 /* Register SCTP with inet layer. */
1169 if (inet_add_protocol(&sctp_protocol, IPPROTO_SCTP) < 0) {
1170 status = -EAGAIN;
1171 goto err_add_protocol;
1172 }
1173
1174 /* Register SCTP with inet6 layer. */
1175 status = sctp_v6_add_protocol();
1176 if (status)
1177 goto err_v6_add_protocol;
1178
1175 __unsafe(THIS_MODULE); 1179 __unsafe(THIS_MODULE);
1176 status = 0; 1180 status = 0;
1177out: 1181out:
1178 return status; 1182 return status;
1183err_v6_add_protocol:
1184 inet_del_protocol(&sctp_protocol, IPPROTO_SCTP);
1185 unregister_inetaddr_notifier(&sctp_inetaddr_notifier);
1186err_add_protocol:
1187 sctp_free_local_addr_list();
1188 sock_release(sctp_ctl_socket);
1179err_ctl_sock_init: 1189err_ctl_sock_init:
1180 sctp_v6_exit(); 1190 sctp_v6_exit();
1181err_v6_init: 1191err_v6_init:
1192 inet_unregister_protosw(&sctp_stream_protosw);
1193 inet_unregister_protosw(&sctp_seqpacket_protosw);
1194 proto_unregister(&sctp_prot);
1195err_proto_register:
1182 sctp_sysctl_unregister(); 1196 sctp_sysctl_unregister();
1183 list_del(&sctp_ipv4_specific.list); 1197 list_del(&sctp_ipv4_specific.list);
1184 free_pages((unsigned long)sctp_port_hashtable, 1198 free_pages((unsigned long)sctp_port_hashtable,
@@ -1192,19 +1206,13 @@ err_ehash_alloc:
1192 sizeof(struct sctp_hashbucket))); 1206 sizeof(struct sctp_hashbucket)));
1193err_ahash_alloc: 1207err_ahash_alloc:
1194 sctp_dbg_objcnt_exit(); 1208 sctp_dbg_objcnt_exit();
1195err_init_proc:
1196 sctp_proc_exit(); 1209 sctp_proc_exit();
1210err_init_proc:
1197 cleanup_sctp_mibs(); 1211 cleanup_sctp_mibs();
1198err_init_mibs: 1212err_init_mibs:
1199 kmem_cache_destroy(sctp_chunk_cachep); 1213 kmem_cache_destroy(sctp_chunk_cachep);
1200err_chunk_cachep: 1214err_chunk_cachep:
1201 kmem_cache_destroy(sctp_bucket_cachep); 1215 kmem_cache_destroy(sctp_bucket_cachep);
1202err_bucket_cachep:
1203 inet_del_protocol(&sctp_protocol, IPPROTO_SCTP);
1204 inet_unregister_protosw(&sctp_seqpacket_protosw);
1205 inet_unregister_protosw(&sctp_stream_protosw);
1206err_add_protocol:
1207 proto_unregister(&sctp_prot);
1208 goto out; 1216 goto out;
1209} 1217}
1210 1218
@@ -1215,8 +1223,9 @@ SCTP_STATIC __exit void sctp_exit(void)
1215 * up all the remaining associations and all that memory. 1223 * up all the remaining associations and all that memory.
1216 */ 1224 */
1217 1225
1218 /* Unregister notifier for inet address additions/deletions. */ 1226 /* Unregister with inet6/inet layers. */
1219 unregister_inetaddr_notifier(&sctp_inetaddr_notifier); 1227 sctp_v6_del_protocol();
1228 inet_del_protocol(&sctp_protocol, IPPROTO_SCTP);
1220 1229
1221 /* Free the local address list. */ 1230 /* Free the local address list. */
1222 sctp_free_local_addr_list(); 1231 sctp_free_local_addr_list();
@@ -1224,7 +1233,16 @@ SCTP_STATIC __exit void sctp_exit(void)
1224 /* Free the control endpoint. */ 1233 /* Free the control endpoint. */
1225 sock_release(sctp_ctl_socket); 1234 sock_release(sctp_ctl_socket);
1226 1235
1236 /* Cleanup v6 initializations. */
1227 sctp_v6_exit(); 1237 sctp_v6_exit();
1238
1239 /* Unregister with socket layer. */
1240 inet_unregister_protosw(&sctp_stream_protosw);
1241 inet_unregister_protosw(&sctp_seqpacket_protosw);
1242
1243 /* Unregister notifier for inet address additions/deletions. */
1244 unregister_inetaddr_notifier(&sctp_inetaddr_notifier);
1245
1228 sctp_sysctl_unregister(); 1246 sctp_sysctl_unregister();
1229 list_del(&sctp_ipv4_specific.list); 1247 list_del(&sctp_ipv4_specific.list);
1230 1248
@@ -1236,16 +1254,13 @@ SCTP_STATIC __exit void sctp_exit(void)
1236 get_order(sctp_port_hashsize * 1254 get_order(sctp_port_hashsize *
1237 sizeof(struct sctp_bind_hashbucket))); 1255 sizeof(struct sctp_bind_hashbucket)));
1238 1256
1239 kmem_cache_destroy(sctp_chunk_cachep);
1240 kmem_cache_destroy(sctp_bucket_cachep);
1241
1242 sctp_dbg_objcnt_exit(); 1257 sctp_dbg_objcnt_exit();
1243 sctp_proc_exit(); 1258 sctp_proc_exit();
1244 cleanup_sctp_mibs(); 1259 cleanup_sctp_mibs();
1245 1260
1246 inet_del_protocol(&sctp_protocol, IPPROTO_SCTP); 1261 kmem_cache_destroy(sctp_chunk_cachep);
1247 inet_unregister_protosw(&sctp_seqpacket_protosw); 1262 kmem_cache_destroy(sctp_bucket_cachep);
1248 inet_unregister_protosw(&sctp_stream_protosw); 1263
1249 proto_unregister(&sctp_prot); 1264 proto_unregister(&sctp_prot);
1250} 1265}
1251 1266
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index be783a3761c4..8d18f570c2e6 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1939,7 +1939,6 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1939 * association. 1939 * association.
1940 */ 1940 */
1941 if (!asoc->temp) { 1941 if (!asoc->temp) {
1942 int assoc_id;
1943 int error; 1942 int error;
1944 1943
1945 asoc->ssnmap = sctp_ssnmap_new(asoc->c.sinit_max_instreams, 1944 asoc->ssnmap = sctp_ssnmap_new(asoc->c.sinit_max_instreams,
@@ -1947,19 +1946,9 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1947 if (!asoc->ssnmap) 1946 if (!asoc->ssnmap)
1948 goto clean_up; 1947 goto clean_up;
1949 1948
1950 retry: 1949 error = sctp_assoc_set_id(asoc, gfp);
1951 if (unlikely(!idr_pre_get(&sctp_assocs_id, gfp))) 1950 if (error)
1952 goto clean_up; 1951 goto clean_up;
1953 spin_lock_bh(&sctp_assocs_id_lock);
1954 error = idr_get_new_above(&sctp_assocs_id, (void *)asoc, 1,
1955 &assoc_id);
1956 spin_unlock_bh(&sctp_assocs_id_lock);
1957 if (error == -EAGAIN)
1958 goto retry;
1959 else if (error)
1960 goto clean_up;
1961
1962 asoc->assoc_id = (sctp_assoc_t) assoc_id;
1963 } 1952 }
1964 1953
1965 /* ADDIP Section 4.1 ASCONF Chunk Procedures 1954 /* ADDIP Section 4.1 ASCONF Chunk Procedures
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index b37a7adeb150..d9fad4f6ffc3 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -862,6 +862,33 @@ static void sctp_cmd_set_sk_err(struct sctp_association *asoc, int error)
862 sk->sk_err = error; 862 sk->sk_err = error;
863} 863}
864 864
865/* Helper function to generate an association change event */
866static void sctp_cmd_assoc_change(sctp_cmd_seq_t *commands,
867 struct sctp_association *asoc,
868 u8 state)
869{
870 struct sctp_ulpevent *ev;
871
872 ev = sctp_ulpevent_make_assoc_change(asoc, 0, state, 0,
873 asoc->c.sinit_num_ostreams,
874 asoc->c.sinit_max_instreams,
875 NULL, GFP_ATOMIC);
876 if (ev)
877 sctp_ulpq_tail_event(&asoc->ulpq, ev);
878}
879
880/* Helper function to generate an adaptation indication event */
881static void sctp_cmd_adaptation_ind(sctp_cmd_seq_t *commands,
882 struct sctp_association *asoc)
883{
884 struct sctp_ulpevent *ev;
885
886 ev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC);
887
888 if (ev)
889 sctp_ulpq_tail_event(&asoc->ulpq, ev);
890}
891
865/* These three macros allow us to pull the debugging code out of the 892/* These three macros allow us to pull the debugging code out of the
866 * main flow of sctp_do_sm() to keep attention focused on the real 893 * main flow of sctp_do_sm() to keep attention focused on the real
867 * functionality there. 894 * functionality there.
@@ -1485,6 +1512,14 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1485 case SCTP_CMD_SET_SK_ERR: 1512 case SCTP_CMD_SET_SK_ERR:
1486 sctp_cmd_set_sk_err(asoc, cmd->obj.error); 1513 sctp_cmd_set_sk_err(asoc, cmd->obj.error);
1487 break; 1514 break;
1515 case SCTP_CMD_ASSOC_CHANGE:
1516 sctp_cmd_assoc_change(commands, asoc,
1517 cmd->obj.u8);
1518 break;
1519 case SCTP_CMD_ADAPTATION_IND:
1520 sctp_cmd_adaptation_ind(commands, asoc);
1521 break;
1522
1488 default: 1523 default:
1489 printk(KERN_WARNING "Impossible command: %u, %p\n", 1524 printk(KERN_WARNING "Impossible command: %u, %p\n",
1490 cmd->verb, cmd->obj.ptr); 1525 cmd->verb, cmd->obj.ptr);
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 9e28a5d51200..f02ce3dddb7b 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -1656,7 +1656,6 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep,
1656 struct sctp_association *new_asoc) 1656 struct sctp_association *new_asoc)
1657{ 1657{
1658 sctp_init_chunk_t *peer_init; 1658 sctp_init_chunk_t *peer_init;
1659 struct sctp_ulpevent *ev;
1660 struct sctp_chunk *repl; 1659 struct sctp_chunk *repl;
1661 1660
1662 /* new_asoc is a brand-new association, so these are not yet 1661 /* new_asoc is a brand-new association, so these are not yet
@@ -1687,34 +1686,28 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep,
1687 * D) IMPLEMENTATION NOTE: An implementation may choose to 1686 * D) IMPLEMENTATION NOTE: An implementation may choose to
1688 * send the Communication Up notification to the SCTP user 1687 * send the Communication Up notification to the SCTP user
1689 * upon reception of a valid COOKIE ECHO chunk. 1688 * upon reception of a valid COOKIE ECHO chunk.
1689 *
1690 * Sadly, this needs to be implemented as a side-effect, because
1691 * we are not guaranteed to have set the association id of the real
1692 * association and so these notifications need to be delayed until
1693 * the association id is allocated.
1690 */ 1694 */
1691 ev = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_COMM_UP, 0,
1692 new_asoc->c.sinit_num_ostreams,
1693 new_asoc->c.sinit_max_instreams,
1694 NULL, GFP_ATOMIC);
1695 if (!ev)
1696 goto nomem_ev;
1697 1695
1698 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); 1696 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_CHANGE, SCTP_U8(SCTP_COMM_UP));
1699 1697
1700 /* Sockets API Draft Section 5.3.1.6 1698 /* Sockets API Draft Section 5.3.1.6
1701 * When a peer sends a Adaptation Layer Indication parameter , SCTP 1699 * When a peer sends a Adaptation Layer Indication parameter , SCTP
1702 * delivers this notification to inform the application that of the 1700 * delivers this notification to inform the application that of the
1703 * peers requested adaptation layer. 1701 * peers requested adaptation layer.
1702 *
1703 * This also needs to be done as a side effect for the same reason as
1704 * above.
1704 */ 1705 */
1705 if (asoc->peer.adaptation_ind) { 1706 if (asoc->peer.adaptation_ind)
1706 ev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC); 1707 sctp_add_cmd_sf(commands, SCTP_CMD_ADAPTATION_IND, SCTP_NULL());
1707 if (!ev)
1708 goto nomem_ev;
1709
1710 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
1711 SCTP_ULPEVENT(ev));
1712 }
1713 1708
1714 return SCTP_DISPOSITION_CONSUME; 1709 return SCTP_DISPOSITION_CONSUME;
1715 1710
1716nomem_ev:
1717 sctp_chunk_free(repl);
1718nomem: 1711nomem:
1719 return SCTP_DISPOSITION_NOMEM; 1712 return SCTP_DISPOSITION_NOMEM;
1720} 1713}
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 2fc0a92caa78..9f1a908776de 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -972,6 +972,7 @@ static int __sctp_connect(struct sock* sk,
972 int walk_size = 0; 972 int walk_size = 0;
973 union sctp_addr *sa_addr; 973 union sctp_addr *sa_addr;
974 void *addr_buf; 974 void *addr_buf;
975 unsigned short port;
975 976
976 sp = sctp_sk(sk); 977 sp = sctp_sk(sk);
977 ep = sp->ep; 978 ep = sp->ep;
@@ -992,6 +993,7 @@ static int __sctp_connect(struct sock* sk,
992 while (walk_size < addrs_size) { 993 while (walk_size < addrs_size) {
993 sa_addr = (union sctp_addr *)addr_buf; 994 sa_addr = (union sctp_addr *)addr_buf;
994 af = sctp_get_af_specific(sa_addr->sa.sa_family); 995 af = sctp_get_af_specific(sa_addr->sa.sa_family);
996 port = ntohs(sa_addr->v4.sin_port);
995 997
996 /* If the address family is not supported or if this address 998 /* If the address family is not supported or if this address
997 * causes the address buffer to overflow return EINVAL. 999 * causes the address buffer to overflow return EINVAL.
@@ -1005,6 +1007,12 @@ static int __sctp_connect(struct sock* sk,
1005 if (err) 1007 if (err)
1006 goto out_free; 1008 goto out_free;
1007 1009
1010 /* Make sure the destination port is correctly set
1011 * in all addresses.
1012 */
1013 if (asoc && asoc->peer.port && asoc->peer.port != port)
1014 goto out_free;
1015
1008 memcpy(&to, sa_addr, af->sockaddr_len); 1016 memcpy(&to, sa_addr, af->sockaddr_len);
1009 1017
1010 /* Check if there already is a matching association on the 1018 /* Check if there already is a matching association on the
@@ -5012,7 +5020,8 @@ pp_found:
5012 struct hlist_node *node; 5020 struct hlist_node *node;
5013 5021
5014 SCTP_DEBUG_PRINTK("sctp_get_port() found a possible match\n"); 5022 SCTP_DEBUG_PRINTK("sctp_get_port() found a possible match\n");
5015 if (pp->fastreuse && sk->sk_reuse) 5023 if (pp->fastreuse && sk->sk_reuse &&
5024 sk->sk_state != SCTP_SS_LISTENING)
5016 goto success; 5025 goto success;
5017 5026
5018 /* Run through the list of sockets bound to the port 5027 /* Run through the list of sockets bound to the port
@@ -5029,7 +5038,8 @@ pp_found:
5029 struct sctp_endpoint *ep2; 5038 struct sctp_endpoint *ep2;
5030 ep2 = sctp_sk(sk2)->ep; 5039 ep2 = sctp_sk(sk2)->ep;
5031 5040
5032 if (reuse && sk2->sk_reuse) 5041 if (reuse && sk2->sk_reuse &&
5042 sk2->sk_state != SCTP_SS_LISTENING)
5033 continue; 5043 continue;
5034 5044
5035 if (sctp_bind_addr_match(&ep2->base.bind_addr, addr, 5045 if (sctp_bind_addr_match(&ep2->base.bind_addr, addr,
@@ -5050,9 +5060,13 @@ pp_not_found:
5050 * if sk->sk_reuse is too (that is, if the caller requested 5060 * if sk->sk_reuse is too (that is, if the caller requested
5051 * SO_REUSEADDR on this socket -sk-). 5061 * SO_REUSEADDR on this socket -sk-).
5052 */ 5062 */
5053 if (hlist_empty(&pp->owner)) 5063 if (hlist_empty(&pp->owner)) {
5054 pp->fastreuse = sk->sk_reuse ? 1 : 0; 5064 if (sk->sk_reuse && sk->sk_state != SCTP_SS_LISTENING)
5055 else if (pp->fastreuse && !sk->sk_reuse) 5065 pp->fastreuse = 1;
5066 else
5067 pp->fastreuse = 0;
5068 } else if (pp->fastreuse &&
5069 (!sk->sk_reuse || sk->sk_state == SCTP_SS_LISTENING))
5056 pp->fastreuse = 0; 5070 pp->fastreuse = 0;
5057 5071
5058 /* We are set, so fill up all the data in the hash table 5072 /* We are set, so fill up all the data in the hash table
@@ -5060,8 +5074,8 @@ pp_not_found:
5060 * sockets FIXME: Blurry, NPI (ipg). 5074 * sockets FIXME: Blurry, NPI (ipg).
5061 */ 5075 */
5062success: 5076success:
5063 inet_sk(sk)->num = snum;
5064 if (!sctp_sk(sk)->bind_hash) { 5077 if (!sctp_sk(sk)->bind_hash) {
5078 inet_sk(sk)->num = snum;
5065 sk_add_bind_node(sk, &pp->owner); 5079 sk_add_bind_node(sk, &pp->owner);
5066 sctp_sk(sk)->bind_hash = pp; 5080 sctp_sk(sk)->bind_hash = pp;
5067 } 5081 }
@@ -5134,12 +5148,16 @@ SCTP_STATIC int sctp_seqpacket_listen(struct sock *sk, int backlog)
5134 * This is not currently spelled out in the SCTP sockets 5148 * This is not currently spelled out in the SCTP sockets
5135 * extensions draft, but follows the practice as seen in TCP 5149 * extensions draft, but follows the practice as seen in TCP
5136 * sockets. 5150 * sockets.
5151 *
5152 * Additionally, turn off fastreuse flag since we are not listening
5137 */ 5153 */
5154 sk->sk_state = SCTP_SS_LISTENING;
5138 if (!ep->base.bind_addr.port) { 5155 if (!ep->base.bind_addr.port) {
5139 if (sctp_autobind(sk)) 5156 if (sctp_autobind(sk))
5140 return -EAGAIN; 5157 return -EAGAIN;
5141 } 5158 } else
5142 sk->sk_state = SCTP_SS_LISTENING; 5159 sctp_sk(sk)->bind_hash->fastreuse = 0;
5160
5143 sctp_hash_endpoint(ep); 5161 sctp_hash_endpoint(ep);
5144 return 0; 5162 return 0;
5145} 5163}
@@ -5177,11 +5195,13 @@ SCTP_STATIC int sctp_stream_listen(struct sock *sk, int backlog)
5177 * extensions draft, but follows the practice as seen in TCP 5195 * extensions draft, but follows the practice as seen in TCP
5178 * sockets. 5196 * sockets.
5179 */ 5197 */
5198 sk->sk_state = SCTP_SS_LISTENING;
5180 if (!ep->base.bind_addr.port) { 5199 if (!ep->base.bind_addr.port) {
5181 if (sctp_autobind(sk)) 5200 if (sctp_autobind(sk))
5182 return -EAGAIN; 5201 return -EAGAIN;
5183 } 5202 } else
5184 sk->sk_state = SCTP_SS_LISTENING; 5203 sctp_sk(sk)->bind_hash->fastreuse = 0;
5204
5185 sk->sk_max_ack_backlog = backlog; 5205 sk->sk_max_ack_backlog = backlog;
5186 sctp_hash_endpoint(ep); 5206 sctp_hash_endpoint(ep);
5187 return 0; 5207 return 0;
diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile
index cdcab9ca4c60..8ebfc4db7f51 100644
--- a/net/sunrpc/Makefile
+++ b/net/sunrpc/Makefile
@@ -9,7 +9,7 @@ obj-$(CONFIG_SUNRPC_GSS) += auth_gss/
9sunrpc-y := clnt.o xprt.o socklib.o xprtsock.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 rpcb_clnt.o timer.o xdr.o \
13 sunrpc_syms.o cache.o rpc_pipe.o 13 sunrpc_syms.o cache.o rpc_pipe.o
14sunrpc-$(CONFIG_PROC_FS) += stats.o 14sunrpc-$(CONFIG_PROC_FS) += stats.o
15sunrpc-$(CONFIG_SYSCTL) += sysctl.o 15sunrpc-$(CONFIG_SYSCTL) += sysctl.o
diff --git a/net/sunrpc/auth_gss/gss_spkm3_seal.c b/net/sunrpc/auth_gss/gss_spkm3_seal.c
index 104cbf4f769f..d158635de6c0 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_seal.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_seal.c
@@ -123,9 +123,6 @@ spkm3_make_token(struct spkm3_ctx *ctx,
123 123
124 return GSS_S_COMPLETE; 124 return GSS_S_COMPLETE;
125out_err: 125out_err:
126 if (md5cksum.data)
127 kfree(md5cksum.data);
128
129 token->data = NULL; 126 token->data = NULL;
130 token->len = 0; 127 token->len = 0;
131 return GSS_S_FAILURE; 128 return GSS_S_FAILURE;
@@ -152,7 +149,7 @@ make_spkm3_checksum(s32 cksumtype, struct xdr_netobj *key, char *header,
152 149
153 switch (cksumtype) { 150 switch (cksumtype) {
154 case CKSUMTYPE_HMAC_MD5: 151 case CKSUMTYPE_HMAC_MD5:
155 cksumname = "md5"; 152 cksumname = "hmac(md5)";
156 break; 153 break;
157 default: 154 default:
158 dprintk("RPC: spkm3_make_checksum:" 155 dprintk("RPC: spkm3_make_checksum:"
@@ -172,8 +169,12 @@ make_spkm3_checksum(s32 cksumtype, struct xdr_netobj *key, char *header,
172 if (err) 169 if (err)
173 goto out; 170 goto out;
174 171
172 err = crypto_hash_init(&desc);
173 if (err)
174 goto out;
175
175 sg_set_buf(sg, header, hdrlen); 176 sg_set_buf(sg, header, hdrlen);
176 crypto_hash_update(&desc, sg, 1); 177 crypto_hash_update(&desc, sg, sg->length);
177 178
178 xdr_process_buf(body, body_offset, body->len - body_offset, 179 xdr_process_buf(body, body_offset, body->len - body_offset,
179 spkm3_checksummer, &desc); 180 spkm3_checksummer, &desc);
@@ -184,5 +185,3 @@ out:
184 185
185 return err ? GSS_S_FAILURE : 0; 186 return err ? GSS_S_FAILURE : 0;
186} 187}
187
188EXPORT_SYMBOL(make_spkm3_checksum);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 396cdbe249d1..d8fbee40a19c 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -36,8 +36,6 @@
36#include <linux/sunrpc/metrics.h> 36#include <linux/sunrpc/metrics.h>
37 37
38 38
39#define RPC_SLACK_SPACE (1024) /* total overkill */
40
41#ifdef RPC_DEBUG 39#ifdef RPC_DEBUG
42# define RPCDBG_FACILITY RPCDBG_CALL 40# define RPCDBG_FACILITY RPCDBG_CALL
43#endif 41#endif
@@ -747,21 +745,38 @@ call_reserveresult(struct rpc_task *task)
747static void 745static void
748call_allocate(struct rpc_task *task) 746call_allocate(struct rpc_task *task)
749{ 747{
748 unsigned int slack = task->tk_auth->au_cslack;
750 struct rpc_rqst *req = task->tk_rqstp; 749 struct rpc_rqst *req = task->tk_rqstp;
751 struct rpc_xprt *xprt = task->tk_xprt; 750 struct rpc_xprt *xprt = task->tk_xprt;
752 unsigned int bufsiz; 751 struct rpc_procinfo *proc = task->tk_msg.rpc_proc;
753 752
754 dprint_status(task); 753 dprint_status(task);
755 754
755 task->tk_status = 0;
756 task->tk_action = call_bind; 756 task->tk_action = call_bind;
757
757 if (req->rq_buffer) 758 if (req->rq_buffer)
758 return; 759 return;
759 760
760 /* FIXME: compute buffer requirements more exactly using 761 if (proc->p_proc != 0) {
761 * auth->au_wslack */ 762 BUG_ON(proc->p_arglen == 0);
762 bufsiz = task->tk_msg.rpc_proc->p_bufsiz + RPC_SLACK_SPACE; 763 if (proc->p_decode != NULL)
764 BUG_ON(proc->p_replen == 0);
765 }
763 766
764 if (xprt->ops->buf_alloc(task, bufsiz << 1) != NULL) 767 /*
768 * Calculate the size (in quads) of the RPC call
769 * and reply headers, and convert both values
770 * to byte sizes.
771 */
772 req->rq_callsize = RPC_CALLHDRSIZE + (slack << 1) + proc->p_arglen;
773 req->rq_callsize <<= 2;
774 req->rq_rcvsize = RPC_REPHDRSIZE + slack + proc->p_replen;
775 req->rq_rcvsize <<= 2;
776
777 req->rq_buffer = xprt->ops->buf_alloc(task,
778 req->rq_callsize + req->rq_rcvsize);
779 if (req->rq_buffer != NULL)
765 return; 780 return;
766 781
767 dprintk("RPC: %5u rpc_buffer allocation failed\n", task->tk_pid); 782 dprintk("RPC: %5u rpc_buffer allocation failed\n", task->tk_pid);
@@ -788,6 +803,17 @@ rpc_task_force_reencode(struct rpc_task *task)
788 task->tk_rqstp->rq_snd_buf.len = 0; 803 task->tk_rqstp->rq_snd_buf.len = 0;
789} 804}
790 805
806static inline void
807rpc_xdr_buf_init(struct xdr_buf *buf, void *start, size_t len)
808{
809 buf->head[0].iov_base = start;
810 buf->head[0].iov_len = len;
811 buf->tail[0].iov_len = 0;
812 buf->page_len = 0;
813 buf->len = 0;
814 buf->buflen = len;
815}
816
791/* 817/*
792 * 3. Encode arguments of an RPC call 818 * 3. Encode arguments of an RPC call
793 */ 819 */
@@ -795,28 +821,17 @@ static void
795call_encode(struct rpc_task *task) 821call_encode(struct rpc_task *task)
796{ 822{
797 struct rpc_rqst *req = task->tk_rqstp; 823 struct rpc_rqst *req = task->tk_rqstp;
798 struct xdr_buf *sndbuf = &req->rq_snd_buf;
799 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
800 unsigned int bufsiz;
801 kxdrproc_t encode; 824 kxdrproc_t encode;
802 __be32 *p; 825 __be32 *p;
803 826
804 dprint_status(task); 827 dprint_status(task);
805 828
806 /* Default buffer setup */ 829 rpc_xdr_buf_init(&req->rq_snd_buf,
807 bufsiz = req->rq_bufsize >> 1; 830 req->rq_buffer,
808 sndbuf->head[0].iov_base = (void *)req->rq_buffer; 831 req->rq_callsize);
809 sndbuf->head[0].iov_len = bufsiz; 832 rpc_xdr_buf_init(&req->rq_rcv_buf,
810 sndbuf->tail[0].iov_len = 0; 833 (char *)req->rq_buffer + req->rq_callsize,
811 sndbuf->page_len = 0; 834 req->rq_rcvsize);
812 sndbuf->len = 0;
813 sndbuf->buflen = bufsiz;
814 rcvbuf->head[0].iov_base = (void *)((char *)req->rq_buffer + bufsiz);
815 rcvbuf->head[0].iov_len = bufsiz;
816 rcvbuf->tail[0].iov_len = 0;
817 rcvbuf->page_len = 0;
818 rcvbuf->len = 0;
819 rcvbuf->buflen = bufsiz;
820 835
821 /* Encode header and provided arguments */ 836 /* Encode header and provided arguments */
822 encode = task->tk_msg.rpc_proc->p_encode; 837 encode = task->tk_msg.rpc_proc->p_encode;
@@ -887,9 +902,11 @@ call_bind_status(struct rpc_task *task)
887 task->tk_pid); 902 task->tk_pid);
888 break; 903 break;
889 case -EPROTONOSUPPORT: 904 case -EPROTONOSUPPORT:
890 dprintk("RPC: %5u remote rpcbind version 2 unavailable\n", 905 dprintk("RPC: %5u remote rpcbind version unavailable, retrying\n",
891 task->tk_pid); 906 task->tk_pid);
892 break; 907 task->tk_status = 0;
908 task->tk_action = call_bind;
909 return;
893 default: 910 default:
894 dprintk("RPC: %5u unrecognized rpcbind error (%d)\n", 911 dprintk("RPC: %5u unrecognized rpcbind error (%d)\n",
895 task->tk_pid, -task->tk_status); 912 task->tk_pid, -task->tk_status);
diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
deleted file mode 100644
index d9f765344589..000000000000
--- a/net/sunrpc/pmap_clnt.c
+++ /dev/null
@@ -1,383 +0,0 @@
1/*
2 * linux/net/sunrpc/pmap_clnt.c
3 *
4 * In-kernel RPC portmapper client.
5 *
6 * Portmapper supports version 2 of the rpcbind protocol (RFC 1833).
7 *
8 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
9 */
10
11#include <linux/types.h>
12#include <linux/socket.h>
13#include <linux/kernel.h>
14#include <linux/errno.h>
15#include <linux/uio.h>
16#include <linux/in.h>
17#include <linux/sunrpc/clnt.h>
18#include <linux/sunrpc/sched.h>
19
20#ifdef RPC_DEBUG
21# define RPCDBG_FACILITY RPCDBG_PMAP
22#endif
23
24#define PMAP_SET 1
25#define PMAP_UNSET 2
26#define PMAP_GETPORT 3
27
28struct portmap_args {
29 u32 pm_prog;
30 u32 pm_vers;
31 u32 pm_prot;
32 unsigned short pm_port;
33 struct rpc_xprt * pm_xprt;
34};
35
36static struct rpc_procinfo pmap_procedures[];
37static struct rpc_clnt * pmap_create(char *, struct sockaddr_in *, int, int);
38static void pmap_getport_done(struct rpc_task *, void *);
39static struct rpc_program pmap_program;
40
41static void pmap_getport_prepare(struct rpc_task *task, void *calldata)
42{
43 struct portmap_args *map = calldata;
44 struct rpc_message msg = {
45 .rpc_proc = &pmap_procedures[PMAP_GETPORT],
46 .rpc_argp = map,
47 .rpc_resp = &map->pm_port,
48 };
49
50 rpc_call_setup(task, &msg, 0);
51}
52
53static inline struct portmap_args *pmap_map_alloc(void)
54{
55 return kmalloc(sizeof(struct portmap_args), GFP_NOFS);
56}
57
58static inline void pmap_map_free(struct portmap_args *map)
59{
60 kfree(map);
61}
62
63static void pmap_map_release(void *data)
64{
65 struct portmap_args *map = data;
66
67 xprt_put(map->pm_xprt);
68 pmap_map_free(map);
69}
70
71static const struct rpc_call_ops pmap_getport_ops = {
72 .rpc_call_prepare = pmap_getport_prepare,
73 .rpc_call_done = pmap_getport_done,
74 .rpc_release = pmap_map_release,
75};
76
77static inline void pmap_wake_portmap_waiters(struct rpc_xprt *xprt, int status)
78{
79 xprt_clear_binding(xprt);
80 rpc_wake_up_status(&xprt->binding, status);
81}
82
83/**
84 * rpc_getport - obtain the port for a given RPC service on a given host
85 * @task: task that is waiting for portmapper request
86 *
87 * This one can be called for an ongoing RPC request, and can be used in
88 * an async (rpciod) context.
89 */
90void rpc_getport(struct rpc_task *task)
91{
92 struct rpc_clnt *clnt = task->tk_client;
93 struct rpc_xprt *xprt = task->tk_xprt;
94 struct sockaddr_in addr;
95 struct portmap_args *map;
96 struct rpc_clnt *pmap_clnt;
97 struct rpc_task *child;
98 int status;
99
100 dprintk("RPC: %5u rpc_getport(%s, %u, %u, %d)\n",
101 task->tk_pid, clnt->cl_server,
102 clnt->cl_prog, clnt->cl_vers, xprt->prot);
103
104 /* Autobind on cloned rpc clients is discouraged */
105 BUG_ON(clnt->cl_parent != clnt);
106
107 status = -EACCES; /* tell caller to check again */
108 if (xprt_test_and_set_binding(xprt))
109 goto bailout_nowake;
110
111 /* Put self on queue before sending rpcbind request, in case
112 * pmap_getport_done completes before we return from rpc_run_task */
113 rpc_sleep_on(&xprt->binding, task, NULL, NULL);
114
115 /* Someone else may have bound if we slept */
116 status = 0;
117 if (xprt_bound(xprt))
118 goto bailout_nofree;
119
120 status = -ENOMEM;
121 map = pmap_map_alloc();
122 if (!map)
123 goto bailout_nofree;
124 map->pm_prog = clnt->cl_prog;
125 map->pm_vers = clnt->cl_vers;
126 map->pm_prot = xprt->prot;
127 map->pm_port = 0;
128 map->pm_xprt = xprt_get(xprt);
129
130 rpc_peeraddr(clnt, (struct sockaddr *) &addr, sizeof(addr));
131 pmap_clnt = pmap_create(clnt->cl_server, &addr, map->pm_prot, 0);
132 status = PTR_ERR(pmap_clnt);
133 if (IS_ERR(pmap_clnt))
134 goto bailout;
135
136 status = -EIO;
137 child = rpc_run_task(pmap_clnt, RPC_TASK_ASYNC, &pmap_getport_ops, map);
138 if (IS_ERR(child))
139 goto bailout_nofree;
140 rpc_put_task(child);
141
142 task->tk_xprt->stat.bind_count++;
143 return;
144
145bailout:
146 pmap_map_free(map);
147 xprt_put(xprt);
148bailout_nofree:
149 pmap_wake_portmap_waiters(xprt, status);
150bailout_nowake:
151 task->tk_status = status;
152}
153
154#ifdef CONFIG_ROOT_NFS
155/**
156 * rpc_getport_external - obtain the port for a given RPC service on a given host
157 * @sin: address of remote peer
158 * @prog: RPC program number to bind
159 * @vers: RPC version number to bind
160 * @prot: transport protocol to use to make this request
161 *
162 * This one is called from outside the RPC client in a synchronous task context.
163 */
164int rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot)
165{
166 struct portmap_args map = {
167 .pm_prog = prog,
168 .pm_vers = vers,
169 .pm_prot = prot,
170 .pm_port = 0
171 };
172 struct rpc_message msg = {
173 .rpc_proc = &pmap_procedures[PMAP_GETPORT],
174 .rpc_argp = &map,
175 .rpc_resp = &map.pm_port,
176 };
177 struct rpc_clnt *pmap_clnt;
178 char hostname[32];
179 int status;
180
181 dprintk("RPC: rpc_getport_external(%u.%u.%u.%u, %u, %u, %d)\n",
182 NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
183
184 sprintf(hostname, "%u.%u.%u.%u", NIPQUAD(sin->sin_addr.s_addr));
185 pmap_clnt = pmap_create(hostname, sin, prot, 0);
186 if (IS_ERR(pmap_clnt))
187 return PTR_ERR(pmap_clnt);
188
189 /* Setup the call info struct */
190 status = rpc_call_sync(pmap_clnt, &msg, 0);
191
192 if (status >= 0) {
193 if (map.pm_port != 0)
194 return map.pm_port;
195 status = -EACCES;
196 }
197 return status;
198}
199#endif
200
201/*
202 * Portmapper child task invokes this callback via tk_exit.
203 */
204static void pmap_getport_done(struct rpc_task *child, void *data)
205{
206 struct portmap_args *map = data;
207 struct rpc_xprt *xprt = map->pm_xprt;
208 int status = child->tk_status;
209
210 if (status < 0) {
211 /* Portmapper not available */
212 xprt->ops->set_port(xprt, 0);
213 } else if (map->pm_port == 0) {
214 /* Requested RPC service wasn't registered */
215 xprt->ops->set_port(xprt, 0);
216 status = -EACCES;
217 } else {
218 /* Succeeded */
219 xprt->ops->set_port(xprt, map->pm_port);
220 xprt_set_bound(xprt);
221 status = 0;
222 }
223
224 dprintk("RPC: %5u pmap_getport_done(status %d, port %u)\n",
225 child->tk_pid, status, map->pm_port);
226
227 pmap_wake_portmap_waiters(xprt, status);
228}
229
230/**
231 * rpc_register - set or unset a port registration with the local portmapper
232 * @prog: RPC program number to bind
233 * @vers: RPC version number to bind
234 * @prot: transport protocol to use to make this request
235 * @port: port value to register
236 * @okay: result code
237 *
238 * port == 0 means unregister, port != 0 means register.
239 */
240int rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
241{
242 struct sockaddr_in sin = {
243 .sin_family = AF_INET,
244 .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
245 };
246 struct portmap_args map = {
247 .pm_prog = prog,
248 .pm_vers = vers,
249 .pm_prot = prot,
250 .pm_port = port,
251 };
252 struct rpc_message msg = {
253 .rpc_proc = &pmap_procedures[port ? PMAP_SET : PMAP_UNSET],
254 .rpc_argp = &map,
255 .rpc_resp = okay,
256 };
257 struct rpc_clnt *pmap_clnt;
258 int error = 0;
259
260 dprintk("RPC: registering (%u, %u, %d, %u) with portmapper.\n",
261 prog, vers, prot, port);
262
263 pmap_clnt = pmap_create("localhost", &sin, IPPROTO_UDP, 1);
264 if (IS_ERR(pmap_clnt)) {
265 error = PTR_ERR(pmap_clnt);
266 dprintk("RPC: couldn't create pmap client. Error = %d\n",
267 error);
268 return error;
269 }
270
271 error = rpc_call_sync(pmap_clnt, &msg, 0);
272
273 if (error < 0) {
274 printk(KERN_WARNING
275 "RPC: failed to contact portmap (errno %d).\n",
276 error);
277 }
278 dprintk("RPC: registration status %d/%d\n", error, *okay);
279
280 /* Client deleted automatically because cl_oneshot == 1 */
281 return error;
282}
283
284static struct rpc_clnt *pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileged)
285{
286 struct rpc_create_args args = {
287 .protocol = proto,
288 .address = (struct sockaddr *)srvaddr,
289 .addrsize = sizeof(*srvaddr),
290 .servername = hostname,
291 .program = &pmap_program,
292 .version = RPC_PMAP_VERSION,
293 .authflavor = RPC_AUTH_UNIX,
294 .flags = (RPC_CLNT_CREATE_ONESHOT |
295 RPC_CLNT_CREATE_NOPING),
296 };
297
298 srvaddr->sin_port = htons(RPC_PMAP_PORT);
299 if (!privileged)
300 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
301 return rpc_create(&args);
302}
303
304/*
305 * XDR encode/decode functions for PMAP
306 */
307static int xdr_encode_mapping(struct rpc_rqst *req, __be32 *p, struct portmap_args *map)
308{
309 dprintk("RPC: xdr_encode_mapping(%u, %u, %u, %u)\n",
310 map->pm_prog, map->pm_vers,
311 map->pm_prot, map->pm_port);
312 *p++ = htonl(map->pm_prog);
313 *p++ = htonl(map->pm_vers);
314 *p++ = htonl(map->pm_prot);
315 *p++ = htonl(map->pm_port);
316
317 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
318 return 0;
319}
320
321static int xdr_decode_port(struct rpc_rqst *req, __be32 *p, unsigned short *portp)
322{
323 *portp = (unsigned short) ntohl(*p++);
324 return 0;
325}
326
327static int xdr_decode_bool(struct rpc_rqst *req, __be32 *p, unsigned int *boolp)
328{
329 *boolp = (unsigned int) ntohl(*p++);
330 return 0;
331}
332
333static struct rpc_procinfo pmap_procedures[] = {
334[PMAP_SET] = {
335 .p_proc = PMAP_SET,
336 .p_encode = (kxdrproc_t) xdr_encode_mapping,
337 .p_decode = (kxdrproc_t) xdr_decode_bool,
338 .p_bufsiz = 4,
339 .p_count = 1,
340 .p_statidx = PMAP_SET,
341 .p_name = "SET",
342 },
343[PMAP_UNSET] = {
344 .p_proc = PMAP_UNSET,
345 .p_encode = (kxdrproc_t) xdr_encode_mapping,
346 .p_decode = (kxdrproc_t) xdr_decode_bool,
347 .p_bufsiz = 4,
348 .p_count = 1,
349 .p_statidx = PMAP_UNSET,
350 .p_name = "UNSET",
351 },
352[PMAP_GETPORT] = {
353 .p_proc = PMAP_GETPORT,
354 .p_encode = (kxdrproc_t) xdr_encode_mapping,
355 .p_decode = (kxdrproc_t) xdr_decode_port,
356 .p_bufsiz = 4,
357 .p_count = 1,
358 .p_statidx = PMAP_GETPORT,
359 .p_name = "GETPORT",
360 },
361};
362
363static struct rpc_version pmap_version2 = {
364 .number = 2,
365 .nrprocs = 4,
366 .procs = pmap_procedures
367};
368
369static struct rpc_version * pmap_version[] = {
370 NULL,
371 NULL,
372 &pmap_version2
373};
374
375static struct rpc_stat pmap_stats;
376
377static struct rpc_program pmap_program = {
378 .name = "portmap",
379 .number = RPC_PMAP_PROGRAM,
380 .nrvers = ARRAY_SIZE(pmap_version),
381 .version = pmap_version,
382 .stats = &pmap_stats,
383};
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
new file mode 100644
index 000000000000..6c7aa8a1f0c6
--- /dev/null
+++ b/net/sunrpc/rpcb_clnt.c
@@ -0,0 +1,625 @@
1/*
2 * In-kernel rpcbind client supporting versions 2, 3, and 4 of the rpcbind
3 * protocol
4 *
5 * Based on RFC 1833: "Binding Protocols for ONC RPC Version 2" and
6 * RFC 3530: "Network File System (NFS) version 4 Protocol"
7 *
8 * Original: Gilles Quillard, Bull Open Source, 2005 <gilles.quillard@bull.net>
9 * Updated: Chuck Lever, Oracle Corporation, 2007 <chuck.lever@oracle.com>
10 *
11 * Descended from net/sunrpc/pmap_clnt.c,
12 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
13 */
14
15#include <linux/types.h>
16#include <linux/socket.h>
17#include <linux/kernel.h>
18#include <linux/errno.h>
19
20#include <linux/sunrpc/clnt.h>
21#include <linux/sunrpc/sched.h>
22
23#ifdef RPC_DEBUG
24# define RPCDBG_FACILITY RPCDBG_BIND
25#endif
26
27#define RPCBIND_PROGRAM (100000u)
28#define RPCBIND_PORT (111u)
29
30enum {
31 RPCBPROC_NULL,
32 RPCBPROC_SET,
33 RPCBPROC_UNSET,
34 RPCBPROC_GETPORT,
35 RPCBPROC_GETADDR = 3, /* alias for GETPORT */
36 RPCBPROC_DUMP,
37 RPCBPROC_CALLIT,
38 RPCBPROC_BCAST = 5, /* alias for CALLIT */
39 RPCBPROC_GETTIME,
40 RPCBPROC_UADDR2TADDR,
41 RPCBPROC_TADDR2UADDR,
42 RPCBPROC_GETVERSADDR,
43 RPCBPROC_INDIRECT,
44 RPCBPROC_GETADDRLIST,
45 RPCBPROC_GETSTAT,
46};
47
48#define RPCB_HIGHPROC_2 RPCBPROC_CALLIT
49#define RPCB_HIGHPROC_3 RPCBPROC_TADDR2UADDR
50#define RPCB_HIGHPROC_4 RPCBPROC_GETSTAT
51
52/*
53 * r_addr
54 *
55 * Quoting RFC 3530, section 2.2:
56 *
57 * For TCP over IPv4 and for UDP over IPv4, the format of r_addr is the
58 * US-ASCII string:
59 *
60 * h1.h2.h3.h4.p1.p2
61 *
62 * The prefix, "h1.h2.h3.h4", is the standard textual form for
63 * representing an IPv4 address, which is always four octets long.
64 * Assuming big-endian ordering, h1, h2, h3, and h4, are respectively,
65 * the first through fourth octets each converted to ASCII-decimal.
66 * Assuming big-endian ordering, p1 and p2 are, respectively, the first
67 * and second octets each converted to ASCII-decimal. For example, if a
68 * host, in big-endian order, has an address of 0x0A010307 and there is
69 * a service listening on, in big endian order, port 0x020F (decimal
70 * 527), then the complete universal address is "10.1.3.7.2.15".
71 *
72 * ...
73 *
74 * For TCP over IPv6 and for UDP over IPv6, the format of r_addr is the
75 * US-ASCII string:
76 *
77 * x1:x2:x3:x4:x5:x6:x7:x8.p1.p2
78 *
79 * The suffix "p1.p2" is the service port, and is computed the same way
80 * as with universal addresses for TCP and UDP over IPv4. The prefix,
81 * "x1:x2:x3:x4:x5:x6:x7:x8", is the standard textual form for
82 * representing an IPv6 address as defined in Section 2.2 of [RFC2373].
83 * Additionally, the two alternative forms specified in Section 2.2 of
84 * [RFC2373] are also acceptable.
85 *
86 * XXX: Currently this implementation does not explicitly convert the
87 * stored address to US-ASCII on non-ASCII systems.
88 */
89#define RPCB_MAXADDRLEN (128u)
90
91/*
92 * r_netid
93 *
94 * Quoting RFC 3530, section 2.2:
95 *
96 * For TCP over IPv4 the value of r_netid is the string "tcp". For UDP
97 * over IPv4 the value of r_netid is the string "udp".
98 *
99 * ...
100 *
101 * For TCP over IPv6 the value of r_netid is the string "tcp6". For UDP
102 * over IPv6 the value of r_netid is the string "udp6".
103 */
104#define RPCB_NETID_UDP "\165\144\160" /* "udp" */
105#define RPCB_NETID_TCP "\164\143\160" /* "tcp" */
106#define RPCB_NETID_UDP6 "\165\144\160\066" /* "udp6" */
107#define RPCB_NETID_TCP6 "\164\143\160\066" /* "tcp6" */
108
109#define RPCB_MAXNETIDLEN (4u)
110
111/*
112 * r_owner
113 *
114 * The "owner" is allowed to unset a service in the rpcbind database.
115 * We always use the following (arbitrary) fixed string.
116 */
117#define RPCB_OWNER_STRING "rpcb"
118#define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING)
119
120static void rpcb_getport_done(struct rpc_task *, void *);
121extern struct rpc_program rpcb_program;
122
123struct rpcbind_args {
124 struct rpc_xprt * r_xprt;
125
126 u32 r_prog;
127 u32 r_vers;
128 u32 r_prot;
129 unsigned short r_port;
130 char * r_netid;
131 char r_addr[RPCB_MAXADDRLEN];
132 char * r_owner;
133};
134
135static struct rpc_procinfo rpcb_procedures2[];
136static struct rpc_procinfo rpcb_procedures3[];
137
138static struct rpcb_info {
139 int rpc_vers;
140 struct rpc_procinfo * rpc_proc;
141} rpcb_next_version[];
142
143static void rpcb_getport_prepare(struct rpc_task *task, void *calldata)
144{
145 struct rpcbind_args *map = calldata;
146 struct rpc_xprt *xprt = map->r_xprt;
147 struct rpc_message msg = {
148 .rpc_proc = rpcb_next_version[xprt->bind_index].rpc_proc,
149 .rpc_argp = map,
150 .rpc_resp = &map->r_port,
151 };
152
153 rpc_call_setup(task, &msg, 0);
154}
155
156static void rpcb_map_release(void *data)
157{
158 struct rpcbind_args *map = data;
159
160 xprt_put(map->r_xprt);
161 kfree(map);
162}
163
164static const struct rpc_call_ops rpcb_getport_ops = {
165 .rpc_call_prepare = rpcb_getport_prepare,
166 .rpc_call_done = rpcb_getport_done,
167 .rpc_release = rpcb_map_release,
168};
169
170static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status)
171{
172 xprt_clear_binding(xprt);
173 rpc_wake_up_status(&xprt->binding, status);
174}
175
176static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
177 int proto, int version, int privileged)
178{
179 struct rpc_create_args args = {
180 .protocol = proto,
181 .address = srvaddr,
182 .addrsize = sizeof(struct sockaddr_in),
183 .servername = hostname,
184 .program = &rpcb_program,
185 .version = version,
186 .authflavor = RPC_AUTH_UNIX,
187 .flags = (RPC_CLNT_CREATE_ONESHOT |
188 RPC_CLNT_CREATE_NOPING),
189 };
190
191 ((struct sockaddr_in *)srvaddr)->sin_port = htons(RPCBIND_PORT);
192 if (!privileged)
193 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
194 return rpc_create(&args);
195}
196
197/**
198 * rpcb_register - set or unset a port registration with the local rpcbind svc
199 * @prog: RPC program number to bind
200 * @vers: RPC version number to bind
201 * @prot: transport protocol to use to make this request
202 * @port: port value to register
203 * @okay: result code
204 *
205 * port == 0 means unregister, port != 0 means register.
206 *
207 * This routine supports only rpcbind version 2.
208 */
209int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
210{
211 struct sockaddr_in sin = {
212 .sin_family = AF_INET,
213 .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
214 };
215 struct rpcbind_args map = {
216 .r_prog = prog,
217 .r_vers = vers,
218 .r_prot = prot,
219 .r_port = port,
220 };
221 struct rpc_message msg = {
222 .rpc_proc = &rpcb_procedures2[port ?
223 RPCBPROC_SET : RPCBPROC_UNSET],
224 .rpc_argp = &map,
225 .rpc_resp = okay,
226 };
227 struct rpc_clnt *rpcb_clnt;
228 int error = 0;
229
230 dprintk("RPC: %sregistering (%u, %u, %d, %u) with local "
231 "rpcbind\n", (port ? "" : "un"),
232 prog, vers, prot, port);
233
234 rpcb_clnt = rpcb_create("localhost", (struct sockaddr *) &sin,
235 IPPROTO_UDP, 2, 1);
236 if (IS_ERR(rpcb_clnt))
237 return PTR_ERR(rpcb_clnt);
238
239 error = rpc_call_sync(rpcb_clnt, &msg, 0);
240
241 if (error < 0)
242 printk(KERN_WARNING "RPC: failed to contact local rpcbind "
243 "server (errno %d).\n", -error);
244 dprintk("RPC: registration status %d/%d\n", error, *okay);
245
246 return error;
247}
248
249#ifdef CONFIG_ROOT_NFS
250/**
251 * rpcb_getport_external - obtain the port for an RPC service on a given host
252 * @sin: address of remote peer
253 * @prog: RPC program number to bind
254 * @vers: RPC version number to bind
255 * @prot: transport protocol to use to make this request
256 *
257 * Called from outside the RPC client in a synchronous task context.
258 *
259 * For now, this supports only version 2 queries, but is used only by
260 * mount_clnt for NFS_ROOT.
261 */
262int rpcb_getport_external(struct sockaddr_in *sin, __u32 prog,
263 __u32 vers, int prot)
264{
265 struct rpcbind_args map = {
266 .r_prog = prog,
267 .r_vers = vers,
268 .r_prot = prot,
269 .r_port = 0,
270 };
271 struct rpc_message msg = {
272 .rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT],
273 .rpc_argp = &map,
274 .rpc_resp = &map.r_port,
275 };
276 struct rpc_clnt *rpcb_clnt;
277 char hostname[40];
278 int status;
279
280 dprintk("RPC: rpcb_getport_external(%u.%u.%u.%u, %u, %u, %d)\n",
281 NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
282
283 sprintf(hostname, "%u.%u.%u.%u", NIPQUAD(sin->sin_addr.s_addr));
284 rpcb_clnt = rpcb_create(hostname, (struct sockaddr *)sin, prot, 2, 0);
285 if (IS_ERR(rpcb_clnt))
286 return PTR_ERR(rpcb_clnt);
287
288 status = rpc_call_sync(rpcb_clnt, &msg, 0);
289
290 if (status >= 0) {
291 if (map.r_port != 0)
292 return map.r_port;
293 status = -EACCES;
294 }
295 return status;
296}
297#endif
298
299/**
300 * rpcb_getport - obtain the port for a given RPC service on a given host
301 * @task: task that is waiting for portmapper request
302 *
303 * This one can be called for an ongoing RPC request, and can be used in
304 * an async (rpciod) context.
305 */
306void rpcb_getport(struct rpc_task *task)
307{
308 struct rpc_clnt *clnt = task->tk_client;
309 int bind_version;
310 struct rpc_xprt *xprt = task->tk_xprt;
311 struct rpc_clnt *rpcb_clnt;
312 static struct rpcbind_args *map;
313 struct rpc_task *child;
314 struct sockaddr addr;
315 int status;
316
317 dprintk("RPC: %5u rpcb_getport(%s, %u, %u, %d)\n",
318 task->tk_pid, clnt->cl_server,
319 clnt->cl_prog, clnt->cl_vers, xprt->prot);
320
321 /* Autobind on cloned rpc clients is discouraged */
322 BUG_ON(clnt->cl_parent != clnt);
323
324 if (xprt_test_and_set_binding(xprt)) {
325 status = -EACCES; /* tell caller to check again */
326 dprintk("RPC: %5u rpcb_getport waiting for another binder\n",
327 task->tk_pid);
328 goto bailout_nowake;
329 }
330
331 /* Put self on queue before sending rpcbind request, in case
332 * rpcb_getport_done completes before we return from rpc_run_task */
333 rpc_sleep_on(&xprt->binding, task, NULL, NULL);
334
335 /* Someone else may have bound if we slept */
336 if (xprt_bound(xprt)) {
337 status = 0;
338 dprintk("RPC: %5u rpcb_getport already bound\n", task->tk_pid);
339 goto bailout_nofree;
340 }
341
342 if (rpcb_next_version[xprt->bind_index].rpc_proc == NULL) {
343 xprt->bind_index = 0;
344 status = -EACCES; /* tell caller to try again later */
345 dprintk("RPC: %5u rpcb_getport no more getport versions "
346 "available\n", task->tk_pid);
347 goto bailout_nofree;
348 }
349 bind_version = rpcb_next_version[xprt->bind_index].rpc_vers;
350
351 dprintk("RPC: %5u rpcb_getport trying rpcbind version %u\n",
352 task->tk_pid, bind_version);
353
354 map = kzalloc(sizeof(struct rpcbind_args), GFP_ATOMIC);
355 if (!map) {
356 status = -ENOMEM;
357 dprintk("RPC: %5u rpcb_getport no memory available\n",
358 task->tk_pid);
359 goto bailout_nofree;
360 }
361 map->r_prog = clnt->cl_prog;
362 map->r_vers = clnt->cl_vers;
363 map->r_prot = xprt->prot;
364 map->r_port = 0;
365 map->r_xprt = xprt_get(xprt);
366 map->r_netid = (xprt->prot == IPPROTO_TCP) ? RPCB_NETID_TCP :
367 RPCB_NETID_UDP;
368 memcpy(&map->r_addr, rpc_peeraddr2str(clnt, RPC_DISPLAY_ADDR),
369 sizeof(map->r_addr));
370 map->r_owner = RPCB_OWNER_STRING; /* ignored for GETADDR */
371
372 rpc_peeraddr(clnt, (void *)&addr, sizeof(addr));
373 rpcb_clnt = rpcb_create(clnt->cl_server, &addr, xprt->prot, bind_version, 0);
374 if (IS_ERR(rpcb_clnt)) {
375 status = PTR_ERR(rpcb_clnt);
376 dprintk("RPC: %5u rpcb_getport rpcb_create failed, error %ld\n",
377 task->tk_pid, PTR_ERR(rpcb_clnt));
378 goto bailout;
379 }
380
381 child = rpc_run_task(rpcb_clnt, RPC_TASK_ASYNC, &rpcb_getport_ops, map);
382 if (IS_ERR(child)) {
383 status = -EIO;
384 dprintk("RPC: %5u rpcb_getport rpc_run_task failed\n",
385 task->tk_pid);
386 goto bailout_nofree;
387 }
388 rpc_put_task(child);
389
390 task->tk_xprt->stat.bind_count++;
391 return;
392
393bailout:
394 kfree(map);
395 xprt_put(xprt);
396bailout_nofree:
397 rpcb_wake_rpcbind_waiters(xprt, status);
398bailout_nowake:
399 task->tk_status = status;
400}
401
402/*
403 * Rpcbind child task calls this callback via tk_exit.
404 */
405static void rpcb_getport_done(struct rpc_task *child, void *data)
406{
407 struct rpcbind_args *map = data;
408 struct rpc_xprt *xprt = map->r_xprt;
409 int status = child->tk_status;
410
411 /* rpcbind server doesn't support this rpcbind protocol version */
412 if (status == -EPROTONOSUPPORT)
413 xprt->bind_index++;
414
415 if (status < 0) {
416 /* rpcbind server not available on remote host? */
417 xprt->ops->set_port(xprt, 0);
418 } else if (map->r_port == 0) {
419 /* Requested RPC service wasn't registered on remote host */
420 xprt->ops->set_port(xprt, 0);
421 status = -EACCES;
422 } else {
423 /* Succeeded */
424 xprt->ops->set_port(xprt, map->r_port);
425 xprt_set_bound(xprt);
426 status = 0;
427 }
428
429 dprintk("RPC: %5u rpcb_getport_done(status %d, port %u)\n",
430 child->tk_pid, status, map->r_port);
431
432 rpcb_wake_rpcbind_waiters(xprt, status);
433}
434
435static int rpcb_encode_mapping(struct rpc_rqst *req, __be32 *p,
436 struct rpcbind_args *rpcb)
437{
438 dprintk("RPC: rpcb_encode_mapping(%u, %u, %d, %u)\n",
439 rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port);
440 *p++ = htonl(rpcb->r_prog);
441 *p++ = htonl(rpcb->r_vers);
442 *p++ = htonl(rpcb->r_prot);
443 *p++ = htonl(rpcb->r_port);
444
445 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
446 return 0;
447}
448
449static int rpcb_decode_getport(struct rpc_rqst *req, __be32 *p,
450 unsigned short *portp)
451{
452 *portp = (unsigned short) ntohl(*p++);
453 dprintk("RPC: rpcb_decode_getport result %u\n",
454 *portp);
455 return 0;
456}
457
458static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p,
459 unsigned int *boolp)
460{
461 *boolp = (unsigned int) ntohl(*p++);
462 dprintk("RPC: rpcb_decode_set result %u\n",
463 *boolp);
464 return 0;
465}
466
467static int rpcb_encode_getaddr(struct rpc_rqst *req, __be32 *p,
468 struct rpcbind_args *rpcb)
469{
470 dprintk("RPC: rpcb_encode_getaddr(%u, %u, %s)\n",
471 rpcb->r_prog, rpcb->r_vers, rpcb->r_addr);
472 *p++ = htonl(rpcb->r_prog);
473 *p++ = htonl(rpcb->r_vers);
474
475 p = xdr_encode_string(p, rpcb->r_netid);
476 p = xdr_encode_string(p, rpcb->r_addr);
477 p = xdr_encode_string(p, rpcb->r_owner);
478
479 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
480
481 return 0;
482}
483
484static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 *p,
485 unsigned short *portp)
486{
487 char *addr;
488 int addr_len, c, i, f, first, val;
489
490 *portp = 0;
491 addr_len = (unsigned int) ntohl(*p++);
492 if (addr_len > RPCB_MAXADDRLEN) /* sanity */
493 return -EINVAL;
494
495 dprintk("RPC: rpcb_decode_getaddr returned string: '%s'\n",
496 (char *) p);
497
498 addr = (char *)p;
499 val = 0;
500 first = 1;
501 f = 1;
502 for (i = addr_len - 1; i > 0; i--) {
503 c = addr[i];
504 if (c >= '0' && c <= '9') {
505 val += (c - '0') * f;
506 f *= 10;
507 } else if (c == '.') {
508 if (first) {
509 *portp = val;
510 val = first = 0;
511 f = 1;
512 } else {
513 *portp |= (val << 8);
514 break;
515 }
516 }
517 }
518
519 dprintk("RPC: rpcb_decode_getaddr port=%u\n", *portp);
520 return 0;
521}
522
523#define RPCB_program_sz (1u)
524#define RPCB_version_sz (1u)
525#define RPCB_protocol_sz (1u)
526#define RPCB_port_sz (1u)
527#define RPCB_boolean_sz (1u)
528
529#define RPCB_netid_sz (1+XDR_QUADLEN(RPCB_MAXNETIDLEN))
530#define RPCB_addr_sz (1+XDR_QUADLEN(RPCB_MAXADDRLEN))
531#define RPCB_ownerstring_sz (1+XDR_QUADLEN(RPCB_MAXOWNERLEN))
532
533#define RPCB_mappingargs_sz RPCB_program_sz+RPCB_version_sz+ \
534 RPCB_protocol_sz+RPCB_port_sz
535#define RPCB_getaddrargs_sz RPCB_program_sz+RPCB_version_sz+ \
536 RPCB_netid_sz+RPCB_addr_sz+ \
537 RPCB_ownerstring_sz
538
539#define RPCB_setres_sz RPCB_boolean_sz
540#define RPCB_getportres_sz RPCB_port_sz
541
542/*
543 * Note that RFC 1833 does not put any size restrictions on the
544 * address string returned by the remote rpcbind database.
545 */
546#define RPCB_getaddrres_sz RPCB_addr_sz
547
548#define PROC(proc, argtype, restype) \
549 [RPCBPROC_##proc] = { \
550 .p_proc = RPCBPROC_##proc, \
551 .p_encode = (kxdrproc_t) rpcb_encode_##argtype, \
552 .p_decode = (kxdrproc_t) rpcb_decode_##restype, \
553 .p_arglen = RPCB_##argtype##args_sz, \
554 .p_replen = RPCB_##restype##res_sz, \
555 .p_statidx = RPCBPROC_##proc, \
556 .p_timer = 0, \
557 .p_name = #proc, \
558 }
559
560/*
561 * Not all rpcbind procedures described in RFC 1833 are implemented
562 * since the Linux kernel RPC code requires only these.
563 */
564static struct rpc_procinfo rpcb_procedures2[] = {
565 PROC(SET, mapping, set),
566 PROC(UNSET, mapping, set),
567 PROC(GETADDR, mapping, getport),
568};
569
570static struct rpc_procinfo rpcb_procedures3[] = {
571 PROC(SET, mapping, set),
572 PROC(UNSET, mapping, set),
573 PROC(GETADDR, getaddr, getaddr),
574};
575
576static struct rpc_procinfo rpcb_procedures4[] = {
577 PROC(SET, mapping, set),
578 PROC(UNSET, mapping, set),
579 PROC(GETVERSADDR, getaddr, getaddr),
580};
581
582static struct rpcb_info rpcb_next_version[] = {
583#ifdef CONFIG_SUNRPC_BIND34
584 { 4, &rpcb_procedures4[RPCBPROC_GETVERSADDR] },
585 { 3, &rpcb_procedures3[RPCBPROC_GETADDR] },
586#endif
587 { 2, &rpcb_procedures2[RPCBPROC_GETPORT] },
588 { 0, NULL },
589};
590
591static struct rpc_version rpcb_version2 = {
592 .number = 2,
593 .nrprocs = RPCB_HIGHPROC_2,
594 .procs = rpcb_procedures2
595};
596
597static struct rpc_version rpcb_version3 = {
598 .number = 3,
599 .nrprocs = RPCB_HIGHPROC_3,
600 .procs = rpcb_procedures3
601};
602
603static struct rpc_version rpcb_version4 = {
604 .number = 4,
605 .nrprocs = RPCB_HIGHPROC_4,
606 .procs = rpcb_procedures4
607};
608
609static struct rpc_version *rpcb_version[] = {
610 NULL,
611 NULL,
612 &rpcb_version2,
613 &rpcb_version3,
614 &rpcb_version4
615};
616
617static struct rpc_stat rpcb_stats;
618
619struct rpc_program rpcb_program = {
620 .name = "rpcbind",
621 .number = RPCBIND_PROGRAM,
622 .nrvers = ARRAY_SIZE(rpcb_version),
623 .version = rpcb_version,
624 .stats = &rpcb_stats,
625};
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 6d87320074b1..4a53e94f8134 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -741,50 +741,53 @@ static void rpc_async_schedule(struct work_struct *work)
741 * @task: RPC task that will use this buffer 741 * @task: RPC task that will use this buffer
742 * @size: requested byte size 742 * @size: requested byte size
743 * 743 *
744 * We try to ensure that some NFS reads and writes can always proceed 744 * To prevent rpciod from hanging, this allocator never sleeps,
745 * by using a mempool when allocating 'small' buffers. 745 * returning NULL if the request cannot be serviced immediately.
746 * The caller can arrange to sleep in a way that is safe for rpciod.
747 *
748 * Most requests are 'small' (under 2KiB) and can be serviced from a
749 * mempool, ensuring that NFS reads and writes can always proceed,
750 * and that there is good locality of reference for these buffers.
751 *
746 * In order to avoid memory starvation triggering more writebacks of 752 * In order to avoid memory starvation triggering more writebacks of
747 * NFS requests, we use GFP_NOFS rather than GFP_KERNEL. 753 * NFS requests, we avoid using GFP_KERNEL.
748 */ 754 */
749void * rpc_malloc(struct rpc_task *task, size_t size) 755void *rpc_malloc(struct rpc_task *task, size_t size)
750{ 756{
751 struct rpc_rqst *req = task->tk_rqstp; 757 size_t *buf;
752 gfp_t gfp; 758 gfp_t gfp = RPC_IS_SWAPPER(task) ? GFP_ATOMIC : GFP_NOWAIT;
753 759
754 if (task->tk_flags & RPC_TASK_SWAPPER) 760 size += sizeof(size_t);
755 gfp = GFP_ATOMIC; 761 if (size <= RPC_BUFFER_MAXSIZE)
762 buf = mempool_alloc(rpc_buffer_mempool, gfp);
756 else 763 else
757 gfp = GFP_NOFS; 764 buf = kmalloc(size, gfp);
758 765 *buf = size;
759 if (size > RPC_BUFFER_MAXSIZE) { 766 dprintk("RPC: %5u allocated buffer of size %u at %p\n",
760 req->rq_buffer = kmalloc(size, gfp); 767 task->tk_pid, size, buf);
761 if (req->rq_buffer) 768 return (void *) ++buf;
762 req->rq_bufsize = size;
763 } else {
764 req->rq_buffer = mempool_alloc(rpc_buffer_mempool, gfp);
765 if (req->rq_buffer)
766 req->rq_bufsize = RPC_BUFFER_MAXSIZE;
767 }
768 return req->rq_buffer;
769} 769}
770 770
771/** 771/**
772 * rpc_free - free buffer allocated via rpc_malloc 772 * rpc_free - free buffer allocated via rpc_malloc
773 * @task: RPC task with a buffer to be freed 773 * @buffer: buffer to free
774 * 774 *
775 */ 775 */
776void rpc_free(struct rpc_task *task) 776void rpc_free(void *buffer)
777{ 777{
778 struct rpc_rqst *req = task->tk_rqstp; 778 size_t size, *buf = (size_t *) buffer;
779 779
780 if (req->rq_buffer) { 780 if (!buffer)
781 if (req->rq_bufsize == RPC_BUFFER_MAXSIZE) 781 return;
782 mempool_free(req->rq_buffer, rpc_buffer_mempool); 782 size = *buf;
783 else 783 buf--;
784 kfree(req->rq_buffer); 784
785 req->rq_buffer = NULL; 785 dprintk("RPC: freeing buffer of size %u at %p\n",
786 req->rq_bufsize = 0; 786 size, buf);
787 } 787 if (size <= RPC_BUFFER_MAXSIZE)
788 mempool_free(buf, rpc_buffer_mempool);
789 else
790 kfree(buf);
788} 791}
789 792
790/* 793/*
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index b4db53ff1435..b7503c103ae8 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -757,7 +757,7 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
757 if (progp->pg_vers[i]->vs_hidden) 757 if (progp->pg_vers[i]->vs_hidden)
758 continue; 758 continue;
759 759
760 error = rpc_register(progp->pg_prog, i, proto, port, &dummy); 760 error = rpcb_register(progp->pg_prog, i, proto, port, &dummy);
761 if (error < 0) 761 if (error < 0)
762 break; 762 break;
763 if (port && !dummy) { 763 if (port && !dummy) {
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 456a14510308..5b05b73e4c1d 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -823,7 +823,6 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
823 req->rq_task = task; 823 req->rq_task = task;
824 req->rq_xprt = xprt; 824 req->rq_xprt = xprt;
825 req->rq_buffer = NULL; 825 req->rq_buffer = NULL;
826 req->rq_bufsize = 0;
827 req->rq_xid = xprt_alloc_xid(xprt); 826 req->rq_xid = xprt_alloc_xid(xprt);
828 req->rq_release_snd_buf = NULL; 827 req->rq_release_snd_buf = NULL;
829 xprt_reset_majortimeo(req); 828 xprt_reset_majortimeo(req);
@@ -855,7 +854,7 @@ void xprt_release(struct rpc_task *task)
855 mod_timer(&xprt->timer, 854 mod_timer(&xprt->timer,
856 xprt->last_used + xprt->idle_timeout); 855 xprt->last_used + xprt->idle_timeout);
857 spin_unlock_bh(&xprt->transport_lock); 856 spin_unlock_bh(&xprt->transport_lock);
858 xprt->ops->buf_free(task); 857 xprt->ops->buf_free(req->rq_buffer);
859 task->tk_rqstp = NULL; 858 task->tk_rqstp = NULL;
860 if (req->rq_release_snd_buf) 859 if (req->rq_release_snd_buf)
861 req->rq_release_snd_buf(req); 860 req->rq_release_snd_buf(req);
@@ -928,6 +927,7 @@ struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t si
928 xprt->timer.data = (unsigned long) xprt; 927 xprt->timer.data = (unsigned long) xprt;
929 xprt->last_used = jiffies; 928 xprt->last_used = jiffies;
930 xprt->cwnd = RPC_INITCWND; 929 xprt->cwnd = RPC_INITCWND;
930 xprt->bind_index = 0;
931 931
932 rpc_init_wait_queue(&xprt->binding, "xprt_binding"); 932 rpc_init_wait_queue(&xprt->binding, "xprt_binding");
933 rpc_init_wait_queue(&xprt->pending, "xprt_pending"); 933 rpc_init_wait_queue(&xprt->pending, "xprt_pending");
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index a5a32029e728..cc33c5880abb 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1476,7 +1476,7 @@ static struct rpc_xprt_ops xs_udp_ops = {
1476 .set_buffer_size = xs_udp_set_buffer_size, 1476 .set_buffer_size = xs_udp_set_buffer_size,
1477 .reserve_xprt = xprt_reserve_xprt_cong, 1477 .reserve_xprt = xprt_reserve_xprt_cong,
1478 .release_xprt = xprt_release_xprt_cong, 1478 .release_xprt = xprt_release_xprt_cong,
1479 .rpcbind = rpc_getport, 1479 .rpcbind = rpcb_getport,
1480 .set_port = xs_set_port, 1480 .set_port = xs_set_port,
1481 .connect = xs_connect, 1481 .connect = xs_connect,
1482 .buf_alloc = rpc_malloc, 1482 .buf_alloc = rpc_malloc,
@@ -1493,7 +1493,7 @@ static struct rpc_xprt_ops xs_udp_ops = {
1493static struct rpc_xprt_ops xs_tcp_ops = { 1493static struct rpc_xprt_ops xs_tcp_ops = {
1494 .reserve_xprt = xprt_reserve_xprt, 1494 .reserve_xprt = xprt_reserve_xprt,
1495 .release_xprt = xs_tcp_release_xprt, 1495 .release_xprt = xs_tcp_release_xprt,
1496 .rpcbind = rpc_getport, 1496 .rpcbind = rpcb_getport,
1497 .set_port = xs_set_port, 1497 .set_port = xs_set_port,
1498 .connect = xs_connect, 1498 .connect = xs_connect,
1499 .buf_alloc = rpc_malloc, 1499 .buf_alloc = rpc_malloc,
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index 67bb29b44d1b..0ee6ded18f3a 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -120,16 +120,18 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
120 120
121static int enable_bearer(struct tipc_bearer *tb_ptr) 121static int enable_bearer(struct tipc_bearer *tb_ptr)
122{ 122{
123 struct net_device *dev = dev_base; 123 struct net_device *dev, *pdev;
124 struct eth_bearer *eb_ptr = &eth_bearers[0]; 124 struct eth_bearer *eb_ptr = &eth_bearers[0];
125 struct eth_bearer *stop = &eth_bearers[MAX_ETH_BEARERS]; 125 struct eth_bearer *stop = &eth_bearers[MAX_ETH_BEARERS];
126 char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; 126 char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
127 127
128 /* Find device with specified name */ 128 /* Find device with specified name */
129 129 dev = NULL;
130 while (dev && dev->name && strncmp(dev->name, driver_name, IFNAMSIZ)) { 130 for_each_netdev(pdev)
131 dev = dev->next; 131 if (!strncmp(dev->name, driver_name, IFNAMSIZ)) {
132 } 132 dev = pdev;
133 break;
134 }
133 if (!dev) 135 if (!dev)
134 return -ENODEV; 136 return -ENODEV;
135 137
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 263e34e45265..95271e8426a1 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -579,7 +579,7 @@ static inline int xfrm_byidx_should_resize(int total)
579 return 0; 579 return 0;
580} 580}
581 581
582void xfrm_spd_getinfo(struct xfrm_spdinfo *si) 582void xfrm_spd_getinfo(struct xfrmk_spdinfo *si)
583{ 583{
584 read_lock_bh(&xfrm_policy_lock); 584 read_lock_bh(&xfrm_policy_lock);
585 si->incnt = xfrm_policy_count[XFRM_POLICY_IN]; 585 si->incnt = xfrm_policy_count[XFRM_POLICY_IN];
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index f3a61ebd8d65..9955ff4da0a2 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -421,7 +421,7 @@ restart:
421} 421}
422EXPORT_SYMBOL(xfrm_state_flush); 422EXPORT_SYMBOL(xfrm_state_flush);
423 423
424void xfrm_sad_getinfo(struct xfrm_sadinfo *si) 424void xfrm_sad_getinfo(struct xfrmk_sadinfo *si)
425{ 425{
426 spin_lock_bh(&xfrm_state_lock); 426 spin_lock_bh(&xfrm_state_lock);
427 si->sadcnt = xfrm_state_num; 427 si->sadcnt = xfrm_state_num;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 4210d91624cd..b14c7e590c31 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -674,7 +674,9 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
674 674
675static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) 675static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
676{ 676{
677 struct xfrm_spdinfo si; 677 struct xfrmk_spdinfo si;
678 struct xfrmu_spdinfo spc;
679 struct xfrmu_spdhinfo sph;
678 struct nlmsghdr *nlh; 680 struct nlmsghdr *nlh;
679 u32 *f; 681 u32 *f;
680 682
@@ -685,23 +687,17 @@ static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
685 f = nlmsg_data(nlh); 687 f = nlmsg_data(nlh);
686 *f = flags; 688 *f = flags;
687 xfrm_spd_getinfo(&si); 689 xfrm_spd_getinfo(&si);
688 690 spc.incnt = si.incnt;
689 if (flags & XFRM_SPD_HMASK) 691 spc.outcnt = si.outcnt;
690 NLA_PUT_U32(skb, XFRMA_SPDHMASK, si.spdhcnt); 692 spc.fwdcnt = si.fwdcnt;
691 if (flags & XFRM_SPD_HMAX) 693 spc.inscnt = si.inscnt;
692 NLA_PUT_U32(skb, XFRMA_SPDHMAX, si.spdhmcnt); 694 spc.outscnt = si.outscnt;
693 if (flags & XFRM_SPD_ICNT) 695 spc.fwdscnt = si.fwdscnt;
694 NLA_PUT_U32(skb, XFRMA_SPDICNT, si.incnt); 696 sph.spdhcnt = si.spdhcnt;
695 if (flags & XFRM_SPD_OCNT) 697 sph.spdhmcnt = si.spdhmcnt;
696 NLA_PUT_U32(skb, XFRMA_SPDOCNT, si.outcnt); 698
697 if (flags & XFRM_SPD_FCNT) 699 NLA_PUT(skb, XFRMA_SPD_INFO, sizeof(spc), &spc);
698 NLA_PUT_U32(skb, XFRMA_SPDFCNT, si.fwdcnt); 700 NLA_PUT(skb, XFRMA_SPD_HINFO, sizeof(sph), &sph);
699 if (flags & XFRM_SPD_ISCNT)
700 NLA_PUT_U32(skb, XFRMA_SPDISCNT, si.inscnt);
701 if (flags & XFRM_SPD_OSCNT)
702 NLA_PUT_U32(skb, XFRMA_SPDOSCNT, si.inscnt);
703 if (flags & XFRM_SPD_FSCNT)
704 NLA_PUT_U32(skb, XFRMA_SPDFSCNT, si.inscnt);
705 701
706 return nlmsg_end(skb, nlh); 702 return nlmsg_end(skb, nlh);
707 703
@@ -719,23 +715,8 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
719 u32 seq = nlh->nlmsg_seq; 715 u32 seq = nlh->nlmsg_seq;
720 int len = NLMSG_LENGTH(sizeof(u32)); 716 int len = NLMSG_LENGTH(sizeof(u32));
721 717
722 718 len += RTA_SPACE(sizeof(struct xfrmu_spdinfo));
723 if (*flags & XFRM_SPD_HMASK) 719 len += RTA_SPACE(sizeof(struct xfrmu_spdhinfo));
724 len += RTA_SPACE(sizeof(u32));
725 if (*flags & XFRM_SPD_HMAX)
726 len += RTA_SPACE(sizeof(u32));
727 if (*flags & XFRM_SPD_ICNT)
728 len += RTA_SPACE(sizeof(u32));
729 if (*flags & XFRM_SPD_OCNT)
730 len += RTA_SPACE(sizeof(u32));
731 if (*flags & XFRM_SPD_FCNT)
732 len += RTA_SPACE(sizeof(u32));
733 if (*flags & XFRM_SPD_ISCNT)
734 len += RTA_SPACE(sizeof(u32));
735 if (*flags & XFRM_SPD_OSCNT)
736 len += RTA_SPACE(sizeof(u32));
737 if (*flags & XFRM_SPD_FSCNT)
738 len += RTA_SPACE(sizeof(u32));
739 720
740 r_skb = alloc_skb(len, GFP_ATOMIC); 721 r_skb = alloc_skb(len, GFP_ATOMIC);
741 if (r_skb == NULL) 722 if (r_skb == NULL)
@@ -749,7 +730,8 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
749 730
750static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) 731static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
751{ 732{
752 struct xfrm_sadinfo si; 733 struct xfrmk_sadinfo si;
734 struct xfrmu_sadhinfo sh;
753 struct nlmsghdr *nlh; 735 struct nlmsghdr *nlh;
754 u32 *f; 736 u32 *f;
755 737
@@ -761,12 +743,11 @@ static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
761 *f = flags; 743 *f = flags;
762 xfrm_sad_getinfo(&si); 744 xfrm_sad_getinfo(&si);
763 745
764 if (flags & XFRM_SAD_HMASK) 746 sh.sadhmcnt = si.sadhmcnt;
765 NLA_PUT_U32(skb, XFRMA_SADHMASK, si.sadhcnt); 747 sh.sadhcnt = si.sadhcnt;
766 if (flags & XFRM_SAD_HMAX) 748
767 NLA_PUT_U32(skb, XFRMA_SADHMAX, si.sadhmcnt); 749 NLA_PUT_U32(skb, XFRMA_SAD_CNT, si.sadcnt);
768 if (flags & XFRM_SAD_CNT) 750 NLA_PUT(skb, XFRMA_SAD_HINFO, sizeof(sh), &sh);
769 NLA_PUT_U32(skb, XFRMA_SADCNT, si.sadcnt);
770 751
771 return nlmsg_end(skb, nlh); 752 return nlmsg_end(skb, nlh);
772 753
@@ -784,12 +765,8 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
784 u32 seq = nlh->nlmsg_seq; 765 u32 seq = nlh->nlmsg_seq;
785 int len = NLMSG_LENGTH(sizeof(u32)); 766 int len = NLMSG_LENGTH(sizeof(u32));
786 767
787 if (*flags & XFRM_SAD_HMASK) 768 len += RTA_SPACE(sizeof(struct xfrmu_sadhinfo));
788 len += RTA_SPACE(sizeof(u32)); 769 len += RTA_SPACE(sizeof(u32));
789 if (*flags & XFRM_SAD_HMAX)
790 len += RTA_SPACE(sizeof(u32));
791 if (*flags & XFRM_SAD_CNT)
792 len += RTA_SPACE(sizeof(u32));
793 770
794 r_skb = alloc_skb(len, GFP_ATOMIC); 771 r_skb = alloc_skb(len, GFP_ATOMIC);
795 772
diff --git a/security/inode.c b/security/inode.c
index d7ecf89fbc74..307211ac7346 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -321,7 +321,7 @@ static int __init securityfs_init(void)
321{ 321{
322 int retval; 322 int retval;
323 323
324 kset_set_kset_s(&security_subsys, kernel_subsys); 324 kobj_set_kset_s(&security_subsys, kernel_subsys);
325 retval = subsystem_register(&security_subsys); 325 retval = subsystem_register(&security_subsys);
326 if (retval) 326 if (retval)
327 return retval; 327 return retval;
diff --git a/sound/core/init.c b/sound/core/init.c
index 4a431e3ea3a2..f2fe35737186 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -26,7 +26,6 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/pci.h>
30#include <linux/pm.h> 29#include <linux/pm.h>
31 30
32#include <sound/core.h> 31#include <sound/core.h>
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index a339f0c0d512..23018a7c063a 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -47,7 +47,6 @@
47#include <linux/interrupt.h> 47#include <linux/interrupt.h>
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/poll.h> 49#include <linux/poll.h>
50#include <linux/pci.h>
51#include <linux/bitops.h> 50#include <linux/bitops.h>
52#include <linux/spinlock.h> 51#include <linux/spinlock.h>
53#include <linux/smp_lock.h> 52#include <linux/smp_lock.h>
diff --git a/sound/oss/dmasound/tas_ioctl.h b/sound/oss/dmasound/tas_ioctl.h
index dccae3a40e01..9d12b373b4a9 100644
--- a/sound/oss/dmasound/tas_ioctl.h
+++ b/sound/oss/dmasound/tas_ioctl.h
@@ -1,7 +1,6 @@
1#ifndef _TAS_IOCTL_H_ 1#ifndef _TAS_IOCTL_H_
2#define _TAS_IOCTL_H_ 2#define _TAS_IOCTL_H_
3 3
4#include <linux/i2c.h>
5#include <linux/soundcard.h> 4#include <linux/soundcard.h>
6 5
7 6
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index dcd8d6d2f56f..a9c23b2502ad 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -44,6 +44,7 @@
44#include <linux/smp_lock.h> 44#include <linux/smp_lock.h>
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/mm.h> 46#include <linux/mm.h>
47#include <linux/device.h>
47 48
48/* 49/*
49 * This ought to be moved into include/asm/dma.h 50 * This ought to be moved into include/asm/dma.h
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index b913a1fb8c21..9c3a9c8d1dc2 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -62,7 +62,6 @@
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/init.h> 63#include <linux/init.h>
64#include <linux/interrupt.h> 64#include <linux/interrupt.h>
65#include <linux/pci.h>
66#include <linux/slab.h> 65#include <linux/slab.h>
67#include <linux/moduleparam.h> 66#include <linux/moduleparam.h>
68#include <sound/core.h> 67#include <sound/core.h>
@@ -71,6 +70,7 @@
71#include <sound/ac97_codec.h> 70#include <sound/ac97_codec.h>
72#include <sound/info.h> 71#include <sound/info.h>
73#include <sound/tlv.h> 72#include <sound/tlv.h>
73#include <asm/io.h>
74 74
75#include "ca0106.h" 75#include "ca0106.h"
76 76
diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c
index 75ca421eb3a1..ae80f51d8c4f 100644
--- a/sound/pci/ca0106/ca0106_proc.c
+++ b/sound/pci/ca0106/ca0106_proc.c
@@ -64,7 +64,6 @@
64#include <linux/delay.h> 64#include <linux/delay.h>
65#include <linux/init.h> 65#include <linux/init.h>
66#include <linux/interrupt.h> 66#include <linux/interrupt.h>
67#include <linux/pci.h>
68#include <linux/slab.h> 67#include <linux/slab.h>
69#include <linux/moduleparam.h> 68#include <linux/moduleparam.h>
70#include <sound/core.h> 69#include <sound/core.h>
@@ -73,6 +72,7 @@
73#include <sound/ac97_codec.h> 72#include <sound/ac97_codec.h>
74#include <sound/info.h> 73#include <sound/info.h>
75#include <sound/asoundef.h> 74#include <sound/asoundef.h>
75#include <asm/io.h>
76 76
77#include "ca0106.h" 77#include "ca0106.h"
78 78
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 89c402770a1d..336e77e2600c 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -23,7 +23,6 @@
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/pci.h>
27#include <linux/pm.h> 26#include <linux/pm.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 343f51d5311b..57e357de1500 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -24,7 +24,6 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <asm/io.h> 25#include <asm/io.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/pci.h>
28#include <linux/pm.h> 27#include <linux/pm.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 1589d2f2917f..1e5ff0cd3709 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -23,7 +23,6 @@
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h>
27#include <sound/core.h> 26#include <sound/core.h>
28#include "hda_codec.h" 27#include "hda_codec.h"
29#include "hda_local.h" 28#include "hda_local.h"
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 17df4d0fe135..e313e685f161 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -23,7 +23,6 @@
23 23
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/pci.h>
27#include <sound/core.h> 26#include <sound/core.h>
28#include "hda_codec.h" 27#include "hda_codec.h"
29#include "hda_local.h" 28#include "hda_local.h"
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 7333f275decd..831469d3a923 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/pci.h>
29#include <sound/core.h> 28#include <sound/core.h>
30#include "hda_codec.h" 29#include "hda_codec.h"
31#include "hda_local.h" 30#include "hda_local.h"
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index ed5e45e35963..6fcda9bcf0cf 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h> 29#include <sound/core.h>
31#include "hda_codec.h" 30#include "hda_codec.h"
32#include "hda_local.h" 31#include "hda_local.h"
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 4c839b031729..2b11ac8689b9 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -35,7 +35,6 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/pci.h>
39#include <sound/core.h> 38#include <sound/core.h>
40#include "hda_codec.h" 39#include "hda_codec.h"
41#include "hda_local.h" 40#include "hda_local.h"